From 697c11ffbec54b9f6994171aefa59f86ddee6b45 Mon Sep 17 00:00:00 2001 From: Carl Ekman Date: Fri, 8 Jan 2021 14:26:15 +0100 Subject: [PATCH 1/8] Make sure to present immediately if the root is a UINavigationController --- Presentation/UIViewController+Presentation.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Presentation/UIViewController+Presentation.swift b/Presentation/UIViewController+Presentation.swift index 0de3b0a..2f0a165 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 is UINavigationController } else { shouldPresentImmediately = false } From cb9b00a397f21824627b54d90b2c9acd97dd9fe5 Mon Sep 17 00:00:00 2001 From: Carl Ekman Date: Fri, 8 Jan 2021 14:26:36 +0100 Subject: [PATCH 2/8] Fix dismiss button bug --- Presentation/PresentationStyle.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Presentation/PresentationStyle.swift b/Presentation/PresentationStyle.swift index e81f16e..8c44b1b 100644 --- a/Presentation/PresentationStyle.swift +++ b/Presentation/PresentationStyle.swift @@ -121,7 +121,7 @@ public extension PresentationStyle { } } - bag += presented.installDismissButton().onValue { + bag += viewController.installDismissButton().onValue { completion(.failure(PresentError.dismissed)) } From d8838941ad88dc2e115d9449b8301521ccb580d3 Mon Sep 17 00:00:00 2001 From: Carl Ekman <60693752+CJEkman@users.noreply.github.com> Date: Mon, 11 Jan 2021 10:38:48 +0100 Subject: [PATCH 3/8] Update Presentation/UIViewController+Presentation.swift Co-authored-by: Nataliya Patsovska <60615368+nataliq-pp@users.noreply.github.com> --- Presentation/UIViewController+Presentation.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Presentation/UIViewController+Presentation.swift b/Presentation/UIViewController+Presentation.swift index 2f0a165..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 || root is UINavigationController + shouldPresentImmediately = root is UISplitViewController || vc is UISplitViewController || (root as? UINavigationController)?.viewControllers.isEmpty == true } else { shouldPresentImmediately = false } From a330469c1c1fd4022289cc5be5e8820378221cea Mon Sep 17 00:00:00 2001 From: Carl Ekman <60693752+CJEkman@users.noreply.github.com> Date: Mon, 11 Jan 2021 16:18:17 +0100 Subject: [PATCH 4/8] Update Presentation/PresentationStyle.swift Co-authored-by: Nataliya Patsovska <60615368+nataliq-pp@users.noreply.github.com> --- Presentation/PresentationStyle.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Presentation/PresentationStyle.swift b/Presentation/PresentationStyle.swift index 8c44b1b..12e6656 100644 --- a/Presentation/PresentationStyle.swift +++ b/Presentation/PresentationStyle.swift @@ -124,6 +124,9 @@ public extension PresentationStyle { bag += viewController.installDismissButton().onValue { completion(.failure(PresentError.dismissed)) } + presented.installDismissButton().onValue { + completion(.failure(PresentError.dismissed)) + } if viewController.modalPresentationStyle == .popover, let popover = viewController.popoverPresentationController { let delegate = PopoverPresentationControllerDelegate { From 10c1352d15e15ca7030fa1925eff04b647c5205c Mon Sep 17 00:00:00 2001 From: Nataliya Patsovska <60615368+nataliq-pp@users.noreply.github.com> Date: Mon, 11 Jan 2021 16:56:26 +0100 Subject: [PATCH 5/8] Update Presentation/PresentationStyle.swift --- Presentation/PresentationStyle.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Presentation/PresentationStyle.swift b/Presentation/PresentationStyle.swift index 12e6656..5eb0359 100644 --- a/Presentation/PresentationStyle.swift +++ b/Presentation/PresentationStyle.swift @@ -124,7 +124,7 @@ public extension PresentationStyle { bag += viewController.installDismissButton().onValue { completion(.failure(PresentError.dismissed)) } - presented.installDismissButton().onValue { + bag += presented.installDismissButton().onValue { completion(.failure(PresentError.dismissed)) } From 8d8caf2e2d5bb7c50417a7283297062b019629cf Mon Sep 17 00:00:00 2001 From: Carl Ekman Date: Tue, 12 Jan 2021 14:47:16 +0100 Subject: [PATCH 6/8] Add UI test in example project covering the dismiss button's function --- .../StylesAndOptions/Example/AppFlow.swift | 4 ++++ .../Example/ChooseOptions.swift | 2 ++ .../Example/NavigationExample.swift | 20 ++++++++++++++++-- .../ExampleUITests/ExampleUITests.swift | 21 +++++++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) 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: () -> ()) { From be070871095d9c2328e7a580f8e2a18cbf55bcda Mon Sep 17 00:00:00 2001 From: Carl Ekman Date: Tue, 12 Jan 2021 17:13:20 +0100 Subject: [PATCH 7/8] Update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) 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 From c8547f873df15b1dd720e737fbb8275507fa9101 Mon Sep 17 00:00:00 2001 From: Carl Ekman Date: Tue, 12 Jan 2021 17:13:34 +0100 Subject: [PATCH 8/8] Bump version to 1.13.3 --- Presentation/Info.plist | 2 +- PresentationFramework.podspec | 2 +- PresentationTests/Info.plist | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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/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