mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 23:32:41 +00:00
Glitchy room list header when scrolling
- update after review
This commit is contained in:
parent
46c0e5b321
commit
356824b1f4
11 changed files with 193 additions and 155 deletions
|
@ -28,6 +28,7 @@
|
|||
|
||||
@protocol Configurable;
|
||||
@protocol LegacyAppDelegateDelegate;
|
||||
@protocol SplitViewMasterViewControllerProtocol;
|
||||
@class CallBar;
|
||||
@class CallPresenter;
|
||||
@class RoomNavigationParameters;
|
||||
|
@ -69,7 +70,7 @@ UINavigationControllerDelegate
|
|||
/**
|
||||
Application main view controller
|
||||
*/
|
||||
@property (nonatomic, readonly) MasterTabBarController *masterTabBarController;
|
||||
@property (nonatomic, readonly) UIViewController<SplitViewMasterViewControllerProtocol>* masterTabBarController;
|
||||
|
||||
@property (strong, nonatomic) UIWindow *window;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class AllChatsCoordinatorParameters {
|
|||
}
|
||||
}
|
||||
|
||||
class AllChatsCoordinator: NSObject, TabBarCoordinatorType {
|
||||
class AllChatsCoordinator: NSObject, SplitViewMasterCoordinatorProtocol {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
|
@ -81,7 +81,7 @@ class AllChatsCoordinator: NSObject, TabBarCoordinatorType {
|
|||
// Must be used only internally
|
||||
var childCoordinators: [Coordinator] = []
|
||||
|
||||
weak var delegate: TabBarCoordinatorDelegate?
|
||||
weak var delegate: SplitViewMasterCoordinatorDelegate?
|
||||
|
||||
weak var splitViewMasterPresentableDelegate: SplitViewMasterPresentableDelegate?
|
||||
|
||||
|
@ -759,7 +759,7 @@ extension AllChatsCoordinator: SecureBackupSetupCoordinatorBridgePresenterDelega
|
|||
// MARK: - AllChatsViewControllerDelegate
|
||||
extension AllChatsCoordinator: AllChatsViewControllerDelegate {
|
||||
func allChatsViewControllerDidCompleteAuthentication(_ allChatsViewController: AllChatsViewController) {
|
||||
self.delegate?.tabBarCoordinatorDidCompleteAuthentication(self)
|
||||
self.delegate?.splitViewMasterCoordinatorDidCompleteAuthentication(self)
|
||||
}
|
||||
|
||||
func allChatsViewController(_ allChatsViewController: AllChatsViewController, didSelectRoomWithParameters roomNavigationParameters: RoomNavigationParameters, completion: @escaping () -> Void) {
|
||||
|
|
|
@ -75,22 +75,22 @@ class AllChatsViewController: HomeViewController {
|
|||
|
||||
private var currentAlert: UIAlertController?
|
||||
|
||||
// MARK: - MasterTabBarController
|
||||
// MARK: - SplitViewMasterViewControllerProtocol
|
||||
|
||||
// References on the currently selected room
|
||||
@objc private(set) var selectedRoomId: String?
|
||||
@objc private(set) var selectedEventId: String?
|
||||
@objc private(set) var selectedRoomSession: MXSession?
|
||||
@objc private(set) var selectedRoomPreviewData: RoomPreviewData?
|
||||
private(set) var selectedRoomId: String?
|
||||
private(set) var selectedEventId: String?
|
||||
private(set) var selectedRoomSession: MXSession?
|
||||
private(set) var selectedRoomPreviewData: RoomPreviewData?
|
||||
|
||||
// References on the currently selected contact
|
||||
@objc private(set) var selectedContact: MXKContact?
|
||||
private(set) var selectedContact: MXKContact?
|
||||
|
||||
// Reference to the current onboarding flow. It is always nil unless the flow is being presented.
|
||||
@objc private(set) var onboardingCoordinatorBridgePresenter: OnboardingCoordinatorBridgePresenter?
|
||||
private(set) var onboardingCoordinatorBridgePresenter: OnboardingCoordinatorBridgePresenter?
|
||||
|
||||
// Tell whether the onboarding screen is preparing.
|
||||
@objc private(set) var isOnboardingInProgress: Bool = false
|
||||
private(set) var isOnboardingInProgress: Bool = false
|
||||
|
||||
// MARK: - Lifecycle
|
||||
|
||||
|
@ -144,7 +144,7 @@ class AllChatsViewController: HomeViewController {
|
|||
// Display a login screen if the account is soft logout
|
||||
// Note: We support only one account
|
||||
if let account = MXKAccountManager.shared().accounts.first, account.isSoftLogout {
|
||||
showSoftLogoutOnboardingFlow(credentials: account.mxCredentials)
|
||||
showSoftLogoutOnboardingFlow(with: account.mxCredentials)
|
||||
authIsShown = true
|
||||
} else {
|
||||
authIsShown = false
|
||||
|
@ -731,11 +731,11 @@ extension AllChatsViewController: BannerPresentationProtocol {
|
|||
}
|
||||
|
||||
// TODO: The `MasterTabBarViewController` is called from the entire app through the `LegacyAppDelegate`. this part of the code should be moved into `AppCoordinator`
|
||||
// MARK: - MasterTabBarViewController
|
||||
extension AllChatsViewController {
|
||||
// MARK: - SplitViewMasterViewControllerProtocol
|
||||
extension AllChatsViewController: SplitViewMasterViewControllerProtocol {
|
||||
|
||||
/// Release the current selected item (if any).
|
||||
@objc func releaseSelectedItem() {
|
||||
func releaseSelectedItem() {
|
||||
selectedRoomId = nil
|
||||
selectedEventId = nil
|
||||
selectedRoomSession = nil
|
||||
|
@ -744,7 +744,7 @@ extension AllChatsViewController {
|
|||
}
|
||||
|
||||
/// Refresh the missed conversations badges on tab bar icon
|
||||
@objc func refreshTabBarBadges() {
|
||||
func refreshTabBarBadges() {
|
||||
// Nothing to do here as we don't have tab bar
|
||||
}
|
||||
|
||||
|
@ -752,7 +752,7 @@ extension AllChatsViewController {
|
|||
///
|
||||
/// - Parameters:
|
||||
/// - session: the matrix session.
|
||||
@objc func presentVerifyCurrentSessionAlertIfNeeded(session: MXSession) {
|
||||
func presentVerifyCurrentSessionAlertIfNeeded(with session: MXSession) {
|
||||
guard !RiotSettings.shared.hideVerifyThisSessionAlert, !reviewSessionAlertHasBeenDisplayed, !isOnboardingInProgress else {
|
||||
return
|
||||
}
|
||||
|
@ -773,7 +773,7 @@ extension AllChatsViewController {
|
|||
///
|
||||
/// - Parameters:
|
||||
/// - session: the matrix session.
|
||||
@objc func presentReviewUnverifiedSessionsAlertIfNeeded(session: MXSession) {
|
||||
func presentReviewUnverifiedSessionsAlertIfNeeded(with session: MXSession) {
|
||||
guard !RiotSettings.shared.hideReviewSessionsAlert, !reviewSessionAlertHasBeenDisplayed else {
|
||||
return
|
||||
}
|
||||
|
@ -793,7 +793,7 @@ extension AllChatsViewController {
|
|||
}
|
||||
}
|
||||
|
||||
@objc func showOnboardingFlow() {
|
||||
func showOnboardingFlow() {
|
||||
MXLog.debug("[AllChatsViewController] showOnboardingFlow")
|
||||
self.showOnboardingFlowAndResetSessionFlags(true)
|
||||
}
|
||||
|
@ -802,7 +802,7 @@ extension AllChatsViewController {
|
|||
///
|
||||
/// - Parameters:
|
||||
/// - credentials: the credentials of the soft logout session.
|
||||
@objc func showSoftLogoutOnboardingFlow(credentials: MXCredentials?) {
|
||||
func showSoftLogoutOnboardingFlow(with credentials: MXCredentials?) {
|
||||
// This method can be called after the user chooses to clear their data as the MXSession
|
||||
// is opened to call logout from. So we only set the credentials when authentication isn't
|
||||
// in progress to prevent a second soft logout screen being shown.
|
||||
|
@ -820,7 +820,7 @@ extension AllChatsViewController {
|
|||
/// - Parameters:
|
||||
/// - parameters: the presentation parameters that contains room information plus display information.
|
||||
/// - completion: the block to execute at the end of the operation.
|
||||
@objc func selectRoom(parameters: RoomNavigationParameters, completion: @escaping () -> Void) {
|
||||
func selectRoom(with parameters: RoomNavigationParameters, completion: @escaping () -> Void) {
|
||||
releaseSelectedItem()
|
||||
|
||||
selectedRoomId = parameters.roomId
|
||||
|
@ -837,7 +837,7 @@ extension AllChatsViewController {
|
|||
/// - Parameters:
|
||||
/// - parameters: the presentation parameters that contains room preview information plus display information.
|
||||
/// - completion: the block to execute at the end of the operation.
|
||||
@objc func selectRoomPreview(parameters: RoomPreviewNavigationParameters, completion: @escaping () -> Void) {
|
||||
func selectRoomPreview(with parameters: RoomPreviewNavigationParameters, completion: @escaping () -> Void) {
|
||||
releaseSelectedItem()
|
||||
|
||||
let roomPreviewData = parameters.previewData
|
||||
|
@ -852,13 +852,13 @@ extension AllChatsViewController {
|
|||
}
|
||||
|
||||
/// Open a ContactDetailsViewController to display the information of the provided contact.
|
||||
@objc func selectContact(_ contact: MXKContact) {
|
||||
func select(_ contact: MXKContact) {
|
||||
let presentationParameters = ScreenPresentationParameters(restoreInitialDisplay: true, stackAboveVisibleViews: false)
|
||||
selectContact(contact, withPresentationParameters: presentationParameters)
|
||||
select(contact, with: presentationParameters)
|
||||
}
|
||||
|
||||
/// Open a ContactDetailsViewController to display the information of the provided contact.
|
||||
@objc func selectContact(_ contact: MXKContact, withPresentationParameters presentationParameters: ScreenPresentationParameters) {
|
||||
func select(_ contact: MXKContact, with presentationParameters: ScreenPresentationParameters) {
|
||||
releaseSelectedItem()
|
||||
|
||||
selectedContact = contact
|
||||
|
@ -869,7 +869,7 @@ extension AllChatsViewController {
|
|||
}
|
||||
|
||||
/// The current number of rooms with missed notifications, including the invites.
|
||||
@objc func missedDiscussionsCount() -> UInt {
|
||||
func missedDiscussionsCount() -> UInt {
|
||||
guard let session = mxSessions as? [MXSession] else {
|
||||
return 0
|
||||
}
|
||||
|
@ -878,7 +878,7 @@ extension AllChatsViewController {
|
|||
}
|
||||
|
||||
/// The current number of rooms with unread highlighted messages.
|
||||
@objc func missedHighlightDiscussionsCount() -> UInt {
|
||||
func missedHighlightDiscussionsCount() -> UInt {
|
||||
guard let session = mxSessions as? [MXSession] else {
|
||||
return 0
|
||||
}
|
||||
|
@ -887,10 +887,14 @@ extension AllChatsViewController {
|
|||
}
|
||||
|
||||
/// Emulated `UItabBarViewController.selectedViewController` member
|
||||
@objc var selectedViewController: UIViewController? {
|
||||
var selectedViewController: UIViewController? {
|
||||
return self
|
||||
}
|
||||
|
||||
var tabBar: UITabBar? {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func presentVerifyCurrentSessionAlert(with session: MXSession) {
|
||||
|
|
|
@ -456,7 +456,7 @@ static CGSize kThreadListBarButtonItemImageSize;
|
|||
radius:6
|
||||
opacity:0.2];
|
||||
|
||||
// self.inputBackgroundView.backgroundColor = [ThemeService.shared.theme.backgroundColor colorWithAlphaComponent:0.98];
|
||||
self.inputBackgroundView.backgroundColor = [ThemeService.shared.theme.backgroundColor colorWithAlphaComponent:0.98];
|
||||
|
||||
if (ThemeService.shared.isCurrentThemeDark)
|
||||
{
|
||||
|
|
|
@ -56,7 +56,7 @@ final class SplitViewCoordinator: NSObject, SplitViewCoordinatorType {
|
|||
return self.masterPresentable?.selectedNavigationRouter
|
||||
}
|
||||
|
||||
private weak var tabBarCoordinator: TabBarCoordinatorType?
|
||||
private weak var masterCoordinator: SplitViewMasterCoordinatorProtocol?
|
||||
|
||||
// Indicate if coordinator has been started once
|
||||
private var hasStartedOnce: Bool = false
|
||||
|
@ -93,29 +93,29 @@ final class SplitViewCoordinator: NSObject, SplitViewCoordinatorType {
|
|||
self.splitViewController.delegate = self
|
||||
|
||||
// Create primary controller
|
||||
let tabBarCoordinator: TabBarCoordinatorType = BuildSettings.isNewAppLayoutActivated ? self.createAllChatsCoordinator() : self.createTabBarCoordinator()
|
||||
tabBarCoordinator.splitViewMasterPresentableDelegate = self
|
||||
tabBarCoordinator.start(with: spaceId)
|
||||
let masterCoordinator: SplitViewMasterCoordinatorProtocol = BuildSettings.isNewAppLayoutActivated ? self.createAllChatsCoordinator() : self.createTabBarCoordinator()
|
||||
masterCoordinator.splitViewMasterPresentableDelegate = self
|
||||
masterCoordinator.start(with: spaceId)
|
||||
|
||||
// Create secondary controller
|
||||
let placeholderDetailViewController = self.createPlaceholderDetailsViewController()
|
||||
let detailNavigationController = RiotNavigationController(rootViewController: placeholderDetailViewController)
|
||||
|
||||
// Setup split view controller
|
||||
self.splitViewController.viewControllers = [tabBarCoordinator.toPresentable(), detailNavigationController]
|
||||
self.splitViewController.viewControllers = [masterCoordinator.toPresentable(), detailNavigationController]
|
||||
|
||||
// Setup detail user indicator presenter
|
||||
let context = SplitViewUserIndicatorPresentationContext(
|
||||
splitViewController: splitViewController,
|
||||
tabBarCoordinator: tabBarCoordinator,
|
||||
masterCoordinator: masterCoordinator,
|
||||
detailNavigationController: detailNavigationController
|
||||
)
|
||||
detailUserIndicatorPresenter = UserIndicatorTypePresenter(presentationContext: context)
|
||||
|
||||
self.add(childCoordinator: tabBarCoordinator)
|
||||
self.add(childCoordinator: masterCoordinator)
|
||||
|
||||
self.tabBarCoordinator = tabBarCoordinator
|
||||
self.masterPresentable = tabBarCoordinator
|
||||
self.masterCoordinator = masterCoordinator
|
||||
self.masterPresentable = masterCoordinator
|
||||
self.detailNavigationController = detailNavigationController
|
||||
self.detailNavigationRouter = NavigationRouter(navigationController: detailNavigationController)
|
||||
|
||||
|
@ -126,7 +126,7 @@ final class SplitViewCoordinator: NSObject, SplitViewCoordinatorType {
|
|||
// Pop to home screen when selecting a new space
|
||||
self.popToHome(animated: true) {
|
||||
// Update tabBarCoordinator selected space
|
||||
self.tabBarCoordinator?.start(with: spaceId)
|
||||
self.masterCoordinator?.start(with: spaceId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,26 +145,26 @@ final class SplitViewCoordinator: NSObject, SplitViewCoordinatorType {
|
|||
self.resetDetailNavigationController(animated: animated)
|
||||
|
||||
// Release the current selected item (room/contact/group...).
|
||||
self.tabBarCoordinator?.releaseSelectedItems()
|
||||
self.masterCoordinator?.releaseSelectedItems()
|
||||
}
|
||||
|
||||
func popToHome(animated: Bool, completion: (() -> Void)?) {
|
||||
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)
|
||||
self.masterCoordinator?.popToHome(animated: animated, completion: completion)
|
||||
}
|
||||
|
||||
func showErroIndicator(with error: Error) {
|
||||
tabBarCoordinator?.showErroIndicator(with: error)
|
||||
masterCoordinator?.showErroIndicator(with: error)
|
||||
}
|
||||
|
||||
func hideAppStateIndicator() {
|
||||
tabBarCoordinator?.hideAppStateIndicator()
|
||||
masterCoordinator?.hideAppStateIndicator()
|
||||
}
|
||||
|
||||
func showAppStateIndicator(with text: String, icon: UIImage?) {
|
||||
tabBarCoordinator?.showAppStateIndicator(with: text, icon: icon)
|
||||
masterCoordinator?.showAppStateIndicator(with: text, icon: icon)
|
||||
}
|
||||
|
||||
// MARK: - Private methods
|
||||
|
@ -347,8 +347,8 @@ extension SplitViewCoordinator: UISplitViewControllerDelegate {
|
|||
}
|
||||
|
||||
// MARK: - TabBarCoordinatorDelegate
|
||||
extension SplitViewCoordinator: TabBarCoordinatorDelegate {
|
||||
func tabBarCoordinatorDidCompleteAuthentication(_ coordinator: TabBarCoordinatorType) {
|
||||
extension SplitViewCoordinator: SplitViewMasterCoordinatorDelegate {
|
||||
func splitViewMasterCoordinatorDidCompleteAuthentication(_ coordinator: SplitViewMasterCoordinatorProtocol) {
|
||||
self.delegate?.splitViewCoordinatorDidCompleteAuthentication(self)
|
||||
}
|
||||
}
|
||||
|
|
112
Riot/Modules/SplitView/SplitViewMasterViewControllerProtocol.h
Normal file
112
Riot/Modules/SplitView/SplitViewMasterViewControllerProtocol.h
Normal file
|
@ -0,0 +1,112 @@
|
|||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#ifndef SplitViewMasterViewControllerProtocol_h
|
||||
#define SplitViewMasterViewControllerProtocol_h
|
||||
|
||||
@class RoomNavigationParameters;
|
||||
@class RoomPreviewNavigationParameters;
|
||||
@class ScreenPresentationParameters;
|
||||
@class OnboardingCoordinatorBridgePresenter;
|
||||
|
||||
@protocol SplitViewMasterTabBarViewControllerProtocol <NSObject>
|
||||
|
||||
/// Refresh the missed conversations badges on tab bar icon
|
||||
- (void)refreshTabBarBadges;
|
||||
|
||||
/// Emulated `UITabBarViewController.selectedViewController` property
|
||||
@property (nonatomic, readonly, nullable) UIViewController *selectedViewController;
|
||||
|
||||
/// Emulated `UITabBarViewController.tabBar` property
|
||||
@property (nonatomic, readonly, nullable) UITabBar *tabBar;
|
||||
|
||||
@end
|
||||
|
||||
/// `SplitViewMasterViewControllerProtocol` describe the methods and properties needed by
|
||||
@protocol SplitViewMasterViewControllerProtocol <SplitViewMasterTabBarViewControllerProtocol>
|
||||
|
||||
/// Display the default onboarding flow.
|
||||
- (void)showOnboardingFlow;
|
||||
|
||||
/// Display the onboarding flow configured to log back into a soft logout session.
|
||||
///
|
||||
/// @param softLogoutCredentials the credentials of the soft logout session.
|
||||
- (void)showSoftLogoutOnboardingFlowWithCredentials:(MXCredentials*)softLogoutCredentials;
|
||||
|
||||
/// Open the room with the provided identifier in a specific matrix session.
|
||||
///
|
||||
/// @param parameters the presentation parameters that contains room information plus display information.
|
||||
/// @param completion the block to execute at the end of the operation.
|
||||
- (void)selectRoomWithParameters:(RoomNavigationParameters*)parameters completion:(void (^)(void))completion;
|
||||
|
||||
/// Open the RoomViewController to display the preview of a room that is unknown for the user.
|
||||
/// This room can come from an email invitation link or a simple link to a room.
|
||||
///
|
||||
/// @param parameters the presentation parameters that contains room preview information plus display information.
|
||||
/// @param completion the block to execute at the end of the operation.
|
||||
- (void)selectRoomPreviewWithParameters:(RoomPreviewNavigationParameters*)parameters completion:(void (^)(void))completion;
|
||||
|
||||
/// Open a ContactDetailsViewController to display the information of the provided contact.
|
||||
///
|
||||
/// @param contact contact to be displayed
|
||||
- (void)selectContact:(MXKContact*)contact;
|
||||
|
||||
/// Open a ContactDetailsViewController to display the information of the provided contact according to the presentation parameters.
|
||||
///
|
||||
/// @param contact contact to be displayed
|
||||
/// @param presentationParameters the presentation parameters that contains room preview information plus display information.
|
||||
- (void)selectContact:(MXKContact*)contact withPresentationParameters:(ScreenPresentationParameters*)presentationParameters;
|
||||
|
||||
/// Release the current selected item (if any).
|
||||
- (void)releaseSelectedItem;
|
||||
|
||||
/// The current number of rooms with missed notifications, including the invites.
|
||||
- (NSUInteger)missedDiscussionsCount;
|
||||
|
||||
/// The current number of rooms with unread highlighted messages.
|
||||
- (NSUInteger)missedHighlightDiscussionsCount;
|
||||
|
||||
/// Verify the current device if needed.
|
||||
///
|
||||
/// @param session the matrix session.
|
||||
- (void)presentVerifyCurrentSessionAlertIfNeededWithSession:(MXSession*)session;
|
||||
|
||||
/// Verify others device if needed.
|
||||
///
|
||||
/// @param session the matrix session.
|
||||
- (void)presentReviewUnverifiedSessionsAlertIfNeededWithSession:(MXSession*)session;
|
||||
|
||||
/// Reference to the current onboarding flow. It is always nil unless the flow is being presented.
|
||||
@property (nonatomic, readonly) OnboardingCoordinatorBridgePresenter *onboardingCoordinatorBridgePresenter;
|
||||
|
||||
/// Reference on the currently selected room
|
||||
@property (nonatomic, readonly) NSString *selectedRoomId;
|
||||
/// Reference on the currently selected event
|
||||
@property (nonatomic, readonly) NSString *selectedEventId;
|
||||
/// Reference on the currently selected room session
|
||||
@property (nonatomic, readonly) MXSession *selectedRoomSession;
|
||||
/// Reference on the currently selected room preview data
|
||||
@property (nonatomic, readonly) RoomPreviewData *selectedRoomPreviewData;
|
||||
|
||||
/// Reference on the currently selected contact
|
||||
@property (nonatomic, readonly) MXKContact *selectedContact;
|
||||
|
||||
/// `true` while the onboarding flow is displayed
|
||||
@property (nonatomic, readonly) BOOL isOnboardingInProgress;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* SplitViewMasterViewControllerProtocol_h */
|
|
@ -19,28 +19,28 @@ import CommonKit
|
|||
|
||||
class SplitViewUserIndicatorPresentationContext: UserIndicatorPresentationContext {
|
||||
private weak var splitViewController: UISplitViewController?
|
||||
private weak var tabBarCoordinator: TabBarCoordinatorType?
|
||||
private weak var masterCoordinator: SplitViewMasterCoordinatorProtocol?
|
||||
private weak var detailNavigationController: UINavigationController?
|
||||
|
||||
init(
|
||||
splitViewController: UISplitViewController,
|
||||
tabBarCoordinator: TabBarCoordinatorType,
|
||||
masterCoordinator: SplitViewMasterCoordinatorProtocol,
|
||||
detailNavigationController: UINavigationController
|
||||
) {
|
||||
self.splitViewController = splitViewController
|
||||
self.tabBarCoordinator = tabBarCoordinator
|
||||
self.masterCoordinator = masterCoordinator
|
||||
self.detailNavigationController = detailNavigationController
|
||||
}
|
||||
|
||||
var indicatorPresentingViewController: UIViewController? {
|
||||
guard
|
||||
let splitViewController = splitViewController,
|
||||
let tabBarCoordinator = tabBarCoordinator,
|
||||
let masterCoordinator = masterCoordinator,
|
||||
let detailNavigationController = detailNavigationController
|
||||
else {
|
||||
MXLog.debug("[SplitViewCoordinator]: Missing tab bar or detail coordinator, cannot update user indicator presenter")
|
||||
return nil
|
||||
}
|
||||
return splitViewController.isCollapsed ? tabBarCoordinator.toPresentable() : detailNavigationController
|
||||
return splitViewController.isCollapsed ? masterCoordinator.toPresentable() : detailNavigationController
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#import "FavouritesViewController.h"
|
||||
#import "PeopleViewController.h"
|
||||
#import "RoomsViewController.h"
|
||||
#import "SplitViewMasterViewControllerProtocol.h"
|
||||
|
||||
#define TABBAR_HOME_INDEX 0
|
||||
#define TABBAR_FAVOURITES_INDEX 1
|
||||
|
@ -42,7 +43,7 @@ typedef NS_ENUM(NSUInteger, MasterTabBarIndex) {
|
|||
@class ScreenPresentationParameters;
|
||||
@class OnboardingCoordinatorBridgePresenter;
|
||||
|
||||
@interface MasterTabBarController : UITabBarController
|
||||
@interface MasterTabBarController : UITabBarController<SplitViewMasterViewControllerProtocol>
|
||||
|
||||
// UITabBarController already have a `delegate` property
|
||||
@property (weak, nonatomic) id<MasterTabBarControllerDelegate> masterTabBarDelegate;
|
||||
|
@ -55,71 +56,6 @@ typedef NS_ENUM(NSUInteger, MasterTabBarIndex) {
|
|||
// Remove a matrix session.
|
||||
- (void)removeMatrixSession:(MXSession*)mxSession;
|
||||
|
||||
/**
|
||||
Display the default onboarding flow.
|
||||
*/
|
||||
- (void)showOnboardingFlow;
|
||||
|
||||
/**
|
||||
Display the onboarding flow configured to log back into a soft logout session.
|
||||
|
||||
@param softLogoutCredentials the credentials of the soft logout session.
|
||||
*/
|
||||
- (void)showSoftLogoutOnboardingFlowWithCredentials:(MXCredentials*)softLogoutCredentials;
|
||||
|
||||
/// Open the room with the provided identifier in a specific matrix session.
|
||||
/// @param parameters the presentation parameters that contains room information plus display information.
|
||||
/// @param completion the block to execute at the end of the operation.
|
||||
- (void)selectRoomWithParameters:(RoomNavigationParameters*)parameters completion:(void (^)(void))completion;
|
||||
|
||||
/// Open the RoomViewController to display the preview of a room that is unknown for the user.
|
||||
/// This room can come from an email invitation link or a simple link to a room.
|
||||
/// @param parameters the presentation parameters that contains room preview information plus display information.
|
||||
/// @param completion the block to execute at the end of the operation.
|
||||
- (void)selectRoomPreviewWithParameters:(RoomPreviewNavigationParameters*)parameters completion:(void (^)(void))completion;
|
||||
|
||||
/**
|
||||
Open a ContactDetailsViewController to display the information of the provided contact.
|
||||
*/
|
||||
- (void)selectContact:(MXKContact*)contact;
|
||||
|
||||
- (void)selectContact:(MXKContact*)contact withPresentationParameters:(ScreenPresentationParameters*)presentationParameters;
|
||||
|
||||
/**
|
||||
Release the current selected item (if any).
|
||||
*/
|
||||
- (void)releaseSelectedItem;
|
||||
|
||||
/**
|
||||
The current number of rooms with missed notifications, including the invites.
|
||||
*/
|
||||
- (NSUInteger)missedDiscussionsCount;
|
||||
|
||||
/**
|
||||
The current number of rooms with unread highlighted messages.
|
||||
*/
|
||||
- (NSUInteger)missedHighlightDiscussionsCount;
|
||||
|
||||
/**
|
||||
Refresh the missed conversations badges on tab bar icon
|
||||
*/
|
||||
- (void)refreshTabBarBadges;
|
||||
|
||||
/**
|
||||
Verify the current device if needed.
|
||||
|
||||
@param session the matrix session.
|
||||
*/
|
||||
- (void)presentVerifyCurrentSessionAlertIfNeededWithSession:(MXSession*)session;
|
||||
|
||||
/**
|
||||
Verify others device if needed.
|
||||
|
||||
@param session the matrix session.
|
||||
*/
|
||||
- (void)presentReviewUnverifiedSessionsAlertIfNeededWithSession:(MXSession*)session;
|
||||
|
||||
|
||||
/// Filter rooms for each tab data source with the given room parent id.
|
||||
/// It should keep rooms having an ancestor with `roomParentId` as parent id.
|
||||
/// @param roomParentId The room parent id used to filter rooms.
|
||||
|
@ -127,27 +63,11 @@ typedef NS_ENUM(NSUInteger, MasterTabBarIndex) {
|
|||
- (void)filterRoomsWithParentId:(NSString*)roomParentId
|
||||
inMatrixSession:(MXSession*)mxSession;
|
||||
|
||||
// Reference to the current onboarding flow. It is always nil unless the flow is being presented.
|
||||
@property (nonatomic, readonly) OnboardingCoordinatorBridgePresenter *onboardingCoordinatorBridgePresenter;
|
||||
|
||||
@property (nonatomic, readonly) HomeViewController *homeViewController;
|
||||
@property (nonatomic, readonly) FavouritesViewController *favouritesViewController;
|
||||
@property (nonatomic, readonly) PeopleViewController *peopleViewController;
|
||||
@property (nonatomic, readonly) RoomsViewController *roomsViewController;
|
||||
|
||||
|
||||
// References on the currently selected room
|
||||
@property (nonatomic, readonly) NSString *selectedRoomId;
|
||||
@property (nonatomic, readonly) NSString *selectedEventId;
|
||||
@property (nonatomic, readonly) MXSession *selectedRoomSession;
|
||||
@property (nonatomic, readonly) RoomPreviewData *selectedRoomPreviewData;
|
||||
|
||||
// References on the currently selected contact
|
||||
@property (nonatomic, readonly) MXKContact *selectedContact;
|
||||
|
||||
// YES while the onboarding flow is displayed
|
||||
@property (nonatomic, readonly) BOOL isOnboardingInProgress;
|
||||
|
||||
// Set tab bar item controllers
|
||||
- (void)updateViewControllers:(NSArray<UIViewController*>*)viewControllers;
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
@end
|
||||
|
||||
@implementation MasterTabBarController
|
||||
@synthesize onboardingCoordinatorBridgePresenter, selectedRoomId, selectedEventId, selectedRoomSession, selectedRoomPreviewData, selectedContact, isOnboardingInProgress;
|
||||
|
||||
#pragma mark - Properties override
|
||||
|
||||
|
@ -530,9 +531,9 @@
|
|||
{
|
||||
[self releaseSelectedItem];
|
||||
|
||||
_selectedRoomId = paramaters.roomId;
|
||||
_selectedEventId = paramaters.eventId;
|
||||
_selectedRoomSession = paramaters.mxSession;
|
||||
selectedRoomId = paramaters.roomId;
|
||||
selectedEventId = paramaters.eventId;
|
||||
selectedRoomSession = paramaters.mxSession;
|
||||
|
||||
[self.masterTabBarDelegate masterTabBarController:self didSelectRoomWithParameters:paramaters completion:completion];
|
||||
|
||||
|
@ -545,9 +546,9 @@
|
|||
|
||||
RoomPreviewData *roomPreviewData = parameters.previewData;
|
||||
|
||||
_selectedRoomPreviewData = roomPreviewData;
|
||||
_selectedRoomId = roomPreviewData.roomId;
|
||||
_selectedRoomSession = roomPreviewData.mxSession;
|
||||
selectedRoomPreviewData = roomPreviewData;
|
||||
selectedRoomId = roomPreviewData.roomId;
|
||||
selectedRoomSession = roomPreviewData.mxSession;
|
||||
|
||||
[self.masterTabBarDelegate masterTabBarController:self didSelectRoomPreviewWithParameters:parameters completion:completion];
|
||||
|
||||
|
@ -565,7 +566,7 @@
|
|||
{
|
||||
[self releaseSelectedItem];
|
||||
|
||||
_selectedContact = contact;
|
||||
selectedContact = contact;
|
||||
|
||||
[self.masterTabBarDelegate masterTabBarController:self didSelectContact:contact withPresentationParameters:presentationParameters];
|
||||
|
||||
|
@ -574,12 +575,12 @@
|
|||
|
||||
- (void)releaseSelectedItem
|
||||
{
|
||||
_selectedRoomId = nil;
|
||||
_selectedEventId = nil;
|
||||
_selectedRoomSession = nil;
|
||||
_selectedRoomPreviewData = nil;
|
||||
selectedRoomId = nil;
|
||||
selectedEventId = nil;
|
||||
selectedRoomSession = nil;
|
||||
selectedRoomPreviewData = nil;
|
||||
|
||||
_selectedContact = nil;
|
||||
selectedContact = nil;
|
||||
}
|
||||
|
||||
- (NSUInteger)missedDiscussionsCount
|
||||
|
|
|
@ -18,15 +18,15 @@
|
|||
|
||||
import Foundation
|
||||
|
||||
protocol TabBarCoordinatorDelegate: AnyObject {
|
||||
// TODO: Remove this method, authentication should not be handled by TabBarCoordinator
|
||||
func tabBarCoordinatorDidCompleteAuthentication(_ coordinator: TabBarCoordinatorType)
|
||||
protocol SplitViewMasterCoordinatorDelegate: AnyObject {
|
||||
// TODO: Remove this method, authentication should not be handled by SplitViewMasterCoordinator
|
||||
func splitViewMasterCoordinatorDidCompleteAuthentication(_ coordinator: SplitViewMasterCoordinatorProtocol)
|
||||
}
|
||||
|
||||
/// `TabBarCoordinatorType` is a protocol describing a Coordinator that handle keybackup setup navigation flow.
|
||||
protocol TabBarCoordinatorType: Coordinator, SplitViewMasterPresentable {
|
||||
/// `SplitViewMasterCoordinatorProtocol` is a protocol describing a Coordinator that handle the master view controller of the `UISplitViewController`
|
||||
protocol SplitViewMasterCoordinatorProtocol: Coordinator, SplitViewMasterPresentable {
|
||||
|
||||
var delegate: TabBarCoordinatorDelegate? { get }
|
||||
var delegate: SplitViewMasterCoordinatorDelegate? { get }
|
||||
|
||||
/// Start coordinator by selecting a Space.
|
||||
/// - Parameter spaceId: The id of the Space to use.
|
|
@ -23,7 +23,7 @@ import CommonKit
|
|||
import MatrixSDK
|
||||
|
||||
@objcMembers
|
||||
final class TabBarCoordinator: NSObject, TabBarCoordinatorType {
|
||||
final class TabBarCoordinator: NSObject, SplitViewMasterCoordinatorProtocol {
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
|
@ -77,7 +77,7 @@ final class TabBarCoordinator: NSObject, TabBarCoordinatorType {
|
|||
// Must be used only internally
|
||||
var childCoordinators: [Coordinator] = []
|
||||
|
||||
weak var delegate: TabBarCoordinatorDelegate?
|
||||
weak var delegate: SplitViewMasterCoordinatorDelegate?
|
||||
|
||||
weak var splitViewMasterPresentableDelegate: SplitViewMasterPresentableDelegate?
|
||||
|
||||
|
@ -933,7 +933,7 @@ extension TabBarCoordinator: MasterTabBarControllerDelegate {
|
|||
}
|
||||
|
||||
func masterTabBarControllerDidCompleteAuthentication(_ masterTabBarController: MasterTabBarController!) {
|
||||
self.delegate?.tabBarCoordinatorDidCompleteAuthentication(self)
|
||||
self.delegate?.splitViewMasterCoordinatorDidCompleteAuthentication(self)
|
||||
}
|
||||
|
||||
func masterTabBarController(_ masterTabBarController: MasterTabBarController!, didSelectRoomWithId roomId: String!, andEventId eventId: String!, inMatrixSession matrixSession: MXSession!, completion: (() -> Void)!) {
|
||||
|
|
Loading…
Reference in a new issue