mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-29 12:46:58 +02:00
Merge branch 'develop' into andy/5958_home_scroll
This commit is contained in:
@@ -675,111 +675,6 @@
|
||||
[self.recentsSearchBar resignFirstResponder];
|
||||
}
|
||||
|
||||
- (UIContextMenuConfiguration *)collectionView:(UICollectionView *)collectionView contextMenuConfigurationForItemAtIndexPath:(NSIndexPath *)indexPath point:(CGPoint)point API_AVAILABLE(ios(13.0))
|
||||
{
|
||||
UIView *cell = [collectionView cellForItemAtIndexPath:indexPath];
|
||||
MXRoom *room = [self.dataSource getRoomAtIndexPath:[NSIndexPath indexPathForRow:indexPath.row inSection:collectionView.tag]];
|
||||
NSString *roomId = room.roomId;
|
||||
|
||||
MXWeakify(self);
|
||||
MXWeakify(room);
|
||||
|
||||
return [UIContextMenuConfiguration configurationWithIdentifier:roomId previewProvider:^UIViewController * _Nullable {
|
||||
// Add a preview using the cell's data to prevent the avatar and displayname from changing with a room list update.
|
||||
return [[ContextMenuSnapshotPreviewViewController alloc] initWithView:cell];
|
||||
|
||||
} actionProvider:^UIMenu * _Nullable(NSArray<UIMenuElement *> * _Nonnull suggestedActions) {
|
||||
MXStrongifyAndReturnValueIfNil(room, nil);
|
||||
|
||||
BOOL isDirect = room.isDirect;
|
||||
UIAction *directChatAction = [UIAction actionWithTitle:isDirect ? VectorL10n.homeContextMenuMakeRoom : VectorL10n.homeContextMenuMakeDm
|
||||
image:[UIImage systemImageNamed:isDirect ? @"person.crop.circle.badge.xmark" : @"person.circle"]
|
||||
identifier:nil
|
||||
handler:^(__kindof UIAction * _Nonnull action) {
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
[self updateRoomWithId:roomId asDirect:!isDirect];
|
||||
}];
|
||||
|
||||
BOOL isMuted = room.isMute || room.isMentionsOnly;
|
||||
UIImage *notificationsImage;
|
||||
NSString *notificationsTitle;
|
||||
if ([BuildSettings showNotificationsV2])
|
||||
{
|
||||
notificationsTitle = VectorL10n.homeContextMenuNotifications;
|
||||
notificationsImage = [UIImage systemImageNamed:@"bell"];
|
||||
}
|
||||
else
|
||||
{
|
||||
notificationsTitle = isMuted ? VectorL10n.homeContextMenuUnmute : VectorL10n.homeContextMenuMute;
|
||||
notificationsImage = [UIImage systemImageNamed:isMuted ? @"bell.slash": @"bell"];
|
||||
}
|
||||
|
||||
UIAction *notificationsAction = [UIAction actionWithTitle:notificationsTitle
|
||||
image:notificationsImage
|
||||
identifier:nil
|
||||
handler:^(__kindof UIAction * _Nonnull action) {
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
[self updateRoomWithId:roomId asMuted:!isMuted];
|
||||
}];
|
||||
|
||||
|
||||
// Get the room tag (use only the first one).
|
||||
MXRoomTag* currentTag = nil;
|
||||
if (room.accountData.tags)
|
||||
{
|
||||
NSArray<MXRoomTag*>* tags = room.accountData.tags.allValues;
|
||||
if (tags.count)
|
||||
{
|
||||
currentTag = tags[0];
|
||||
}
|
||||
}
|
||||
|
||||
BOOL isFavourite = (currentTag && [kMXRoomTagFavourite isEqualToString:currentTag.name]);
|
||||
UIAction *favouriteAction = [UIAction actionWithTitle:isFavourite ? VectorL10n.homeContextMenuUnfavourite : VectorL10n.homeContextMenuFavourite
|
||||
image:[UIImage systemImageNamed:isFavourite ? @"star.slash" : @"star"]
|
||||
identifier:nil
|
||||
handler:^(__kindof UIAction * _Nonnull action) {
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
[self updateRoomWithId:roomId asFavourite:!isFavourite];
|
||||
}];
|
||||
|
||||
BOOL isLowPriority = (currentTag && [kMXRoomTagLowPriority isEqualToString:currentTag.name]);
|
||||
UIAction *lowPriorityAction = [UIAction actionWithTitle:isLowPriority ? VectorL10n.homeContextMenuNormalPriority : VectorL10n.homeContextMenuLowPriority
|
||||
image:[UIImage systemImageNamed:isLowPriority ? @"arrow.up" : @"arrow.down"]
|
||||
identifier:nil
|
||||
handler:^(__kindof UIAction * _Nonnull action) {
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
[self updateRoomWithId:roomId asLowPriority:!isLowPriority];
|
||||
}];
|
||||
|
||||
UIImage *leaveImage;
|
||||
if (@available(iOS 14.0, *))
|
||||
{
|
||||
leaveImage = [UIImage systemImageNamed:@"rectangle.righthalf.inset.fill.arrow.right"];
|
||||
}
|
||||
else
|
||||
{
|
||||
leaveImage = [UIImage systemImageNamed:@"rectangle.xmark"];
|
||||
}
|
||||
UIAction *leaveAction = [UIAction actionWithTitle:VectorL10n.homeContextMenuLeave
|
||||
image:leaveImage
|
||||
identifier:nil
|
||||
handler:^(__kindof UIAction * _Nonnull action) {
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
[self leaveRoomWithId:roomId];
|
||||
}];
|
||||
leaveAction.attributes = UIMenuElementAttributesDestructive;
|
||||
|
||||
return [UIMenu menuWithTitle:@"" children:@[
|
||||
directChatAction,
|
||||
notificationsAction,
|
||||
favouriteAction,
|
||||
lowPriorityAction,
|
||||
leaveAction
|
||||
]];
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - UICollectionViewDelegateFlowLayout
|
||||
|
||||
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
|
||||
@@ -916,50 +811,6 @@
|
||||
[self leaveEditedRoom];
|
||||
}
|
||||
|
||||
// MARK: - Context Menu Actions
|
||||
|
||||
- (void)updateRoomWithId:(NSString *)roomId asDirect:(BOOL)direct
|
||||
{
|
||||
editedRoomId = roomId;
|
||||
[self makeDirectEditedRoom:direct];
|
||||
editedRoomId = nil;
|
||||
}
|
||||
|
||||
- (void)updateRoomWithId:(NSString *)roomId asMuted:(BOOL)muted
|
||||
{
|
||||
editedRoomId = roomId;
|
||||
if ([BuildSettings showNotificationsV2])
|
||||
{
|
||||
[self changeEditedRoomNotificationSettings];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self muteEditedRoomNotifications:muted];
|
||||
}
|
||||
editedRoomId = nil;
|
||||
}
|
||||
|
||||
- (void)updateRoomWithId:(NSString *)roomId asFavourite:(BOOL)favourite
|
||||
{
|
||||
editedRoomId = roomId;
|
||||
[self updateEditedRoomTag:favourite ? kMXRoomTagFavourite : nil];
|
||||
editedRoomId = nil;
|
||||
}
|
||||
|
||||
- (void)updateRoomWithId:(NSString *)roomId asLowPriority:(BOOL)lowPriority
|
||||
{
|
||||
editedRoomId = roomId;
|
||||
[self updateEditedRoomTag:lowPriority ? kMXRoomTagLowPriority : nil];
|
||||
editedRoomId = nil;
|
||||
}
|
||||
|
||||
- (void)leaveRoomWithId:(NSString *)roomId
|
||||
{
|
||||
editedRoomId = roomId;
|
||||
[self leaveEditedRoom];
|
||||
editedRoomId = nil;
|
||||
}
|
||||
|
||||
#pragma mark - SecureBackupSetupCoordinatorBridgePresenterDelegate
|
||||
|
||||
- (void)secureBackupSetupCoordinatorBridgePresenterDelegateDidComplete:(SecureBackupSetupCoordinatorBridgePresenter *)coordinatorBridgePresenter
|
||||
@@ -1087,4 +938,47 @@
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Context Menu
|
||||
|
||||
- (UIContextMenuConfiguration *)tableView:(UITableView *)tableView contextMenuConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath point:(CGPoint)point API_AVAILABLE(ios(13.0))
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (UIContextMenuConfiguration *)collectionView:(UICollectionView *)collectionView contextMenuConfigurationForItemAtIndexPath:(NSIndexPath *)indexPath point:(CGPoint)point API_AVAILABLE(ios(13.0))
|
||||
{
|
||||
id<MXKRecentCellDataStoring> cellData = [recentsDataSource cellDataAtIndexPath:[NSIndexPath indexPathForRow:indexPath.item inSection:collectionView.tag]];
|
||||
UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];
|
||||
|
||||
if (!cellData || !cell)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
self.recentsUpdateEnabled = NO;
|
||||
return [self.contextMenuProvider contextMenuConfigurationWith:cellData from:cell session:self.dataSource.mxSession];
|
||||
}
|
||||
|
||||
- (void)collectionView:(UICollectionView *)collectionView willPerformPreviewActionForMenuWithConfiguration:(UIContextMenuConfiguration *)configuration animator:(id<UIContextMenuInteractionCommitAnimating>)animator API_AVAILABLE(ios(13.0))
|
||||
{
|
||||
NSString *roomId = [self.contextMenuProvider roomIdFrom:configuration.identifier];
|
||||
|
||||
if (!roomId)
|
||||
{
|
||||
self.recentsUpdateEnabled = YES;
|
||||
return;
|
||||
}
|
||||
|
||||
[animator addCompletion:^{
|
||||
self.recentsUpdateEnabled = YES;
|
||||
[self showRoomWithRoomId:roomId inMatrixSession:self.mainSession];
|
||||
}];
|
||||
}
|
||||
|
||||
- (UITargetedPreview *)collectionView:(UICollectionView *)collectionView previewForDismissingContextMenuWithConfiguration:(UIContextMenuConfiguration *)configuration API_AVAILABLE(ios(13.0))
|
||||
{
|
||||
self.recentsUpdateEnabled = YES;
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user