From a99db651dfc0063e57277d7a0f52fe98f878500f Mon Sep 17 00:00:00 2001 From: Gordon Tucker Date: Fri, 21 Aug 2020 09:36:31 -0600 Subject: [PATCH 01/33] Added missing FittedSheets scheme --- FittedSheets.xcodeproj/project.pbxproj | 4 +- .../xcschemes/FittedSheets.xcscheme | 98 +++++++++++++++++++ 2 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 FittedSheets.xcodeproj/xcshareddata/xcschemes/FittedSheets.xcscheme diff --git a/FittedSheets.xcodeproj/project.pbxproj b/FittedSheets.xcodeproj/project.pbxproj index 76313cf..68f0448 100644 --- a/FittedSheets.xcodeproj/project.pbxproj +++ b/FittedSheets.xcodeproj/project.pbxproj @@ -826,7 +826,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 3KLL357N6U; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = FittedSheets/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = ( @@ -846,7 +846,7 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 3KLL357N6U; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = FittedSheets/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = ( diff --git a/FittedSheets.xcodeproj/xcshareddata/xcschemes/FittedSheets.xcscheme b/FittedSheets.xcodeproj/xcshareddata/xcschemes/FittedSheets.xcscheme new file mode 100644 index 0000000..88a1fd9 --- /dev/null +++ b/FittedSheets.xcodeproj/xcshareddata/xcschemes/FittedSheets.xcscheme @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 489561eaabbe820dc8dea36628e00ff97015d085 Mon Sep 17 00:00:00 2001 From: Gordon Tucker Date: Fri, 21 Aug 2020 09:49:53 -0600 Subject: [PATCH 02/33] Selected team and bundle identifier for bitrise to compile --- FittedSheets.xcodeproj/project.pbxproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/FittedSheets.xcodeproj/project.pbxproj b/FittedSheets.xcodeproj/project.pbxproj index 68f0448..3b6ce20 100644 --- a/FittedSheets.xcodeproj/project.pbxproj +++ b/FittedSheets.xcodeproj/project.pbxproj @@ -826,14 +826,14 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = 478Z685Y37; INFOPLIST_FILE = FittedSheets/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = jane.FittedSheets; + PRODUCT_BUNDLE_IDENTIFIER = gtucker.FittedSheets; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -846,14 +846,14 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = 478Z685Y37; INFOPLIST_FILE = FittedSheets/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = jane.FittedSheets; + PRODUCT_BUNDLE_IDENTIFIER = gtucker.FittedSheets; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; From 78b780e59946c6bbde9e82994a11ffecb24bb1c6 Mon Sep 17 00:00:00 2001 From: Gordon Tucker Date: Fri, 21 Aug 2020 09:59:19 -0600 Subject: [PATCH 03/33] Added bitrise build status image to readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 4f8d094..de4f26f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # FittedSheets Bottom sheets for iOS +[Bitrise Status](https://app.bitrise.io/app/13f283bd401bbe1c.svg?token=MGSP3TGNYPSgB5gWq4MEQg) + Minimum requirement: ![iOSVersion](https://img.shields.io/badge/iOS-11-green.svg) ![SwiftVersion](https://img.shields.io/badge/Swift-5-green.svg) From a75014ed1920a9b00743b3ebd2646071adc6618b Mon Sep 17 00:00:00 2001 From: Gordon Tucker Date: Fri, 21 Aug 2020 10:05:56 -0600 Subject: [PATCH 04/33] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index de4f26f..8900467 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # FittedSheets Bottom sheets for iOS -[Bitrise Status](https://app.bitrise.io/app/13f283bd401bbe1c.svg?token=MGSP3TGNYPSgB5gWq4MEQg) +![Bitrise Status](https://app.bitrise.io/app/13f283bd401bbe1c.svg?token=MGSP3TGNYPSgB5gWq4MEQg) Minimum requirement: ![iOSVersion](https://img.shields.io/badge/iOS-11-green.svg) From 290586e789b29ec98cbc0a5c34e7c5acef1d6b3a Mon Sep 17 00:00:00 2001 From: Gordon Tucker Date: Fri, 21 Aug 2020 10:59:14 -0600 Subject: [PATCH 05/33] Updated readme to show how to use inline more explicitly --- FittedSheets/InlineExamplesViewController.swift | 11 ++++++++--- README.md | 15 ++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/FittedSheets/InlineExamplesViewController.swift b/FittedSheets/InlineExamplesViewController.swift index f1a5267..ad73485 100644 --- a/FittedSheets/InlineExamplesViewController.swift +++ b/FittedSheets/InlineExamplesViewController.swift @@ -70,9 +70,14 @@ class InlineExamplesViewController: UIViewController { self.addChild(sheet) self.containerView.addSubview(sheet.view) sheet.didMove(toParent: self) - Constraints(for: sheet.view) { - $0.edges(.top, .left, .bottom, .right).pinToSuperview() - } + + sheet.view.translatesAutoresizingMaskIntoConstraints = false + NSLayoutConstraint.activate([ + sheet.view.topAnchor.constraint(equalTo: self.containerView.topAnchor), + sheet.view.bottomAnchor.constraint(equalTo: self.containerView.bottomAnchor), + sheet.view.leadingAnchor.constraint(equalTo: self.containerView.leadingAnchor), + sheet.view.trailingAnchor.constraint(equalTo: self.containerView.trailingAnchor) + ]) sheet.didDismiss = { [weak self] _ in print("did dismiss") diff --git a/README.md b/README.md index 8900467..ca49e56 100644 --- a/README.md +++ b/README.md @@ -137,20 +137,17 @@ let sheetController = SheetViewController(controller: controller, sizes: [.perce // Add child sheetController.willMove(toParent: self) self.addChild(sheetController) -self.view.addSubview(sheetController.view) +view.addSubview(sheetController.view) sheetController.didMove(toParent: self) +sheetController.view.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ - sheet.view.topAnchor.constraint(equalTo: self.view.topAnchor), - sheet.view.bottomAnchor.constraint(equalTo: self.view.bottomAnchor), - sheet.view.leadingAnchor.constraint(equalTo: self.view.leadingAnchor), - sheet.view.trailingAnchor.constraint(equalTo: self.view.trailingAnchor) + sheetController.view.topAnchor.constraint(equalTo: view.topAnchor), + sheetController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor), + sheetController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor), + sheetController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor) ]) -Constraints(for: sheet.view) { - $0.edges(.top, .left, .bottom, .right).pinToSuperview() -} - // animate in sheet.animateIn() ``` From f0c085dc6fd32ca1d2c056e2d1e0ab47db36f52d Mon Sep 17 00:00:00 2001 From: Gordon Tucker Date: Wed, 16 Sep 2020 09:36:32 -0600 Subject: [PATCH 06/33] Fixed bug where start/end transitions don't match error (maybe?) --- FittedSheets.podspec.json | 4 ++-- FittedSheets.xcodeproj/project.pbxproj | 8 ++++---- FittedSheetsPod/SheetTransition.swift | 13 +++++++------ 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/FittedSheets.podspec.json b/FittedSheets.podspec.json index 1d6801d..2c32e4f 100644 --- a/FittedSheets.podspec.json +++ b/FittedSheets.podspec.json @@ -1,6 +1,6 @@ { "name": "FittedSheets", - "version": "2.1.1", + "version": "2.1.3", "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": "2.1.1" + "tag": "2.1.3" }, "platforms": { "ios": "11.0" diff --git a/FittedSheets.xcodeproj/project.pbxproj b/FittedSheets.xcodeproj/project.pbxproj index 3b6ce20..402de2d 100644 --- a/FittedSheets.xcodeproj/project.pbxproj +++ b/FittedSheets.xcodeproj/project.pbxproj @@ -826,14 +826,14 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 478Z685Y37; + DEVELOPMENT_TEAM = YU9U6J5U3K; INFOPLIST_FILE = FittedSheets/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = gtucker.FittedSheets; + PRODUCT_BUNDLE_IDENTIFIER = jane.FittedSheets; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -846,14 +846,14 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 478Z685Y37; + DEVELOPMENT_TEAM = YU9U6J5U3K; INFOPLIST_FILE = FittedSheets/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = gtucker.FittedSheets; + PRODUCT_BUNDLE_IDENTIFIER = jane.FittedSheets; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/FittedSheetsPod/SheetTransition.swift b/FittedSheetsPod/SheetTransition.swift index ec90220..cdf88d7 100644 --- a/FittedSheetsPod/SheetTransition.swift +++ b/FittedSheetsPod/SheetTransition.swift @@ -10,12 +10,17 @@ import UIKit public class SheetTransition: NSObject, UIViewControllerAnimatedTransitioning { - public static var transitionDuration: TimeInterval = 0.3 + public static var showRransitionDuration: TimeInterval = 0.3 + public static var hideRransitionDuration: TimeInterval = 0.2 var presenting = true weak var presenter: UIViewController? var options: SheetOptions - var duration = SheetTransition.transitionDuration + var showDuration = SheetTransition.showRransitionDuration + var hideDuration = SheetTransition.hideRransitionDuration + var duration: TimeInterval { + return self.presenting ? self.showDuration : self.hideDuration + } init(options: SheetOptions) { self.options = options @@ -60,8 +65,6 @@ public class SheetTransition: NSObject, UIViewControllerAnimatedTransitioning { sheet.overlayView.alpha = 1 }, completion: { _ in - presenter.endAppearanceTransition() - sheet.endAppearanceTransition() transitionContext.completeTransition(!transitionContext.transitionWasCancelled) } ) @@ -81,8 +84,6 @@ public class SheetTransition: NSObject, UIViewControllerAnimatedTransitioning { contentView.transform = CGAffineTransform(translationX: 0, y: contentView.bounds.height) sheet.overlayView.alpha = 0 }, completion: { _ in - sheet.endAppearanceTransition() - presenter.endAppearanceTransition() transitionContext.completeTransition(!transitionContext.transitionWasCancelled) } ) From 5f2bf4b50ba3074c6a2354dfe5aaa71818d49126 Mon Sep 17 00:00:00 2001 From: Gordon Tucker Date: Wed, 16 Sep 2020 09:41:19 -0600 Subject: [PATCH 07/33] Reset the animation duration back --- FittedSheets.podspec.json | 4 ++-- FittedSheetsPod/SheetTransition.swift | 9 ++------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/FittedSheets.podspec.json b/FittedSheets.podspec.json index 2c32e4f..5e9314b 100644 --- a/FittedSheets.podspec.json +++ b/FittedSheets.podspec.json @@ -1,6 +1,6 @@ { "name": "FittedSheets", - "version": "2.1.3", + "version": "2.1.4", "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": "2.1.3" + "tag": "2.1.4" }, "platforms": { "ios": "11.0" diff --git a/FittedSheetsPod/SheetTransition.swift b/FittedSheetsPod/SheetTransition.swift index cdf88d7..46a1776 100644 --- a/FittedSheetsPod/SheetTransition.swift +++ b/FittedSheetsPod/SheetTransition.swift @@ -10,17 +10,12 @@ import UIKit public class SheetTransition: NSObject, UIViewControllerAnimatedTransitioning { - public static var showRransitionDuration: TimeInterval = 0.3 - public static var hideRransitionDuration: TimeInterval = 0.2 + public static var transitionDuration: TimeInterval = 0.3 var presenting = true weak var presenter: UIViewController? var options: SheetOptions - var showDuration = SheetTransition.showRransitionDuration - var hideDuration = SheetTransition.hideRransitionDuration - var duration: TimeInterval { - return self.presenting ? self.showDuration : self.hideDuration - } + var duration = SheetTransition.transitionDuration init(options: SheetOptions) { self.options = options From 8c3a1d8de96e0ed3c4752a8a4dab50b68c004598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A7=D0=B5=D1=81=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2=20=D0=9C?= =?UTF-8?q?=D0=B0=D0=BA=D1=81=D0=B8=D0=BC?= Date: Tue, 22 Sep 2020 15:57:31 +0300 Subject: [PATCH 08/33] add allowPullingPastMinHeight --- FittedSheetsPod/SheetViewController.swift | 54 ++++++++++++++--------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/FittedSheetsPod/SheetViewController.swift b/FittedSheetsPod/SheetViewController.swift index d7f82e9..5dc5f3a 100644 --- a/FittedSheetsPod/SheetViewController.swift +++ b/FittedSheetsPod/SheetViewController.swift @@ -17,10 +17,14 @@ public class SheetViewController: UIViewController { /// Automatically grow/move the sheet to accomidate the keyboard. Defaults to false. public var autoAdjustToKeyboard = SheetViewController.autoAdjustToKeyboard - /// Default value for allowPullingPastMaxHeight. Defaults to true. - public static var allowPullingPastMaxHeight = true - /// Allow pulling past the maximum height and bounce back. Defaults to true. - public var allowPullingPastMaxHeight = SheetViewController.allowPullingPastMaxHeight + /// Default value for allowPullingPastMaxHeight. Defaults to true. + public static var allowPullingPastMaxHeight = true + /// Default value for allowPullingPastMinHeight. Defaults to true. + public static var allowPullingPastMinHeight = true + /// Allow pulling past the maximum height and bounce back. Defaults to true. + public var allowPullingPastMaxHeight = SheetViewController.allowPullingPastMaxHeight + /// Allow pulling past the minimum height and bounce back. Defaults to true. + public var allowPullingPastMinHeight = SheetViewController.allowPullingPastMaxHeight /// The sizes that the sheet will attempt to pin to. Defaults to intrensic only. public var sizes: [SheetSize] = [.intrinsic] { @@ -358,23 +362,31 @@ public class SheetViewController: UIViewController { self.isPanning = true } - let minHeight: CGFloat = self.height(for: self.orderedSizes.first) - let maxHeight: CGFloat - if self.allowPullingPastMaxHeight { - maxHeight = self.height(for: .fullscreen) // self.view.bounds.height - } else { - maxHeight = max(self.height(for: self.orderedSizes.last), self.prePanHeight) - } - - var newHeight = max(0, self.prePanHeight + (self.firstPanPoint.y - point.y)) - var offset: CGFloat = 0 - if newHeight < minHeight { - offset = minHeight - newHeight - newHeight = minHeight - } - if newHeight > maxHeight { - newHeight = maxHeight - } + let minHeight: CGFloat + let maxHeight: CGFloat + if self.allowPullingPastMaxHeight { + maxHeight = self.height(for: .fullscreen) // self.view.bounds.height + } else { + maxHeight = max(self.height(for: self.orderedSizes.last), self.prePanHeight) + } + if self.allowPullingPastMinHeight { + minHeight = self.height(for: .fixed(0)) + } else { + minHeight = self.height(for: self.orderedSizes.first) + } + + var newHeight = max(0, self.prePanHeight + (self.firstPanPoint.y - point.y)) + var offset: CGFloat = 0 + if newHeight < minHeight { + if self.allowPullingPastMinHeight { + offset = minHeight - newHeight + + } + newHeight = minHeight + } + if newHeight > maxHeight { + newHeight = maxHeight + } switch gesture.state { case .cancelled, .failed: From bedd943bfc19285b917979b387a2755a77bdc4e8 Mon Sep 17 00:00:00 2001 From: Gordon Tucker Date: Tue, 22 Sep 2020 13:33:40 -0600 Subject: [PATCH 09/33] Updated allowPullPastMinHeight to work right and fixed formatting issues from PR --- FittedSheets.podspec.json | 4 +- FittedSheets.xcodeproj/project.pbxproj | 12 +++-- .../InlineExamplesViewController.swift | 3 +- .../IntrensicDemo/MaxMinHeightDemo.swift | 24 +++++++++ FittedSheets/RootViewController.swift | 3 +- FittedSheetsPod/SheetViewController.swift | 53 +++++++++---------- 6 files changed, 62 insertions(+), 37 deletions(-) create mode 100644 FittedSheets/IntrensicDemo/MaxMinHeightDemo.swift diff --git a/FittedSheets.podspec.json b/FittedSheets.podspec.json index 5e9314b..276c1f6 100644 --- a/FittedSheets.podspec.json +++ b/FittedSheets.podspec.json @@ -1,6 +1,6 @@ { "name": "FittedSheets", - "version": "2.1.4", + "version": "2.1.5", "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": "2.1.4" + "tag": "2.1.5" }, "platforms": { "ios": "11.0" diff --git a/FittedSheets.xcodeproj/project.pbxproj b/FittedSheets.xcodeproj/project.pbxproj index 402de2d..9417d7f 100644 --- a/FittedSheets.xcodeproj/project.pbxproj +++ b/FittedSheets.xcodeproj/project.pbxproj @@ -35,6 +35,7 @@ F857D0C02204DD00004C862F /* NavigationRootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F857D0BF2204DD00004C862F /* NavigationRootViewController.swift */; }; F857D0C32204DFC7004C862F /* KeyboardExample.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F857D0C22204DFC7004C862F /* KeyboardExample.storyboard */; }; F857D0C52204DFDA004C862F /* UITextFieldExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F857D0C42204DFDA004C862F /* UITextFieldExampleViewController.swift */; }; + F89C6247251A86A6008CBC68 /* IntrensicDemo.swift in Sources */ = {isa = PBXBuildFile; fileRef = F89C6246251A86A6008CBC68 /* IntrensicDemo.swift */; }; F8A42B4A24D1E241005DE55B /* SheetViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8A42B4924D1E241005DE55B /* SheetViewController.swift */; }; F8A42B4C24D1E2EF005DE55B /* SheetContentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8A42B4B24D1E2EF005DE55B /* SheetContentViewController.swift */; }; F8A42B4E24D1E40A005DE55B /* SheetOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8A42B4D24D1E40A005DE55B /* SheetOptions.swift */; }; @@ -42,7 +43,7 @@ F8A42B5224D1F6D3005DE55B /* SheetContentViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8A42B5124D1F6D3005DE55B /* SheetContentViewDelegate.swift */; }; F8A42B5A24D36893005DE55B /* RootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8A42B5924D36893005DE55B /* RootViewController.swift */; }; F8A42B5C24D369A8005DE55B /* Demoable.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8A42B5B24D369A8005DE55B /* Demoable.swift */; }; - F8A42B6024D36DE3005DE55B /* IntrensicDemo.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8A42B5F24D36DE3005DE55B /* IntrensicDemo.swift */; }; + F8A42B6024D36DE3005DE55B /* MaxMinHeightDemo.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8A42B5F24D36DE3005DE55B /* MaxMinHeightDemo.swift */; }; F8A42B6224D36EA7005DE55B /* EmbededIntrensicDemo.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8A42B6124D36EA7005DE55B /* EmbededIntrensicDemo.swift */; }; F8A42B6424D371C7005DE55B /* IntrensicAndFullscreenDemo.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8A42B6324D371C7005DE55B /* IntrensicAndFullscreenDemo.swift */; }; F8A42B6724D3784B005DE55B /* ResizingDemo.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F8A42B6624D3784B005DE55B /* ResizingDemo.storyboard */; }; @@ -147,6 +148,7 @@ F857D0BF2204DD00004C862F /* NavigationRootViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationRootViewController.swift; sourceTree = ""; }; F857D0C22204DFC7004C862F /* KeyboardExample.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = KeyboardExample.storyboard; sourceTree = ""; }; F857D0C42204DFDA004C862F /* UITextFieldExampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UITextFieldExampleViewController.swift; sourceTree = ""; }; + F89C6246251A86A6008CBC68 /* IntrensicDemo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntrensicDemo.swift; sourceTree = ""; }; F8A42B4924D1E241005DE55B /* SheetViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SheetViewController.swift; sourceTree = ""; }; F8A42B4B24D1E2EF005DE55B /* SheetContentViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SheetContentViewController.swift; sourceTree = ""; }; F8A42B4D24D1E40A005DE55B /* SheetOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SheetOptions.swift; sourceTree = ""; }; @@ -154,7 +156,7 @@ F8A42B5124D1F6D3005DE55B /* SheetContentViewDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SheetContentViewDelegate.swift; sourceTree = ""; }; F8A42B5924D36893005DE55B /* RootViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootViewController.swift; sourceTree = ""; }; F8A42B5B24D369A8005DE55B /* Demoable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Demoable.swift; sourceTree = ""; }; - F8A42B5F24D36DE3005DE55B /* IntrensicDemo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntrensicDemo.swift; sourceTree = ""; }; + F8A42B5F24D36DE3005DE55B /* MaxMinHeightDemo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MaxMinHeightDemo.swift; sourceTree = ""; }; F8A42B6124D36EA7005DE55B /* EmbededIntrensicDemo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmbededIntrensicDemo.swift; sourceTree = ""; }; F8A42B6324D371C7005DE55B /* IntrensicAndFullscreenDemo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntrensicAndFullscreenDemo.swift; sourceTree = ""; }; F8A42B6624D3784B005DE55B /* ResizingDemo.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = ResizingDemo.storyboard; sourceTree = ""; }; @@ -341,7 +343,8 @@ children = ( F857D0B42204DA22004C862F /* IntrensicDemo.storyboard */, F857D0B82204DA4E004C862F /* IntrinsicExampleViewController.swift */, - F8A42B5F24D36DE3005DE55B /* IntrensicDemo.swift */, + F8A42B5F24D36DE3005DE55B /* MaxMinHeightDemo.swift */, + F89C6246251A86A6008CBC68 /* IntrensicDemo.swift */, F8A42B6124D36EA7005DE55B /* EmbededIntrensicDemo.swift */, F8A42B6324D371C7005DE55B /* IntrensicAndFullscreenDemo.swift */, F8A42B9924DB4577005DE55B /* IntrensicAndTrueFullscreenDemo.swift */, @@ -610,7 +613,8 @@ F8A42B6924D37890005DE55B /* ResizingDemo.swift in Sources */, F8A42B8C24DB1A67005DE55B /* InlineExamplesViewController.swift in Sources */, F8A42B7524D9FD11005DE55B /* ColorDemo.swift in Sources */, - F8A42B6024D36DE3005DE55B /* IntrensicDemo.swift in Sources */, + F89C6247251A86A6008CBC68 /* IntrensicDemo.swift in Sources */, + F8A42B6024D36DE3005DE55B /* MaxMinHeightDemo.swift in Sources */, F8A42B8424DA022F005DE55B /* NoClosingExampleViewController.swift in Sources */, F8A42B7324D9FCC1005DE55B /* ScrollViewDemo.swift in Sources */, F857D0AE2204D709004C862F /* TableViewExampleViewController.swift in Sources */, diff --git a/FittedSheets/InlineExamplesViewController.swift b/FittedSheets/InlineExamplesViewController.swift index ad73485..e34c070 100644 --- a/FittedSheets/InlineExamplesViewController.swift +++ b/FittedSheets/InlineExamplesViewController.swift @@ -32,7 +32,8 @@ class InlineExamplesViewController: UIViewController { NoPullBarDemo(), ClearPullBarDemo(), NoCloseDemo(), - RecursionDemo() + RecursionDemo(), + MaxMinHeightDemo() ] override func viewDidLoad() { diff --git a/FittedSheets/IntrensicDemo/MaxMinHeightDemo.swift b/FittedSheets/IntrensicDemo/MaxMinHeightDemo.swift new file mode 100644 index 0000000..f7004e9 --- /dev/null +++ b/FittedSheets/IntrensicDemo/MaxMinHeightDemo.swift @@ -0,0 +1,24 @@ +// +// IntrensicDemo.swift +// FittedSheets +// +// Created by Gordon Tucker on 7/30/20. +// Copyright © 2020 Gordon Tucker. All rights reserved. +// + +import UIKit +import FittedSheetsPod + +class MaxMinHeightDemo: Demoable { + var name: String { + return "Max Min Height" + } + + func buildDemo(useInlineMode: Bool) -> SheetViewController { + let controller = IntrinsicExampleViewController.instantiate() + let sheet = SheetViewController(controller: controller, sizes: [.intrinsic, .fixed(350)], options: SheetOptions(useInlineMode: useInlineMode)) + sheet.allowPullingPastMaxHeight = false + sheet.allowPullingPastMinHeight = false + return sheet + } +} diff --git a/FittedSheets/RootViewController.swift b/FittedSheets/RootViewController.swift index f22f87d..06015f6 100644 --- a/FittedSheets/RootViewController.swift +++ b/FittedSheets/RootViewController.swift @@ -31,7 +31,8 @@ class RootViewController: UIViewController { ClearPullBarDemo(), NoCloseDemo(), BlurDemo(), - RecursionDemo() + RecursionDemo(), + MaxMinHeightDemo() ] override func viewDidLoad() { diff --git a/FittedSheetsPod/SheetViewController.swift b/FittedSheetsPod/SheetViewController.swift index 5dc5f3a..1ffa57c 100644 --- a/FittedSheetsPod/SheetViewController.swift +++ b/FittedSheetsPod/SheetViewController.swift @@ -19,12 +19,13 @@ public class SheetViewController: UIViewController { /// Default value for allowPullingPastMaxHeight. Defaults to true. public static var allowPullingPastMaxHeight = true + /// Allow pulling past the maximum height and bounce back. Defaults to true. + public var allowPullingPastMaxHeight = SheetViewController.allowPullingPastMaxHeight + /// Default value for allowPullingPastMinHeight. Defaults to true. public static var allowPullingPastMinHeight = true - /// Allow pulling past the maximum height and bounce back. Defaults to true. - public var allowPullingPastMaxHeight = SheetViewController.allowPullingPastMaxHeight - /// Allow pulling past the minimum height and bounce back. Defaults to true. - public var allowPullingPastMinHeight = SheetViewController.allowPullingPastMaxHeight + /// Allow pulling below the minimum height and bounce back. Defaults to true. + public var allowPullingPastMinHeight = SheetViewController.allowPullingPastMinHeight /// The sizes that the sheet will attempt to pin to. Defaults to intrensic only. public var sizes: [SheetSize] = [.intrinsic] { @@ -362,31 +363,25 @@ public class SheetViewController: UIViewController { self.isPanning = true } - let minHeight: CGFloat - let maxHeight: CGFloat - if self.allowPullingPastMaxHeight { - maxHeight = self.height(for: .fullscreen) // self.view.bounds.height - } else { - maxHeight = max(self.height(for: self.orderedSizes.last), self.prePanHeight) - } - if self.allowPullingPastMinHeight { - minHeight = self.height(for: .fixed(0)) - } else { - minHeight = self.height(for: self.orderedSizes.first) - } - - var newHeight = max(0, self.prePanHeight + (self.firstPanPoint.y - point.y)) - var offset: CGFloat = 0 - if newHeight < minHeight { - if self.allowPullingPastMinHeight { - offset = minHeight - newHeight - - } - newHeight = minHeight - } - if newHeight > maxHeight { - newHeight = maxHeight - } + let minHeight: CGFloat = self.height(for: self.orderedSizes.first) + let maxHeight: CGFloat + if self.allowPullingPastMaxHeight { + maxHeight = self.height(for: .fullscreen) // self.view.bounds.height + } else { + maxHeight = max(self.height(for: self.orderedSizes.last), self.prePanHeight) + } + + var newHeight = max(0, self.prePanHeight + (self.firstPanPoint.y - point.y)) + var offset: CGFloat = 0 + if newHeight < minHeight { + if self.allowPullingPastMinHeight { + offset = minHeight - newHeight + } + newHeight = minHeight + } + if newHeight > maxHeight { + newHeight = maxHeight + } switch gesture.state { case .cancelled, .failed: From d36ec6b9492a9dc34897a1f6064e0cc2c037b4e4 Mon Sep 17 00:00:00 2001 From: Gordon Tucker Date: Tue, 29 Sep 2020 11:56:10 -0600 Subject: [PATCH 10/33] Added new example to show bottom safe area works properly when inline mode is enabled --- FittedSheets.xcodeproj/project.pbxproj | 4 + FittedSheets/Base.lproj/Main.storyboard | 60 ++++++++++++-- .../SafeAreaInlineExampleViewController.swift | 80 +++++++++++++++++++ 3 files changed, 137 insertions(+), 7 deletions(-) create mode 100644 FittedSheets/SafeAreaInlineExampleViewController.swift diff --git a/FittedSheets.xcodeproj/project.pbxproj b/FittedSheets.xcodeproj/project.pbxproj index 9417d7f..23513f5 100644 --- a/FittedSheets.xcodeproj/project.pbxproj +++ b/FittedSheets.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ F803416F212625DF00EAD717 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F803416D212625DF00EAD717 /* LaunchScreen.storyboard */; }; F803417A212625DF00EAD717 /* FittedSheetsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8034179212625DF00EAD717 /* FittedSheetsTests.swift */; }; F8034185212625DF00EAD717 /* FittedSheetsUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8034184212625DF00EAD717 /* FittedSheetsUITests.swift */; }; + F846406D2523AB9900A8A5C4 /* SafeAreaInlineExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F846406C2523AB9900A8A5C4 /* SafeAreaInlineExampleViewController.swift */; }; F857D0952204B71F004C862F /* FittedSheetsPod.h in Headers */ = {isa = PBXBuildFile; fileRef = F857D0932204B71F004C862F /* FittedSheetsPod.h */; settings = {ATTRIBUTES = (Public, ); }; }; F857D0982204B71F004C862F /* FittedSheetsPod.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F857D0912204B71F004C862F /* FittedSheetsPod.framework */; }; F857D0992204B71F004C862F /* FittedSheetsPod.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = F857D0912204B71F004C862F /* FittedSheetsPod.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; @@ -128,6 +129,7 @@ F8034186212625DF00EAD717 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; F8034192212628FE00EAD717 /* FittedSheets.podspec.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = FittedSheets.podspec.json; sourceTree = ""; }; F803419C212F208300EAD717 /* Yalta.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Yalta.swift; sourceTree = ""; }; + F846406C2523AB9900A8A5C4 /* SafeAreaInlineExampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafeAreaInlineExampleViewController.swift; sourceTree = ""; }; F84FF4AA21348A2900248951 /* SheetSize.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SheetSize.swift; sourceTree = ""; }; F84FF4AE2134A95300248951 /* InitialTouchPanGestureRecognizer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InitialTouchPanGestureRecognizer.swift; sourceTree = ""; }; F84FF4B02135BE1A00248951 /* UIViewControllerExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIViewControllerExtension.swift; sourceTree = ""; }; @@ -266,6 +268,7 @@ F8A42B5B24D369A8005DE55B /* Demoable.swift */, F8A42B8B24DB1A67005DE55B /* InlineExamplesViewController.swift */, F8A42B9D24DB58A6005DE55B /* RecursionDemo.swift */, + F846406C2523AB9900A8A5C4 /* SafeAreaInlineExampleViewController.swift */, ); path = FittedSheets; sourceTree = ""; @@ -598,6 +601,7 @@ F8A42B7124D9FCAE005DE55B /* TableViewControllerDemo.swift in Sources */, F857D0C52204DFDA004C862F /* UITextFieldExampleViewController.swift in Sources */, F857D0B72204DA2E004C862F /* ResizingExampleViewController.swift in Sources */, + F846406D2523AB9900A8A5C4 /* SafeAreaInlineExampleViewController.swift in Sources */, F8A42B9A24DB4577005DE55B /* IntrensicAndTrueFullscreenDemo.swift in Sources */, F8A42B6F24D9FC82005DE55B /* TableViewDemo.swift in Sources */, F8A42B5C24D369A8005DE55B /* Demoable.swift in Sources */, diff --git a/FittedSheets/Base.lproj/Main.storyboard b/FittedSheets/Base.lproj/Main.storyboard index 83fa462..8fbfd32 100644 --- a/FittedSheets/Base.lproj/Main.storyboard +++ b/FittedSheets/Base.lproj/Main.storyboard @@ -1,10 +1,11 @@ - + - + + @@ -37,14 +38,14 @@ - + + - @@ -94,7 +95,7 @@ - + @@ -103,6 +104,7 @@ + @@ -110,9 +112,14 @@ - - + + + + + + + @@ -123,6 +130,37 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -142,4 +180,12 @@ + + + + + + + + diff --git a/FittedSheets/SafeAreaInlineExampleViewController.swift b/FittedSheets/SafeAreaInlineExampleViewController.swift new file mode 100644 index 0000000..b33bd01 --- /dev/null +++ b/FittedSheets/SafeAreaInlineExampleViewController.swift @@ -0,0 +1,80 @@ +// +// SafeAreaInlineExampleViewController.swift +// FittedSheets +// +// Created by Gordon Tucker on 9/29/20. +// Copyright © 2020 Gordon Tucker. All rights reserved. +// + +import UIKit +import FittedSheetsPod + +class SafeAreaInlineExampleViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + } + + @IBAction func showSheetTapped(_ sender: Any) { + let viewController = ColorExampleViewController.instantiate() + + let options = SheetOptions( + pullBarHeight: 24, + presentingViewCornerRadius: 16, + useFullScreenMode: true, + useInlineMode: true + ) + + let bottomSheet = SheetViewController( + controller: viewController, + sizes: [ + .percent(0.8), + .percent(0.88) + ], + options: options + ) + + bottomSheet.willMove(toParent: self) + self.addChild(bottomSheet) + view.addSubview(bottomSheet.view) + bottomSheet.didMove(toParent: self) + + // Auto layout + bottomSheet.view.translatesAutoresizingMaskIntoConstraints = false + NSLayoutConstraint.activate([ + bottomSheet.view.topAnchor.constraint(equalTo: view.topAnchor), + bottomSheet.view.bottomAnchor.constraint(equalTo: view.bottomAnchor), + bottomSheet.view.leadingAnchor.constraint(equalTo: view.leadingAnchor), + bottomSheet.view.trailingAnchor.constraint(equalTo: view.trailingAnchor) + ]) + + // The size of the grip in the pull bar + bottomSheet.gripSize = CGSize(width: 29, height: 3) + + // The color of the grip on the pull bar + bottomSheet.gripColor = UIColor( + red: 199/255, + green: 199/255, + blue: 204/255, + alpha: 1 + ) + + // Disable the dismiss on background tap functionality + bottomSheet.dismissOnOverlayTap = false + + // Disable the ability to pull down to dismiss the modal + bottomSheet.dismissOnPull = false + + // Change the overlay color + bottomSheet.overlayColor = .clear + + // + bottomSheet.allowGestureThroughOverlay = true + + // + bottomSheet.allowPullingPastMinHeight = false + + // animate in + bottomSheet.animateIn() + } +} From d3b05fafad03dc4ba704bbe728157c99e0b66bfe Mon Sep 17 00:00:00 2001 From: Gordon Tucker Date: Mon, 5 Oct 2020 11:03:17 -0600 Subject: [PATCH 11/33] Update README.md Renamed willDismiss to shouldDismiss --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ca49e56..2ee6179 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ self.present(sheetController, animated: false, completion: nil) **Handling dismiss events** ```swift let sheet = SheetViewController(controller: controller, sizes: [.fixed(420), .fullScreen]) -sheet.willDismiss = { _ in +sheet.shouldDismiss = { _ in // This is called just before the sheet is dismissed. Return false to prevent the build in dismiss events return true } From 52fbc0fa463d320c529b1f1fbbc421d51a882795 Mon Sep 17 00:00:00 2001 From: Gordon Tucker Date: Tue, 6 Oct 2020 15:39:33 -0600 Subject: [PATCH 12/33] Fixed autoAdjustToKeyboard to work. It was defaulting to true even though the docs said false, so updated to match the actual default behavior --- FittedSheets.podspec.json | 4 ++-- FittedSheets/KeyboardExample/KeyboardDemo.swift | 6 +++++- FittedSheetsPod/SheetViewController.swift | 6 +++--- README.md | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/FittedSheets.podspec.json b/FittedSheets.podspec.json index 276c1f6..d2faafe 100644 --- a/FittedSheets.podspec.json +++ b/FittedSheets.podspec.json @@ -1,6 +1,6 @@ { "name": "FittedSheets", - "version": "2.1.5", + "version": "2.1.6", "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": "2.1.5" + "tag": "2.1.6" }, "platforms": { "ios": "11.0" diff --git a/FittedSheets/KeyboardExample/KeyboardDemo.swift b/FittedSheets/KeyboardExample/KeyboardDemo.swift index c21d84d..fbf1621 100644 --- a/FittedSheets/KeyboardExample/KeyboardDemo.swift +++ b/FittedSheets/KeyboardExample/KeyboardDemo.swift @@ -17,6 +17,10 @@ class KeyboardDemo: Demoable { func buildDemo(useInlineMode: Bool) -> SheetViewController { let controller = UITextFieldExampleViewController.instantiate() - return SheetViewController(controller: controller, sizes: [.percent(0.5), .fullscreen], options: SheetOptions(useInlineMode: useInlineMode)) + let c = SheetViewController(controller: controller, sizes: [.percent(0.5), .fullscreen], options: SheetOptions(useInlineMode: useInlineMode)) + + c.autoAdjustToKeyboard = false + + return c } } diff --git a/FittedSheetsPod/SheetViewController.swift b/FittedSheetsPod/SheetViewController.swift index 1ffa57c..a6c0c65 100644 --- a/FittedSheetsPod/SheetViewController.swift +++ b/FittedSheetsPod/SheetViewController.swift @@ -12,8 +12,8 @@ import UIKit public class SheetViewController: UIViewController { public private(set) var options: SheetOptions - /// Default value for autoAdjustToKeyboard. Defaults to false. - public static var autoAdjustToKeyboard = false + /// Default value for autoAdjustToKeyboard. Defaults to true. + public static var autoAdjustToKeyboard = true /// Automatically grow/move the sheet to accomidate the keyboard. Defaults to false. public var autoAdjustToKeyboard = SheetViewController.autoAdjustToKeyboard @@ -491,7 +491,7 @@ public class SheetViewController: UIViewController { } private func adjustForKeyboard(height: CGFloat, from notification: Notification) { - guard let info:[AnyHashable: Any] = notification.userInfo else { return } + guard self.autoAdjustToKeyboard, let info:[AnyHashable: Any] = notification.userInfo else { return } self.keyboardHeight = height let duration:TimeInterval = (info[UIResponder.keyboardAnimationDurationUserInfoKey] as? NSNumber)?.doubleValue ?? 0 diff --git a/README.md b/README.md index 2ee6179..593af0f 100644 --- a/README.md +++ b/README.md @@ -95,8 +95,8 @@ sheetController.dismissOnPull = false /// Allow pulling past the maximum height and bounce back. Defaults to true. sheetController.allowPullingPastMaxHeight = false -/// Automatically grow/move the sheet to accomidate the keyboard. Defaults to false. -sheetController.autoAdjustToKeyboard = false +/// Automatically grow/move the sheet to accomidate the keyboard. Defaults to true. +sheetController.autoAdjustToKeyboard = true // Color of the sheet anywhere the child view controller may not show (or is transparent), such as behind the keyboard currently sheetController.contentBackgroundColor From 0f7c87dcdfb77c58ab4207ffdb651f3fa4b48ca3 Mon Sep 17 00:00:00 2001 From: Martin Grider Date: Wed, 7 Oct 2020 11:14:39 -0500 Subject: [PATCH 13/33] added transition animation spring dampening, spring velocity, and options to the SheetOptions, and used them in various transitions. --- FittedSheetsPod/SheetOptions.swift | 6 ++++ FittedSheetsPod/SheetTransition.swift | 38 +++++++++++++---------- FittedSheetsPod/SheetViewController.swift | 16 ++++++++-- 3 files changed, 42 insertions(+), 18 deletions(-) diff --git a/FittedSheetsPod/SheetOptions.swift b/FittedSheetsPod/SheetOptions.swift index 3dc246f..2993ce7 100644 --- a/FittedSheetsPod/SheetOptions.swift +++ b/FittedSheetsPod/SheetOptions.swift @@ -17,6 +17,12 @@ public struct SheetOptions { public var presentingViewCornerRadius: CGFloat = 12 public var shouldExtendBackground = true public var setIntrensicHeightOnNavigationControllers = true + + public var transitionAnimationOptions: UIView.AnimationOptions = [.curveEaseOut] + public var transitionDampening: CGFloat = 0.8 + public var transitionDuration: TimeInterval = 0.4 + public var transitionVelocity: CGFloat = 0.75 + /// Allow the sheet to become full screen if pulled all the way to the top and not larger than the maximum size specified in sizes. Defaults to false. public var useFullScreenMode = true public var shrinkPresentingViewController = true diff --git a/FittedSheetsPod/SheetTransition.swift b/FittedSheetsPod/SheetTransition.swift index 46a1776..c760bdf 100644 --- a/FittedSheetsPod/SheetTransition.swift +++ b/FittedSheetsPod/SheetTransition.swift @@ -10,22 +10,20 @@ import UIKit public class SheetTransition: NSObject, UIViewControllerAnimatedTransitioning { - public static var transitionDuration: TimeInterval = 0.3 - + var presenting = true weak var presenter: UIViewController? var options: SheetOptions - var duration = SheetTransition.transitionDuration - + init(options: SheetOptions) { self.options = options super.init() } - + public func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { - return self.duration + return self.options.transitionDuration } - + public func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { let containerView = transitionContext.containerView if self.presenting { @@ -44,9 +42,13 @@ public class SheetTransition: NSObject, UIViewControllerAnimatedTransitioning { let contentView = sheet.contentViewController.contentView contentView.transform = CGAffineTransform(translationX: 0, y: contentView.bounds.height) sheet.overlayView.alpha = 0 - + UIView.animate( - withDuration: self.duration, + withDuration: self.options.transitionDuration, + delay: 0, + usingSpringWithDamping: self.options.transitionDampening, + initialSpringVelocity: self.options.transitionVelocity, + options: self.options.transitionAnimationOptions, animations: { if self.options.shrinkPresentingViewController { @@ -69,10 +71,10 @@ public class SheetTransition: NSObject, UIViewControllerAnimatedTransitioning { transitionContext.completeTransition(true) return } - + containerView.addSubview(sheet.view) let contentView = sheet.contentViewController.contentView - + self.restorePresentor( presenter, animations: { @@ -84,10 +86,14 @@ public class SheetTransition: NSObject, UIViewControllerAnimatedTransitioning { ) } } - + func restorePresentor(_ presenter: UIViewController, animated: Bool = true, animations: (() -> Void)? = nil, completion: ((Bool) -> Void)? = nil) { UIView.animate( - withDuration: self.duration, + withDuration: self.options.transitionDuration, + delay: 0, + usingSpringWithDamping: self.options.transitionDampening, + initialSpringVelocity: self.options.transitionVelocity, + options: self.options.transitionAnimationOptions, animations: { if self.options.shrinkPresentingViewController { presenter.view.layer.transform = CATransform3DMakeScale(1, 1, 1) @@ -100,13 +106,13 @@ public class SheetTransition: NSObject, UIViewControllerAnimatedTransitioning { } ) } - + func setPresentor(percentComplete: CGFloat) { guard self.options.shrinkPresentingViewController, let presenter = self.presenter else { return } let scale: CGFloat = min(1, 0.92 + (0.08 * percentComplete)) - + let topSafeArea = UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.safeAreaInsets.top ?? 0 - + presenter.view.layer.transform = CATransform3DConcat(CATransform3DMakeTranslation(0, (1 - percentComplete) * topSafeArea/2, 0), CATransform3DMakeScale(scale, scale, 1)) presenter.view.layer.cornerRadius = self.options.presentingViewCornerRadius * (1 - percentComplete) } diff --git a/FittedSheetsPod/SheetViewController.swift b/FittedSheetsPod/SheetViewController.swift index a6c0c65..0b4f811 100644 --- a/FittedSheetsPod/SheetViewController.swift +++ b/FittedSheetsPod/SheetViewController.swift @@ -417,7 +417,13 @@ public class SheetViewController: UIViewController { guard finalHeight > 0 || !self.dismissOnPull else { // Dismiss - UIView.animate(withDuration: animationDuration, delay: 0, options: [.curveEaseOut], animations: { + UIView.animate( + withDuration: animationDuration, + delay: 0, + usingSpringWithDamping: self.options.transitionDampening, + initialSpringVelocity: self.options.transitionVelocity, + options: self.options.transitionAnimationOptions, + animations: { self.contentViewController.view.transform = CGAffineTransform(translationX: 0, y: self.contentViewController.view.bounds.height) self.view.backgroundColor = UIColor.clear self.transition.setPresentor(percentComplete: 1) @@ -454,7 +460,13 @@ public class SheetViewController: UIViewController { self.currentSize = newSize let newContentHeight = self.height(for: newSize) - UIView.animate(withDuration: animationDuration, delay: 0, options: [.curveEaseOut], animations: { + UIView.animate( + withDuration: animationDuration, + delay: 0, + usingSpringWithDamping: self.options.transitionDampening, + initialSpringVelocity: self.options.transitionVelocity, + options: self.options.transitionAnimationOptions, + animations: { self.contentViewController.view.transform = CGAffineTransform.identity self.contentViewHeightConstraint.constant = newContentHeight self.transition.setPresentor(percentComplete: 0) From 0d0bd076e89de67a0587ae3e5abe5d8f5d025914 Mon Sep 17 00:00:00 2001 From: Gordon Tucker Date: Fri, 9 Oct 2020 11:20:24 -0600 Subject: [PATCH 14/33] Finished the implementation to add bounce to the initial display of the fitted sheets. --- FittedSheets.podspec.json | 4 +-- .../IntrensicAndFullscreenDemo.swift | 2 +- FittedSheets/RecursionDemo.swift | 1 + .../SheetContentViewController.swift | 35 +++++++++++++++--- FittedSheetsPod/SheetOptions.swift | 15 ++++++-- FittedSheetsPod/SheetTransition.swift | 36 ++++++++++--------- FittedSheetsPod/SheetViewController.swift | 1 + 7 files changed, 66 insertions(+), 28 deletions(-) diff --git a/FittedSheets.podspec.json b/FittedSheets.podspec.json index d2faafe..7c92062 100644 --- a/FittedSheets.podspec.json +++ b/FittedSheets.podspec.json @@ -1,6 +1,6 @@ { "name": "FittedSheets", - "version": "2.1.6", + "version": "2.2.0", "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": "2.1.6" + "tag": "2.2.0" }, "platforms": { "ios": "11.0" diff --git a/FittedSheets/IntrensicDemo/IntrensicAndFullscreenDemo.swift b/FittedSheets/IntrensicDemo/IntrensicAndFullscreenDemo.swift index e5bf968..3e50f84 100644 --- a/FittedSheets/IntrensicDemo/IntrensicAndFullscreenDemo.swift +++ b/FittedSheets/IntrensicDemo/IntrensicAndFullscreenDemo.swift @@ -19,7 +19,7 @@ class IntrensicAndFullscreenDemo: Demoable { let options = SheetOptions( useFullScreenMode: false, useInlineMode: useInlineMode) - let sheet = SheetViewController(controller: controller, sizes: [.intrinsic, .fullscreen], options: options) + let sheet = SheetViewController(controller: controller, sizes: [.fullscreen, .intrinsic], options: options) sheet.minimumSpaceAbovePullBar = 44 return sheet } diff --git a/FittedSheets/RecursionDemo.swift b/FittedSheets/RecursionDemo.swift index daac2ec..c45e9b6 100644 --- a/FittedSheets/RecursionDemo.swift +++ b/FittedSheets/RecursionDemo.swift @@ -19,6 +19,7 @@ class RecursionDemo: Demoable { var options = SheetOptions() options.useInlineMode = useInlineMode options.useFullScreenMode = false + options.transitionOverflowType = .color(color: .blue) let sheet = SheetViewController(controller: controller, sizes: [.percent(0.50), .fullscreen], options: options) return sheet diff --git a/FittedSheetsPod/SheetContentViewController.swift b/FittedSheetsPod/SheetContentViewController.swift index 30d79ab..99db5d9 100644 --- a/FittedSheetsPod/SheetContentViewController.swift +++ b/FittedSheetsPod/SheetContentViewController.swift @@ -57,6 +57,7 @@ public class SheetContentViewController: UIViewController { weak var delegate: SheetContentViewDelegate? + public var contentWrapperView = UIView() public var contentView = UIView() private var contentTopConstraint: NSLayoutConstraint? private var contentBottomConstraint: NSLayoutConstraint? @@ -120,7 +121,7 @@ public class SheetContentViewController: UIViewController { } private func updateCornerRadius() { - self.contentView.layer.cornerRadius = self.treatPullBarAsClear ? 0 : self.cornerRadius + self.contentWrapperView.layer.cornerRadius = self.treatPullBarAsClear ? 0 : self.cornerRadius self.childContainerView.layer.cornerRadius = self.treatPullBarAsClear ? self.cornerRadius : 0 } @@ -196,13 +197,37 @@ public class SheetContentViewController: UIViewController { $0.bottom.pinToSuperview() self.contentTopConstraint = $0.top.pinToSuperview() } + self.contentView.addSubview(self.contentWrapperView) { + $0.edges.pinToSuperview() + } + + self.contentWrapperView.layer.masksToBounds = true + self.contentWrapperView.layer.maskedCorners = [.layerMaxXMinYCorner, .layerMinXMinYCorner] - self.contentView.layer.masksToBounds = true - self.contentView.layer.maskedCorners = [.layerMaxXMinYCorner, .layerMinXMinYCorner] + let overflowView = UIView() + switch (self.options.transitionOverflowType) { + case .view(view: let view): + overflowView.backgroundColor = .clear + overflowView.addSubview(view) { + $0.edges.pinToSuperview() + } + case .automatic: + overflowView.backgroundColor = self.childViewController.view.backgroundColor + case .color(color: let color): + overflowView.backgroundColor = color + case .none: + overflowView.backgroundColor = .clear + } + + self.contentView.addSubview(overflowView) { + $0.edges(.left, .right).pinToSuperview() + $0.height.set(200) + $0.top.align(with: self.contentView.al.bottom - 1) + } } private func setupChildContainerView() { - self.contentView.addSubview(self.childContainerView) + self.contentWrapperView.addSubview(self.childContainerView) Constraints(for: self.childContainerView) { view in @@ -223,7 +248,7 @@ public class SheetContentViewController: UIViewController { let pullBarView = self.pullBarView pullBarView.isUserInteractionEnabled = true pullBarView.backgroundColor = self.pullBarBackgroundColor - self.contentView.addSubview(pullBarView) + self.contentWrapperView.addSubview(pullBarView) Constraints(for: pullBarView) { $0.top.pinToSuperview() $0.left.pinToSuperview() diff --git a/FittedSheetsPod/SheetOptions.swift b/FittedSheetsPod/SheetOptions.swift index 2993ce7..9abe6d0 100644 --- a/FittedSheetsPod/SheetOptions.swift +++ b/FittedSheetsPod/SheetOptions.swift @@ -12,6 +12,13 @@ import UIKit public struct SheetOptions { public static var `default` = SheetOptions() + public enum TransitionOverflowType { + case color(color: UIColor) + case view(view: UIView) + case none + case automatic + } + public var pullBarHeight: CGFloat = 24 public var presentingViewCornerRadius: CGFloat = 12 @@ -19,10 +26,12 @@ public struct SheetOptions { public var setIntrensicHeightOnNavigationControllers = true public var transitionAnimationOptions: UIView.AnimationOptions = [.curveEaseOut] - public var transitionDampening: CGFloat = 0.8 + public var transitionDampening: CGFloat = 0.7 public var transitionDuration: TimeInterval = 0.4 - public var transitionVelocity: CGFloat = 0.75 - + /// Transition velocity base value. Automatically adjusts based on the initial size of the sheet. + public var transitionVelocity: CGFloat = 0.8 + public var transitionOverflowType: TransitionOverflowType = .automatic + /// Allow the sheet to become full screen if pulled all the way to the top and not larger than the maximum size specified in sizes. Defaults to false. public var useFullScreenMode = true public var shrinkPresentingViewController = true diff --git a/FittedSheetsPod/SheetTransition.swift b/FittedSheetsPod/SheetTransition.swift index c760bdf..a0a0823 100644 --- a/FittedSheetsPod/SheetTransition.swift +++ b/FittedSheetsPod/SheetTransition.swift @@ -10,11 +10,10 @@ import UIKit public class SheetTransition: NSObject, UIViewControllerAnimatedTransitioning { - var presenting = true weak var presenter: UIViewController? var options: SheetOptions - + init(options: SheetOptions) { self.options = options super.init() @@ -42,24 +41,31 @@ public class SheetTransition: NSObject, UIViewControllerAnimatedTransitioning { let contentView = sheet.contentViewController.contentView contentView.transform = CGAffineTransform(translationX: 0, y: contentView.bounds.height) sheet.overlayView.alpha = 0 + + let heightPercent = contentView.bounds.height / UIScreen.main.bounds.height + + // Use a normal animation to animate the shadown and background view + UIView.animate(withDuration: self.options.transitionDuration * 0.6, delay: 0, options: [.curveEaseOut]) { + if self.options.shrinkPresentingViewController { + + let topSafeArea = UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.safeAreaInsets.top ?? 0 + + presenter.view.layer.transform = CATransform3DConcat(CATransform3DMakeTranslation(0, topSafeArea/2, 0), CATransform3DMakeScale(0.92, 0.92, 1)) + presenter.view.layer.cornerRadius = self.options.presentingViewCornerRadius + presenter.view.layer.masksToBounds = true + } + sheet.overlayView.alpha = 1 + } completion: { _ in } + // Use a bounce effect to animate the view in UIView.animate( withDuration: self.options.transitionDuration, delay: 0, - usingSpringWithDamping: self.options.transitionDampening, - initialSpringVelocity: self.options.transitionVelocity, + usingSpringWithDamping: self.options.transitionDampening + ((heightPercent - 0.2) * 1.25 * 0.17), + initialSpringVelocity: self.options.transitionVelocity * heightPercent, options: self.options.transitionAnimationOptions, animations: { - if self.options.shrinkPresentingViewController { - - let topSafeArea = UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.safeAreaInsets.top ?? 0 - - presenter.view.layer.transform = CATransform3DConcat(CATransform3DMakeTranslation(0, topSafeArea/2, 0), CATransform3DMakeScale(0.92, 0.92, 1)) - presenter.view.layer.cornerRadius = self.options.presentingViewCornerRadius - presenter.view.layer.masksToBounds = true - } contentView.transform = .identity - sheet.overlayView.alpha = 1 }, completion: { _ in transitionContext.completeTransition(!transitionContext.transitionWasCancelled) @@ -90,10 +96,6 @@ public class SheetTransition: NSObject, UIViewControllerAnimatedTransitioning { func restorePresentor(_ presenter: UIViewController, animated: Bool = true, animations: (() -> Void)? = nil, completion: ((Bool) -> Void)? = nil) { UIView.animate( withDuration: self.options.transitionDuration, - delay: 0, - usingSpringWithDamping: self.options.transitionDampening, - initialSpringVelocity: self.options.transitionVelocity, - options: self.options.transitionAnimationOptions, animations: { if self.options.shrinkPresentingViewController { presenter.view.layer.transform = CATransform3DMakeScale(1, 1, 1) diff --git a/FittedSheetsPod/SheetViewController.swift b/FittedSheetsPod/SheetViewController.swift index 0b4f811..acf291b 100644 --- a/FittedSheetsPod/SheetViewController.swift +++ b/FittedSheetsPod/SheetViewController.swift @@ -152,6 +152,7 @@ public class SheetViewController: UIViewController { var overlayView = UIView() var blurView = UIVisualEffectView() var overlayTapView = UIView() + var overflowView = UIView() var overlayTapGesture: UITapGestureRecognizer? private var contentViewHeightConstraint: NSLayoutConstraint! From 998f1a5984b02a51c9149603203251650d9aeba5 Mon Sep 17 00:00:00 2001 From: Charles Hopman Date: Sat, 17 Oct 2020 08:34:18 +0530 Subject: [PATCH 15/33] Minor change on Inline presentation code Changed the sheetController name in the Inline presentation code when calling animateIn(). --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 593af0f..8039c5d 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,7 @@ NSLayoutConstraint.activate([ ]) // animate in -sheet.animateIn() +sheetController.animateIn() ``` ## Scrolling From 71023c9e260060ab66eb777116c2e3c646049e99 Mon Sep 17 00:00:00 2001 From: Rukshan Marapana Date: Mon, 19 Oct 2020 14:51:24 +0530 Subject: [PATCH 16/33] fixed a compile error due to incorrect swift code --- FittedSheetsPod/SheetTransition.swift | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/FittedSheetsPod/SheetTransition.swift b/FittedSheetsPod/SheetTransition.swift index a0a0823..1e864fd 100644 --- a/FittedSheetsPod/SheetTransition.swift +++ b/FittedSheetsPod/SheetTransition.swift @@ -45,17 +45,17 @@ public class SheetTransition: NSObject, UIViewControllerAnimatedTransitioning { let heightPercent = contentView.bounds.height / UIScreen.main.bounds.height // Use a normal animation to animate the shadown and background view - UIView.animate(withDuration: self.options.transitionDuration * 0.6, delay: 0, options: [.curveEaseOut]) { - if self.options.shrinkPresentingViewController { + UIView.animate(withDuration: self.options.transitionDuration * 0.6, delay: 0, options: [.curveEaseOut], animations: { + if self.options.shrinkPresentingViewController { - let topSafeArea = UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.safeAreaInsets.top ?? 0 - - presenter.view.layer.transform = CATransform3DConcat(CATransform3DMakeTranslation(0, topSafeArea/2, 0), CATransform3DMakeScale(0.92, 0.92, 1)) - presenter.view.layer.cornerRadius = self.options.presentingViewCornerRadius - presenter.view.layer.masksToBounds = true - } - sheet.overlayView.alpha = 1 - } completion: { _ in } + let topSafeArea = UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.safeAreaInsets.top ?? 0 + + presenter.view.layer.transform = CATransform3DConcat(CATransform3DMakeTranslation(0, topSafeArea/2, 0), CATransform3DMakeScale(0.92, 0.92, 1)) + presenter.view.layer.cornerRadius = self.options.presentingViewCornerRadius + presenter.view.layer.masksToBounds = true + } + sheet.overlayView.alpha = 1 + }) // Use a bounce effect to animate the view in UIView.animate( From 34c6f444eb7804a51d43f7cb90b7a2c9e9651059 Mon Sep 17 00:00:00 2001 From: Gordon Tucker Date: Mon, 19 Oct 2020 10:44:29 -0600 Subject: [PATCH 17/33] Fixed spacing and bumped version --- FittedSheets.podspec.json | 2 +- FittedSheetsPod/SheetTransition.swift | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/FittedSheets.podspec.json b/FittedSheets.podspec.json index 7c92062..5cd45a5 100644 --- a/FittedSheets.podspec.json +++ b/FittedSheets.podspec.json @@ -1,6 +1,6 @@ { "name": "FittedSheets", - "version": "2.2.0", + "version": "2.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", diff --git a/FittedSheetsPod/SheetTransition.swift b/FittedSheetsPod/SheetTransition.swift index 1e864fd..01ff8d1 100644 --- a/FittedSheetsPod/SheetTransition.swift +++ b/FittedSheetsPod/SheetTransition.swift @@ -46,16 +46,15 @@ public class SheetTransition: NSObject, UIViewControllerAnimatedTransitioning { // Use a normal animation to animate the shadown and background view UIView.animate(withDuration: self.options.transitionDuration * 0.6, delay: 0, options: [.curveEaseOut], animations: { - if self.options.shrinkPresentingViewController { - - let topSafeArea = UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.safeAreaInsets.top ?? 0 - - presenter.view.layer.transform = CATransform3DConcat(CATransform3DMakeTranslation(0, topSafeArea/2, 0), CATransform3DMakeScale(0.92, 0.92, 1)) - presenter.view.layer.cornerRadius = self.options.presentingViewCornerRadius - presenter.view.layer.masksToBounds = true - } - sheet.overlayView.alpha = 1 - }) + if self.options.shrinkPresentingViewController { + let topSafeArea = UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.safeAreaInsets.top ?? 0 + + presenter.view.layer.transform = CATransform3DConcat(CATransform3DMakeTranslation(0, topSafeArea/2, 0), CATransform3DMakeScale(0.92, 0.92, 1)) + presenter.view.layer.cornerRadius = self.options.presentingViewCornerRadius + presenter.view.layer.masksToBounds = true + } + sheet.overlayView.alpha = 1 + }, completion: nil) // Use a bounce effect to animate the view in UIView.animate( From 145023a002409e4378be6ff8c83f7bf9c1e07bab Mon Sep 17 00:00:00 2001 From: Gordon Tucker Date: Mon, 19 Oct 2020 10:59:24 -0600 Subject: [PATCH 18/33] Fixed version --- FittedSheets.podspec.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FittedSheets.podspec.json b/FittedSheets.podspec.json index 5cd45a5..c7aadcf 100644 --- a/FittedSheets.podspec.json +++ b/FittedSheets.podspec.json @@ -1,6 +1,6 @@ { "name": "FittedSheets", - "version": "2.2.1", + "version": "2.2.2", "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": "2.2.0" + "tag": "2.2.2" }, "platforms": { "ios": "11.0" From f1ad79ce2399ad2c091a9953b0592399e8fdd6ef Mon Sep 17 00:00:00 2001 From: Gordon Tucker Date: Thu, 22 Oct 2020 12:42:42 -0600 Subject: [PATCH 19/33] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8039c5d..cda182b 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,7 @@ let options = SheetOptions( ) let sheetController = SheetViewController(controller: controller, sizes: [.percent(0.3), .fullscreen], options: options) +sheetController.allowGestureThroughOverlay = true // Add child sheetController.willMove(toParent: self) From e24e9c8c98526d3ef51bd51e0075c214815731b6 Mon Sep 17 00:00:00 2001 From: farhad Date: Fri, 27 Nov 2020 20:57:10 +0330 Subject: [PATCH 20/33] move overflowView.backgroundColor = self.childViewController.view.backgroundColor line after setupChildViewController in SheetContentViewController --- .../SheetContentViewController.swift | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/FittedSheetsPod/SheetContentViewController.swift b/FittedSheetsPod/SheetContentViewController.swift index 99db5d9..143b526 100644 --- a/FittedSheetsPod/SheetContentViewController.swift +++ b/FittedSheetsPod/SheetContentViewController.swift @@ -66,6 +66,7 @@ public class SheetContentViewController: UIViewController { public var childContainerView = UIView() public var pullBarView = UIView() public var gripView = UIView() + private let overflowView = UIView() public init(childViewController: UIViewController, options: SheetOptions) { self.options = options @@ -91,6 +92,7 @@ public class SheetContentViewController: UIViewController { self.setupChildViewController() self.updatePreferredHeight() self.updateCornerRadius() + self.setupOverflowView() } public override func viewWillAppear(_ animated: Bool) { @@ -125,6 +127,22 @@ public class SheetContentViewController: UIViewController { self.childContainerView.layer.cornerRadius = self.treatPullBarAsClear ? self.cornerRadius : 0 } + private func setupOverflowView() { + switch (self.options.transitionOverflowType) { + case .view(view: let view): + overflowView.backgroundColor = .clear + overflowView.addSubview(view) { + $0.edges.pinToSuperview() + } + case .automatic: + overflowView.backgroundColor = self.childViewController.view.backgroundColor + case .color(color: let color): + overflowView.backgroundColor = color + case .none: + overflowView.backgroundColor = .clear + } + } + private func updateNavigationControllerHeight() { // UINavigationControllers don't set intrensic size, this is a workaround to fix that guard self.options.setIntrensicHeightOnNavigationControllers, let navigationController = self.childViewController as? UINavigationController else { return } @@ -203,22 +221,7 @@ public class SheetContentViewController: UIViewController { self.contentWrapperView.layer.masksToBounds = true self.contentWrapperView.layer.maskedCorners = [.layerMaxXMinYCorner, .layerMinXMinYCorner] - - let overflowView = UIView() - switch (self.options.transitionOverflowType) { - case .view(view: let view): - overflowView.backgroundColor = .clear - overflowView.addSubview(view) { - $0.edges.pinToSuperview() - } - case .automatic: - overflowView.backgroundColor = self.childViewController.view.backgroundColor - case .color(color: let color): - overflowView.backgroundColor = color - case .none: - overflowView.backgroundColor = .clear - } - + self.contentView.addSubview(overflowView) { $0.edges(.left, .right).pinToSuperview() $0.height.set(200) From c2bd4937d88585ab89a0156abbf42b7356478238 Mon Sep 17 00:00:00 2001 From: Gordon Tucker Date: Mon, 30 Nov 2020 13:09:41 -0700 Subject: [PATCH 21/33] Update FittedSheets.podspec.json Bumped to 2.2.3 --- FittedSheets.podspec.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FittedSheets.podspec.json b/FittedSheets.podspec.json index c7aadcf..f9327ec 100644 --- a/FittedSheets.podspec.json +++ b/FittedSheets.podspec.json @@ -1,6 +1,6 @@ { "name": "FittedSheets", - "version": "2.2.2", + "version": "2.2.3", "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": "2.2.2" + "tag": "2.2.3" }, "platforms": { "ios": "11.0" From f81cc594734793c9ab6fb602a90966d3ad82ae04 Mon Sep 17 00:00:00 2001 From: Gordon Tucker Date: Mon, 4 Jan 2021 11:20:49 -0700 Subject: [PATCH 22/33] Updated sheet to allow specifying width settings --- FittedSheets.podspec.json | 2 +- FittedSheets.xcodeproj/project.pbxproj | 8 +++ FittedSheets/Demoable.swift | 2 +- .../InlineExamplesViewController.swift | 4 +- .../IntrensicDemo/HorizontalPaddingDemo.swift | 21 +++++++ FittedSheets/IntrensicDemo/MaxWidthDemo.swift | 22 +++++++ FittedSheets/RootViewController.swift | 4 +- FittedSheetsPod/SheetOptions.swift | 60 +++++++------------ FittedSheetsPod/SheetViewController.swift | 43 +++++-------- README.md | 8 ++- 10 files changed, 102 insertions(+), 72 deletions(-) create mode 100644 FittedSheets/IntrensicDemo/HorizontalPaddingDemo.swift create mode 100644 FittedSheets/IntrensicDemo/MaxWidthDemo.swift diff --git a/FittedSheets.podspec.json b/FittedSheets.podspec.json index f9327ec..a6cf4d6 100644 --- a/FittedSheets.podspec.json +++ b/FittedSheets.podspec.json @@ -1,6 +1,6 @@ { "name": "FittedSheets", - "version": "2.2.3", + "version": "2.3.0", "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", diff --git a/FittedSheets.xcodeproj/project.pbxproj b/FittedSheets.xcodeproj/project.pbxproj index 23513f5..63b22de 100644 --- a/FittedSheets.xcodeproj/project.pbxproj +++ b/FittedSheets.xcodeproj/project.pbxproj @@ -72,6 +72,8 @@ F8C1A06D24E2FF6B00807078 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = F8C1A06B24E2FF6B00807078 /* Localizable.strings */; }; F8C1A07024E3017F00807078 /* Localize.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8C1A06F24E3017F00807078 /* Localize.swift */; }; F8C1A07224E4929900807078 /* RecycledDemo.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8C1A07124E4929900807078 /* RecycledDemo.swift */; }; + F8FAC6B425A38D570042A307 /* HorizontalPaddingDemo.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8FAC6B325A38D570042A307 /* HorizontalPaddingDemo.swift */; }; + F8FAC6B925A3930F0042A307 /* MaxWidthDemo.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8FAC6B825A3930F0042A307 /* MaxWidthDemo.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -187,6 +189,8 @@ F8C1A06C24E2FF6B00807078 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Localizable.strings; sourceTree = ""; }; F8C1A06F24E3017F00807078 /* Localize.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Localize.swift; sourceTree = ""; }; F8C1A07124E4929900807078 /* RecycledDemo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecycledDemo.swift; sourceTree = ""; }; + F8FAC6B325A38D570042A307 /* HorizontalPaddingDemo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HorizontalPaddingDemo.swift; sourceTree = ""; }; + F8FAC6B825A3930F0042A307 /* MaxWidthDemo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MaxWidthDemo.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -352,6 +356,8 @@ F8A42B6324D371C7005DE55B /* IntrensicAndFullscreenDemo.swift */, F8A42B9924DB4577005DE55B /* IntrensicAndTrueFullscreenDemo.swift */, F8C1A07124E4929900807078 /* RecycledDemo.swift */, + F8FAC6B325A38D570042A307 /* HorizontalPaddingDemo.swift */, + F8FAC6B825A3930F0042A307 /* MaxWidthDemo.swift */, ); path = IntrensicDemo; sourceTree = ""; @@ -613,6 +619,7 @@ F8A42B6B24D37BB1005DE55B /* NavigationDemo.swift in Sources */, F857D0B92204DA4E004C862F /* IntrinsicExampleViewController.swift in Sources */, F8A42B6424D371C7005DE55B /* IntrensicAndFullscreenDemo.swift in Sources */, + F8FAC6B425A38D570042A307 /* HorizontalPaddingDemo.swift in Sources */, C4E231E524E55E4E00D367FD /* BlurDemo.swift in Sources */, F8A42B6924D37890005DE55B /* ResizingDemo.swift in Sources */, F8A42B8C24DB1A67005DE55B /* InlineExamplesViewController.swift in Sources */, @@ -622,6 +629,7 @@ F8A42B8424DA022F005DE55B /* NoClosingExampleViewController.swift in Sources */, F8A42B7324D9FCC1005DE55B /* ScrollViewDemo.swift in Sources */, F857D0AE2204D709004C862F /* TableViewExampleViewController.swift in Sources */, + F8FAC6B925A3930F0042A307 /* MaxWidthDemo.swift in Sources */, F857D0B02204D71E004C862F /* ExampleTableViewController.swift in Sources */, F8A42B9424DB2C04005DE55B /* MapDemo.swift in Sources */, F8A42B6D24D9FC15005DE55B /* KeyboardDemo.swift in Sources */, diff --git a/FittedSheets/Demoable.swift b/FittedSheets/Demoable.swift index c182d3a..cc53500 100644 --- a/FittedSheets/Demoable.swift +++ b/FittedSheets/Demoable.swift @@ -16,6 +16,6 @@ protocol Demoable { extension Demoable { func buildDemo() -> SheetViewController { - self.buildDemo(useInlineMode: false) + return self.buildDemo(useInlineMode: false) } } diff --git a/FittedSheets/InlineExamplesViewController.swift b/FittedSheets/InlineExamplesViewController.swift index e34c070..1ba2442 100644 --- a/FittedSheets/InlineExamplesViewController.swift +++ b/FittedSheets/InlineExamplesViewController.swift @@ -33,7 +33,9 @@ class InlineExamplesViewController: UIViewController { ClearPullBarDemo(), NoCloseDemo(), RecursionDemo(), - MaxMinHeightDemo() + MaxMinHeightDemo(), + HorizontalPaddingDemo(), + MaxWidthDemo() ] override func viewDidLoad() { diff --git a/FittedSheets/IntrensicDemo/HorizontalPaddingDemo.swift b/FittedSheets/IntrensicDemo/HorizontalPaddingDemo.swift new file mode 100644 index 0000000..3df25d8 --- /dev/null +++ b/FittedSheets/IntrensicDemo/HorizontalPaddingDemo.swift @@ -0,0 +1,21 @@ +// +// HorizontalPaddingDemo.swift +// FittedSheets +// +// Created by Gordon Tucker on 1/4/21. +// Copyright © 2021 Gordon Tucker. All rights reserved. +// + +import UIKit +import FittedSheetsPod + +class HorizontalPaddingDemo: Demoable { + var name: String { + return "Horizontal Padding" + } + + func buildDemo(useInlineMode: Bool) -> SheetViewController { + let controller = IntrinsicExampleViewController.instantiate() + return SheetViewController(controller: controller, options: SheetOptions(useInlineMode: useInlineMode, horizontalPadding: 20)) + } +} diff --git a/FittedSheets/IntrensicDemo/MaxWidthDemo.swift b/FittedSheets/IntrensicDemo/MaxWidthDemo.swift new file mode 100644 index 0000000..4f518fd --- /dev/null +++ b/FittedSheets/IntrensicDemo/MaxWidthDemo.swift @@ -0,0 +1,22 @@ +// +// MaxWidthDemo.swift +// FittedSheets +// +// Created by Gordon Tucker on 1/4/21. +// Copyright © 2021 Gordon Tucker. All rights reserved. +// + +import UIKit +import FittedSheetsPod + +class MaxWidthDemo: Demoable { + var name: String { + return "Max Width" + } + + func buildDemo(useInlineMode: Bool) -> SheetViewController { + let controller = IntrinsicExampleViewController.instantiate() + return SheetViewController(controller: controller, options: SheetOptions(useInlineMode: useInlineMode, maxWidth: 100)) + } +} + diff --git a/FittedSheets/RootViewController.swift b/FittedSheets/RootViewController.swift index 06015f6..76fb9c6 100644 --- a/FittedSheets/RootViewController.swift +++ b/FittedSheets/RootViewController.swift @@ -32,7 +32,9 @@ class RootViewController: UIViewController { NoCloseDemo(), BlurDemo(), RecursionDemo(), - MaxMinHeightDemo() + MaxMinHeightDemo(), + HorizontalPaddingDemo(), + MaxWidthDemo() ] override func viewDidLoad() { diff --git a/FittedSheetsPod/SheetOptions.swift b/FittedSheetsPod/SheetOptions.swift index 9abe6d0..de37715 100644 --- a/FittedSheetsPod/SheetOptions.swift +++ b/FittedSheetsPod/SheetOptions.swift @@ -38,42 +38,25 @@ public struct SheetOptions { /// Set true to be able to use the sheet view controller as a subview instead of a modal. Defaults to false. public var useInlineMode = false + public var horizontalPadding: CGFloat = 0 + public var maxWidth: CGFloat? + /* These properties will be removed in an upcoming release, leaving them for now so people can transition slowly */ - @available(*, deprecated, message: "minimumSpaceAbovePullBar is now a property on SheetViewController") - public var minimumSpaceAbovePullBar: CGFloat { - get { return _minimumSpaceAbovePullBar } - set { _minimumSpaceAbovePullBar = newValue } - } - var _minimumSpaceAbovePullBar: CGFloat = 0 + @available(*, unavailable, message: "minimumSpaceAbovePullBar is now a property on SheetViewController") + public var minimumSpaceAbovePullBar: CGFloat = 0 - @available(*, deprecated, message: "gripSize is now a property on SheetViewController") - public var gripSize: CGSize { - get { return _gripSize } - set { _gripSize = newValue } - } - var _gripSize = CGSize (width: 50, height: 6) + @available(*, unavailable, message: "gripSize is now a property on SheetViewController") + public var gripSize: CGSize = .zero - @available(*, deprecated, message: "gripColor is now a property on SheetViewController") - public var gripColor: UIColor { - get { return _gripColor } - set { _gripColor = newValue } - } - var _gripColor = UIColor(white: 0.868, black: 0.1) + @available(*, unavailable, message: "gripColor is now a property on SheetViewController") + public var gripColor: UIColor = .white - @available(*, deprecated, message: "pullBarBackgroundColor is now a property on SheetViewController") - public var pullBarBackgroundColor: UIColor { - get { return _pullBarBackgroundColor } - set { _pullBarBackgroundColor = newValue } - } - var _pullBarBackgroundColor = UIColor.clear + @available(*, unavailable, message: "pullBarBackgroundColor is now a property on SheetViewController") + public var pullBarBackgroundColor: UIColor = UIColor.clear - @available(*, deprecated, message: "cornerRadius is now a property on SheetViewController") - public var cornerRadius: CGFloat { - get { return _cornerRadius } - set { _cornerRadius = newValue } - } - var _cornerRadius: CGFloat = 12 + @available(*, unavailable, message: "cornerRadius is now a property on SheetViewController") + public var cornerRadius: CGFloat = 0 public init() { } public init(pullBarHeight: CGFloat? = nil, @@ -82,22 +65,23 @@ public struct SheetOptions { setIntrensicHeightOnNavigationControllers: Bool? = nil, useFullScreenMode: Bool? = nil, shrinkPresentingViewController: Bool? = nil, - useInlineMode: Bool? = nil) { + useInlineMode: Bool? = nil, + horizontalPadding: CGFloat? = nil, + maxWidth: CGFloat? = nil) { let defaultOptions = SheetOptions.default self.pullBarHeight = pullBarHeight ?? defaultOptions.pullBarHeight - self._gripSize = defaultOptions._gripSize - self._gripColor = defaultOptions._gripColor - self._cornerRadius = defaultOptions._cornerRadius self.presentingViewCornerRadius = presentingViewCornerRadius ?? defaultOptions.presentingViewCornerRadius self.shouldExtendBackground = shouldExtendBackground ?? defaultOptions.shouldExtendBackground self.setIntrensicHeightOnNavigationControllers = setIntrensicHeightOnNavigationControllers ?? defaultOptions.setIntrensicHeightOnNavigationControllers self.useFullScreenMode = useFullScreenMode ?? defaultOptions.useFullScreenMode self.shrinkPresentingViewController = shrinkPresentingViewController ?? defaultOptions.shrinkPresentingViewController self.useInlineMode = useInlineMode ?? defaultOptions.useInlineMode - self._minimumSpaceAbovePullBar = defaultOptions._minimumSpaceAbovePullBar + self.horizontalPadding = horizontalPadding ?? defaultOptions.horizontalPadding + let maxWidth = maxWidth ?? defaultOptions.maxWidth + self.maxWidth = maxWidth == 0 ? nil : maxWidth } - @available(*, deprecated, message: "cornerRadius, minimumSpaceAbovePullBar, gripSize and gripColor are now properties on SheetViewController. Use them instead.") + @available(*, unavailable, message: "cornerRadius, minimumSpaceAbovePullBar, gripSize and gripColor are now properties on SheetViewController. Use them instead.") public init(pullBarHeight: CGFloat? = nil, gripSize: CGSize? = nil, gripColor: UIColor? = nil, @@ -111,16 +95,12 @@ public struct SheetOptions { minimumSpaceAbovePullBar: CGFloat? = nil) { let defaultOptions = SheetOptions.default self.pullBarHeight = pullBarHeight ?? defaultOptions.pullBarHeight - self._gripSize = gripSize ?? defaultOptions._gripSize - self._gripColor = gripColor ?? defaultOptions._gripColor - self._cornerRadius = cornerRadius ?? defaultOptions._cornerRadius self.presentingViewCornerRadius = presentingViewCornerRadius ?? defaultOptions.presentingViewCornerRadius self.shouldExtendBackground = shouldExtendBackground ?? defaultOptions.shouldExtendBackground self.setIntrensicHeightOnNavigationControllers = setIntrensicHeightOnNavigationControllers ?? defaultOptions.setIntrensicHeightOnNavigationControllers self.useFullScreenMode = useFullScreenMode ?? defaultOptions.useFullScreenMode self.shrinkPresentingViewController = shrinkPresentingViewController ?? defaultOptions.shrinkPresentingViewController self.useInlineMode = useInlineMode ?? defaultOptions.useInlineMode - self._minimumSpaceAbovePullBar = minimumSpaceAbovePullBar ?? defaultOptions._minimumSpaceAbovePullBar } } diff --git a/FittedSheetsPod/SheetViewController.swift b/FittedSheetsPod/SheetViewController.swift index acf291b..3689161 100644 --- a/FittedSheetsPod/SheetViewController.swift +++ b/FittedSheetsPod/SheetViewController.swift @@ -63,10 +63,7 @@ public class SheetViewController: UIViewController { } } - public static var minimumSpaceAbovePullBar: CGFloat { - get { return SheetOptions.default._minimumSpaceAbovePullBar } - set { SheetOptions.default._minimumSpaceAbovePullBar = newValue } - } + public static var minimumSpaceAbovePullBar: CGFloat = 0 public var minimumSpaceAbovePullBar: CGFloat { didSet { if self.isViewLoaded { @@ -100,37 +97,25 @@ public class SheetViewController: UIViewController { } } - public static var cornerRadius: CGFloat { - get { return SheetOptions.default._cornerRadius } - set { SheetOptions.default._cornerRadius = newValue } - } + public static var cornerRadius: CGFloat = 12 public var cornerRadius: CGFloat { get { return self.contentViewController.cornerRadius } set { self.contentViewController.cornerRadius = newValue } } - public static var gripSize: CGSize { - get { return SheetOptions.default._gripSize } - set { SheetOptions.default._gripSize = newValue } - } + public static var gripSize: CGSize = CGSize (width: 50, height: 6) public var gripSize: CGSize { get { return self.contentViewController.gripSize } set { self.contentViewController.gripSize = newValue } } - public static var gripColor: UIColor { - get { return SheetOptions.default._gripColor } - set { SheetOptions.default._gripColor = newValue } - } + public static var gripColor: UIColor = UIColor(white: 0.868, black: 0.1) public var gripColor: UIColor? { get { return self.contentViewController.gripColor } set { self.contentViewController.gripColor = newValue } } - public static var pullBarBackgroundColor: UIColor { - get { return SheetOptions.default._pullBarBackgroundColor } - set { SheetOptions.default._pullBarBackgroundColor = newValue } - } + public static var pullBarBackgroundColor: UIColor = UIColor.clear public var pullBarBackgroundColor: UIColor? { get { return self.contentViewController.pullBarBackgroundColor } set { self.contentViewController.pullBarBackgroundColor = newValue } @@ -182,12 +167,12 @@ public class SheetViewController: UIViewController { self.sizes = sizes.count > 0 ? sizes : [.intrinsic] self.options = options self.transition = SheetTransition(options: options) - self.minimumSpaceAbovePullBar = options._minimumSpaceAbovePullBar + self.minimumSpaceAbovePullBar = SheetViewController.minimumSpaceAbovePullBar super.init(nibName: nil, bundle: nil) - self.gripColor = options._gripColor - self.gripSize = options._gripSize - self.pullBarBackgroundColor = options._pullBarBackgroundColor - self.cornerRadius = options._cornerRadius + self.gripColor = SheetViewController.gripColor + self.gripSize = SheetViewController.gripSize + self.pullBarBackgroundColor = SheetViewController.pullBarBackgroundColor + self.cornerRadius = SheetViewController.cornerRadius self.updateOrderedSizes() self.modalPresentationStyle = .custom self.transitioningDelegate = self @@ -334,7 +319,11 @@ public class SheetViewController: UIViewController { self.contentViewController.delegate = self Constraints(for: self.contentViewController.view) { $0.left.pinToSuperview().priority = UILayoutPriority(999) - $0.left.pinToSuperview(inset: 0, relation: .greaterThanOrEqual) + $0.left.pinToSuperview(inset: self.options.horizontalPadding, relation: .greaterThanOrEqual) + if let maxWidth = self.options.maxWidth { + $0.width.set(maxWidth, relation: .lessThanOrEqual) + } + $0.centerX.alignWithSuperview() self.contentViewHeightConstraint = $0.height.set(self.height(for: self.currentSize)) @@ -342,7 +331,7 @@ public class SheetViewController: UIViewController { if (self.options.useFullScreenMode) { top = 0 } else { - top = max(12, UIApplication.shared.keyWindow?.safeAreaInsets.top ?? 12) + top = max(12, UIApplication.shared.windows.first(where: { $0.isKeyWindow })?.safeAreaInsets.top ?? 12) } $0.bottom.pinToSuperview() $0.top.pinToSuperview(inset: top, relation: .greaterThanOrEqual).priority = UILayoutPriority(999) diff --git a/README.md b/README.md index cda182b..4120032 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,13 @@ let options = SheetOptions( shrinkPresentingViewController: true, // Determines if using inline mode or not - useInlineMode: false + useInlineMode: false, + + // Adds a padding on the left and right of the sheet with this amount. Defaults to zero (no padding) + horizontalPadding: 0, + + // Sets the maximum width allowed for the sheet. This defaults to nil and doesn't limit the width. + maxWidth: nil ) let sheetController = SheetViewController( From 65a4c04af8fe23527dd167eede516d63331caec2 Mon Sep 17 00:00:00 2001 From: Gordon Tucker Date: Mon, 4 Jan 2021 11:21:02 -0700 Subject: [PATCH 23/33] Bumped podspec --- FittedSheets.podspec.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FittedSheets.podspec.json b/FittedSheets.podspec.json index a6cf4d6..c2002ee 100644 --- a/FittedSheets.podspec.json +++ b/FittedSheets.podspec.json @@ -10,7 +10,7 @@ }, "source": { "git": "https://github.com/gordontucker/FittedSheets.git", - "tag": "2.2.3" + "tag": "2.3.0" }, "platforms": { "ios": "11.0" From b913197d82131173dc5359f5f915e179637c7cec Mon Sep 17 00:00:00 2001 From: Gordon Tucker Date: Mon, 4 Jan 2021 11:47:43 -0700 Subject: [PATCH 24/33] Fixed inline sheets not being reusable --- .../InlineExamplesViewController.swift | 1 + FittedSheets/IntrensicDemo/RecycledDemo.swift | 10 +++- FittedSheetsPod/SheetViewController.swift | 52 +++++++++++-------- 3 files changed, 40 insertions(+), 23 deletions(-) diff --git a/FittedSheets/InlineExamplesViewController.swift b/FittedSheets/InlineExamplesViewController.swift index 1ba2442..1ecd6f1 100644 --- a/FittedSheets/InlineExamplesViewController.swift +++ b/FittedSheets/InlineExamplesViewController.swift @@ -22,6 +22,7 @@ class InlineExamplesViewController: UIViewController { IntrensicAndFullscreenDemo(), IntrensicAndTrueFullscreenDemo(), ResizingDemo(), + RecycledDemo(), NavigationDemo(), KeyboardDemo(), ScrollViewDemo(), diff --git a/FittedSheets/IntrensicDemo/RecycledDemo.swift b/FittedSheets/IntrensicDemo/RecycledDemo.swift index a10d854..b2df7b6 100644 --- a/FittedSheets/IntrensicDemo/RecycledDemo.swift +++ b/FittedSheets/IntrensicDemo/RecycledDemo.swift @@ -11,15 +11,21 @@ import FittedSheetsPod class RecycledDemo: Demoable { static var shared: SheetViewController? + static var inlineShared: SheetViewController? var name: String { return "Recycled Sheet" } func buildDemo(useInlineMode: Bool) -> SheetViewController { - guard let shared = RecycledDemo.shared else { + guard let shared = useInlineMode ? RecycledDemo.inlineShared : RecycledDemo.shared else { let controller = IntrinsicExampleViewController.instantiate() let sheet = SheetViewController(controller: controller, options: SheetOptions(useInlineMode: useInlineMode)) - RecycledDemo.shared = sheet + + if useInlineMode { + RecycledDemo.inlineShared = sheet + } else { + RecycledDemo.shared = sheet + } return sheet } return shared diff --git a/FittedSheetsPod/SheetViewController.swift b/FittedSheetsPod/SheetViewController.swift index 3689161..33944ad 100644 --- a/FittedSheetsPod/SheetViewController.swift +++ b/FittedSheetsPod/SheetViewController.swift @@ -406,21 +406,23 @@ public class SheetViewController: UIViewController { let animationDuration = TimeInterval(abs(velocity*0.0002) + 0.2) guard finalHeight > 0 || !self.dismissOnPull else { - // Dismiss - UIView.animate( - withDuration: animationDuration, - delay: 0, - usingSpringWithDamping: self.options.transitionDampening, - initialSpringVelocity: self.options.transitionVelocity, - options: self.options.transitionAnimationOptions, - animations: { - self.contentViewController.view.transform = CGAffineTransform(translationX: 0, y: self.contentViewController.view.bounds.height) - self.view.backgroundColor = UIColor.clear - self.transition.setPresentor(percentComplete: 1) - self.overlayView.alpha = 0 - }, completion: { complete in - self.attemptDismiss(animated: false) - }) + if self.options.useInlineMode { + self.attemptDismiss(animated: true, duration: animationDuration) + } else { + // Dismiss + UIView.animate( + withDuration: animationDuration, + delay: 0, + usingSpringWithDamping: self.options.transitionDampening, + initialSpringVelocity: self.options.transitionVelocity, + options: self.options.transitionAnimationOptions, + animations: { + self.contentViewController.view.transform = CGAffineTransform(translationX: 0, y: self.contentViewController.view.bounds.height) + self.view.backgroundColor = UIColor.clear + self.transition.setPresentor(percentComplete: 1) + self.overlayView.alpha = 0 + }, completion: nil) + } return } @@ -569,11 +571,11 @@ public class SheetViewController: UIViewController { } } - public func attemptDismiss(animated: Bool) { + public func attemptDismiss(animated: Bool, duration: TimeInterval = 0.3) { if self.shouldDismiss?(self) != false { if self.options.useInlineMode { if animated { - self.animateOut { + self.animateOut(duration: duration) { self.didDismiss?(self) } } else { @@ -588,12 +590,16 @@ public class SheetViewController: UIViewController { } /// Animates the sheet in, but only if presenting using the inline mode - public func animateIn(duration: TimeInterval = 0.3, completion: (() -> Void)? = nil) { + public func animateIn(size: SheetSize? = nil, duration: TimeInterval = 0.3, completion: (() -> Void)? = nil) { guard self.options.useInlineMode else { return } + guard self.view.superview != nil else { + print("It appears your sheet is not set as a subview of another view. Make sure to add this view as a subview before trying to animate it in.") + return + } self.view.superview?.layoutIfNeeded() self.contentViewController.updatePreferredHeight() - self.resize(to: self.currentSize, animated: false) - let contentView = self.contentViewController.contentView + self.resize(to: size ?? self.sizes.first ?? self.currentSize, animated: false) + let contentView = self.contentViewController.view! contentView.transform = CGAffineTransform(translationX: 0, y: contentView.bounds.height) self.overlayView.alpha = 0 self.updateOrderedSizes() @@ -613,10 +619,14 @@ public class SheetViewController: UIViewController { /// Animates the sheet out, but only if presenting using the inline mode public func animateOut(duration: TimeInterval = 0.3, completion: (() -> Void)? = nil) { guard self.options.useInlineMode else { return } - let contentView = self.contentViewController.contentView + let contentView = self.contentViewController.view! UIView.animate( withDuration: duration, + delay: 0, + usingSpringWithDamping: self.options.transitionDampening, + initialSpringVelocity: self.options.transitionVelocity, + options: self.options.transitionAnimationOptions, animations: { contentView.transform = CGAffineTransform(translationX: 0, y: contentView.bounds.height) self.overlayView.alpha = 0 From a96e472357afe5490533b9b31cf48a5c3163e0fd Mon Sep 17 00:00:00 2001 From: Gordon Tucker Date: Mon, 11 Jan 2021 09:07:54 -0700 Subject: [PATCH 25/33] Fixed bug with dismiss not working properly --- FittedSheets.podspec.json | 4 +-- FittedSheetsPod/SheetViewController.swift | 36 +++++++++++------------ 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/FittedSheets.podspec.json b/FittedSheets.podspec.json index c2002ee..d7a88d2 100644 --- a/FittedSheets.podspec.json +++ b/FittedSheets.podspec.json @@ -1,6 +1,6 @@ { "name": "FittedSheets", - "version": "2.3.0", + "version": "2.3.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": "2.3.0" + "tag": "2.3.1" }, "platforms": { "ios": "11.0" diff --git a/FittedSheetsPod/SheetViewController.swift b/FittedSheetsPod/SheetViewController.swift index 33944ad..99de93b 100644 --- a/FittedSheetsPod/SheetViewController.swift +++ b/FittedSheetsPod/SheetViewController.swift @@ -406,23 +406,21 @@ public class SheetViewController: UIViewController { let animationDuration = TimeInterval(abs(velocity*0.0002) + 0.2) guard finalHeight > 0 || !self.dismissOnPull else { - if self.options.useInlineMode { - self.attemptDismiss(animated: true, duration: animationDuration) - } else { - // Dismiss - UIView.animate( - withDuration: animationDuration, - delay: 0, - usingSpringWithDamping: self.options.transitionDampening, - initialSpringVelocity: self.options.transitionVelocity, - options: self.options.transitionAnimationOptions, - animations: { - self.contentViewController.view.transform = CGAffineTransform(translationX: 0, y: self.contentViewController.view.bounds.height) - self.view.backgroundColor = UIColor.clear - self.transition.setPresentor(percentComplete: 1) - self.overlayView.alpha = 0 - }, completion: nil) - } + // Dismiss + UIView.animate( + withDuration: animationDuration, + delay: 0, + usingSpringWithDamping: self.options.transitionDampening, + initialSpringVelocity: self.options.transitionVelocity, + options: self.options.transitionAnimationOptions, + animations: { + self.contentViewController.view.transform = CGAffineTransform(translationX: 0, y: self.contentViewController.view.bounds.height) + self.view.backgroundColor = UIColor.clear + self.transition.setPresentor(percentComplete: 1) + self.overlayView.alpha = 0 + }, completion: { complete in + self.attemptDismiss(animated: false) + }) return } @@ -571,11 +569,11 @@ public class SheetViewController: UIViewController { } } - public func attemptDismiss(animated: Bool, duration: TimeInterval = 0.3) { + public func attemptDismiss(animated: Bool) { if self.shouldDismiss?(self) != false { if self.options.useInlineMode { if animated { - self.animateOut(duration: duration) { + self.animateOut { self.didDismiss?(self) } } else { From a6577adc7a7eafa9da4e298ffbd7797b869106fb Mon Sep 17 00:00:00 2001 From: Gordon Tucker Date: Fri, 22 Jan 2021 15:50:11 -0700 Subject: [PATCH 26/33] Updated how animateIn works to prevent confusion about having to add sheet as a child every time you display it --- FittedSheets.podspec.json | 4 ++-- FittedSheets/InlineExamplesViewController.swift | 16 +--------------- FittedSheetsPod/SheetViewController.swift | 17 +++++++++++++++++ README.md | 16 +--------------- 4 files changed, 21 insertions(+), 32 deletions(-) diff --git a/FittedSheets.podspec.json b/FittedSheets.podspec.json index d7a88d2..5d4cf7d 100644 --- a/FittedSheets.podspec.json +++ b/FittedSheets.podspec.json @@ -1,6 +1,6 @@ { "name": "FittedSheets", - "version": "2.3.1", + "version": "2.3.2", "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": "2.3.1" + "tag": "2.3.2" }, "platforms": { "ios": "11.0" diff --git a/FittedSheets/InlineExamplesViewController.swift b/FittedSheets/InlineExamplesViewController.swift index 1ecd6f1..db7f86c 100644 --- a/FittedSheets/InlineExamplesViewController.swift +++ b/FittedSheets/InlineExamplesViewController.swift @@ -69,20 +69,6 @@ class InlineExamplesViewController: UIViewController { func presentDemo(_ demo: Demoable) { let sheet = demo.buildDemo(useInlineMode: true) - // Add child - sheet.willMove(toParent: self) - self.addChild(sheet) - self.containerView.addSubview(sheet.view) - sheet.didMove(toParent: self) - - sheet.view.translatesAutoresizingMaskIntoConstraints = false - NSLayoutConstraint.activate([ - sheet.view.topAnchor.constraint(equalTo: self.containerView.topAnchor), - sheet.view.bottomAnchor.constraint(equalTo: self.containerView.bottomAnchor), - sheet.view.leadingAnchor.constraint(equalTo: self.containerView.leadingAnchor), - sheet.view.trailingAnchor.constraint(equalTo: self.containerView.trailingAnchor) - ]) - sheet.didDismiss = { [weak self] _ in print("did dismiss") self?.mapView?.removeFromSuperview() @@ -95,7 +81,7 @@ class InlineExamplesViewController: UIViewController { } // animate in - sheet.animateIn() + sheet.animateIn(to: self.containerView, in: self) } func addMapView() { diff --git a/FittedSheetsPod/SheetViewController.swift b/FittedSheetsPod/SheetViewController.swift index 99de93b..dcf7021 100644 --- a/FittedSheetsPod/SheetViewController.swift +++ b/FittedSheetsPod/SheetViewController.swift @@ -588,6 +588,23 @@ public class SheetViewController: UIViewController { } /// Animates the sheet in, but only if presenting using the inline mode + public func animateIn(to view: UIView, in parent: UIViewController, size: SheetSize? = nil, duration: TimeInterval = 0.3, completion: (() -> Void)? = nil) { + + self.willMove(toParent: parent) + parent.addChild(self) + view.addSubview(self.view) + self.didMove(toParent: parent) + + self.view.translatesAutoresizingMaskIntoConstraints = false + NSLayoutConstraint.activate([ + self.view.topAnchor.constraint(equalTo: view.topAnchor), + self.view.bottomAnchor.constraint(equalTo: view.bottomAnchor), + self.view.leadingAnchor.constraint(equalTo: view.leadingAnchor), + self.view.trailingAnchor.constraint(equalTo: view.trailingAnchor) + ]) + self.animateIn(size: size, duration: duration, completion: completion) + } + public func animateIn(size: SheetSize? = nil, duration: TimeInterval = 0.3, completion: (() -> Void)? = nil) { guard self.options.useInlineMode else { return } guard self.view.superview != nil else { diff --git a/README.md b/README.md index 4120032..eb07eb7 100644 --- a/README.md +++ b/README.md @@ -141,22 +141,8 @@ let options = SheetOptions( let sheetController = SheetViewController(controller: controller, sizes: [.percent(0.3), .fullscreen], options: options) sheetController.allowGestureThroughOverlay = true -// Add child -sheetController.willMove(toParent: self) -self.addChild(sheetController) -view.addSubview(sheetController.view) -sheetController.didMove(toParent: self) - -sheetController.view.translatesAutoresizingMaskIntoConstraints = false -NSLayoutConstraint.activate([ - sheetController.view.topAnchor.constraint(equalTo: view.topAnchor), - sheetController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor), - sheetController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor), - sheetController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor) -]) - // animate in -sheetController.animateIn() +sheetController.animateIn(to: view, in: self) ``` ## Scrolling From 0502be20c95d5bae93a155081a1f1d7ca69924d3 Mon Sep 17 00:00:00 2001 From: Gordon Tucker Date: Tue, 26 Jan 2021 11:20:01 -0700 Subject: [PATCH 27/33] Refactor demos (#133) * Refactored demos to make them easier for new users to parse * Added comments explaining workaround for bug 118 --- {FittedSheets => Demos}/AppDelegate.swift | 0 .../AppIcon.appiconset/Contents.json | 0 .../Assets.xcassets/Contents.json | 0 .../map.imageset/Contents.json | 0 .../Assets.xcassets/map.imageset/map.jpg | Bin .../Base.lproj/LaunchScreen.storyboard | 0 Demos/Base.lproj/Main.storyboard | 369 ++++++++++ .../SlideInAnimationBug118.storyboard | 72 ++ .../SlideInAnimationBug118TagCell.swift | 47 ++ ...SlideInAnimationBug118ViewController.swift | 102 +++ Demos/BugVerificationsViewController.swift | 40 ++ .../DemoControllers}/BlurDemo.swift | 23 +- .../DemoControllers}/ClearPullBarDemo.swift | 25 +- Demos/DemoControllers/ColorDemo.swift | 41 ++ .../HorizontalPaddingDemo.swift | 33 + .../IntrinsicAndFullscreenDemo.storyboard | 73 ++ .../IntrinsicAndFullscreenDemo.swift | 38 + .../IntrinsicAndTrueFullscreenDemo.storyboard | 73 ++ .../IntrinsicAndTrueFullscreenDemo.swift | 33 + .../DemoControllers/IntrinsicDemo.storyboard | 20 +- Demos/DemoControllers/IntrinsicDemo.swift | 36 + .../IntrinsicInNavigationDemo.storyboard | 73 ++ .../IntrinsicInNavigationDemo.swift | 34 + .../DemoControllers/KeyboardDemo.storyboard | 10 +- Demos/DemoControllers/KeyboardDemo.swift | 43 ++ Demos/DemoControllers/MapDemo.swift | 44 ++ .../MaxMinHeightDemo copy.swift | 35 + Demos/DemoControllers/MaxWidthDemo.swift | 36 + .../NavigationDemo.storyboard | 10 +- Demos/DemoControllers/NavigationDemo.swift | 52 ++ Demos/DemoControllers/NestedSheetsDemo.swift | 37 + .../DemoControllers}/NoPullBarDemo.swift | 30 +- .../OnlyCloseWithButtonDemo.storyboard | 20 +- .../OnlyCloseWithButtonDemo.swift | 47 ++ .../DemoControllers}/ResizingDemo.storyboard | 18 +- Demos/DemoControllers/ResizingDemo.swift | 53 ++ .../ScrollInNavigationDemo.storyboard | 106 +-- .../ScrollInNavigationDemo.swift | 42 ++ .../DemoControllers/ScrollViewDemo.storyboard | 149 ++++ Demos/DemoControllers/ScrollViewDemo.swift | 40 ++ Demos/DemoControllers/SimpleDemo.swift | 56 ++ .../TableViewControllerDemo.storyboard | 47 ++ .../TableViewControllerDemo.swift | 25 +- .../DemoControllers/TableViewDemo.storyboard | 64 ++ Demos/DemoControllers/TableViewDemo.swift | 53 ++ Demos/Demoable.swift | 37 + Demos/Info.plist | 45 ++ Demos/InlineDemosViewController.swift | 65 ++ Demos/MapViewController.swift | 26 + Demos/ModalDemosViewController.swift | 66 ++ .../UIClosureActionClosure.swift | 0 FittedSheets.podspec.json | 6 +- FittedSheets.xcodeproj/project.pbxproj | 658 +++++------------- .../xcschemes/FittedSheets.xcscheme | 45 +- ...od.xcscheme => FittedSheetsDemos.xcscheme} | 49 +- FittedSheets/Base.lproj/Main.storyboard | 191 ----- FittedSheets/ColorExample/ColorDemo.swift | 30 - .../ColorExample/ColorExample.storyboard | 89 --- .../ColorExampleViewController.swift | 20 - FittedSheets/Demoable.swift | 21 - .../FittedSheetsPod.h | 0 FittedSheets/Info.plist | 27 +- .../InitialTouchPanGestureRecognizer.swift | 0 .../InlineExamplesViewController.swift | 105 --- .../IntrensicDemo/EmbededIntrensicDemo.swift | 22 - .../IntrensicDemo/HorizontalPaddingDemo.swift | 21 - .../IntrensicAndFullscreenDemo.swift | 26 - .../IntrensicAndTrueFullscreenDemo.swift | 21 - .../IntrensicDemo/IntrensicDemo.swift | 21 - .../IntrinsicExampleViewController.swift | 21 - .../IntrensicDemo/MaxMinHeightDemo.swift | 24 - FittedSheets/IntrensicDemo/MaxWidthDemo.swift | 22 - FittedSheets/IntrensicDemo/RecycledDemo.swift | 33 - .../KeyboardExample/KeyboardDemo.swift | 26 - .../UITextFieldExampleViewController.swift | 26 - .../Base.lproj/Localizable.strings | 0 .../Localization/Localize.swift | 0 .../NavigationDemo/NavigationDemo.swift | 25 - .../NavigationRootViewController.swift | 31 - FittedSheets/NoClosingExample/MapDemo.swift | 30 - .../NoClosingExample/NoCloseDemo.swift | 23 - .../NoClosingExampleViewController.swift | 28 - FittedSheets/RecursionDemo.swift | 27 - FittedSheets/ResizingDemo/ResizingDemo.swift | 19 - .../ResizingExampleViewController.swift | 37 - FittedSheets/RootViewController.swift | 74 -- .../SafeAreaInlineExampleViewController.swift | 80 --- .../ScrollInNavigationDemo.swift | 23 - .../ScrollExamples/ScrollViewDemo.swift | 22 - .../ScrollViewExampleViewController.swift | 24 - .../TableViewControllerDemo.swift | 22 - .../ScrollExamples/TableViewDemo.swift | 22 - .../TableViewExampleViewController.swift | 36 - .../SheetContentViewController.swift | 6 +- .../SheetContentViewDelegate.swift | 0 .../SheetOptions.swift | 10 +- .../SheetSize.swift | 0 .../SheetTransition.swift | 13 +- .../SheetView.swift | 0 .../SheetViewController.swift | 4 +- .../SheetViewDelegate.swift | 0 .../UIColorExtension.swift | 0 .../UIViewControllerExtension.swift | 0 {FittedSheetsPod => FittedSheets}/Yalta.swift | 0 FittedSheetsPod/Info.plist | 22 - FittedSheetsTests/FittedSheetsTests.swift | 36 - FittedSheetsTests/Info.plist | 22 - FittedSheetsUITests/FittedSheetsUITests.swift | 36 - FittedSheetsUITests/Info.plist | 22 - Package.swift | 2 +- README.md | 12 +- 111 files changed, 2492 insertions(+), 2108 deletions(-) rename {FittedSheets => Demos}/AppDelegate.swift (100%) rename {FittedSheets => Demos}/Assets.xcassets/AppIcon.appiconset/Contents.json (100%) rename {FittedSheets => Demos}/Assets.xcassets/Contents.json (100%) rename {FittedSheets => Demos}/Assets.xcassets/map.imageset/Contents.json (100%) rename {FittedSheets => Demos}/Assets.xcassets/map.imageset/map.jpg (100%) rename {FittedSheets => Demos}/Base.lproj/LaunchScreen.storyboard (100%) create mode 100644 Demos/Base.lproj/Main.storyboard create mode 100644 Demos/BugVerificationControllers/SlideInAnimationBug118/SlideInAnimationBug118.storyboard create mode 100644 Demos/BugVerificationControllers/SlideInAnimationBug118/SlideInAnimationBug118TagCell.swift create mode 100644 Demos/BugVerificationControllers/SlideInAnimationBug118/SlideInAnimationBug118ViewController.swift create mode 100644 Demos/BugVerificationsViewController.swift rename {FittedSheets/ColorExample => Demos/DemoControllers}/BlurDemo.swift (52%) rename {FittedSheets/ColorExample => Demos/DemoControllers}/ClearPullBarDemo.swift (57%) create mode 100644 Demos/DemoControllers/ColorDemo.swift create mode 100644 Demos/DemoControllers/HorizontalPaddingDemo.swift create mode 100644 Demos/DemoControllers/IntrinsicAndFullscreenDemo.storyboard create mode 100644 Demos/DemoControllers/IntrinsicAndFullscreenDemo.swift create mode 100644 Demos/DemoControllers/IntrinsicAndTrueFullscreenDemo.storyboard create mode 100644 Demos/DemoControllers/IntrinsicAndTrueFullscreenDemo.swift rename FittedSheets/IntrensicDemo/IntrensicDemo.storyboard => Demos/DemoControllers/IntrinsicDemo.storyboard (87%) create mode 100644 Demos/DemoControllers/IntrinsicDemo.swift create mode 100644 Demos/DemoControllers/IntrinsicInNavigationDemo.storyboard create mode 100644 Demos/DemoControllers/IntrinsicInNavigationDemo.swift rename FittedSheets/KeyboardExample/KeyboardExample.storyboard => Demos/DemoControllers/KeyboardDemo.storyboard (90%) create mode 100644 Demos/DemoControllers/KeyboardDemo.swift create mode 100644 Demos/DemoControllers/MapDemo.swift create mode 100644 Demos/DemoControllers/MaxMinHeightDemo copy.swift create mode 100644 Demos/DemoControllers/MaxWidthDemo.swift rename {FittedSheets/NavigationDemo => Demos/DemoControllers}/NavigationDemo.storyboard (87%) create mode 100644 Demos/DemoControllers/NavigationDemo.swift create mode 100644 Demos/DemoControllers/NestedSheetsDemo.swift rename {FittedSheets/ColorExample => Demos/DemoControllers}/NoPullBarDemo.swift (50%) rename FittedSheets/NoClosingExample/NoClosing.storyboard => Demos/DemoControllers/OnlyCloseWithButtonDemo.storyboard (82%) create mode 100644 Demos/DemoControllers/OnlyCloseWithButtonDemo.swift rename {FittedSheets/ResizingDemo => Demos/DemoControllers}/ResizingDemo.storyboard (85%) create mode 100644 Demos/DemoControllers/ResizingDemo.swift rename FittedSheets/ScrollExamples/ScrollExample.storyboard => Demos/DemoControllers/ScrollInNavigationDemo.storyboard (64%) create mode 100644 Demos/DemoControllers/ScrollInNavigationDemo.swift create mode 100644 Demos/DemoControllers/ScrollViewDemo.storyboard create mode 100644 Demos/DemoControllers/ScrollViewDemo.swift create mode 100644 Demos/DemoControllers/SimpleDemo.swift create mode 100644 Demos/DemoControllers/TableViewControllerDemo.storyboard rename FittedSheets/ScrollExamples/ExampleTableViewController.swift => Demos/DemoControllers/TableViewControllerDemo.swift (54%) create mode 100644 Demos/DemoControllers/TableViewDemo.storyboard create mode 100644 Demos/DemoControllers/TableViewDemo.swift create mode 100644 Demos/Demoable.swift create mode 100644 Demos/Info.plist create mode 100644 Demos/InlineDemosViewController.swift create mode 100644 Demos/MapViewController.swift create mode 100644 Demos/ModalDemosViewController.swift rename {FittedSheets => Demos}/UIClosureActionClosure.swift (100%) rename FittedSheets.xcodeproj/xcshareddata/xcschemes/{FittedSheetsPod.xcscheme => FittedSheetsDemos.xcscheme} (53%) delete mode 100644 FittedSheets/Base.lproj/Main.storyboard delete mode 100644 FittedSheets/ColorExample/ColorDemo.swift delete mode 100644 FittedSheets/ColorExample/ColorExample.storyboard delete mode 100644 FittedSheets/ColorExample/ColorExampleViewController.swift delete mode 100644 FittedSheets/Demoable.swift rename {FittedSheetsPod => FittedSheets}/FittedSheetsPod.h (100%) rename {FittedSheetsPod => FittedSheets}/InitialTouchPanGestureRecognizer.swift (100%) delete mode 100644 FittedSheets/InlineExamplesViewController.swift delete mode 100644 FittedSheets/IntrensicDemo/EmbededIntrensicDemo.swift delete mode 100644 FittedSheets/IntrensicDemo/HorizontalPaddingDemo.swift delete mode 100644 FittedSheets/IntrensicDemo/IntrensicAndFullscreenDemo.swift delete mode 100644 FittedSheets/IntrensicDemo/IntrensicAndTrueFullscreenDemo.swift delete mode 100644 FittedSheets/IntrensicDemo/IntrensicDemo.swift delete mode 100644 FittedSheets/IntrensicDemo/IntrinsicExampleViewController.swift delete mode 100644 FittedSheets/IntrensicDemo/MaxMinHeightDemo.swift delete mode 100644 FittedSheets/IntrensicDemo/MaxWidthDemo.swift delete mode 100644 FittedSheets/IntrensicDemo/RecycledDemo.swift delete mode 100644 FittedSheets/KeyboardExample/KeyboardDemo.swift delete mode 100644 FittedSheets/KeyboardExample/UITextFieldExampleViewController.swift rename {FittedSheetsPod => FittedSheets}/Localization/Base.lproj/Localizable.strings (100%) rename {FittedSheetsPod => FittedSheets}/Localization/Localize.swift (100%) delete mode 100644 FittedSheets/NavigationDemo/NavigationDemo.swift delete mode 100644 FittedSheets/NavigationDemo/NavigationRootViewController.swift delete mode 100644 FittedSheets/NoClosingExample/MapDemo.swift delete mode 100644 FittedSheets/NoClosingExample/NoCloseDemo.swift delete mode 100644 FittedSheets/NoClosingExample/NoClosingExampleViewController.swift delete mode 100644 FittedSheets/RecursionDemo.swift delete mode 100644 FittedSheets/ResizingDemo/ResizingDemo.swift delete mode 100644 FittedSheets/ResizingDemo/ResizingExampleViewController.swift delete mode 100644 FittedSheets/RootViewController.swift delete mode 100644 FittedSheets/SafeAreaInlineExampleViewController.swift delete mode 100644 FittedSheets/ScrollExamples/ScrollInNavigationDemo.swift delete mode 100644 FittedSheets/ScrollExamples/ScrollViewDemo.swift delete mode 100644 FittedSheets/ScrollExamples/ScrollViewExampleViewController.swift delete mode 100644 FittedSheets/ScrollExamples/TableViewControllerDemo.swift delete mode 100644 FittedSheets/ScrollExamples/TableViewDemo.swift delete mode 100644 FittedSheets/ScrollExamples/TableViewExampleViewController.swift rename {FittedSheetsPod => FittedSheets}/SheetContentViewController.swift (98%) rename {FittedSheetsPod => FittedSheets}/SheetContentViewDelegate.swift (100%) rename {FittedSheetsPod => FittedSheets}/SheetOptions.swift (91%) rename {FittedSheetsPod => FittedSheets}/SheetSize.swift (100%) rename {FittedSheetsPod => FittedSheets}/SheetTransition.swift (93%) rename {FittedSheetsPod => FittedSheets}/SheetView.swift (100%) rename {FittedSheetsPod => FittedSheets}/SheetViewController.swift (99%) rename {FittedSheetsPod => FittedSheets}/SheetViewDelegate.swift (100%) rename {FittedSheetsPod => FittedSheets}/UIColorExtension.swift (100%) rename {FittedSheetsPod => FittedSheets}/UIViewControllerExtension.swift (100%) rename {FittedSheetsPod => FittedSheets}/Yalta.swift (100%) delete mode 100644 FittedSheetsPod/Info.plist delete mode 100644 FittedSheetsTests/FittedSheetsTests.swift delete mode 100644 FittedSheetsTests/Info.plist delete mode 100644 FittedSheetsUITests/FittedSheetsUITests.swift delete mode 100644 FittedSheetsUITests/Info.plist diff --git a/FittedSheets/AppDelegate.swift b/Demos/AppDelegate.swift similarity index 100% rename from FittedSheets/AppDelegate.swift rename to Demos/AppDelegate.swift diff --git a/FittedSheets/Assets.xcassets/AppIcon.appiconset/Contents.json b/Demos/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from FittedSheets/Assets.xcassets/AppIcon.appiconset/Contents.json rename to Demos/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/FittedSheets/Assets.xcassets/Contents.json b/Demos/Assets.xcassets/Contents.json similarity index 100% rename from FittedSheets/Assets.xcassets/Contents.json rename to Demos/Assets.xcassets/Contents.json diff --git a/FittedSheets/Assets.xcassets/map.imageset/Contents.json b/Demos/Assets.xcassets/map.imageset/Contents.json similarity index 100% rename from FittedSheets/Assets.xcassets/map.imageset/Contents.json rename to Demos/Assets.xcassets/map.imageset/Contents.json diff --git a/FittedSheets/Assets.xcassets/map.imageset/map.jpg b/Demos/Assets.xcassets/map.imageset/map.jpg similarity index 100% rename from FittedSheets/Assets.xcassets/map.imageset/map.jpg rename to Demos/Assets.xcassets/map.imageset/map.jpg diff --git a/FittedSheets/Base.lproj/LaunchScreen.storyboard b/Demos/Base.lproj/LaunchScreen.storyboard similarity index 100% rename from FittedSheets/Base.lproj/LaunchScreen.storyboard rename to Demos/Base.lproj/LaunchScreen.storyboard diff --git a/Demos/Base.lproj/Main.storyboard b/Demos/Base.lproj/Main.storyboard new file mode 100644 index 0000000..993f1fe --- /dev/null +++ b/Demos/Base.lproj/Main.storyboard @@ -0,0 +1,369 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Demos/BugVerificationControllers/SlideInAnimationBug118/SlideInAnimationBug118.storyboard b/Demos/BugVerificationControllers/SlideInAnimationBug118/SlideInAnimationBug118.storyboard new file mode 100644 index 0000000..7762786 --- /dev/null +++ b/Demos/BugVerificationControllers/SlideInAnimationBug118/SlideInAnimationBug118.storyboard @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Demos/BugVerificationControllers/SlideInAnimationBug118/SlideInAnimationBug118TagCell.swift b/Demos/BugVerificationControllers/SlideInAnimationBug118/SlideInAnimationBug118TagCell.swift new file mode 100644 index 0000000..8c9fd86 --- /dev/null +++ b/Demos/BugVerificationControllers/SlideInAnimationBug118/SlideInAnimationBug118TagCell.swift @@ -0,0 +1,47 @@ +// +// TagCollectionViewCell.swift +// Test +// +// Created by Jordan Hipwell on 1/4/21. +// + +import UIKit + +class SlideInAnimationBug118TagCell: UICollectionViewCell { + var button = UIButton(type: .system) + + override init(frame: CGRect) { + super.init(frame: frame) + + baseInit() + } + + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private func baseInit() { + contentView.translatesAutoresizingMaskIntoConstraints = false + + NSLayoutConstraint.activate([ + contentView.leadingAnchor.constraint(equalTo: leadingAnchor), + contentView.trailingAnchor.constraint(equalTo: trailingAnchor), + contentView.topAnchor.constraint(equalTo: topAnchor), + contentView.bottomAnchor.constraint(equalTo: bottomAnchor) + ]) + + button.translatesAutoresizingMaskIntoConstraints = false + button.setContentHuggingPriority(.required, for: .horizontal) + button.setContentCompressionResistancePriority(.required, for: .horizontal) + + contentView.addSubview(button) + + NSLayoutConstraint.activate([ + button.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), + button.trailingAnchor.constraint(equalTo: contentView.trailingAnchor), + button.topAnchor.constraint(equalTo: contentView.topAnchor), + button.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), + button.heightAnchor.constraint(equalToConstant: 32) + ]) + } +} diff --git a/Demos/BugVerificationControllers/SlideInAnimationBug118/SlideInAnimationBug118ViewController.swift b/Demos/BugVerificationControllers/SlideInAnimationBug118/SlideInAnimationBug118ViewController.swift new file mode 100644 index 0000000..ed4fe96 --- /dev/null +++ b/Demos/BugVerificationControllers/SlideInAnimationBug118/SlideInAnimationBug118ViewController.swift @@ -0,0 +1,102 @@ +// +// AddTagsViewController.swift +// Test +// +// Created by Jordan Hipwell on 1/4/21. +// + +import UIKit +import FittedSheets + +class SlideInAnimationBug118ViewController: UIViewController, Demoable { + static var name: String { "#118 - Sweeping background animation bug" } + + var selectedTags = [String]() + + @IBOutlet private var collectionView: UICollectionView! + + @IBOutlet private var collectionViewHeightConstraint: NSLayoutConstraint! + + private let tags = ["Anger","Misery","Sadness","Happiness","Joy","Fear","Anticipation","Surprise","Shame","Envy","Indignation","Courage","Pride","Love","Confusion","Hope","Respect","Caution","Pain","Rage Melon"] + + private var contentSizeObserverToken: NSKeyValueObservation? = nil + + override func viewDidLoad() { + super.viewDidLoad() + + collectionView.contentInset = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20) + collectionView.register(SlideInAnimationBug118TagCell.self, forCellWithReuseIdentifier: "cell") + + let layout = collectionView.collectionViewLayout as! UICollectionViewFlowLayout + layout.estimatedItemSize = CGSize(width: 150, height: 32) + + //keep the height of the collection view equal to the height of its content size + contentSizeObserverToken = collectionView.observe(\UICollectionView.contentSize, options: [.new]) { [weak self] (object, change) in + guard let selfie = self else { return } + + let newHeight = selfie.collectionView.contentSize.height + if newHeight > 0 && newHeight != selfie.collectionViewHeightConstraint.constant { + //FIXME: Causes sheet dim overlay to animate strangely. + // Moving the + print(selfie.collectionView.contentSize.height) + UIView.performWithoutAnimation { + selfie.collectionViewHeightConstraint.constant = newHeight + } + } + } + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) +/* + // By moving the section from viewDidLoad to the commented out code block below, the bug goes away. + + contentSizeObserverToken?.invalidate() + contentSizeObserverToken = collectionView.observe(\UICollectionView.contentSize, options: [.new]) { [weak self] (object, change) in + guard let selfie = self else { return } + + let newHeight = selfie.collectionView.contentSize.height + if newHeight > 0 && newHeight != selfie.collectionViewHeightConstraint.constant { + //FIXME: Causes sheet dim overlay to animate strangely. + // Moving the + print(selfie.collectionView.contentSize.height) + UIView.performWithoutAnimation { + selfie.collectionViewHeightConstraint.constant = newHeight + } + } + } + */ + } + + static func openDemo(from parent: UIViewController, in view: UIView?) { + let addTags = UIStoryboard(name: "SlideInAnimationBug118", bundle: nil).instantiateInitialViewController()! + + let sheetController = SheetViewController( + controller: addTags, + sizes: [.intrinsic], + options: SheetOptions( + pullBarHeight: 0, + shouldExtendBackground: true, + useFullScreenMode: false, + shrinkPresentingViewController: false)) + parent.present(sheetController, animated: true, completion: nil) + } +} + +extension SlideInAnimationBug118ViewController: UICollectionViewDataSource, UICollectionViewDelegate { + + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return tags.count + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! SlideInAnimationBug118TagCell + let tag = tags[indexPath.item] + + cell.button.setTitle(tag, for: .normal) + cell.button.contentEdgeInsets = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 10) + + return cell + } + +} diff --git a/Demos/BugVerificationsViewController.swift b/Demos/BugVerificationsViewController.swift new file mode 100644 index 0000000..c2b9bbc --- /dev/null +++ b/Demos/BugVerificationsViewController.swift @@ -0,0 +1,40 @@ +// +// InlineExamplesViewController.swift +// FittedSheets +// +// Created by Gordon Tucker on 8/5/20. +// Copyright © 2020 Gordon Tucker. All rights reserved. +// + +import UIKit +import FittedSheets + +class BugVerificationsViewController: UIViewController { + + @IBOutlet var stackView: UIStackView! + @IBOutlet var containerView: UIView! + + override func viewDidLoad() { + super.viewDidLoad() + + self.addButton(for: SlideInAnimationBug118ViewController.self) + } + + func addButton(for demo: (UIViewController & Demoable).Type, onTap: (() -> Void)? = nil) { + let button = UIButton() + button.setTitle(demo.name, for: .normal) + button.contentHorizontalAlignment = .left + button.backgroundColor = UIColor.black + button.setTitleColor(UIColor.white, for: .normal) + button.contentEdgeInsets = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20) + button.heightAnchor.constraint(equalToConstant: 44).isActive = true + button.layer.cornerRadius = 22 + button.layer.masksToBounds = true + + button.onTap { [unowned self] in + demo.openDemo(from: self, in: nil) + onTap?() + } + self.stackView.addArrangedSubview(button) + } +} diff --git a/FittedSheets/ColorExample/BlurDemo.swift b/Demos/DemoControllers/BlurDemo.swift similarity index 52% rename from FittedSheets/ColorExample/BlurDemo.swift rename to Demos/DemoControllers/BlurDemo.swift index d261688..96506e4 100644 --- a/FittedSheets/ColorExample/BlurDemo.swift +++ b/Demos/DemoControllers/BlurDemo.swift @@ -7,15 +7,15 @@ // import UIKit -import FittedSheetsPod +import FittedSheets -class BlurDemo: Demoable { - var name: String { - return "Blur Effect" - } +class BlurDemo: SimpleDemo { + override class var name: String { "Blur Effect" } - func buildDemo(useInlineMode: Bool) -> SheetViewController { - let controller = UIStoryboard(name: "ColorExample", bundle: nil).instantiateViewController(withIdentifier: "customize") + override class func openDemo(from parent: UIViewController, in view: UIView?) { + let useInlineMode = view != nil + + let controller = ColorDemo() var options = SheetOptions() options.pullBarHeight = 30 @@ -26,6 +26,13 @@ class BlurDemo: Demoable { sheet.cornerRadius = 30 sheet.gripSize = CGSize(width: 100, height: 12) - return sheet + + addSheetEventLogging(to: sheet) + + if let view = view { + sheet.animateIn(to: view, in: parent) + } else { + parent.present(sheet, animated: true, completion: nil) + } } } diff --git a/FittedSheets/ColorExample/ClearPullBarDemo.swift b/Demos/DemoControllers/ClearPullBarDemo.swift similarity index 57% rename from FittedSheets/ColorExample/ClearPullBarDemo.swift rename to Demos/DemoControllers/ClearPullBarDemo.swift index 6d09a90..604db7c 100644 --- a/FittedSheets/ColorExample/ClearPullBarDemo.swift +++ b/Demos/DemoControllers/ClearPullBarDemo.swift @@ -7,15 +7,15 @@ // import UIKit -import FittedSheetsPod +import FittedSheets -class ClearPullBarDemo: Demoable { - var name: String { - return "Clear Pull Bar" - } - - func buildDemo(useInlineMode: Bool) -> SheetViewController { - let controller = UIStoryboard(name: "ColorExample", bundle: nil).instantiateViewController(withIdentifier: "customize") +class ClearPullBarDemo: SimpleDemo { + override class var name: String { "Clear Pull Bar" } + + override class func openDemo(from parent: UIViewController, in view: UIView?) { + let useInlineMode = view != nil + + let controller = ColorDemo() var options = SheetOptions() options.pullBarHeight = 30 @@ -29,6 +29,13 @@ class ClearPullBarDemo: Demoable { sheet.minimumSpaceAbovePullBar = 20 sheet.cornerRadius = 30 sheet.gripSize = CGSize(width: 100, height: 12) - return sheet + + addSheetEventLogging(to: sheet) + + if let view = view { + sheet.animateIn(to: view, in: parent) + } else { + parent.present(sheet, animated: true, completion: nil) + } } } diff --git a/Demos/DemoControllers/ColorDemo.swift b/Demos/DemoControllers/ColorDemo.swift new file mode 100644 index 0000000..986a12e --- /dev/null +++ b/Demos/DemoControllers/ColorDemo.swift @@ -0,0 +1,41 @@ +// +// FullScreenExampleViewController.swift +// FittedSheets +// +// Created by Gordon Tucker on 2/1/19. +// Copyright © 2019 Gordon Tucker. All rights reserved. +// + +import UIKit +import FittedSheets + +class ColorDemo: SimpleDemo { + override class var name: String { "Color Options" } + + override class func openDemo(from parent: UIViewController, in view: UIView?) { + let useInlineMode = view != nil + + let controller = ColorDemo() + + var options = SheetOptions() + options.useInlineMode = useInlineMode + options.shouldExtendBackground = false + + let sheet = SheetViewController( + controller: controller, + sizes: [.percent(0.25), .percent(0.75), .fullscreen], + options: options) + sheet.overlayColor = UIColor(red: 0.933, green: 0.314, blue: 0.349, alpha: 0.3) + sheet.gripColor = .purple + sheet.pullBarBackgroundColor = .yellow + sheet.cornerRadius = 40 + + addSheetEventLogging(to: sheet) + + if let view = view { + sheet.animateIn(to: view, in: parent) + } else { + parent.present(sheet, animated: true, completion: nil) + } + } +} diff --git a/Demos/DemoControllers/HorizontalPaddingDemo.swift b/Demos/DemoControllers/HorizontalPaddingDemo.swift new file mode 100644 index 0000000..35d77cc --- /dev/null +++ b/Demos/DemoControllers/HorizontalPaddingDemo.swift @@ -0,0 +1,33 @@ +// +// HorizontalPaddingDemo.swift +// FittedSheets +// +// Created by Gordon Tucker on 1/4/21. +// Copyright © 2021 Gordon Tucker. All rights reserved. +// + +import UIKit +import FittedSheets + +class HorizontalPaddingDemo: SimpleDemo { + override class var name: String { "Horizontal Padding" } + + override class func openDemo(from parent: UIViewController, in view: UIView?) { + let useInlineMode = view != nil + + let controller = ColorDemo() + + let sheet = SheetViewController( + controller: controller, + sizes: [.fixed(150), .fixed(350)], + options: SheetOptions(useInlineMode: useInlineMode, horizontalPadding: 20)) + + addSheetEventLogging(to: sheet) + + if let view = view { + sheet.animateIn(to: view, in: parent) + } else { + parent.present(sheet, animated: true, completion: nil) + } + } +} diff --git a/Demos/DemoControllers/IntrinsicAndFullscreenDemo.storyboard b/Demos/DemoControllers/IntrinsicAndFullscreenDemo.storyboard new file mode 100644 index 0000000..b44f49d --- /dev/null +++ b/Demos/DemoControllers/IntrinsicAndFullscreenDemo.storyboard @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Demos/DemoControllers/IntrinsicAndFullscreenDemo.swift b/Demos/DemoControllers/IntrinsicAndFullscreenDemo.swift new file mode 100644 index 0000000..acc9b5d --- /dev/null +++ b/Demos/DemoControllers/IntrinsicAndFullscreenDemo.swift @@ -0,0 +1,38 @@ +// +// IntrinsicDemo.swift +// FittedSheets +// +// Created by Gordon Tucker on 7/30/20. +// Copyright © 2020 Gordon Tucker. All rights reserved. +// + +import UIKit +import FittedSheets + +class IntrinsicAndFullscreenDemo: UIViewController, Demoable { + static var name: String { "Intrinsic And Fullscreen" } + + override func viewDidLoad() { + super.viewDidLoad() + } + + static func openDemo(from parent: UIViewController, in view: UIView?) { + let useInlineMode = view != nil + + let controller = UIStoryboard(name: "IntrinsicAndFullscreenDemo", bundle: nil).instantiateInitialViewController()! + + let options = SheetOptions( + useFullScreenMode: false, + useInlineMode: useInlineMode) + let sheet = SheetViewController(controller: controller, sizes: [.fullscreen, .intrinsic], options: options) + sheet.minimumSpaceAbovePullBar = 44 + + addSheetEventLogging(to: sheet) + + if let view = view { + sheet.animateIn(to: view, in: parent) + } else { + parent.present(sheet, animated: true, completion: nil) + } + } +} diff --git a/Demos/DemoControllers/IntrinsicAndTrueFullscreenDemo.storyboard b/Demos/DemoControllers/IntrinsicAndTrueFullscreenDemo.storyboard new file mode 100644 index 0000000..21b366a --- /dev/null +++ b/Demos/DemoControllers/IntrinsicAndTrueFullscreenDemo.storyboard @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Demos/DemoControllers/IntrinsicAndTrueFullscreenDemo.swift b/Demos/DemoControllers/IntrinsicAndTrueFullscreenDemo.swift new file mode 100644 index 0000000..a9b1481 --- /dev/null +++ b/Demos/DemoControllers/IntrinsicAndTrueFullscreenDemo.swift @@ -0,0 +1,33 @@ +// +// IntrinsicDemo.swift +// FittedSheets +// +// Created by Gordon Tucker on 7/30/20. +// Copyright © 2020 Gordon Tucker. All rights reserved. +// + +import UIKit +import FittedSheets + +class IntrinsicAndTrueFullscreenDemo: UIViewController, Demoable { + static var name: String { "Intrinsic And True Fullscreen" } + + static func openDemo(from parent: UIViewController, in view: UIView?) { + let useInlineMode = view != nil + + let controller = UIStoryboard(name: "IntrinsicAndTrueFullscreenDemo", bundle: nil).instantiateInitialViewController()! + + let sheet = SheetViewController( + controller: controller, + sizes: [.intrinsic, .fullscreen], + options: SheetOptions(useInlineMode: useInlineMode)) + + addSheetEventLogging(to: sheet) + + if let view = view { + sheet.animateIn(to: view, in: parent) + } else { + parent.present(sheet, animated: true, completion: nil) + } + } +} diff --git a/FittedSheets/IntrensicDemo/IntrensicDemo.storyboard b/Demos/DemoControllers/IntrinsicDemo.storyboard similarity index 87% rename from FittedSheets/IntrensicDemo/IntrensicDemo.storyboard rename to Demos/DemoControllers/IntrinsicDemo.storyboard index 7b89107..06bb59e 100644 --- a/FittedSheets/IntrensicDemo/IntrensicDemo.storyboard +++ b/Demos/DemoControllers/IntrinsicDemo.storyboard @@ -1,17 +1,18 @@ - + - + + - + - + @@ -40,7 +41,8 @@ - + + @@ -53,9 +55,8 @@ - - + @@ -64,4 +65,9 @@ + + + + + diff --git a/Demos/DemoControllers/IntrinsicDemo.swift b/Demos/DemoControllers/IntrinsicDemo.swift new file mode 100644 index 0000000..56a12a7 --- /dev/null +++ b/Demos/DemoControllers/IntrinsicDemo.swift @@ -0,0 +1,36 @@ +// +// IntrinsicExampleViewController.swift +// FittedSheets +// +// Created by Gordon Tucker on 2/1/19. +// Copyright © 2019 Gordon Tucker. All rights reserved. +// + +import UIKit +import FittedSheets + +class IntrinsicDemo: UIViewController, Demoable { + static var name: String { "Intrinsic Height" } + + override func viewDidLoad() { + super.viewDidLoad() + } + + static func openDemo(from parent: UIViewController, in view: UIView?) { + let useInlineMode = view != nil + + let controller = UIStoryboard(name: "IntrinsicDemo", bundle: nil).instantiateInitialViewController()! + + let sheet = SheetViewController( + controller: controller, + options: SheetOptions(useInlineMode: useInlineMode)) + + addSheetEventLogging(to: sheet) + + if let view = view { + sheet.animateIn(to: view, in: parent) + } else { + parent.present(sheet, animated: true, completion: nil) + } + } +} diff --git a/Demos/DemoControllers/IntrinsicInNavigationDemo.storyboard b/Demos/DemoControllers/IntrinsicInNavigationDemo.storyboard new file mode 100644 index 0000000..efcee12 --- /dev/null +++ b/Demos/DemoControllers/IntrinsicInNavigationDemo.storyboard @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Demos/DemoControllers/IntrinsicInNavigationDemo.swift b/Demos/DemoControllers/IntrinsicInNavigationDemo.swift new file mode 100644 index 0000000..07dcf33 --- /dev/null +++ b/Demos/DemoControllers/IntrinsicInNavigationDemo.swift @@ -0,0 +1,34 @@ +// +// EmbededIntrinsicDemo.swift +// FittedSheets +// +// Created by Gordon Tucker on 7/30/20. +// Copyright © 2020 Gordon Tucker. All rights reserved. +// + +import UIKit +import FittedSheets + +class IntrinsicInNavigationDemo: UIViewController, Demoable { + static var name: String { "Intrinsic height in navigation controller" } + + static func openDemo(from parent: UIViewController, in view: UIView?) { + let useInlineMode = view != nil + + let controller = UIStoryboard(name: "IntrinsicInNavigationDemo", bundle: nil).instantiateInitialViewController()! + + let nav = UINavigationController(rootViewController: controller) + + let sheet = SheetViewController( + controller: nav, + options: SheetOptions(useInlineMode: useInlineMode)) + + addSheetEventLogging(to: sheet) + + if let view = view { + sheet.animateIn(to: view, in: parent) + } else { + parent.present(sheet, animated: true, completion: nil) + } + } +} diff --git a/FittedSheets/KeyboardExample/KeyboardExample.storyboard b/Demos/DemoControllers/KeyboardDemo.storyboard similarity index 90% rename from FittedSheets/KeyboardExample/KeyboardExample.storyboard rename to Demos/DemoControllers/KeyboardDemo.storyboard index 13670e6..5fc6f1e 100644 --- a/FittedSheets/KeyboardExample/KeyboardExample.storyboard +++ b/Demos/DemoControllers/KeyboardDemo.storyboard @@ -1,9 +1,9 @@ - + - + @@ -11,7 +11,7 @@ - + @@ -21,7 +21,7 @@ - + @@ -47,7 +48,6 @@ - diff --git a/Demos/DemoControllers/KeyboardDemo.swift b/Demos/DemoControllers/KeyboardDemo.swift new file mode 100644 index 0000000..c0f2f4b --- /dev/null +++ b/Demos/DemoControllers/KeyboardDemo.swift @@ -0,0 +1,43 @@ +// +// UITextFieldExampleViewController.swift +// FittedSheets +// +// Created by Gordon Tucker on 2/1/19. +// Copyright © 2019 Gordon Tucker. All rights reserved. +// + +import UIKit +import FittedSheets + +class KeyboardDemo: UIViewController, Demoable { + static var name: String { "Keyboard" } + + override func viewDidLoad() { + super.viewDidLoad() + } + + @IBAction func doneTapped(_ sender: Any) { + self.view.endEditing(true) + } + + static func openDemo(from parent: UIViewController, in view: UIView?) { + let useInlineMode = view != nil + + let controller = UIStoryboard(name: "KeyboardDemo", bundle: nil).instantiateInitialViewController()! + + let sheet = SheetViewController( + controller: controller, + sizes: [.percent(0.5), .fullscreen], + options: SheetOptions(useInlineMode: useInlineMode)) + + sheet.autoAdjustToKeyboard = false + + addSheetEventLogging(to: sheet) + + if let view = view { + sheet.animateIn(to: view, in: parent) + } else { + parent.present(sheet, animated: true, completion: nil) + } + } +} diff --git a/Demos/DemoControllers/MapDemo.swift b/Demos/DemoControllers/MapDemo.swift new file mode 100644 index 0000000..132a7be --- /dev/null +++ b/Demos/DemoControllers/MapDemo.swift @@ -0,0 +1,44 @@ +// +// IntrinsicDemo.swift +// FittedSheets +// +// Created by Gordon Tucker on 7/30/20. +// Copyright © 2020 Gordon Tucker. All rights reserved. +// + +import UIKit +import FittedSheets + +class MapDemo: SimpleDemo { + override class var name: String { "Map Demo" } + + override class func openDemo(from parent: UIViewController, in view: UIView?) { + let useInlineMode = view != nil + + let controller = ColorDemo() + + let sheet = SheetViewController( + controller: controller, + sizes: [.fixed(100), .percent(0.5), .fullscreen], + options: SheetOptions(useInlineMode: useInlineMode)) + sheet.allowPullingPastMaxHeight = false + sheet.allowPullingPastMinHeight = false + + sheet.dismissOnPull = false + sheet.dismissOnOverlayTap = false + sheet.overlayColor = UIColor.clear + + sheet.contentViewController.view.layer.shadowColor = UIColor.black.cgColor + sheet.contentViewController.view.layer.shadowOpacity = 0.1 + sheet.contentViewController.view.layer.shadowRadius = 10 + sheet.allowGestureThroughOverlay = true + + addSheetEventLogging(to: sheet) + + if let view = view { + sheet.animateIn(to: view, in: parent) + } else { + parent.present(sheet, animated: true, completion: nil) + } + } +} diff --git a/Demos/DemoControllers/MaxMinHeightDemo copy.swift b/Demos/DemoControllers/MaxMinHeightDemo copy.swift new file mode 100644 index 0000000..6d56f22 --- /dev/null +++ b/Demos/DemoControllers/MaxMinHeightDemo copy.swift @@ -0,0 +1,35 @@ +// +// IntrinsicDemo.swift +// FittedSheets +// +// Created by Gordon Tucker on 7/30/20. +// Copyright © 2020 Gordon Tucker. All rights reserved. +// + +import UIKit +import FittedSheets + +class MaxMinHeightDemo: SimpleDemo { + override class var name: String { "Max Min Height" } + + override class func openDemo(from parent: UIViewController, in view: UIView?) { + let useInlineMode = view != nil + + let controller = ColorDemo() + + let sheet = SheetViewController( + controller: controller, + sizes: [.fixed(150), .fixed(350)], + options: SheetOptions(useInlineMode: useInlineMode)) + sheet.allowPullingPastMaxHeight = false + sheet.allowPullingPastMinHeight = false + + addSheetEventLogging(to: sheet) + + if let view = view { + sheet.animateIn(to: view, in: parent) + } else { + parent.present(sheet, animated: true, completion: nil) + } + } +} diff --git a/Demos/DemoControllers/MaxWidthDemo.swift b/Demos/DemoControllers/MaxWidthDemo.swift new file mode 100644 index 0000000..3477cd9 --- /dev/null +++ b/Demos/DemoControllers/MaxWidthDemo.swift @@ -0,0 +1,36 @@ +// +// MaxWidthDemo.swift +// FittedSheets +// +// Created by Gordon Tucker on 1/4/21. +// Copyright © 2021 Gordon Tucker. All rights reserved. +// + +import UIKit +import FittedSheets + +class MaxWidthDemo: SimpleDemo { + override class var name: String { + return "Max Width" + } + + override class func openDemo(from parent: UIViewController, in view: UIView?) { + let useInlineMode = view != nil + + let controller = ColorDemo() + + let sheet = SheetViewController( + controller: controller, + sizes: [.fixed(150), .fixed(350)], + options: SheetOptions(useInlineMode: useInlineMode, maxWidth: 100)) + + addSheetEventLogging(to: sheet) + + if let view = view { + sheet.animateIn(to: view, in: parent) + } else { + parent.present(sheet, animated: true, completion: nil) + } + } +} + diff --git a/FittedSheets/NavigationDemo/NavigationDemo.storyboard b/Demos/DemoControllers/NavigationDemo.storyboard similarity index 87% rename from FittedSheets/NavigationDemo/NavigationDemo.storyboard rename to Demos/DemoControllers/NavigationDemo.storyboard index b9f788d..08dd4bb 100644 --- a/FittedSheets/NavigationDemo/NavigationDemo.storyboard +++ b/Demos/DemoControllers/NavigationDemo.storyboard @@ -1,9 +1,9 @@ - + - + @@ -11,12 +11,12 @@ - + - + - diff --git a/Demos/DemoControllers/NavigationDemo.swift b/Demos/DemoControllers/NavigationDemo.swift new file mode 100644 index 0000000..1d1c242 --- /dev/null +++ b/Demos/DemoControllers/NavigationDemo.swift @@ -0,0 +1,52 @@ +// +// NavigationRootViewController.swift +// FittedSheets +// +// Created by Gordon Tucker on 2/1/19. +// Copyright © 2019 Gordon Tucker. All rights reserved. +// + +import UIKit +import FittedSheets + +class NavigationDemo: UIViewController, Demoable { + static var name: String { "Navigation controller" } + + var exampleViewController: UIViewController! + + @IBAction func navigateToChildTapped(_ sender: Any) { + self.navigationController?.pushViewController(exampleViewController, animated: true) + } + + @IBAction func closeTapped(_ sender: Any) { + if self.sheetViewController?.options.useInlineMode == true { + self.sheetViewController?.attemptDismiss(animated: true) + } else { + self.dismiss(animated: true, completion: nil) + } + } + + static func openDemo(from parent: UIViewController, in view: UIView?) { + let useInlineMode = view != nil + + let controller2 = UIStoryboard(name: "KeyboardDemo", bundle: nil).instantiateInitialViewController()! + + let controller = UIStoryboard(name: "NavigationDemo", bundle: nil).instantiateInitialViewController() as! NavigationDemo + controller.exampleViewController = controller2 + + let nav = UINavigationController(rootViewController: controller) + + let sheet = SheetViewController( + controller: nav, + sizes: [.intrinsic, .percent(0.5), .fullscreen], + options: SheetOptions(useInlineMode: useInlineMode)) + + addSheetEventLogging(to: sheet) + + if let view = view { + sheet.animateIn(to: view, in: parent) + } else { + parent.present(sheet, animated: true, completion: nil) + } + } +} diff --git a/Demos/DemoControllers/NestedSheetsDemo.swift b/Demos/DemoControllers/NestedSheetsDemo.swift new file mode 100644 index 0000000..53f0b0b --- /dev/null +++ b/Demos/DemoControllers/NestedSheetsDemo.swift @@ -0,0 +1,37 @@ +// +// TableViewDemo.swift +// FittedSheets +// +// Created by Gordon Tucker on 8/4/20. +// Copyright © 2020 Gordon Tucker. All rights reserved. +// + +import UIKit +import FittedSheets + +class NestedSheetsDemo: UIViewController, Demoable { + class var name: String { "Nested Sheets" } + + class func openDemo(from parent: UIViewController, in view: UIView?) { + let useInlineMode = view != nil + + let controller = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()! + + var options = SheetOptions() + options.useInlineMode = useInlineMode + options.useFullScreenMode = false + options.transitionOverflowType = .color(color: .blue) + let sheet = SheetViewController( + controller: controller, + sizes: [.percent(0.50), .fullscreen], + options: options) + + addSheetEventLogging(to: sheet) + + if let view = view { + sheet.animateIn(to: view, in: parent) + } else { + parent.present(sheet, animated: true, completion: nil) + } + } +} diff --git a/FittedSheets/ColorExample/NoPullBarDemo.swift b/Demos/DemoControllers/NoPullBarDemo.swift similarity index 50% rename from FittedSheets/ColorExample/NoPullBarDemo.swift rename to Demos/DemoControllers/NoPullBarDemo.swift index 4d2807f..ce420ba 100644 --- a/FittedSheets/ColorExample/NoPullBarDemo.swift +++ b/Demos/DemoControllers/NoPullBarDemo.swift @@ -7,22 +7,24 @@ // import UIKit -import FittedSheetsPod +import FittedSheets -class NoPullBarDemo: Demoable { - var name: String { - return "No Pull Bar" - } - - func buildDemo(useInlineMode: Bool) -> SheetViewController { - let controller = UIStoryboard(name: "ColorExample", bundle: nil).instantiateViewController(withIdentifier: "customize") +class NoPullBarDemo: SimpleDemo { + override class var name: String { "No Pull Bar" } + + override class func openDemo(from parent: UIViewController, in view: UIView?) { + let useInlineMode = view != nil + + let controller = ColorDemo() var options = SheetOptions() options.pullBarHeight = 0 options.useInlineMode = useInlineMode - let sheet = SheetViewController(controller: controller, sizes: [.percent(0.25), .fullscreen], options: options) - + let sheet = SheetViewController( + controller: controller, + sizes: [.percent(0.25), .fullscreen], + options: options) sheet.cornerRadius = 4 sheet.allowPullingPastMaxHeight = false sheet.overlayColor = .clear @@ -30,6 +32,12 @@ class NoPullBarDemo: Demoable { sheet.contentViewController.view.layer.shadowOpacity = 0.06 sheet.contentViewController.view.layer.shadowRadius = 10 - return sheet + addSheetEventLogging(to: sheet) + + if let view = view { + sheet.animateIn(to: view, in: parent) + } else { + parent.present(sheet, animated: true, completion: nil) + } } } diff --git a/FittedSheets/NoClosingExample/NoClosing.storyboard b/Demos/DemoControllers/OnlyCloseWithButtonDemo.storyboard similarity index 82% rename from FittedSheets/NoClosingExample/NoClosing.storyboard rename to Demos/DemoControllers/OnlyCloseWithButtonDemo.storyboard index e826fcc..c63cf92 100644 --- a/FittedSheets/NoClosingExample/NoClosing.storyboard +++ b/Demos/DemoControllers/OnlyCloseWithButtonDemo.storyboard @@ -1,22 +1,23 @@ - + - + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FittedSheets/ColorExample/ColorDemo.swift b/FittedSheets/ColorExample/ColorDemo.swift deleted file mode 100644 index e8eab70..0000000 --- a/FittedSheets/ColorExample/ColorDemo.swift +++ /dev/null @@ -1,30 +0,0 @@ -// -// ColorDemo.swift -// FittedSheets -// -// Created by Gordon Tucker on 8/4/20. -// Copyright © 2020 Gordon Tucker. All rights reserved. -// - -import UIKit -import FittedSheetsPod - -class ColorDemo: Demoable { - var name: String { - return "Colors" - } - - func buildDemo(useInlineMode: Bool) -> SheetViewController { - let controller = ColorExampleViewController.instantiate() - var options = SheetOptions() - options.useInlineMode = useInlineMode - options.shouldExtendBackground = false - let sheet = SheetViewController(controller: controller, sizes: [.intrinsic, .percent(0.75), .fullscreen], options: options) - sheet.overlayColor = UIColor(red: 0.933, green: 0.314, blue: 0.349, alpha: 0.3) - sheet.gripColor = .purple - sheet.pullBarBackgroundColor = .orange - sheet.cornerRadius = 40 - - return sheet - } -} diff --git a/FittedSheets/ColorExample/ColorExample.storyboard b/FittedSheets/ColorExample/ColorExample.storyboard deleted file mode 100644 index e298ed6..0000000 --- a/FittedSheets/ColorExample/ColorExample.storyboard +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FittedSheets/ColorExample/ColorExampleViewController.swift b/FittedSheets/ColorExample/ColorExampleViewController.swift deleted file mode 100644 index fd7ce1c..0000000 --- a/FittedSheets/ColorExample/ColorExampleViewController.swift +++ /dev/null @@ -1,20 +0,0 @@ -// -// FullScreenExampleViewController.swift -// FittedSheets -// -// Created by Gordon Tucker on 2/1/19. -// Copyright © 2019 Gordon Tucker. All rights reserved. -// - -import UIKit - -class ColorExampleViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - } - - static func instantiate() -> ColorExampleViewController { - return UIStoryboard(name: "ColorExample", bundle: nil).instantiateInitialViewController() as! ColorExampleViewController - } -} diff --git a/FittedSheets/Demoable.swift b/FittedSheets/Demoable.swift deleted file mode 100644 index cc53500..0000000 --- a/FittedSheets/Demoable.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// Demoable.swift -// FittedSheets -// -// Created by Gordon Tucker on 7/30/20. -// Copyright © 2020 Gordon Tucker. All rights reserved. -// - -import UIKit -import FittedSheetsPod - -protocol Demoable { - var name: String { get } - func buildDemo(useInlineMode: Bool) -> SheetViewController -} - -extension Demoable { - func buildDemo() -> SheetViewController { - return self.buildDemo(useInlineMode: false) - } -} diff --git a/FittedSheetsPod/FittedSheetsPod.h b/FittedSheets/FittedSheetsPod.h similarity index 100% rename from FittedSheetsPod/FittedSheetsPod.h rename to FittedSheets/FittedSheetsPod.h diff --git a/FittedSheets/Info.plist b/FittedSheets/Info.plist index 16be3b6..e1fe4cf 100644 --- a/FittedSheets/Info.plist +++ b/FittedSheets/Info.plist @@ -13,33 +13,10 @@ CFBundleName $(PRODUCT_NAME) CFBundlePackageType - APPL + FMWK CFBundleShortVersionString 1.0 CFBundleVersion - 1 - LSRequiresIPhoneOS - - UILaunchStoryboardName - LaunchScreen - UIMainStoryboardFile - Main - UIRequiredDeviceCapabilities - - armv7 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - + $(CURRENT_PROJECT_VERSION) diff --git a/FittedSheetsPod/InitialTouchPanGestureRecognizer.swift b/FittedSheets/InitialTouchPanGestureRecognizer.swift similarity index 100% rename from FittedSheetsPod/InitialTouchPanGestureRecognizer.swift rename to FittedSheets/InitialTouchPanGestureRecognizer.swift diff --git a/FittedSheets/InlineExamplesViewController.swift b/FittedSheets/InlineExamplesViewController.swift deleted file mode 100644 index db7f86c..0000000 --- a/FittedSheets/InlineExamplesViewController.swift +++ /dev/null @@ -1,105 +0,0 @@ -// -// InlineExamplesViewController.swift -// FittedSheets -// -// Created by Gordon Tucker on 8/5/20. -// Copyright © 2020 Gordon Tucker. All rights reserved. -// - -import UIKit -import FittedSheetsPod - -class InlineExamplesViewController: UIViewController { - - @IBOutlet var stackView: UIStackView! - @IBOutlet var containerView: UIView! - @IBOutlet var stackViewBottomConstraint: NSLayoutConstraint! - var mapView: UIView? - - var demos: [Demoable] = [ - IntrensicDemo(), - EmbededIntrensicDemo(), - IntrensicAndFullscreenDemo(), - IntrensicAndTrueFullscreenDemo(), - ResizingDemo(), - RecycledDemo(), - NavigationDemo(), - KeyboardDemo(), - ScrollViewDemo(), - ScrollInNavigationDemo(), - TableViewDemo(), - TableViewControllerDemo(), - ColorDemo(), - NoPullBarDemo(), - ClearPullBarDemo(), - NoCloseDemo(), - RecursionDemo(), - MaxMinHeightDemo(), - HorizontalPaddingDemo(), - MaxWidthDemo() - ] - - override func viewDidLoad() { - super.viewDidLoad() - - self.addButton(demo: MapDemo()) { [weak self] in - self?.addMapView() - } - - for demo in demos { - self.addButton(demo: demo) - } - } - - func addButton(demo: Demoable, onTap: (() -> Void)? = nil) { - let button = UIButton() - button.setTitle(demo.name, for: .normal) - if #available(iOS 13.0, *) { - button.setTitleColor(.label, for: .normal) - } else { - button.setTitleColor(UIColor.darkText, for: .normal) - } - button.onTap { [weak self] in - onTap?() - self?.presentDemo(demo) - } - self.stackView.addArrangedSubview(button) - } - - func presentDemo(_ demo: Demoable) { - let sheet = demo.buildDemo(useInlineMode: true) - - sheet.didDismiss = { [weak self] _ in - print("did dismiss") - self?.mapView?.removeFromSuperview() - self?.stackViewBottomConstraint.constant = 20 - } - - sheet.shouldDismiss = { _ in - print("should dismiss") - return true - } - - // animate in - sheet.animateIn(to: self.containerView, in: self) - } - - func addMapView() { - let view = UIScrollView() - let imageView = UIImageView() - view.addSubview(imageView) - imageView.image = UIImage(named: "map") - imageView.contentMode = .scaleAspectFill - Constraints(for: imageView) { - $0.size.height.set(UIScreen.main.bounds.size.height) - $0.size.width.set(UIScreen.main.bounds.size.width * 2) - $0.edges.pinToSuperview() - } - - self.containerView.addSubview(view) - Constraints(for: view) { - $0.edges.pinToSuperview() - } - self.mapView = view - } -} diff --git a/FittedSheets/IntrensicDemo/EmbededIntrensicDemo.swift b/FittedSheets/IntrensicDemo/EmbededIntrensicDemo.swift deleted file mode 100644 index e4d9fbf..0000000 --- a/FittedSheets/IntrensicDemo/EmbededIntrensicDemo.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// EmbededIntrensicDemo.swift -// FittedSheets -// -// Created by Gordon Tucker on 7/30/20. -// Copyright © 2020 Gordon Tucker. All rights reserved. -// - -import UIKit -import FittedSheetsPod - -class EmbededIntrensicDemo: Demoable { - var name: String { - return "Embeded Intrensic Height" - } - - func buildDemo(useInlineMode: Bool) -> SheetViewController { - let controller = IntrinsicExampleViewController.instantiate() - let nav = UINavigationController(rootViewController: controller) - return SheetViewController(controller: nav, options: SheetOptions(useInlineMode: useInlineMode)) - } -} diff --git a/FittedSheets/IntrensicDemo/HorizontalPaddingDemo.swift b/FittedSheets/IntrensicDemo/HorizontalPaddingDemo.swift deleted file mode 100644 index 3df25d8..0000000 --- a/FittedSheets/IntrensicDemo/HorizontalPaddingDemo.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// HorizontalPaddingDemo.swift -// FittedSheets -// -// Created by Gordon Tucker on 1/4/21. -// Copyright © 2021 Gordon Tucker. All rights reserved. -// - -import UIKit -import FittedSheetsPod - -class HorizontalPaddingDemo: Demoable { - var name: String { - return "Horizontal Padding" - } - - func buildDemo(useInlineMode: Bool) -> SheetViewController { - let controller = IntrinsicExampleViewController.instantiate() - return SheetViewController(controller: controller, options: SheetOptions(useInlineMode: useInlineMode, horizontalPadding: 20)) - } -} diff --git a/FittedSheets/IntrensicDemo/IntrensicAndFullscreenDemo.swift b/FittedSheets/IntrensicDemo/IntrensicAndFullscreenDemo.swift deleted file mode 100644 index 3e50f84..0000000 --- a/FittedSheets/IntrensicDemo/IntrensicAndFullscreenDemo.swift +++ /dev/null @@ -1,26 +0,0 @@ -// -// IntrensicDemo.swift -// FittedSheets -// -// Created by Gordon Tucker on 7/30/20. -// Copyright © 2020 Gordon Tucker. All rights reserved. -// - -import UIKit -import FittedSheetsPod - -class IntrensicAndFullscreenDemo: Demoable { - var name: String { - return "Intrensic And Fullscreen" - } - - func buildDemo(useInlineMode: Bool) -> SheetViewController { - let controller = IntrinsicExampleViewController.instantiate() - let options = SheetOptions( - useFullScreenMode: false, - useInlineMode: useInlineMode) - let sheet = SheetViewController(controller: controller, sizes: [.fullscreen, .intrinsic], options: options) - sheet.minimumSpaceAbovePullBar = 44 - return sheet - } -} diff --git a/FittedSheets/IntrensicDemo/IntrensicAndTrueFullscreenDemo.swift b/FittedSheets/IntrensicDemo/IntrensicAndTrueFullscreenDemo.swift deleted file mode 100644 index d88c8f6..0000000 --- a/FittedSheets/IntrensicDemo/IntrensicAndTrueFullscreenDemo.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// IntrensicDemo.swift -// FittedSheets -// -// Created by Gordon Tucker on 7/30/20. -// Copyright © 2020 Gordon Tucker. All rights reserved. -// - -import UIKit -import FittedSheetsPod - -class IntrensicAndTrueFullscreenDemo: Demoable { - var name: String { - return "Intrensic And True Fullscreen" - } - - func buildDemo(useInlineMode: Bool) -> SheetViewController { - let controller = IntrinsicExampleViewController.instantiate() - return SheetViewController(controller: controller, sizes: [.intrinsic, .fullscreen], options: SheetOptions(useInlineMode: useInlineMode)) - } -} diff --git a/FittedSheets/IntrensicDemo/IntrensicDemo.swift b/FittedSheets/IntrensicDemo/IntrensicDemo.swift deleted file mode 100644 index fb7f645..0000000 --- a/FittedSheets/IntrensicDemo/IntrensicDemo.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// IntrensicDemo.swift -// FittedSheets -// -// Created by Gordon Tucker on 7/30/20. -// Copyright © 2020 Gordon Tucker. All rights reserved. -// - -import UIKit -import FittedSheetsPod - -class IntrensicDemo: Demoable { - var name: String { - return "Intrensic Height" - } - - func buildDemo(useInlineMode: Bool) -> SheetViewController { - let controller = IntrinsicExampleViewController.instantiate() - return SheetViewController(controller: controller, options: SheetOptions(useInlineMode: useInlineMode)) - } -} diff --git a/FittedSheets/IntrensicDemo/IntrinsicExampleViewController.swift b/FittedSheets/IntrensicDemo/IntrinsicExampleViewController.swift deleted file mode 100644 index 64d62de..0000000 --- a/FittedSheets/IntrensicDemo/IntrinsicExampleViewController.swift +++ /dev/null @@ -1,21 +0,0 @@ -// -// IntrinsicExampleViewController.swift -// FittedSheets -// -// Created by Gordon Tucker on 2/1/19. -// Copyright © 2019 Gordon Tucker. All rights reserved. -// - -import UIKit -import FittedSheetsPod - -class IntrinsicExampleViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - } - - static func instantiate() -> UIViewController { - return UIStoryboard(name: "IntrensicDemo", bundle: nil).instantiateViewController(withIdentifier: "intrinsic") - } -} diff --git a/FittedSheets/IntrensicDemo/MaxMinHeightDemo.swift b/FittedSheets/IntrensicDemo/MaxMinHeightDemo.swift deleted file mode 100644 index f7004e9..0000000 --- a/FittedSheets/IntrensicDemo/MaxMinHeightDemo.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// IntrensicDemo.swift -// FittedSheets -// -// Created by Gordon Tucker on 7/30/20. -// Copyright © 2020 Gordon Tucker. All rights reserved. -// - -import UIKit -import FittedSheetsPod - -class MaxMinHeightDemo: Demoable { - var name: String { - return "Max Min Height" - } - - func buildDemo(useInlineMode: Bool) -> SheetViewController { - let controller = IntrinsicExampleViewController.instantiate() - let sheet = SheetViewController(controller: controller, sizes: [.intrinsic, .fixed(350)], options: SheetOptions(useInlineMode: useInlineMode)) - sheet.allowPullingPastMaxHeight = false - sheet.allowPullingPastMinHeight = false - return sheet - } -} diff --git a/FittedSheets/IntrensicDemo/MaxWidthDemo.swift b/FittedSheets/IntrensicDemo/MaxWidthDemo.swift deleted file mode 100644 index 4f518fd..0000000 --- a/FittedSheets/IntrensicDemo/MaxWidthDemo.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// MaxWidthDemo.swift -// FittedSheets -// -// Created by Gordon Tucker on 1/4/21. -// Copyright © 2021 Gordon Tucker. All rights reserved. -// - -import UIKit -import FittedSheetsPod - -class MaxWidthDemo: Demoable { - var name: String { - return "Max Width" - } - - func buildDemo(useInlineMode: Bool) -> SheetViewController { - let controller = IntrinsicExampleViewController.instantiate() - return SheetViewController(controller: controller, options: SheetOptions(useInlineMode: useInlineMode, maxWidth: 100)) - } -} - diff --git a/FittedSheets/IntrensicDemo/RecycledDemo.swift b/FittedSheets/IntrensicDemo/RecycledDemo.swift deleted file mode 100644 index b2df7b6..0000000 --- a/FittedSheets/IntrensicDemo/RecycledDemo.swift +++ /dev/null @@ -1,33 +0,0 @@ -// -// RecycledDemo.swift -// FittedSheets -// -// Created by Gordon Tucker on 8/12/20. -// Copyright © 2020 Gordon Tucker. All rights reserved. -// - -import UIKit -import FittedSheetsPod - -class RecycledDemo: Demoable { - static var shared: SheetViewController? - static var inlineShared: SheetViewController? - var name: String { - return "Recycled Sheet" - } - - func buildDemo(useInlineMode: Bool) -> SheetViewController { - guard let shared = useInlineMode ? RecycledDemo.inlineShared : RecycledDemo.shared else { - let controller = IntrinsicExampleViewController.instantiate() - let sheet = SheetViewController(controller: controller, options: SheetOptions(useInlineMode: useInlineMode)) - - if useInlineMode { - RecycledDemo.inlineShared = sheet - } else { - RecycledDemo.shared = sheet - } - return sheet - } - return shared - } -} diff --git a/FittedSheets/KeyboardExample/KeyboardDemo.swift b/FittedSheets/KeyboardExample/KeyboardDemo.swift deleted file mode 100644 index fbf1621..0000000 --- a/FittedSheets/KeyboardExample/KeyboardDemo.swift +++ /dev/null @@ -1,26 +0,0 @@ -// -// KeyboardDemo.swift -// FittedSheets -// -// Created by Gordon Tucker on 8/4/20. -// Copyright © 2020 Gordon Tucker. All rights reserved. -// - -import UIKit -import FittedSheetsPod - -class KeyboardDemo: Demoable { - var name: String { - return "Keyboard" - } - - func buildDemo(useInlineMode: Bool) -> SheetViewController { - let controller = UITextFieldExampleViewController.instantiate() - - let c = SheetViewController(controller: controller, sizes: [.percent(0.5), .fullscreen], options: SheetOptions(useInlineMode: useInlineMode)) - - c.autoAdjustToKeyboard = false - - return c - } -} diff --git a/FittedSheets/KeyboardExample/UITextFieldExampleViewController.swift b/FittedSheets/KeyboardExample/UITextFieldExampleViewController.swift deleted file mode 100644 index ef088f6..0000000 --- a/FittedSheets/KeyboardExample/UITextFieldExampleViewController.swift +++ /dev/null @@ -1,26 +0,0 @@ -// -// UITextFieldExampleViewController.swift -// FittedSheets -// -// Created by Gordon Tucker on 2/1/19. -// Copyright © 2019 Gordon Tucker. All rights reserved. -// - -import UIKit - -class UITextFieldExampleViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - - // Do any additional setup after loading the view. - } - - @IBAction func doneTapped(_ sender: Any) { - self.view.endEditing(true) - } - - static func instantiate() -> UITextFieldExampleViewController { - return UIStoryboard(name: "KeyboardExample", bundle: nil).instantiateViewController(withIdentifier: "text-field") as! UITextFieldExampleViewController - } -} diff --git a/FittedSheetsPod/Localization/Base.lproj/Localizable.strings b/FittedSheets/Localization/Base.lproj/Localizable.strings similarity index 100% rename from FittedSheetsPod/Localization/Base.lproj/Localizable.strings rename to FittedSheets/Localization/Base.lproj/Localizable.strings diff --git a/FittedSheetsPod/Localization/Localize.swift b/FittedSheets/Localization/Localize.swift similarity index 100% rename from FittedSheetsPod/Localization/Localize.swift rename to FittedSheets/Localization/Localize.swift diff --git a/FittedSheets/NavigationDemo/NavigationDemo.swift b/FittedSheets/NavigationDemo/NavigationDemo.swift deleted file mode 100644 index ad05ccf..0000000 --- a/FittedSheets/NavigationDemo/NavigationDemo.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// NavigationDemo.swift -// FittedSheets -// -// Created by Gordon Tucker on 7/30/20. -// Copyright © 2020 Gordon Tucker. All rights reserved. -// - -import UIKit -import FittedSheetsPod - -class NavigationDemo: Demoable { - var name: String { - return "Pushing on Navigation" - } - - func buildDemo(useInlineMode: Bool) -> SheetViewController { - let controller2 = UITextFieldExampleViewController.instantiate() - - let controller = NavigationRootViewController.instantiate(exampleViewController: controller2) - - let nav = UINavigationController(rootViewController: controller) - return SheetViewController(controller: nav, sizes: [.intrinsic, .percent(0.5), .fullscreen], options: SheetOptions(useInlineMode: useInlineMode)) - } -} diff --git a/FittedSheets/NavigationDemo/NavigationRootViewController.swift b/FittedSheets/NavigationDemo/NavigationRootViewController.swift deleted file mode 100644 index 292db36..0000000 --- a/FittedSheets/NavigationDemo/NavigationRootViewController.swift +++ /dev/null @@ -1,31 +0,0 @@ -// -// NavigationRootViewController.swift -// FittedSheets -// -// Created by Gordon Tucker on 2/1/19. -// Copyright © 2019 Gordon Tucker. All rights reserved. -// - -import UIKit - -class NavigationRootViewController: UIViewController { - var exampleViewController: UIViewController! - - @IBAction func navigateToChildTapped(_ sender: Any) { - self.navigationController?.pushViewController(exampleViewController, animated: true) - } - - @IBAction func closeTapped(_ sender: Any) { - if self.sheetViewController?.options.useInlineMode == true { - self.sheetViewController?.attemptDismiss(animated: true) - } else { - self.dismiss(animated: true, completion: nil) - } - } - - static func instantiate(exampleViewController: UIViewController) -> NavigationRootViewController { - let controller = UIStoryboard(name: "NavigationDemo", bundle: nil).instantiateViewController(withIdentifier: "root") as! NavigationRootViewController - controller.exampleViewController = exampleViewController - return controller - } -} diff --git a/FittedSheets/NoClosingExample/MapDemo.swift b/FittedSheets/NoClosingExample/MapDemo.swift deleted file mode 100644 index 0d7bf0b..0000000 --- a/FittedSheets/NoClosingExample/MapDemo.swift +++ /dev/null @@ -1,30 +0,0 @@ -// -// MapDemo.swift -// FittedSheets -// -// Created by Gordon Tucker on 8/5/20. -// Copyright © 2020 Gordon Tucker. All rights reserved. -// - -import UIKit -import FittedSheetsPod - -class MapDemo: Demoable { - var name: String = "Map" - - func buildDemo(useInlineMode: Bool) -> SheetViewController { - let controller = NoClosingExampleViewController.instantiate() - - let sheet = SheetViewController(controller: controller, sizes: [.percent(0.5), .fullscreen], options: SheetOptions(useInlineMode: useInlineMode)) - sheet.dismissOnPull = false - sheet.dismissOnOverlayTap = false - sheet.overlayColor = UIColor.clear - - sheet.contentViewController.view.layer.shadowColor = UIColor.black.cgColor - sheet.contentViewController.view.layer.shadowOpacity = 0.1 - sheet.contentViewController.view.layer.shadowRadius = 10 - sheet.allowGestureThroughOverlay = true - - return sheet - } -} diff --git a/FittedSheets/NoClosingExample/NoCloseDemo.swift b/FittedSheets/NoClosingExample/NoCloseDemo.swift deleted file mode 100644 index 0a9c26e..0000000 --- a/FittedSheets/NoClosingExample/NoCloseDemo.swift +++ /dev/null @@ -1,23 +0,0 @@ -// -// NoCloseDemo.swift -// FittedSheets -// -// Created by Gordon Tucker on 8/4/20. -// Copyright © 2020 Gordon Tucker. All rights reserved. -// - -import UIKit -import FittedSheetsPod - -class NoCloseDemo: Demoable { - var name: String = "Non Closing" - - func buildDemo(useInlineMode: Bool) -> SheetViewController { - let controller = NoClosingExampleViewController.instantiate() - - let sheet = SheetViewController(controller: controller, sizes: [.percent(0.5), .fullscreen], options: SheetOptions(useInlineMode: useInlineMode)) - sheet.dismissOnPull = false - sheet.dismissOnOverlayTap = false - return sheet - } -} diff --git a/FittedSheets/NoClosingExample/NoClosingExampleViewController.swift b/FittedSheets/NoClosingExample/NoClosingExampleViewController.swift deleted file mode 100644 index c31534f..0000000 --- a/FittedSheets/NoClosingExample/NoClosingExampleViewController.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// NoClosingExampleViewController.swift -// FittedSheets -// -// Created by Gordon Tucker on 8/4/20. -// Copyright © 2020 Gordon Tucker. All rights reserved. -// - -import UIKit - -class NoClosingExampleViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - } - - @IBAction func closeTapped(_ sender: Any) { - if self.sheetViewController?.options.useInlineMode == true { - self.sheetViewController?.attemptDismiss(animated: true) - } else { - self.dismiss(animated: true, completion: nil) - } - } - - static func instantiate() -> NoClosingExampleViewController { - return UIStoryboard(name: "NoClosing", bundle: nil).instantiateViewController(withIdentifier: "noclose") as! NoClosingExampleViewController - } -} diff --git a/FittedSheets/RecursionDemo.swift b/FittedSheets/RecursionDemo.swift deleted file mode 100644 index c45e9b6..0000000 --- a/FittedSheets/RecursionDemo.swift +++ /dev/null @@ -1,27 +0,0 @@ -// -// RecursionDemo.swift -// FittedSheets -// -// Created by Gordon Tucker on 8/5/20. -// Copyright © 2020 Gordon Tucker. All rights reserved. -// - -import UIKit -import FittedSheetsPod - -class RecursionDemo: Demoable { - var name: String { - return "Rescursion!" - } - - func buildDemo(useInlineMode: Bool) -> SheetViewController { - let controller = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()! - var options = SheetOptions() - options.useInlineMode = useInlineMode - options.useFullScreenMode = false - options.transitionOverflowType = .color(color: .blue) - let sheet = SheetViewController(controller: controller, sizes: [.percent(0.50), .fullscreen], options: options) - - return sheet - } -} diff --git a/FittedSheets/ResizingDemo/ResizingDemo.swift b/FittedSheets/ResizingDemo/ResizingDemo.swift deleted file mode 100644 index c4a7c8a..0000000 --- a/FittedSheets/ResizingDemo/ResizingDemo.swift +++ /dev/null @@ -1,19 +0,0 @@ -// -// IntrensicDemo.swift -// FittedSheets -// -// Created by Gordon Tucker on 7/30/20. -// Copyright © 2020 Gordon Tucker. All rights reserved. -// - -import UIKit -import FittedSheetsPod - -class ResizingDemo: Demoable { - var name: String = "Self Resizing" - - func buildDemo(useInlineMode: Bool) -> SheetViewController { - let controller = ResizingExampleViewController.instantiate() - return SheetViewController(controller: controller, sizes: [.fixed(200), .fixed(300), .fixed(450), .marginFromTop(50)], options: SheetOptions(useInlineMode: useInlineMode)) - } -} diff --git a/FittedSheets/ResizingDemo/ResizingExampleViewController.swift b/FittedSheets/ResizingDemo/ResizingExampleViewController.swift deleted file mode 100644 index 6978be9..0000000 --- a/FittedSheets/ResizingDemo/ResizingExampleViewController.swift +++ /dev/null @@ -1,37 +0,0 @@ -// -// SelfSizingExampleViewController.swift -// FittedSheets -// -// Created by Gordon Tucker on 2/1/19. -// Copyright © 2019 Gordon Tucker. All rights reserved. -// - -import UIKit -import FittedSheetsPod - -class ResizingExampleViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - } - - @IBAction func resizeTo150(_ sender: Any) { - self.sheetViewController?.resize(to: .fixed(150)) - } - - @IBAction func resizeTo300(_ sender: Any) { - self.sheetViewController?.resize(to: .fixed(300)) - } - - @IBAction func resizeTo450(_ sender: Any) { - self.sheetViewController?.resize(to: .fixed(450)) - } - - @IBAction func resizeToMargin50(_ sender: Any) { - self.sheetViewController?.resize(to: .marginFromTop(50)) - } - - static func instantiate() -> ResizingExampleViewController { - return UIStoryboard(name: "ResizingDemo", bundle: nil).instantiateViewController(withIdentifier: "resizing") as! ResizingExampleViewController - } -} diff --git a/FittedSheets/RootViewController.swift b/FittedSheets/RootViewController.swift deleted file mode 100644 index 76fb9c6..0000000 --- a/FittedSheets/RootViewController.swift +++ /dev/null @@ -1,74 +0,0 @@ -// -// RootViewController.swift -// FittedSheets -// -// Created by Gordon Tucker on 7/30/20. -// Copyright © 2020 Gordon Tucker. All rights reserved. -// - -import UIKit - -class RootViewController: UIViewController { - - @IBOutlet var stackView: UIStackView! - @IBOutlet var scrollView: UIScrollView! - - var demos: [Demoable] = [ - IntrensicDemo(), - EmbededIntrensicDemo(), - IntrensicAndFullscreenDemo(), - IntrensicAndTrueFullscreenDemo(), - RecycledDemo(), - ResizingDemo(), - NavigationDemo(), - KeyboardDemo(), - ScrollViewDemo(), - ScrollInNavigationDemo(), - TableViewDemo(), - TableViewControllerDemo(), - ColorDemo(), - NoPullBarDemo(), - ClearPullBarDemo(), - NoCloseDemo(), - BlurDemo(), - RecursionDemo(), - MaxMinHeightDemo(), - HorizontalPaddingDemo(), - MaxWidthDemo() - ] - - override func viewDidLoad() { - super.viewDidLoad() - - for demo in demos { - self.addButton(demo: demo) - } - - self.sheetViewController?.handleScrollView(self.scrollView) - } - - func addButton(demo: Demoable) { - let button = UIButton() - button.setTitle(demo.name, for: .normal) - if #available(iOS 13.0, *) { - button.setTitleColor(.label, for: .normal) - } else { - button.setTitleColor(UIColor.darkText, for: .normal) - } - button.onTap { [weak self] in - let sheet = demo.buildDemo() - - sheet.didDismiss = { _ in - print("did dismiss") - } - - sheet.shouldDismiss = { _ in - print("should dismiss") - return true - } - - self?.present(sheet, animated: true, completion: nil) - } - self.stackView.addArrangedSubview(button) - } -} diff --git a/FittedSheets/SafeAreaInlineExampleViewController.swift b/FittedSheets/SafeAreaInlineExampleViewController.swift deleted file mode 100644 index b33bd01..0000000 --- a/FittedSheets/SafeAreaInlineExampleViewController.swift +++ /dev/null @@ -1,80 +0,0 @@ -// -// SafeAreaInlineExampleViewController.swift -// FittedSheets -// -// Created by Gordon Tucker on 9/29/20. -// Copyright © 2020 Gordon Tucker. All rights reserved. -// - -import UIKit -import FittedSheetsPod - -class SafeAreaInlineExampleViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - } - - @IBAction func showSheetTapped(_ sender: Any) { - let viewController = ColorExampleViewController.instantiate() - - let options = SheetOptions( - pullBarHeight: 24, - presentingViewCornerRadius: 16, - useFullScreenMode: true, - useInlineMode: true - ) - - let bottomSheet = SheetViewController( - controller: viewController, - sizes: [ - .percent(0.8), - .percent(0.88) - ], - options: options - ) - - bottomSheet.willMove(toParent: self) - self.addChild(bottomSheet) - view.addSubview(bottomSheet.view) - bottomSheet.didMove(toParent: self) - - // Auto layout - bottomSheet.view.translatesAutoresizingMaskIntoConstraints = false - NSLayoutConstraint.activate([ - bottomSheet.view.topAnchor.constraint(equalTo: view.topAnchor), - bottomSheet.view.bottomAnchor.constraint(equalTo: view.bottomAnchor), - bottomSheet.view.leadingAnchor.constraint(equalTo: view.leadingAnchor), - bottomSheet.view.trailingAnchor.constraint(equalTo: view.trailingAnchor) - ]) - - // The size of the grip in the pull bar - bottomSheet.gripSize = CGSize(width: 29, height: 3) - - // The color of the grip on the pull bar - bottomSheet.gripColor = UIColor( - red: 199/255, - green: 199/255, - blue: 204/255, - alpha: 1 - ) - - // Disable the dismiss on background tap functionality - bottomSheet.dismissOnOverlayTap = false - - // Disable the ability to pull down to dismiss the modal - bottomSheet.dismissOnPull = false - - // Change the overlay color - bottomSheet.overlayColor = .clear - - // - bottomSheet.allowGestureThroughOverlay = true - - // - bottomSheet.allowPullingPastMinHeight = false - - // animate in - bottomSheet.animateIn() - } -} diff --git a/FittedSheets/ScrollExamples/ScrollInNavigationDemo.swift b/FittedSheets/ScrollExamples/ScrollInNavigationDemo.swift deleted file mode 100644 index e3c32d0..0000000 --- a/FittedSheets/ScrollExamples/ScrollInNavigationDemo.swift +++ /dev/null @@ -1,23 +0,0 @@ -// -// ScrollViewDemo.swift -// FittedSheets -// -// Created by Gordon Tucker on 8/4/20. -// Copyright © 2020 Gordon Tucker. All rights reserved. -// - -import UIKit -import FittedSheetsPod - -class ScrollInNavigationDemo: Demoable { - var name: String { - return "Scroll View In Navigation" - } - - func buildDemo(useInlineMode: Bool) -> SheetViewController { - let controller = ScrollViewExampleViewController.instantiate() - - let nav = UINavigationController(rootViewController: controller) - return SheetViewController(controller: nav, sizes: [.percent(0.25), .fullscreen], options: SheetOptions(useInlineMode: useInlineMode)) - } -} diff --git a/FittedSheets/ScrollExamples/ScrollViewDemo.swift b/FittedSheets/ScrollExamples/ScrollViewDemo.swift deleted file mode 100644 index c27f0a4..0000000 --- a/FittedSheets/ScrollExamples/ScrollViewDemo.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// ScrollViewDemo.swift -// FittedSheets -// -// Created by Gordon Tucker on 8/4/20. -// Copyright © 2020 Gordon Tucker. All rights reserved. -// - -import UIKit -import FittedSheetsPod - -class ScrollViewDemo: Demoable { - var name: String { - return "Scroll View" - } - - func buildDemo(useInlineMode: Bool) -> SheetViewController { - let controller = ScrollViewExampleViewController.instantiate() - - return SheetViewController(controller: controller, sizes: [.percent(0.25), .fullscreen], options: SheetOptions(useInlineMode: useInlineMode)) - } -} diff --git a/FittedSheets/ScrollExamples/ScrollViewExampleViewController.swift b/FittedSheets/ScrollExamples/ScrollViewExampleViewController.swift deleted file mode 100644 index 9a7bb20..0000000 --- a/FittedSheets/ScrollExamples/ScrollViewExampleViewController.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// ScrollViewExampleViewController.swift -// FittedSheets -// -// Created by Gordon Tucker on 2/1/19. -// Copyright © 2019 Gordon Tucker. All rights reserved. -// - -import UIKit -import FittedSheetsPod - -class ScrollViewExampleViewController: UIViewController { - - @IBOutlet weak var scrollView: UIScrollView! - - override func viewDidLoad() { - super.viewDidLoad() - self.sheetViewController?.handleScrollView(self.scrollView) - } - - static func instantiate() -> ScrollViewExampleViewController { - return UIStoryboard(name: "ScrollExample", bundle: nil).instantiateViewController(withIdentifier: "scrollView") as! ScrollViewExampleViewController - } -} diff --git a/FittedSheets/ScrollExamples/TableViewControllerDemo.swift b/FittedSheets/ScrollExamples/TableViewControllerDemo.swift deleted file mode 100644 index e0140af..0000000 --- a/FittedSheets/ScrollExamples/TableViewControllerDemo.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// TableViewDemo.swift -// FittedSheets -// -// Created by Gordon Tucker on 8/4/20. -// Copyright © 2020 Gordon Tucker. All rights reserved. -// - -import UIKit -import FittedSheetsPod - -class TableViewControllerDemo: Demoable { - var name: String { - return "Table View Controller" - } - - func buildDemo(useInlineMode: Bool) -> SheetViewController { - let controller = ExampleTableViewController.instantiate() - - return SheetViewController(controller: controller, sizes: [.percent(0.25), .fullscreen], options: SheetOptions(useInlineMode: useInlineMode)) - } -} diff --git a/FittedSheets/ScrollExamples/TableViewDemo.swift b/FittedSheets/ScrollExamples/TableViewDemo.swift deleted file mode 100644 index 9ef8334..0000000 --- a/FittedSheets/ScrollExamples/TableViewDemo.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// TableViewDemo.swift -// FittedSheets -// -// Created by Gordon Tucker on 8/4/20. -// Copyright © 2020 Gordon Tucker. All rights reserved. -// - -import UIKit -import FittedSheetsPod - -class TableViewDemo: Demoable { - var name: String { - return "Table View" - } - - func buildDemo(useInlineMode: Bool) -> SheetViewController { - let controller = TableViewExampleViewController.instantiate() - - return SheetViewController(controller: controller, sizes: [.percent(0.25), .fullscreen], options: SheetOptions(useInlineMode: useInlineMode)) - } -} diff --git a/FittedSheets/ScrollExamples/TableViewExampleViewController.swift b/FittedSheets/ScrollExamples/TableViewExampleViewController.swift deleted file mode 100644 index b417a36..0000000 --- a/FittedSheets/ScrollExamples/TableViewExampleViewController.swift +++ /dev/null @@ -1,36 +0,0 @@ -// -// TableViewExampleViewController.swift -// FittedSheets -// -// Created by Gordon Tucker on 2/1/19. -// Copyright © 2019 Gordon Tucker. All rights reserved. -// - -import UIKit - -class TableViewExampleViewController: UIViewController { - - @IBOutlet weak var tableView: UITableView! - - override func viewDidLoad() { - super.viewDidLoad() - - self.sheetViewController?.handleScrollView(self.tableView) - } - - static func instantiate() -> TableViewExampleViewController { - return UIStoryboard(name: "ScrollExample", bundle: nil).instantiateViewController(withIdentifier: "tableView") as! TableViewExampleViewController - } -} - -extension TableViewExampleViewController: UITableViewDelegate, UITableViewDataSource { - func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return 30 - } - - func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCell(withIdentifier: "row", for: indexPath) - cell.textLabel?.text = "Row \(indexPath.row)" - return cell - } -} diff --git a/FittedSheetsPod/SheetContentViewController.swift b/FittedSheets/SheetContentViewController.swift similarity index 98% rename from FittedSheetsPod/SheetContentViewController.swift rename to FittedSheets/SheetContentViewController.swift index 143b526..aeeca8d 100644 --- a/FittedSheetsPod/SheetContentViewController.swift +++ b/FittedSheets/SheetContentViewController.swift @@ -74,7 +74,7 @@ public class SheetContentViewController: UIViewController { self.preferredHeight = 0 super.init(nibName: nil, bundle: nil) - if options.setIntrensicHeightOnNavigationControllers, let navigationController = self.childViewController as? UINavigationController { + if options.setIntrinsicHeightOnNavigationControllers, let navigationController = self.childViewController as? UINavigationController { navigationController.delegate = self } } @@ -144,8 +144,8 @@ public class SheetContentViewController: UIViewController { } private func updateNavigationControllerHeight() { - // UINavigationControllers don't set intrensic size, this is a workaround to fix that - guard self.options.setIntrensicHeightOnNavigationControllers, let navigationController = self.childViewController as? UINavigationController else { return } + // UINavigationControllers don't set intrinsic size, this is a workaround to fix that + guard self.options.setIntrinsicHeightOnNavigationControllers, let navigationController = self.childViewController as? UINavigationController else { return } self.navigationHeightConstraint?.isActive = false self.contentTopConstraint?.isActive = false diff --git a/FittedSheetsPod/SheetContentViewDelegate.swift b/FittedSheets/SheetContentViewDelegate.swift similarity index 100% rename from FittedSheetsPod/SheetContentViewDelegate.swift rename to FittedSheets/SheetContentViewDelegate.swift diff --git a/FittedSheetsPod/SheetOptions.swift b/FittedSheets/SheetOptions.swift similarity index 91% rename from FittedSheetsPod/SheetOptions.swift rename to FittedSheets/SheetOptions.swift index de37715..f6dd612 100644 --- a/FittedSheetsPod/SheetOptions.swift +++ b/FittedSheets/SheetOptions.swift @@ -23,7 +23,7 @@ public struct SheetOptions { public var presentingViewCornerRadius: CGFloat = 12 public var shouldExtendBackground = true - public var setIntrensicHeightOnNavigationControllers = true + public var setIntrinsicHeightOnNavigationControllers = true public var transitionAnimationOptions: UIView.AnimationOptions = [.curveEaseOut] public var transitionDampening: CGFloat = 0.7 @@ -62,7 +62,7 @@ public struct SheetOptions { public init(pullBarHeight: CGFloat? = nil, presentingViewCornerRadius: CGFloat? = nil, shouldExtendBackground: Bool? = nil, - setIntrensicHeightOnNavigationControllers: Bool? = nil, + setIntrinsicHeightOnNavigationControllers: Bool? = nil, useFullScreenMode: Bool? = nil, shrinkPresentingViewController: Bool? = nil, useInlineMode: Bool? = nil, @@ -72,7 +72,7 @@ public struct SheetOptions { self.pullBarHeight = pullBarHeight ?? defaultOptions.pullBarHeight self.presentingViewCornerRadius = presentingViewCornerRadius ?? defaultOptions.presentingViewCornerRadius self.shouldExtendBackground = shouldExtendBackground ?? defaultOptions.shouldExtendBackground - self.setIntrensicHeightOnNavigationControllers = setIntrensicHeightOnNavigationControllers ?? defaultOptions.setIntrensicHeightOnNavigationControllers + self.setIntrinsicHeightOnNavigationControllers = setIntrinsicHeightOnNavigationControllers ?? defaultOptions.setIntrinsicHeightOnNavigationControllers self.useFullScreenMode = useFullScreenMode ?? defaultOptions.useFullScreenMode self.shrinkPresentingViewController = shrinkPresentingViewController ?? defaultOptions.shrinkPresentingViewController self.useInlineMode = useInlineMode ?? defaultOptions.useInlineMode @@ -88,7 +88,7 @@ public struct SheetOptions { cornerRadius: CGFloat? = nil, presentingViewCornerRadius: CGFloat? = nil, shouldExtendBackground: Bool? = nil, - setIntrensicHeightOnNavigationControllers: Bool? = nil, + setIntrinsicHeightOnNavigationControllers: Bool? = nil, useFullScreenMode: Bool? = nil, shrinkPresentingViewController: Bool? = nil, useInlineMode: Bool? = nil, @@ -97,7 +97,7 @@ public struct SheetOptions { self.pullBarHeight = pullBarHeight ?? defaultOptions.pullBarHeight self.presentingViewCornerRadius = presentingViewCornerRadius ?? defaultOptions.presentingViewCornerRadius self.shouldExtendBackground = shouldExtendBackground ?? defaultOptions.shouldExtendBackground - self.setIntrensicHeightOnNavigationControllers = setIntrensicHeightOnNavigationControllers ?? defaultOptions.setIntrensicHeightOnNavigationControllers + self.setIntrinsicHeightOnNavigationControllers = setIntrinsicHeightOnNavigationControllers ?? defaultOptions.setIntrinsicHeightOnNavigationControllers self.useFullScreenMode = useFullScreenMode ?? defaultOptions.useFullScreenMode self.shrinkPresentingViewController = shrinkPresentingViewController ?? defaultOptions.shrinkPresentingViewController self.useInlineMode = useInlineMode ?? defaultOptions.useInlineMode diff --git a/FittedSheetsPod/SheetSize.swift b/FittedSheets/SheetSize.swift similarity index 100% rename from FittedSheetsPod/SheetSize.swift rename to FittedSheets/SheetSize.swift diff --git a/FittedSheetsPod/SheetTransition.swift b/FittedSheets/SheetTransition.swift similarity index 93% rename from FittedSheetsPod/SheetTransition.swift rename to FittedSheets/SheetTransition.swift index 01ff8d1..c756b3d 100644 --- a/FittedSheetsPod/SheetTransition.swift +++ b/FittedSheets/SheetTransition.swift @@ -34,8 +34,13 @@ public class SheetTransition: NSObject, UIViewControllerAnimatedTransitioning { sheet.contentViewController.view.transform = .identity containerView.addSubview(sheet.view) - sheet.view.setNeedsLayout() - sheet.view.layoutIfNeeded() + //sheet.view.frame = containerView.frame + Constraints(for: sheet.view) { + $0.edges.pinToSuperview() + } + UIView.performWithoutAnimation { + sheet.view.layoutIfNeeded() + } sheet.contentViewController.updatePreferredHeight() sheet.resize(to: sheet.currentSize, animated: false) let contentView = sheet.contentViewController.contentView @@ -44,6 +49,10 @@ public class SheetTransition: NSObject, UIViewControllerAnimatedTransitioning { let heightPercent = contentView.bounds.height / UIScreen.main.bounds.height + UIView.performWithoutAnimation { + sheet.view.layoutIfNeeded() + } + // Use a normal animation to animate the shadown and background view UIView.animate(withDuration: self.options.transitionDuration * 0.6, delay: 0, options: [.curveEaseOut], animations: { if self.options.shrinkPresentingViewController { diff --git a/FittedSheetsPod/SheetView.swift b/FittedSheets/SheetView.swift similarity index 100% rename from FittedSheetsPod/SheetView.swift rename to FittedSheets/SheetView.swift diff --git a/FittedSheetsPod/SheetViewController.swift b/FittedSheets/SheetViewController.swift similarity index 99% rename from FittedSheetsPod/SheetViewController.swift rename to FittedSheets/SheetViewController.swift index dcf7021..89a54d4 100644 --- a/FittedSheetsPod/SheetViewController.swift +++ b/FittedSheets/SheetViewController.swift @@ -27,7 +27,7 @@ public class SheetViewController: UIViewController { /// Allow pulling below the minimum height and bounce back. Defaults to true. public var allowPullingPastMinHeight = SheetViewController.allowPullingPastMinHeight - /// The sizes that the sheet will attempt to pin to. Defaults to intrensic only. + /// The sizes that the sheet will attempt to pin to. Defaults to intrinsic only. public var sizes: [SheetSize] = [.intrinsic] { didSet { self.updateOrderedSizes() @@ -726,7 +726,7 @@ extension SheetViewController: SheetContentViewDelegate { if self.sizes.contains(.intrinsic) { self.updateOrderedSizes() } - // If our intrensic size changed and that is what we are sized to currently, use that + // If our intrinsic size changed and that is what we are sized to currently, use that if self.currentSize == .intrinsic, !self.isPanning { self.resize(to: .intrinsic) } diff --git a/FittedSheetsPod/SheetViewDelegate.swift b/FittedSheets/SheetViewDelegate.swift similarity index 100% rename from FittedSheetsPod/SheetViewDelegate.swift rename to FittedSheets/SheetViewDelegate.swift diff --git a/FittedSheetsPod/UIColorExtension.swift b/FittedSheets/UIColorExtension.swift similarity index 100% rename from FittedSheetsPod/UIColorExtension.swift rename to FittedSheets/UIColorExtension.swift diff --git a/FittedSheetsPod/UIViewControllerExtension.swift b/FittedSheets/UIViewControllerExtension.swift similarity index 100% rename from FittedSheetsPod/UIViewControllerExtension.swift rename to FittedSheets/UIViewControllerExtension.swift diff --git a/FittedSheetsPod/Yalta.swift b/FittedSheets/Yalta.swift similarity index 100% rename from FittedSheetsPod/Yalta.swift rename to FittedSheets/Yalta.swift diff --git a/FittedSheetsPod/Info.plist b/FittedSheetsPod/Info.plist deleted file mode 100644 index e1fe4cf..0000000 --- a/FittedSheetsPod/Info.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - FMWK - CFBundleShortVersionString - 1.0 - CFBundleVersion - $(CURRENT_PROJECT_VERSION) - - diff --git a/FittedSheetsTests/FittedSheetsTests.swift b/FittedSheetsTests/FittedSheetsTests.swift deleted file mode 100644 index 81072df..0000000 --- a/FittedSheetsTests/FittedSheetsTests.swift +++ /dev/null @@ -1,36 +0,0 @@ -// -// FittedSheetsTests.swift -// FittedSheetsTests -// -// Created by Gordon Tucker on 8/16/18. -// Copyright © 2018 Gordon Tucker. All rights reserved. -// - -import XCTest -@testable import FittedSheets - -class FittedSheetsTests: XCTestCase { - - override func setUp() { - super.setUp() - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDown() { - // Put teardown code here. This method is called after the invocation of each test method in the class. - super.tearDown() - } - - func testExample() { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct results. - } - - func testPerformanceExample() { - // This is an example of a performance test case. - self.measure { - // Put the code you want to measure the time of here. - } - } - -} diff --git a/FittedSheetsTests/Info.plist b/FittedSheetsTests/Info.plist deleted file mode 100644 index 6c40a6c..0000000 --- a/FittedSheetsTests/Info.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - - diff --git a/FittedSheetsUITests/FittedSheetsUITests.swift b/FittedSheetsUITests/FittedSheetsUITests.swift deleted file mode 100644 index e9e672b..0000000 --- a/FittedSheetsUITests/FittedSheetsUITests.swift +++ /dev/null @@ -1,36 +0,0 @@ -// -// FittedSheetsUITests.swift -// FittedSheetsUITests -// -// Created by Gordon Tucker on 8/16/18. -// Copyright © 2018 Gordon Tucker. All rights reserved. -// - -import XCTest - -class FittedSheetsUITests: XCTestCase { - - override func setUp() { - super.setUp() - - // Put setup code here. This method is called before the invocation of each test method in the class. - - // In UI tests it is usually best to stop immediately when a failure occurs. - continueAfterFailure = false - // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. - XCUIApplication().launch() - - // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. - } - - override func tearDown() { - // Put teardown code here. This method is called after the invocation of each test method in the class. - super.tearDown() - } - - func testExample() { - // Use recording to get started writing UI tests. - // Use XCTAssert and related functions to verify your tests produce the correct results. - } - -} diff --git a/FittedSheetsUITests/Info.plist b/FittedSheetsUITests/Info.plist deleted file mode 100644 index 6c40a6c..0000000 --- a/FittedSheetsUITests/Info.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - - diff --git a/Package.swift b/Package.swift index f1038f8..9b49dd6 100644 --- a/Package.swift +++ b/Package.swift @@ -18,7 +18,7 @@ let package = Package( .library(name: "FittedSheets", targets: ["FittedSheets"]), ], targets: [ - .target(name: "FittedSheets", path: "FittedSheetsPod"), + .target(name: "FittedSheets", path: "FittedSheets"), ], swiftLanguageVersions: [.v5] ) diff --git a/README.md b/README.md index eb07eb7..afb8fbb 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,11 @@ Minimum requirement: ## 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. +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 intrinsic height of the presented view controller. If it is larger, it will stop at each height specified in the initializer or setSizes function. -| Intrensic Heights | Fullscreen Modal | True Fullscreen | Scrolling | Inline | +| Intrinsic Heights | Fullscreen Modal | True Fullscreen | Scrolling | Inline | |:-:|:-:|:-:|:-:|:-:| -| ![Intrensid Heights](./Screens/IntrensicHeight.gif) | ![Fullscreen Modal](./Screens/FullscreenHeight.gif) | ![True Fullscreen](./Screens/TrueFullscreenHeight.gif) | ![Scrolling](./Screens/Scrolling.gif) | ![Inline](./Screens/Inline.gif) | +| ![Intrensid Heights](./Screens/IntrinsicHeight.gif) | ![Fullscreen Modal](./Screens/FullscreenHeight.gif) | ![True Fullscreen](./Screens/TrueFullscreenHeight.gif) | ![Scrolling](./Screens/Scrolling.gif) | ![Inline](./Screens/Inline.gif) | ## Usage @@ -50,8 +50,8 @@ let options = SheetOptions( // Extends the background behind the pull bar or not shouldExtendBackground: true, - // Attempts to use intrensic heights on navigation controllers. This does not work well in combination with keyboards without your code handling it. - setIntrensicHeightOnNavigationControllers: true, + // Attempts to use intrinsic heights on navigation controllers. This does not work well in combination with keyboards without your code handling it. + setIntrinsicHeightOnNavigationControllers: true, // Pulls the view controller behind the safe area top, especially useful when embedding navigation controllers useFullScreenMode: true, @@ -71,7 +71,7 @@ let options = SheetOptions( let sheetController = SheetViewController( controller: controller, - sizes: [.intrensic, .percent(0.25), .fixed(200), .fullScreen]) + sizes: [.intrinsic, .percent(0.25), .fixed(200), .fullScreen]) // The size of the grip in the pull bar From f3595eb88d48f0fa1c838bce4069ab158edcfbba Mon Sep 17 00:00:00 2001 From: Richard Lee <14349+dlackty@users.noreply.github.com> Date: Mon, 22 Feb 2021 23:37:59 +0800 Subject: [PATCH 28/33] Correct typo --- README.md | 2 +- .../{IntrensicHeight.gif => IntrinsicHeight.gif} | Bin 2 files changed, 1 insertion(+), 1 deletion(-) rename Screens/{IntrensicHeight.gif => IntrinsicHeight.gif} (100%) diff --git a/README.md b/README.md index afb8fbb..ceca266 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ The bottom sheet tries to be smart about the height it takes. If the view contro | Intrinsic Heights | Fullscreen Modal | True Fullscreen | Scrolling | Inline | |:-:|:-:|:-:|:-:|:-:| -| ![Intrensid Heights](./Screens/IntrinsicHeight.gif) | ![Fullscreen Modal](./Screens/FullscreenHeight.gif) | ![True Fullscreen](./Screens/TrueFullscreenHeight.gif) | ![Scrolling](./Screens/Scrolling.gif) | ![Inline](./Screens/Inline.gif) | +| ![Intrinsic Heights](./Screens/IntrinsicHeight.gif) | ![Fullscreen Modal](./Screens/FullscreenHeight.gif) | ![True Fullscreen](./Screens/TrueFullscreenHeight.gif) | ![Scrolling](./Screens/Scrolling.gif) | ![Inline](./Screens/Inline.gif) | ## Usage diff --git a/Screens/IntrensicHeight.gif b/Screens/IntrinsicHeight.gif similarity index 100% rename from Screens/IntrensicHeight.gif rename to Screens/IntrinsicHeight.gif From fbc9daf59646b98ba6514062b00fc05894097b58 Mon Sep 17 00:00:00 2001 From: Mattio Valentino Date: Sat, 6 Mar 2021 09:11:29 -0500 Subject: [PATCH 29/33] Fix storyboard class reference --- Demos/DemoControllers/NavigationDemo.storyboard | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Demos/DemoControllers/NavigationDemo.storyboard b/Demos/DemoControllers/NavigationDemo.storyboard index 08dd4bb..f4af008 100644 --- a/Demos/DemoControllers/NavigationDemo.storyboard +++ b/Demos/DemoControllers/NavigationDemo.storyboard @@ -11,7 +11,7 @@ - + From 60ec14aae7ca877042c5660c075e080607458808 Mon Sep 17 00:00:00 2001 From: Ben Rudhart Date: Fri, 28 May 2021 09:52:18 +0200 Subject: [PATCH 30/33] Setup childForStatusBarStyle --- FittedSheets/SheetViewController.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/FittedSheets/SheetViewController.swift b/FittedSheets/SheetViewController.swift index 89a54d4..de36e90 100644 --- a/FittedSheets/SheetViewController.swift +++ b/FittedSheets/SheetViewController.swift @@ -54,6 +54,10 @@ public class SheetViewController: UIViewController { public var childViewController: UIViewController { return self.contentViewController.childViewController } + + public override var childForStatusBarStyle: UIViewController? { + childViewController + } public static var hasBlurBackground = false public var hasBlurBackground = SheetViewController.hasBlurBackground { From b13586b5681cd1181829707af6a7f07abb9730e1 Mon Sep 17 00:00:00 2001 From: Gordon Tucker Date: Mon, 14 Jun 2021 10:27:27 -0600 Subject: [PATCH 31/33] Update FittedSheets.podspec.json --- FittedSheets.podspec.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FittedSheets.podspec.json b/FittedSheets.podspec.json index 91ec5ff..84d2f9f 100644 --- a/FittedSheets.podspec.json +++ b/FittedSheets.podspec.json @@ -1,6 +1,6 @@ { "name": "FittedSheets", - "version": "2.4.0", + "version": "2.4.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": "2.4.0" + "tag": "2.4.1" }, "platforms": { "ios": "11.0" From 8d6dfb180c5c6ea8c52225eddb059fff964e300e Mon Sep 17 00:00:00 2001 From: Brad Patras Date: Wed, 4 Aug 2021 14:13:54 -0500 Subject: [PATCH 32/33] Allow for intrinsic height to be recalculated Added a public func 'updateIntrinsicHeight()' that will recalculate the sheet content's intrinsic height and update the sheet to match. --- FittedSheets/SheetViewController.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/FittedSheets/SheetViewController.swift b/FittedSheets/SheetViewController.swift index de36e90..46d5dac 100644 --- a/FittedSheets/SheetViewController.swift +++ b/FittedSheets/SheetViewController.swift @@ -591,6 +591,13 @@ public class SheetViewController: UIViewController { } } + /// Recalculates the intrinsic height of the sheet based on the content, and updates the sheet height to match. + /// + /// **Note:** Only meant for use with `.intrinsic` sheet size + public func updateIntrinsicHeight() { + contentViewController.updatePreferredHeight() + } + /// Animates the sheet in, but only if presenting using the inline mode public func animateIn(to view: UIView, in parent: UIViewController, size: SheetSize? = nil, duration: TimeInterval = 0.3, completion: (() -> Void)? = nil) { From 65f9c93718f96c6de234d38c9976e67a0d9e2b28 Mon Sep 17 00:00:00 2001 From: Gordon Tucker Date: Fri, 6 Aug 2021 09:12:53 -0600 Subject: [PATCH 33/33] Update FittedSheets.podspec.json --- FittedSheets.podspec.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FittedSheets.podspec.json b/FittedSheets.podspec.json index 84d2f9f..413436d 100644 --- a/FittedSheets.podspec.json +++ b/FittedSheets.podspec.json @@ -1,6 +1,6 @@ { "name": "FittedSheets", - "version": "2.4.1", + "version": "2.4.2", "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": "2.4.1" + "tag": "2.4.2" }, "platforms": { "ios": "11.0"