diff --git a/FittedSheets.podspec.json b/FittedSheets.podspec.json index 6ae04db..9ce9430 100644 --- a/FittedSheets.podspec.json +++ b/FittedSheets.podspec.json @@ -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", @@ -10,7 +10,7 @@ }, "source": { "git": "https://github.com/gordontucker/FittedSheets.git", - "tag": "1.2.0" + "tag": "1.2.1" }, "platforms": { "ios": "9.0" diff --git a/FittedSheets/ColorExample/ColorExampleViewController.swift b/FittedSheets/ColorExample/ColorExampleViewController.swift index 6a34545..11aac9a 100644 --- a/FittedSheets/ColorExample/ColorExampleViewController.swift +++ b/FittedSheets/ColorExample/ColorExampleViewController.swift @@ -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) } diff --git a/FittedSheetsPod/SheetViewController.swift b/FittedSheetsPod/SheetViewController.swift index 534f0e7..72e9306 100644 --- a/FittedSheetsPod/SheetViewController.swift +++ b/FittedSheetsPod/SheetViewController.swift @@ -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 @@ -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() } } @@ -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() @@ -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() { diff --git a/README.md b/README.md index 1fd026c..9fada35 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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** @@ -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) ``` @@ -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) @@ -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 } ``` @@ -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: diff --git a/ss_colors.png b/ss_colors.png new file mode 100644 index 0000000..ec90151 Binary files /dev/null and b/ss_colors.png differ diff --git a/ss_default_options.png b/ss_default_options.png new file mode 100644 index 0000000..b51bf18 Binary files /dev/null and b/ss_default_options.png differ diff --git a/ss_extend_background.png b/ss_extend_background.png new file mode 100644 index 0000000..c07c32c Binary files /dev/null and b/ss_extend_background.png differ diff --git a/ss_navigation.png b/ss_navigation.png new file mode 100644 index 0000000..6b5fe7f Binary files /dev/null and b/ss_navigation.png differ