Skip to content

Commit

Permalink
Merge pull request #5086 from vector-im/steve/5084_fix_leaving_room_2
Browse files Browse the repository at this point in the history
Do not make the placeholder appearing when leaving a room on iPhone
  • Loading branch information
SBiOSoftWhare authored Nov 3, 2021
2 parents 72d2ead + 424ca90 commit 1601689
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Riot/Modules/Application/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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!) {
Expand Down
23 changes: 17 additions & 6 deletions Riot/Modules/SplitView/SplitViewCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -353,6 +364,6 @@ extension SplitViewCoordinator: SplitViewMasterPresentableDelegate {
}

func splitViewMasterPresentableWantsToResetDetail(_ presentable: Presentable) {
self.resetDetailNavigationControllerWithPlaceholder(animated: false)
self.resetDetails(animated: false)
}
}
6 changes: 4 additions & 2 deletions Riot/Modules/SplitView/SplitViewCoordinatorType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 change: 1 addition & 0 deletions changelog.d/5084.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Do not make the placeholder appearing when leaving a room on iPhone.

0 comments on commit 1601689

Please sign in to comment.