2017-03-23 16:48:05 +00:00
|
|
|
/*
|
|
|
|
Copyright 2017 Vector Creations Ltd
|
2020-09-15 14:48:35 +00:00
|
|
|
Copyright 2020 New Vector Ltd
|
2017-03-23 16:48:05 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import "AuthenticationViewController.h"
|
|
|
|
|
2021-10-05 14:41:37 +00:00
|
|
|
#import "RoomPreviewData.h"
|
2017-03-23 16:48:05 +00:00
|
|
|
#import "HomeViewController.h"
|
2017-04-06 12:27:45 +00:00
|
|
|
#import "FavouritesViewController.h"
|
|
|
|
#import "PeopleViewController.h"
|
|
|
|
#import "RoomsViewController.h"
|
2017-12-12 15:03:26 +00:00
|
|
|
#import "GroupsViewController.h"
|
2017-03-23 16:48:05 +00:00
|
|
|
|
|
|
|
#define TABBAR_HOME_INDEX 0
|
|
|
|
#define TABBAR_FAVOURITES_INDEX 1
|
|
|
|
#define TABBAR_PEOPLE_INDEX 2
|
|
|
|
#define TABBAR_ROOMS_INDEX 3
|
2017-12-12 15:03:26 +00:00
|
|
|
#define TABBAR_GROUPS_INDEX 4
|
|
|
|
#define TABBAR_COUNT 5
|
2017-03-23 16:48:05 +00:00
|
|
|
|
2021-09-22 16:49:22 +00:00
|
|
|
typedef NS_ENUM(NSUInteger, MasterTabBarIndex) {
|
|
|
|
MasterTabBarIndexHome = TABBAR_HOME_INDEX,
|
|
|
|
MasterTabBarIndexFavourites = TABBAR_FAVOURITES_INDEX,
|
|
|
|
MasterTabBarIndexPeople = TABBAR_PEOPLE_INDEX,
|
|
|
|
MasterTabBarIndexRooms = TABBAR_ROOMS_INDEX,
|
|
|
|
MasterTabBarIndexGroups = TABBAR_GROUPS_INDEX
|
|
|
|
};
|
2020-09-07 08:01:06 +00:00
|
|
|
|
|
|
|
@protocol MasterTabBarControllerDelegate;
|
2021-10-21 09:40:18 +00:00
|
|
|
@class RoomNavigationParameters;
|
2021-10-21 12:47:17 +00:00
|
|
|
@class RoomPreviewNavigationParameters;
|
2021-10-21 08:00:37 +00:00
|
|
|
@class ScreenPresentationParameters;
|
2020-09-15 14:48:35 +00:00
|
|
|
|
2017-03-23 16:48:05 +00:00
|
|
|
@interface MasterTabBarController : UITabBarController
|
|
|
|
|
2020-09-07 08:01:06 +00:00
|
|
|
// UITabBarController already have a `delegate` property
|
|
|
|
@property (weak, nonatomic) id<MasterTabBarControllerDelegate> masterTabBarDelegate;
|
|
|
|
|
2017-03-23 16:48:05 +00:00
|
|
|
// Associated matrix sessions (empty by default).
|
2021-05-26 19:02:41 +00:00
|
|
|
@property (nonatomic, readonly) NSArray<MXSession*> *mxSessions;
|
2017-03-23 16:48:05 +00:00
|
|
|
|
|
|
|
// Add a matrix session. This session is propagated to all view controllers handled by the tab bar controller.
|
|
|
|
- (void)addMatrixSession:(MXSession*)mxSession;
|
|
|
|
// Remove a matrix session.
|
|
|
|
- (void)removeMatrixSession:(MXSession*)mxSession;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Display the authentication screen.
|
|
|
|
*/
|
|
|
|
- (void)showAuthenticationScreen;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Display the authentication screen in order to pursue a registration process by using a predefined set
|
|
|
|
of parameters.
|
|
|
|
|
|
|
|
If the provided registration parameters are not supported, we switch back to the default login screen.
|
|
|
|
|
|
|
|
@param parameters the set of parameters.
|
|
|
|
*/
|
|
|
|
- (void)showAuthenticationScreenWithRegistrationParameters:(NSDictionary*)parameters;
|
|
|
|
|
2019-07-19 12:25:45 +00:00
|
|
|
/**
|
|
|
|
Display the authentication screen in order to login back a soft logout session.
|
|
|
|
|
|
|
|
@param softLogoutCredentials the credentials of the soft logout session.
|
|
|
|
*/
|
|
|
|
- (void)showAuthenticationScreenAfterSoftLogout:(MXCredentials*)softLogoutCredentials;
|
|
|
|
|
2021-10-12 17:10:30 +00:00
|
|
|
/// 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.
|
2021-10-21 09:40:18 +00:00
|
|
|
- (void)selectRoomWithParameters:(RoomNavigationParameters*)parameters completion:(void (^)(void))completion;
|
2017-03-23 16:48:05 +00:00
|
|
|
|
2021-10-12 17:10:30 +00:00
|
|
|
/// 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.
|
2021-10-21 12:47:17 +00:00
|
|
|
- (void)selectRoomPreviewWithParameters:(RoomPreviewNavigationParameters*)parameters completion:(void (^)(void))completion;
|
2017-03-23 16:48:05 +00:00
|
|
|
|
|
|
|
/**
|
2017-03-28 15:26:50 +00:00
|
|
|
Open a ContactDetailsViewController to display the information of the provided contact.
|
2017-03-23 16:48:05 +00:00
|
|
|
*/
|
2017-03-28 15:26:50 +00:00
|
|
|
- (void)selectContact:(MXKContact*)contact;
|
|
|
|
|
2021-10-21 08:00:37 +00:00
|
|
|
- (void)selectContact:(MXKContact*)contact withPresentationParameters:(ScreenPresentationParameters*)presentationParameters;
|
2021-10-20 13:55:46 +00:00
|
|
|
|
2017-12-12 15:03:26 +00:00
|
|
|
/**
|
|
|
|
Open a GroupDetailsViewController to display the information of the provided group.
|
|
|
|
|
2021-10-20 13:55:46 +00:00
|
|
|
@param group Selected community.
|
2021-07-02 15:46:27 +00:00
|
|
|
@param matrixSession the matrix session in which the group should be available.
|
2017-12-12 15:03:26 +00:00
|
|
|
*/
|
|
|
|
- (void)selectGroup:(MXGroup*)group inMatrixSession:(MXSession*)matrixSession;
|
|
|
|
|
2021-10-21 08:00:37 +00:00
|
|
|
- (void)selectGroup:(MXGroup*)group inMatrixSession:(MXSession*)matrixSession presentationParameters:(ScreenPresentationParameters*)presentationParameters;
|
2021-10-20 13:55:46 +00:00
|
|
|
|
2017-03-28 15:26:50 +00:00
|
|
|
/**
|
|
|
|
Release the current selected item (if any).
|
|
|
|
*/
|
|
|
|
- (void)releaseSelectedItem;
|
|
|
|
|
2017-04-18 13:55:51 +00:00
|
|
|
/**
|
|
|
|
The current number of rooms with missed notifications, including the invites.
|
|
|
|
*/
|
|
|
|
- (NSUInteger)missedDiscussionsCount;
|
|
|
|
|
|
|
|
/**
|
|
|
|
The current number of rooms with unread highlighted messages.
|
|
|
|
*/
|
|
|
|
- (NSUInteger)missedHighlightDiscussionsCount;
|
|
|
|
|
2017-04-28 12:06:58 +00:00
|
|
|
/**
|
|
|
|
Refresh the missed conversations badges on tab bar icon
|
|
|
|
*/
|
|
|
|
- (void)refreshTabBarBadges;
|
|
|
|
|
2020-09-29 15:02:02 +00:00
|
|
|
/**
|
|
|
|
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;
|
|
|
|
|
2017-03-23 16:48:05 +00:00
|
|
|
|
2021-07-02 16:35:29 +00:00
|
|
|
/// 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.
|
|
|
|
/// @param mxSession The matrix session in which the room filtering should be done.
|
|
|
|
- (void)filterRoomsWithParentId:(NSString*)roomParentId
|
|
|
|
inMatrixSession:(MXSession*)mxSession;
|
|
|
|
|
2017-03-23 16:48:05 +00:00
|
|
|
// Reference to the current auth VC. It is not nil only when the auth screen is displayed.
|
|
|
|
@property (nonatomic, readonly) AuthenticationViewController *authViewController;
|
|
|
|
|
|
|
|
@property (nonatomic, readonly) HomeViewController *homeViewController;
|
2017-04-06 12:27:45 +00:00
|
|
|
@property (nonatomic, readonly) FavouritesViewController *favouritesViewController;
|
|
|
|
@property (nonatomic, readonly) PeopleViewController *peopleViewController;
|
|
|
|
@property (nonatomic, readonly) RoomsViewController *roomsViewController;
|
2017-12-12 15:03:26 +00:00
|
|
|
@property (nonatomic, readonly) GroupsViewController *groupsViewController;
|
2017-03-23 16:48:05 +00:00
|
|
|
|
2021-05-20 19:42:04 +00:00
|
|
|
|
2021-10-05 14:24:58 +00:00
|
|
|
// References on the currently selected room
|
2017-03-23 16:48:05 +00:00
|
|
|
@property (nonatomic, readonly) NSString *selectedRoomId;
|
|
|
|
@property (nonatomic, readonly) NSString *selectedEventId;
|
|
|
|
@property (nonatomic, readonly) MXSession *selectedRoomSession;
|
|
|
|
@property (nonatomic, readonly) RoomPreviewData *selectedRoomPreviewData;
|
|
|
|
|
2021-10-05 14:24:58 +00:00
|
|
|
// References on the currently selected contact
|
2017-03-28 15:26:50 +00:00
|
|
|
@property (nonatomic, readonly) MXKContact *selectedContact;
|
|
|
|
|
2021-10-05 14:24:58 +00:00
|
|
|
// References on the currently selected group
|
2017-12-12 15:03:26 +00:00
|
|
|
@property (nonatomic, readonly) MXGroup *selectedGroup;
|
|
|
|
@property (nonatomic, readonly) MXSession *selectedGroupSession;
|
|
|
|
|
2020-09-15 14:48:35 +00:00
|
|
|
// YES while the authentication screen is displayed
|
|
|
|
@property (nonatomic, readonly) BOOL authenticationInProgress;
|
|
|
|
|
2021-05-20 19:42:04 +00:00
|
|
|
// Set tab bar item controllers
|
|
|
|
- (void)updateViewControllers:(NSArray<UIViewController*>*)viewControllers;
|
|
|
|
|
2021-09-22 16:49:22 +00:00
|
|
|
- (void)removeTabAt:(MasterTabBarIndex)index;
|
|
|
|
|
2021-10-05 08:34:42 +00:00
|
|
|
- (void)selectTabAtIndex:(MasterTabBarIndex)tabBarIndex;
|
|
|
|
|
2017-03-23 16:48:05 +00:00
|
|
|
@end
|
|
|
|
|
2020-09-15 14:48:35 +00:00
|
|
|
|
2020-09-07 08:01:06 +00:00
|
|
|
@protocol MasterTabBarControllerDelegate <NSObject>
|
2020-09-15 14:48:35 +00:00
|
|
|
|
|
|
|
- (void)masterTabBarControllerDidCompleteAuthentication:(MasterTabBarController *)masterTabBarController;
|
2021-09-20 08:10:27 +00:00
|
|
|
- (void)masterTabBarController:(MasterTabBarController*)masterTabBarController needsSideMenuIconWithNotification:(BOOL)displayNotification;
|
2021-10-21 09:40:18 +00:00
|
|
|
- (void)masterTabBarController:(MasterTabBarController *)masterTabBarController didSelectRoomWithParameters:(RoomNavigationParameters*)roomNavigationParameters completion:(void (^)(void))completion;
|
2021-10-21 12:47:17 +00:00
|
|
|
- (void)masterTabBarController:(MasterTabBarController *)masterTabBarController didSelectRoomPreviewWithParameters:(RoomPreviewNavigationParameters*)roomPreviewNavigationParameters completion:(void (^)(void))completion;
|
2021-10-21 08:00:37 +00:00
|
|
|
- (void)masterTabBarController:(MasterTabBarController *)masterTabBarController didSelectContact:(MXKContact*)contact withPresentationParameters:(ScreenPresentationParameters*)presentationParameters;
|
|
|
|
- (void)masterTabBarController:(MasterTabBarController *)masterTabBarController didSelectGroup:(MXGroup*)group inMatrixSession:(MXSession*)matrixSession presentationParameters:(ScreenPresentationParameters*)presentationParameters;
|
2021-12-07 12:09:26 +00:00
|
|
|
- (void)masterTabBarController:(MasterTabBarController *)masterTabBarController shouldPresentAnalyticsPromptForMatrixSession:(MXSession*)matrixSession;
|
2020-09-15 14:48:35 +00:00
|
|
|
|
2020-09-07 08:01:06 +00:00
|
|
|
@end
|