Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not make the placeholder appearing when leaving a room on iPhone #5086

Merged
merged 2 commits into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.