mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-23 10:02:46 +02:00
Add support for Apple context menus in matrix items list screens (#5963)
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
|
||||
NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewControllerDataReadyNotification";
|
||||
|
||||
@interface RecentsViewController () <CreateRoomCoordinatorBridgePresenterDelegate, RoomsDirectoryCoordinatorBridgePresenterDelegate, RoomNotificationSettingsCoordinatorBridgePresenterDelegate, DialpadViewControllerDelegate, ExploreRoomCoordinatorBridgePresenterDelegate, SpaceChildRoomDetailBridgePresenterDelegate>
|
||||
@interface RecentsViewController () <CreateRoomCoordinatorBridgePresenterDelegate, RoomsDirectoryCoordinatorBridgePresenterDelegate, RoomNotificationSettingsCoordinatorBridgePresenterDelegate, DialpadViewControllerDelegate, ExploreRoomCoordinatorBridgePresenterDelegate, SpaceChildRoomDetailBridgePresenterDelegate, RoomContextActionServiceDelegate>
|
||||
{
|
||||
// Tell whether a recents refresh is pending (suspended during editing mode).
|
||||
BOOL isRefreshPending;
|
||||
@@ -138,6 +138,9 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
|
||||
|
||||
displayedSectionHeaders = [NSMutableArray array];
|
||||
|
||||
_contextMenuProvider = [RecentCellContextMenuProvider new];
|
||||
self.contextMenuProvider.serviceDelegate = self;
|
||||
|
||||
// Set itself as delegate by default.
|
||||
self.delegate = self;
|
||||
}
|
||||
@@ -2487,4 +2490,69 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Context Menu
|
||||
|
||||
- (UIContextMenuConfiguration *)tableView:(UITableView *)tableView contextMenuConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath point:(CGPoint)point API_AVAILABLE(ios(13.0))
|
||||
{
|
||||
id<MXKRecentCellDataStoring> cellData = [self.dataSource cellDataAtIndexPath:indexPath];
|
||||
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
|
||||
|
||||
if (!cellData || !cell)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
return [self.contextMenuProvider contextMenuConfigurationWith:cellData from:cell session:self.dataSource.mxSession];
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView willPerformPreviewActionForMenuWithConfiguration:(UIContextMenuConfiguration *)configuration animator:(id<UIContextMenuInteractionCommitAnimating>)animator API_AVAILABLE(ios(13.0))
|
||||
{
|
||||
NSString *roomId = [self.contextMenuProvider roomIdFrom:configuration.identifier];
|
||||
|
||||
if (!roomId)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
[animator addCompletion:^{
|
||||
[self showRoomWithRoomId:roomId inMatrixSession:self.mainSession];
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - RoomContextActionServiceDelegate
|
||||
|
||||
- (void)roomContextActionServiceDidJoinRoom:(id<RoomContextActionServiceProtocol>)service
|
||||
{
|
||||
[self showRoomWithRoomId:service.roomId inMatrixSession:service.session];
|
||||
}
|
||||
|
||||
- (void)roomContextActionServiceDidLeaveRoom:(id<RoomContextActionServiceProtocol>)service
|
||||
{
|
||||
[self.userIndicatorStore presentSuccessWithLabel:VectorL10n.roomParticipantsLeaveSuccess];
|
||||
}
|
||||
|
||||
- (void)roomContextActionService:(id<RoomContextActionServiceProtocol>)service presentAlert:(UIAlertController *)alertController
|
||||
{
|
||||
[self presentViewController:alertController animated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (void)roomContextActionService:(id<RoomContextActionServiceProtocol>)service updateActivityIndicator:(BOOL)isActive
|
||||
{
|
||||
if (isActive)
|
||||
{
|
||||
[self startActivityIndicator];
|
||||
}
|
||||
else if ([self canStopActivityIndicator])
|
||||
{
|
||||
[self stopActivityIndicator];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)roomContextActionService:(id<RoomContextActionServiceProtocol>)service showRoomNotificationSettingsForRoomWithId:(NSString *)roomId
|
||||
{
|
||||
editedRoomId = roomId;
|
||||
[self changeEditedRoomNotificationSettings];
|
||||
editedRoomId = nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user