Skip to content

Commit

Permalink
Fixed a bug with how we were setting the handle color and updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
gordontucker committed Feb 1, 2019
1 parent d002975 commit f9eb359
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 38 deletions.
4 changes: 2 additions & 2 deletions FittedSheets.podspec.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "FittedSheets",
"version": "1.2.0",
"version": "1.2.1",
"summary": "A bottom sheets implementation for iOS apps.",
"description": "iOS doesn't have a good way to use bottom sheets natively, so this is to bridge the gap with a decent looking implementation.",
"homepage": "https://github.com/gordontucker/FittedSheets",
Expand All @@ -10,7 +10,7 @@
},
"source": {
"git": "https://github.com/gordontucker/FittedSheets.git",
"tag": "1.2.0"
"tag": "1.2.1"
},
"platforms": {
"ios": "9.0"
Expand Down
3 changes: 0 additions & 3 deletions FittedSheets/ColorExample/ColorExampleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ class ColorExampleViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
}

override func viewWillAppear(_ animated: Bool) {
self.sheetViewController?.handleColor = UIColor(red: 0.933, green: 0.314, blue: 0.349, alpha: 0.8)
self.sheetViewController?.overlayColor = UIColor(red: 0.933, green: 0.314, blue: 0.349, alpha: 0.3)
}
Expand Down
12 changes: 7 additions & 5 deletions FittedSheetsPod/SheetViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ public class SheetViewController: UIViewController {
/// The view that can be pulled to resize a sheeet. This includes the background. To change the color of the bar, use `handleView` instead
public let pullBarView = UIView()
public let handleView = UIView()
public var handleColor: UIColor? {
get { return handleView.backgroundColor }
set { handleView.backgroundColor = newValue }
public var handleColor: UIColor = UIColor(white: 0.868, alpha: 1) {
didSet {
self.handleView.backgroundColor = self.handleColor
}
}

/// If true, tapping on the overlay above the sheet will dismiss the sheet view controller
Expand All @@ -42,6 +43,7 @@ public class SheetViewController: UIViewController {
/// Turn rounding on or off for the top corners. Only available for iOS 11 and above
public var roundTopCorners: Bool = true {
didSet {
guard isViewLoaded else { return }
self.updateRoundedCorners()
}
}
Expand Down Expand Up @@ -108,7 +110,7 @@ public class SheetViewController: UIViewController {
fatalError("SheetViewController requires a child view controller")
}

self.view.backgroundColor = UIColor.clear
self.view.backgroundColor = self.overlayColor
self.setUpContainerView()
self.setUpDismissView()

Expand Down Expand Up @@ -275,7 +277,7 @@ public class SheetViewController: UIViewController {

handleView.layer.cornerRadius = 3
handleView.layer.masksToBounds = true
handleView.backgroundColor = UIColor(white: 0.868, alpha: 1)
handleView.backgroundColor = self.handleColor
}

@objc func dismissTapped() {
Expand Down
59 changes: 31 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
Bottom sheets for iOS

Minimum requirement:
![iOSVersion](https://img.shields.io/badge/iOS-10.3-green.svg)
![iOSVersion](https://img.shields.io/badge/iOS-9-green.svg)
![SwiftVersion](https://img.shields.io/badge/Swift-4.2-green.svg)
![XcodeVersion](https://img.shields.io/badge/Xcode-10-green.svg)

![Demo](https://raw.githubusercontent.com/gordontucker/FittedSheets/master/fullDemo.gif)

## About
This project is to enable easily presenting view controllers in a bottom sheet that supports scrollviews and multiple sizes. Contributions and feedback are very welcome.

The bottom sheet tries to be smart about the height it takes. If the view controller is smaller than the sizes specified, it will only grow as large as the intrensic height of the presented view controller. If it is larger, it will stop at each height specified in the initializer or setSizes function.

| Default Settings | Extended Background | Color Tinted | Navigation Controller |
|:-:|:-:|:-:|:-:|
| ![Default Options](ss_default_options.png) | ![Extend Background Behind Bar](ss_extend_background.png) | ![Color Tinting](ss_colors.png) | ![Color Tinting](ss_navigation.png) |

## Usage
Using a bottom sheet is simple.

Expand All @@ -25,7 +27,8 @@ let controller = MyViewController()

let sheetController = SheetViewController(controller: controller)

self.present(sheetController, animated: false, completion: nil) // It is important to set animated to false or it behaves weird currently
// It is important to set animated to false or it behaves weird currently
self.present(sheetController, animated: false, completion: nil)
```

**Customizing settings**
Expand All @@ -34,9 +37,26 @@ self.present(sheetController, animated: false, completion: nil) // It is importa
let controller = MyViewController()

let sheetController = SheetViewController(controller: controller, sizes: [.fixed(100), .fixed(200), .halfScreen, .fullScreen])

// Adjust how the bottom safe area is handled on iPhone X screens
sheetController.blurBottomSafeArea = false
sheetController.adjustForBottomSafeArea = true

// Turn off rounded corners
sheetController.roundTopCorners = false

// Disable the dismiss on background tap functionality
sheetController.dismissOnBackgroundTap = false

// Extend the background behind the pull bar instead of having it transparent
sheetController.extendBackgroundBehindHandle = true

// Change the overlay color
sheetController.overlayColor = UIColor.red

// Change the handle color
sheetController.handleColor = UIColor.orange

self.present(controller, animated: false, completion: nil)
```

Expand All @@ -54,29 +74,6 @@ self.present(sheet, animated: false, completion: nil)

## Settings

```swift
/// Determines if we should inset the view controller to account for the bottom safe area.
/// If your view controller already handles this, leave it false (the default)
/// If your view controller does *not* handle this, set it to true
var adjustForBottomSafeArea: Bool = false
```

```swift
/// Determines if we blur the contents under the bottom safe area (if there is a safe area)
/// The default value is true
var blurBottomSafeArea: Bool = true
```

```swift
/// The color of the overlay above the sheet.
var overlayColor: UIColor = UIColor(white: 0, alpha: 0.7)
```

```swift
/// Sets the heights the sheets will try to stick to. It will not resize the current size, but will affect all future resizing of the sheet.
func setSizes(_ sizes: [SheetSize])
```

```swift
/// This should be called by any child view controller that expects the sheet to use be able to expand/collapse when the scroll view is at the top.
func handleScrollView(_ scrollView: UIScrollView)
Expand All @@ -88,7 +85,7 @@ There is an extension on UIViewController that gives you a `sheetViewController`
override func viewDidLoad() {
super.viewDidLoad()

self.sheetViewController?.handleScrollView(self.scrollView) // or tableView/collectionView/etc
self.sheetViewController!.handleScrollView(self.scrollView) // or tableView/collectionView/etc
}
```

Expand All @@ -100,6 +97,12 @@ Add this to your podfile to add FittedSheets to your project.
pod 'FittedSheets'
```

## TODO

* Add support for carthage
* Add bounce effect when opening/closing
* Support interacting with the background while the sheet is open

## License
FittedSheets uses the MIT License:

Expand Down
Binary file added ss_colors.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ss_default_options.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ss_extend_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ss_navigation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f9eb359

Please sign in to comment.