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

Use split controller's top navigation controller to present toasts #5767

Merged
merged 2 commits into from
Mar 8, 2022

Conversation

Anderas
Copy link
Contributor

@Anderas Anderas commented Mar 8, 2022

Fixes #5752

The issue of missing spinner is actually a layout issue caused by split view controller allowing multiple nested navigation controllers. Previously when a toast was presented on a navigation controller, it was added on top of the navigation bar and anchored to the title, which could happen before the navigation controller itself was added to the view controller hierarchy. Once the navigation controller was properly added to the hierarchy, the parent navigation took control over the navigation bar and placed it on top of the spinner as well as invalidating any previously set constraints.

To solve for this issue the app needs to get hold of the ever-present top navigation controller, owned by the split view controller. On iPhones, this is the navigation controller that holds onto the detail navigation controller, whereas on iPads the detail navigation controller is the top navigation controller.

The whole point of this change is to expose navigation controller that is always in the view hierarchy, as opposed to a temporary one that may not have stable navigation bar.

@Anderas Anderas requested review from a team and pixlwave and removed request for a team March 8, 2022 08:39
@github-actions
Copy link

github-actions bot commented Mar 8, 2022

📱 Scan the QR code below to install the build for this PR.
🔒 This build is for internal testing purpose. Only devices listed in the ad-hoc provisioning profile can install Element Alpha.

QR code

If you can't scan the QR code you can install the build via this link: https://i.diawi.com/EGi6WG

Comment on lines 106 to 108
// Setup detail user indicator presenter
let presentingViewController = splitViewController.isCollapsed ? tabBarCoordinator.toPresentable() : detailNavigationController
detailUserIndicatorPresenter = UserIndicatorTypePresenter(presentingViewController: presentingViewController)
Copy link
Member

@pixlwave pixlwave Mar 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this should be pulled out into its own method and also called from the 2 UISplitViewControllerDelegate methods too, to handle iPad layout changes?

SplitViewCoordinator.splitViewController(_:separateSecondaryFrom:)
SplitViewCoordinator.splitViewController(_:collapseSecondary:onto:)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense, although the fix I just pushed is not sufficient yet either, because currently each time the layout is changed, the presenter will be recreated, incl creating a new indicator queue, which is bad. Because this is a relative edge case (ie you need iPad + detail shown + spinner active + change of layout) I'd go with this for now and in separete PR I want to hide the presentingViewController behind some kind of factory interface that gets passed into the presenter. That way only the view controller is changed on demand rather than the entire indicator presenter

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me 👍

@Anderas Anderas requested a review from pixlwave March 8, 2022 10:43
@@ -15,6 +15,7 @@
*/

import Foundation
import MatrixSDK
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not needed, but Xcode 13 seems to like adding this 🤷‍♂️

Copy link
Member

@pixlwave pixlwave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Syncing spinner is often missing despite showing stale unsynced timeline
2 participants