From 5198c5a2ed6ede44aac737407111b44295a7060d Mon Sep 17 00:00:00 2001 From: SBiOSoftWhare Date: Wed, 3 Nov 2021 11:41:11 +0100 Subject: [PATCH 1/2] SplitViewCoordinator: Fix detail screen reset behaviour. --- Riot/Modules/Application/AppCoordinator.swift | 2 +- .../SplitView/SplitViewCoordinator.swift | 23 ++++++++++++++----- .../SplitView/SplitViewCoordinatorType.swift | 6 +++-- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Riot/Modules/Application/AppCoordinator.swift b/Riot/Modules/Application/AppCoordinator.swift index 32121a0f6..d60faf924 100755 --- a/Riot/Modules/Application/AppCoordinator.swift +++ b/Riot/Modules/Application/AppCoordinator.swift @@ -228,7 +228,7 @@ extension AppCoordinator: LegacyAppDelegateDelegate { } func legacyAppDelegateRestoreEmptyDetailsViewController(_ legacyAppDelegate: LegacyAppDelegate!) { - self.splitViewCoordinator?.restorePlaceholderDetails() + self.splitViewCoordinator?.resetDetails(animated: false) } func legacyAppDelegate(_ legacyAppDelegate: LegacyAppDelegate!, didAddMatrixSession session: MXSession!) { diff --git a/Riot/Modules/SplitView/SplitViewCoordinator.swift b/Riot/Modules/SplitView/SplitViewCoordinator.swift index 479ebf702..ee1ad5af7 100644 --- a/Riot/Modules/SplitView/SplitViewCoordinator.swift +++ b/Riot/Modules/SplitView/SplitViewCoordinator.swift @@ -125,20 +125,20 @@ final class SplitViewCoordinator: NSObject, SplitViewCoordinatorType { } // TODO: Do not expose publicly this method - func restorePlaceholderDetails() { + func resetDetails(animated: Bool) { // Be sure that the primary is then visible too. if splitViewController.displayMode == .primaryHidden { splitViewController.preferredDisplayMode = .allVisible } - self.resetDetailNavigationControllerWithPlaceholder(animated: false) + self.resetDetailNavigationController(animated: animated) // Release the current selected item (room/contact/group...). self.tabBarCoordinator?.releaseSelectedItems() - } + } func popToHome(animated: Bool, completion: (() -> Void)?) { - self.resetDetailNavigationControllerWithPlaceholder(animated: animated) + self.resetDetails(animated: animated) // Force back to the main screen if this is not the one that is displayed self.tabBarCoordinator?.popToHome(animated: animated, completion: completion) @@ -172,6 +172,17 @@ final class SplitViewCoordinator: NSObject, SplitViewCoordinatorType { // Set placeholder screen as root controller of detail navigation controller let placeholderDetailsVC = self.createPlaceholderDetailsViewController() detailNavigationRouter.setRootModule(placeholderDetailsVC, hideNavigationBar: false, animated: animated, popCompletion: nil) + } + + private func resetDetailNavigationController(animated: Bool) { + + if self.splitViewController.isCollapsed { + if let topMostNavigationController = self.selectedNavigationRouter?.modules.last as? UINavigationController, topMostNavigationController == self.detailNavigationController { + self.selectedNavigationRouter?.popModule(animated: animated) + } + } else { + self.resetDetailNavigationControllerWithPlaceholder(animated: animated) + } } private func isPlaceholderShown(from secondaryViewController: UIViewController) -> Bool { @@ -270,7 +281,7 @@ extension SplitViewCoordinator: UISplitViewControllerDelegate { } // Restore detail navigation controller with placeholder as root - self.resetDetailNavigationControllerWithPlaceholder(animated: false) + self.resetDetailNavigationController(animated: false) // Return up to date detail navigation controller // In any cases `detailNavigationController` will be used as secondary view of the split view controller. @@ -353,6 +364,6 @@ extension SplitViewCoordinator: SplitViewMasterPresentableDelegate { } func splitViewMasterPresentableWantsToResetDetail(_ presentable: Presentable) { - self.resetDetailNavigationControllerWithPlaceholder(animated: false) + self.resetDetails(animated: false) } } diff --git a/Riot/Modules/SplitView/SplitViewCoordinatorType.swift b/Riot/Modules/SplitView/SplitViewCoordinatorType.swift index e49a54879..4fd2cfef6 100644 --- a/Riot/Modules/SplitView/SplitViewCoordinatorType.swift +++ b/Riot/Modules/SplitView/SplitViewCoordinatorType.swift @@ -30,8 +30,10 @@ protocol SplitViewCoordinatorType: Coordinator, Presentable { /// - Parameter spaceId: The id of the Space to use. func start(with spaceId: String?) + /// Restore navigation stack and show home screen func popToHome(animated: Bool, completion: (() -> Void)?) - + // TODO: Do not expose publicly this method - func restorePlaceholderDetails() + /// Remove detail screens and display placeholder if needed + func resetDetails(animated: Bool) } From b8fa2106d2eea0a3951507b7f492651942eb558d Mon Sep 17 00:00:00 2001 From: SBiOSoftWhare Date: Wed, 3 Nov 2021 11:42:11 +0100 Subject: [PATCH 2/2] Update changes --- changelog.d/5084.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/5084.bugfix diff --git a/changelog.d/5084.bugfix b/changelog.d/5084.bugfix new file mode 100644 index 000000000..c7826659d --- /dev/null +++ b/changelog.d/5084.bugfix @@ -0,0 +1 @@ +Do not make the placeholder appearing when leaving a room on iPhone. \ No newline at end of file