2015-11-20 17:14:15 +00:00
|
|
|
/*
|
|
|
|
Copyright 2015 OpenMarket Ltd
|
2017-04-06 12:27:45 +00:00
|
|
|
Copyright 2017 Vector Creations Ltd
|
2015-11-20 17:14:15 +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.
|
|
|
|
*/
|
|
|
|
|
2021-11-30 15:09:53 +00:00
|
|
|
#import "MatrixKit.h"
|
2015-11-20 17:14:15 +00:00
|
|
|
|
2017-04-06 12:27:45 +00:00
|
|
|
#import "PublicRoomsDirectoryDataSource.h"
|
2015-12-18 16:17:03 +00:00
|
|
|
|
2021-10-04 14:28:21 +00:00
|
|
|
@protocol RecentsListServiceProtocol;
|
2021-09-24 15:50:41 +00:00
|
|
|
@class DiscussionsCount;
|
2021-07-15 12:10:01 +00:00
|
|
|
@class MXSpace;
|
|
|
|
|
2015-11-20 17:14:15 +00:00
|
|
|
/**
|
2017-04-06 12:27:45 +00:00
|
|
|
List the different modes used to prepare the recents data source.
|
|
|
|
Each mode corresponds to an application tab: Home, Favourites, People and Rooms.
|
2021-10-12 19:56:52 +00:00
|
|
|
Used as the tag of UITableView, starting from 1 in order to avoid collision with default tag of UIView.
|
2015-11-20 17:14:15 +00:00
|
|
|
*/
|
2021-09-24 15:50:41 +00:00
|
|
|
typedef NS_ENUM(NSInteger, RecentsDataSourceMode)
|
2017-04-06 12:27:45 +00:00
|
|
|
{
|
2021-10-12 19:56:52 +00:00
|
|
|
RecentsDataSourceModeHome = 1,
|
2017-04-06 12:27:45 +00:00
|
|
|
RecentsDataSourceModeFavourites,
|
|
|
|
RecentsDataSourceModePeople,
|
|
|
|
RecentsDataSourceModeRooms
|
2021-09-24 15:50:41 +00:00
|
|
|
};
|
2015-11-20 17:14:15 +00:00
|
|
|
|
2019-01-31 18:52:32 +00:00
|
|
|
/**
|
2020-06-25 15:52:36 +00:00
|
|
|
List the different secure backup banners that could be displayed.
|
2019-01-31 18:52:32 +00:00
|
|
|
*/
|
2020-06-25 15:52:36 +00:00
|
|
|
typedef NS_ENUM(NSInteger, SecureBackupBannerDisplay)
|
2019-01-31 18:52:32 +00:00
|
|
|
{
|
2020-06-25 15:52:36 +00:00
|
|
|
SecureBackupBannerDisplayNone,
|
2020-06-26 11:07:53 +00:00
|
|
|
SecureBackupBannerDisplaySetup
|
2019-01-31 18:52:32 +00:00
|
|
|
};
|
2017-04-20 16:06:49 +00:00
|
|
|
|
2020-06-30 15:31:44 +00:00
|
|
|
/**
|
2020-06-30 19:46:10 +00:00
|
|
|
List the different cross-signing banners that could be displayed.
|
2020-06-30 15:31:44 +00:00
|
|
|
*/
|
2020-06-30 19:46:10 +00:00
|
|
|
typedef NS_ENUM(NSInteger, CrossSigningBannerDisplay)
|
2020-06-30 15:31:44 +00:00
|
|
|
{
|
2020-06-30 19:46:10 +00:00
|
|
|
CrossSigningBannerDisplayNone,
|
|
|
|
CrossSigningBannerDisplaySetup
|
2020-06-30 15:31:44 +00:00
|
|
|
};
|
|
|
|
|
2017-04-20 16:06:49 +00:00
|
|
|
/**
|
|
|
|
Action identifier used when the user tapped on the directory change button.
|
|
|
|
|
|
|
|
The `userInfo` is nil.
|
|
|
|
*/
|
|
|
|
extern NSString *const kRecentsDataSourceTapOnDirectoryServerChange;
|
|
|
|
|
2015-12-11 13:59:55 +00:00
|
|
|
/**
|
2017-04-06 12:27:45 +00:00
|
|
|
'RecentsDataSource' class inherits from 'MXKInterleavedRecentsDataSource' to define the Riot recents source
|
|
|
|
shared between all the applications tabs.
|
2015-12-14 09:47:10 +00:00
|
|
|
*/
|
2017-04-06 12:27:45 +00:00
|
|
|
@interface RecentsDataSource : MXKInterleavedRecentsDataSource
|
2017-04-07 13:33:48 +00:00
|
|
|
|
2020-06-30 19:46:10 +00:00
|
|
|
@property (nonatomic) NSInteger crossSigningBannerSection;
|
2020-06-25 15:52:36 +00:00
|
|
|
@property (nonatomic) NSInteger secureBackupBannerSection;
|
2017-04-07 13:33:48 +00:00
|
|
|
@property (nonatomic) NSInteger directorySection;
|
|
|
|
@property (nonatomic) NSInteger invitesSection;
|
|
|
|
@property (nonatomic) NSInteger favoritesSection;
|
2017-05-11 09:51:42 +00:00
|
|
|
@property (nonatomic) NSInteger peopleSection;
|
2017-04-07 13:33:48 +00:00
|
|
|
@property (nonatomic) NSInteger conversationSection;
|
|
|
|
@property (nonatomic) NSInteger lowPrioritySection;
|
2018-08-23 14:50:14 +00:00
|
|
|
@property (nonatomic) NSInteger serverNoticeSection;
|
2021-07-29 21:24:34 +00:00
|
|
|
@property (nonatomic) NSInteger suggestedRoomsSection;
|
2017-04-07 13:33:48 +00:00
|
|
|
|
2021-10-04 14:28:21 +00:00
|
|
|
@property (nonatomic, readonly) NSInteger totalVisibleItemCount;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Counts for favorited rooms.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, readonly) DiscussionsCount *favoriteMissedDiscussionsCount;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Counts for direct rooms.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, readonly) DiscussionsCount *directMissedDiscussionsCount;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Counts for group rooms.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, readonly) DiscussionsCount *groupMissedDiscussionsCount;
|
2017-05-05 13:30:35 +00:00
|
|
|
|
2020-06-25 15:52:36 +00:00
|
|
|
@property (nonatomic, readonly) SecureBackupBannerDisplay secureBackupBannerDisplay;
|
2020-06-30 19:46:10 +00:00
|
|
|
@property (nonatomic, readonly) CrossSigningBannerDisplay crossSigningBannerDisplay;
|
2019-01-31 18:52:32 +00:00
|
|
|
|
2021-10-04 14:28:21 +00:00
|
|
|
@property (nonatomic, readonly) id<RecentsListServiceProtocol> recentsListService;
|
|
|
|
|
|
|
|
+ (instancetype)new NS_UNAVAILABLE;
|
|
|
|
- (instancetype)init NS_UNAVAILABLE;
|
|
|
|
- (instancetype)initWithMatrixSession:(MXSession*)mxSession NS_UNAVAILABLE;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Initializer
|
|
|
|
@param mxSession session instance
|
|
|
|
@param recentsListService service instance
|
|
|
|
*/
|
|
|
|
- (instancetype)initWithMatrixSession:(MXSession*)mxSession
|
|
|
|
recentsListService:(id<RecentsListServiceProtocol>)recentsListService;
|
|
|
|
|
2015-12-11 13:59:55 +00:00
|
|
|
/**
|
2017-04-06 12:27:45 +00:00
|
|
|
Set the delegate by specifying the selected display mode.
|
2015-12-11 13:59:55 +00:00
|
|
|
*/
|
2017-04-06 12:27:45 +00:00
|
|
|
- (void)setDelegate:(id<MXKDataSourceDelegate>)delegate andRecentsDataSourceMode:(RecentsDataSourceMode)recentsDataSourceMode;
|
2015-12-11 13:59:55 +00:00
|
|
|
|
2015-12-18 16:17:03 +00:00
|
|
|
/**
|
2017-04-06 12:27:45 +00:00
|
|
|
The current mode (RecentsDataSourceModeHome by default).
|
2015-12-18 16:17:03 +00:00
|
|
|
*/
|
2017-04-06 12:27:45 +00:00
|
|
|
@property (nonatomic, readonly) RecentsDataSourceMode recentsDataSourceMode;
|
2015-12-18 16:17:03 +00:00
|
|
|
|
2016-05-30 11:42:45 +00:00
|
|
|
/**
|
2017-04-06 12:27:45 +00:00
|
|
|
The data source used to manage the rooms from directory.
|
2016-05-30 11:42:45 +00:00
|
|
|
*/
|
2017-04-06 12:27:45 +00:00
|
|
|
@property (nonatomic) PublicRoomsDirectoryDataSource *publicRoomsDirectoryDataSource;
|
2016-05-30 11:42:45 +00:00
|
|
|
|
|
|
|
/**
|
2017-04-06 12:27:45 +00:00
|
|
|
Refresh the recents data source and notify its delegate.
|
2016-05-30 11:42:45 +00:00
|
|
|
*/
|
2017-04-06 12:27:45 +00:00
|
|
|
- (void)forceRefresh;
|
2016-05-30 11:42:45 +00:00
|
|
|
|
2015-12-02 16:18:55 +00:00
|
|
|
/**
|
2017-04-06 12:27:45 +00:00
|
|
|
Tell whether the sections are shrinkable. NO by default.
|
2015-12-02 16:18:55 +00:00
|
|
|
*/
|
2017-04-06 12:27:45 +00:00
|
|
|
@property (nonatomic) BOOL areSectionsShrinkable;
|
2015-12-02 16:18:55 +00:00
|
|
|
|
2017-04-14 09:49:14 +00:00
|
|
|
/**
|
|
|
|
Get the sticky header view for the specified section.
|
|
|
|
|
|
|
|
@param section the section index
|
|
|
|
@param frame the drawing area for the header of the specified section.
|
2022-02-10 00:19:00 +00:00
|
|
|
@param tableView the table view
|
2017-04-14 09:49:14 +00:00
|
|
|
@return the sticky header view.
|
|
|
|
*/
|
2022-02-10 00:19:00 +00:00
|
|
|
- (UIView *)viewForStickyHeaderInSection:(NSInteger)section withFrame:(CGRect)frame inTableView:(UITableView*)tableView;
|
2017-04-14 09:49:14 +00:00
|
|
|
|
2017-04-20 16:06:49 +00:00
|
|
|
/**
|
|
|
|
Get the height of the section header view.
|
|
|
|
|
|
|
|
@param section the section index
|
|
|
|
@return the header height.
|
|
|
|
*/
|
|
|
|
- (CGFloat)heightForHeaderInSection:(NSInteger)section;
|
|
|
|
|
2017-04-06 12:27:45 +00:00
|
|
|
#pragma mark - Drag & Drop handling
|
2015-12-11 10:50:13 +00:00
|
|
|
/**
|
|
|
|
Return true of the cell can be moved from a section to another one.
|
|
|
|
*/
|
|
|
|
- (BOOL)isDraggableCellAt:(NSIndexPath*)path;
|
|
|
|
|
2015-12-11 15:20:26 +00:00
|
|
|
/**
|
|
|
|
Return true of the cell can be moved from a section to another one.
|
|
|
|
*/
|
|
|
|
- (BOOL)canCellMoveFrom:(NSIndexPath*)oldPath to:(NSIndexPath*)newPath;
|
|
|
|
|
2017-04-06 12:27:45 +00:00
|
|
|
/**
|
|
|
|
There is a pending drag and drop cell.
|
|
|
|
It defines its path of the source cell.
|
|
|
|
*/
|
|
|
|
@property (nonatomic) NSIndexPath* hiddenCellIndexPath;
|
|
|
|
|
|
|
|
/**
|
|
|
|
There is a pending drag and drop cell.
|
|
|
|
It defines its path of the destination cell.
|
|
|
|
*/
|
|
|
|
@property (nonatomic) NSIndexPath* droppingCellIndexPath;
|
|
|
|
|
|
|
|
/**
|
|
|
|
The movingCellBackgroundImage.
|
|
|
|
*/
|
|
|
|
@property (nonatomic) UIImageView* droppingCellBackGroundView;
|
|
|
|
|
2022-01-04 01:30:40 +00:00
|
|
|
/**
|
|
|
|
Paginate in the given section. Results will be notified from delegate methods.
|
|
|
|
|
|
|
|
@param section section index to be paginated
|
|
|
|
*/
|
|
|
|
- (void)paginateInSection:(NSInteger)section;
|
|
|
|
|
2015-12-11 10:50:13 +00:00
|
|
|
/**
|
|
|
|
Move a cell from a path to another one.
|
|
|
|
It is based on room Tag.
|
|
|
|
*/
|
2019-01-05 02:28:03 +00:00
|
|
|
- (void)moveRoomCell:(MXRoom*)room from:(NSIndexPath*)oldPath to:(NSIndexPath*)newPath success:(void (^)(void))moveSuccess failure:(void (^)(NSError *error))moveFailure;
|
2015-12-11 10:50:13 +00:00
|
|
|
|
2015-11-20 17:14:15 +00:00
|
|
|
@end
|