diff --git a/CHANGELOG.md b/CHANGELOG.md index 653b0ce..1f758fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 1.13.3 +- [Bug fix] Fix bug related to presenting a `UINavigationController` modally without an explicit root `UIViewController`, resulting in unexpected behaviour of `UITextField` input cursors. + # 1.13.2 - Update project settings for Xcode 12 and fix some deprecation warnings diff --git a/Examples/StylesAndOptions/Example/AppFlow.swift b/Examples/StylesAndOptions/Example/AppFlow.swift index 6cb3ed5..92ffdc9 100644 --- a/Examples/StylesAndOptions/Example/AppFlow.swift +++ b/Examples/StylesAndOptions/Example/AppFlow.swift @@ -63,6 +63,10 @@ extension AppFlow: Presentable { return containerController.present(Presentation(TestNavigationBarHiding(), style: .modal)).toVoid() } + if options.contains(.modalNavigationControllerFlow) { + return containerController.present(Presentation(TestNavigationControllerFlow(), style: .modal, configure: withDismiss)) + } + if options.contains(.allowSwipeDismissAlways) { struct NavigationStack: Presentable { func materialize() -> (UIViewController, Disposable) { diff --git a/Examples/StylesAndOptions/Example/ChooseOptions.swift b/Examples/StylesAndOptions/Example/ChooseOptions.swift index c476b21..627ccad 100644 --- a/Examples/StylesAndOptions/Example/ChooseOptions.swift +++ b/Examples/StylesAndOptions/Example/ChooseOptions.swift @@ -19,6 +19,7 @@ struct ChoosePresentationOptions { } extension PresentationOptions { static let navigationBarPreference = PresentationOptions() static let showAlertOnDidAttemptToDismiss = PresentationOptions() + static let modalNavigationControllerFlow = PresentationOptions() } extension PresentationOptions { @@ -26,6 +27,7 @@ extension PresentationOptions { let presentationOptions: [(String, PresentationOptions)] = [ ("Default", .defaults), ("Embed In Navigation Controller", .embedInNavigationController), + ("Modal Navigation Controller flow", .modalNavigationControllerFlow), ("Dont Wait For Dismiss Animation", .dontWaitForDismissAnimation), ("Unanimated", .unanimated), ("Restore first responder", .restoreFirstResponder), diff --git a/Examples/StylesAndOptions/Example/NavigationExample.swift b/Examples/StylesAndOptions/Example/NavigationExample.swift index 84cc0a0..4ef8992 100644 --- a/Examples/StylesAndOptions/Example/NavigationExample.swift +++ b/Examples/StylesAndOptions/Example/NavigationExample.swift @@ -12,9 +12,9 @@ import Flow struct NavigationExample { } -struct TestNavigationBarHiding { +struct TestNavigationBarHiding { } -} +struct TestNavigationControllerFlow { } extension TestNavigationBarHiding: Presentable { func materialize() -> (UIViewController, Disposable) { @@ -52,3 +52,19 @@ extension NavigationExample: Presentable { }) } } + +extension TestNavigationControllerFlow: Presentable { + public func materialize() -> (UIViewController, Future) { + let nc = UINavigationController() + + return (nc, Future { completion in + let bag = DisposeBag() + + bag += nc.present(NavigationExample()).onValueDisposePrevious { _ in + nc.present(NavigationExample()).onValue { completion(.success)} + } + + return bag + }) + } +} diff --git a/Examples/StylesAndOptions/ExampleUITests/ExampleUITests.swift b/Examples/StylesAndOptions/ExampleUITests/ExampleUITests.swift index c7e1bcb..58ebee1 100644 --- a/Examples/StylesAndOptions/ExampleUITests/ExampleUITests.swift +++ b/Examples/StylesAndOptions/ExampleUITests/ExampleUITests.swift @@ -210,6 +210,27 @@ class ExampleUITests: XCTestCase { app.terminate() } + + func testModalNavigationController() { + app.launch() + + let navBar = app.navigationBars["UIView"] + let cancelButton = app.buttons["Cancel"] + let nextButton = app.buttons["Next"] + let backButton = navBar.buttons["Back"] + + chooseStyleAndOption(style: "default", option: "Modal Navigation Controller flow") + + XCTAssertTrue(navBar.exists) + cancelButton.waitForExistenceAndTap() + + chooseStyleAndOption(style: "default", option: "Modal Navigation Controller flow") + + nextButton.waitForExistenceAndTap() + backButton.waitForExistenceAndTap() + nextButton.waitForExistenceAndTap() + nextButton.waitForExistenceAndTap() + } // MARK: - Helpers func verifyForAllContainerConfigurations(_ verify: () -> ()) { diff --git a/Presentation/Info.plist b/Presentation/Info.plist index f57117c..dd91ab7 100644 --- a/Presentation/Info.plist +++ b/Presentation/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.13.2 + 1.13.3 CFBundleSignature ???? CFBundleVersion diff --git a/Presentation/PresentationStyle.swift b/Presentation/PresentationStyle.swift index e81f16e..5eb0359 100644 --- a/Presentation/PresentationStyle.swift +++ b/Presentation/PresentationStyle.swift @@ -121,6 +121,9 @@ public extension PresentationStyle { } } + bag += viewController.installDismissButton().onValue { + completion(.failure(PresentError.dismissed)) + } bag += presented.installDismissButton().onValue { completion(.failure(PresentError.dismissed)) } diff --git a/Presentation/UIViewController+Presentation.swift b/Presentation/UIViewController+Presentation.swift index 0de3b0a..b8f4a7b 100644 --- a/Presentation/UIViewController+Presentation.swift +++ b/Presentation/UIViewController+Presentation.swift @@ -28,7 +28,7 @@ public extension UIViewController { // iOS 13 temporary fix for issue #40: https://github.com/iZettle/Presentation/issues/40 let shouldPresentImmediately: Bool if #available(iOS 13.0, *) { - shouldPresentImmediately = root is UISplitViewController || vc is UISplitViewController + shouldPresentImmediately = root is UISplitViewController || vc is UISplitViewController || (root as? UINavigationController)?.viewControllers.isEmpty == true } else { shouldPresentImmediately = false } diff --git a/PresentationFramework.podspec b/PresentationFramework.podspec index 7907c64..1435004 100644 --- a/PresentationFramework.podspec +++ b/PresentationFramework.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "PresentationFramework" - s.version = "1.13.2" + s.version = "1.13.3" s.module_name = "Presentation" s.summary = "Driving presentations from model to result" s.description = <<-DESC diff --git a/PresentationTests/Info.plist b/PresentationTests/Info.plist index b5f9039..5e58402 100644 --- a/PresentationTests/Info.plist +++ b/PresentationTests/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.13.2 + 1.13.3 CFBundleVersion 1