TabBarCoordinator: Prepare space switching.

This commit is contained in:
SBiOSoftWhare 2021-07-02 16:46:53 +02:00
parent 20670812b8
commit 4a7ebd2bec
2 changed files with 34 additions and 12 deletions

View file

@ -50,6 +50,8 @@ final class TabBarCoordinator: NSObject, TabBarCoordinatorType {
private let navigationRouter: NavigationRouterType
private let masterNavigationController: UINavigationController
private var currentSpaceId: String?
// MARK: Public
// Must be used only internally
@ -72,21 +74,33 @@ final class TabBarCoordinator: NSObject, TabBarCoordinatorType {
// MARK: - Public methods
func start() {
let masterTabBarController = self.createMasterTabBarController()
masterTabBarController.masterTabBarDelegate = self
self.masterTabBarController = masterTabBarController
self.navigationRouter.setRootModule(masterTabBarController)
self.start(with: nil)
}
// Add existing Matrix sessions if any
for userSession in self.parameters.userSessionsService.userSessions {
self.addMatrixSessionToMasterTabBarController(userSession.matrixSession)
func start(with spaceId: String?) {
self.currentSpaceId = spaceId
// If start has been done once do setup view controllers again
if self.masterTabBarController == nil {
let masterTabBarController = self.createMasterTabBarController()
masterTabBarController.masterTabBarDelegate = self
self.masterTabBarController = masterTabBarController
self.navigationRouter.setRootModule(masterTabBarController)
// Add existing Matrix sessions if any
for userSession in self.parameters.userSessionsService.userSessions {
self.addMatrixSessionToMasterTabBarController(userSession.matrixSession)
}
if BuildSettings.enableSideMenu {
self.setupSideMenuGestures()
}
self.registerUserSessionsServiceNotifications()
}
if BuildSettings.enableSideMenu {
self.setupSideMenuGestures()
}
self.registerUserSessionsServiceNotifications()
// Update masterNavigationController.navigationItem.titleView
self.updateMasterNavigationBarTitleView(with: spaceId)
}
func toPresentable() -> UIViewController {
@ -248,6 +262,10 @@ final class TabBarCoordinator: NSObject, TabBarCoordinatorType {
self.parameters.appNavigator.sideMenu.addScreenEdgePanGesturesToPresent(to: self.masterNavigationController.view)
self.parameters.appNavigator.sideMenu.addPanGestureToPresent(to: self.masterNavigationController.navigationBar)
}
private func updateMasterNavigationBarTitleView(with spaceId: String?) {
// TODO: Update masterNavigationController title view with new space info
}
// MARK: Navigation

View file

@ -27,6 +27,10 @@ protocol TabBarCoordinatorDelegate: class {
protocol TabBarCoordinatorType: Coordinator, SplitViewMasterPresentable {
var delegate: TabBarCoordinatorDelegate? { get }
/// Start coordinator by selecting a Space.
/// - Parameter spaceId: The id of the Space to use.
func start(with spaceId: String?)
func popToHome(animated: Bool, completion: (() -> Void)?)