     
     private let splitViewController: UISplitViewController
     
-    // TODO: Move to TabBarCoordinator
-    private let masterNavigationController: UINavigationController
-    private let masterTabBarController: MasterTabBarController
+    private weak var masterPresentable: SplitViewMasterPresentable?
+    private weak var detailNavigationController: UINavigationController?
     
-    /// Completion called when `popToHomeViewControllerAnimated:` has been completed.
-    private var popToHomeViewControllerCompletion: (() -> Void)?
+    private weak var tabBarCoordinator: TabBarCoordinatorType?
     
     // MARK: Public
     

    }
    
    func splitViewController(_ splitViewController: UISplitViewController, collapseSecondary secondaryViewController: UIViewController, onto primaryViewController: UIViewController) -> Bool {
        if (masterTabBarController.currentRoomViewController == nil) && (masterTabBarController.currentContactDetailViewController == nil) && (masterTabBarController.currentGroupDetailViewController == nil) {
            // Return YES to indicate that we have handled the collapse by doing nothing; the secondary controller will be discarded.
            return true
        } else {
            return false
        }
    }
}

// MARK: - UINavigationControllerDelegate
extension SplitViewCoordinator: UINavigationControllerDelegate {
    
    func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
        
        if viewController == masterTabBarController {
            masterNavigationController.delegate = nil
            
            // For unknown reason, the navigation bar is not restored correctly by [popToViewController:animated:]
            // when a ViewController has hidden it (see MXKAttachmentsViewController).
            // Patch: restore navigation bar by default here.
            masterNavigationController.isNavigationBarHidden = false

            // Release the current selected item (room/contact/...).
            masterTabBarController.releaseSelectedItem()

            if let popToHomeViewControllerCompletion = self.popToHomeViewControllerCompletion {
                let popToHomeViewControllerCompletion2: (() -> Void)? = popToHomeViewControllerCompletion
                self.popToHomeViewControllerCompletion = nil

                DispatchQueue.main.async {
                    popToHomeViewControllerCompletion2?()
                }
            }
        }
        
    }
}

extension SplitViewCoordinator: UISplitViewControllerDelegate {
    
    func splitViewController(_ splitViewController: UISplitViewController, separateSecondaryFrom primaryViewController: UIViewController) -> UIViewController? {
        
        if let detailViewController = self.masterPresentable?.secondViewControllerWhenSeparatedFromPrimary() {
            return detailViewController
        }

        // Else return the default empty details view controller from the storyboard.
