Merge pull request #5086 from vector-im/steve/5084_fix_leaving_room_2

Do not make the placeholder appearing when leaving a room on iPhone
This commit is contained in:
SBiOSoftWhare
2021-11-03 16:31:27 +01:00
committed by GitHub
4 changed files with 23 additions and 9 deletions
@@ -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!) {
@@ -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)
}
}
@@ -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)
}
+1
View File
@@ -0,0 +1 @@
Do not make the placeholder appearing when leaving a room on iPhone.