Implement new space selector bottom sheet (#6518)

* Delight: Edit layout experiment #6079
This commit is contained in:
Gil Eluard
2022-08-05 13:39:45 +02:00
committed by GitHub
parent e39982a555
commit 1a2e6fdb89
47 changed files with 1705 additions and 295 deletions
@@ -1118,166 +1118,6 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
#pragma mark - Swipe actions
- (void)tableView:(UITableView*)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
[self cancelEditionMode:isRefreshPending];
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellEditingStyleNone;
}
- (nullable UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath
{
MXRoom *room = [self.dataSource getRoomAtIndexPath:indexPath];
if (!room)
{
return nil;
}
// Display no action for the invited room
if (room.summary.membership == MXMembershipInvite)
{
return nil;
}
// Store the identifier of the room related to the edited cell.
editedRoomId = room.roomId;
UIColor *selectedColor = ThemeService.shared.theme.tintColor;
UIColor *unselectedColor = ThemeService.shared.theme.tabBarUnselectedItemTintColor;
UIColor *actionBackgroundColor = ThemeService.shared.theme.baseColor;
NSString* title = @" ";
// Direct chat toggle
BOOL isDirect = room.isDirect;
UIContextualAction *directChatAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive
title:title
handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
[self makeDirectEditedRoom:!isDirect];
completionHandler(YES);
}];
directChatAction.backgroundColor = actionBackgroundColor;
UIImage *directChatImage = AssetImages.roomActionDirectChat.image;
directChatImage = [directChatImage vc_tintedImageUsingColor:isDirect ? selectedColor : unselectedColor];
directChatAction.image = [directChatImage vc_notRenderedImage];
// Notification toggle
BOOL isMuted = room.isMute || room.isMentionsOnly;
UIContextualAction *muteAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive
title:title
handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
if ([BuildSettings showNotificationsV2])
{
[self changeEditedRoomNotificationSettings];
}
else
{
[self muteEditedRoomNotifications:!isMuted];
}
completionHandler(YES);
}];
muteAction.backgroundColor = actionBackgroundColor;
UIImage *notificationImage;
if([BuildSettings showNotificationsV2] && isMuted)
{
notificationImage = AssetImages.roomActionNotificationMuted.image;
}
else
{
notificationImage = AssetImages.roomActionNotification.image;
}
notificationImage = [notificationImage vc_tintedImageUsingColor:isMuted ? unselectedColor : selectedColor];
muteAction.image = [notificationImage vc_notRenderedImage];
// Favorites management
MXRoomTag* currentTag = nil;
// Get the room tag (use only the first one).
if (room.accountData.tags)
{
NSArray<MXRoomTag*>* tags = room.accountData.tags.allValues;
if (tags.count)
{
currentTag = tags[0];
}
}
BOOL isFavourite = (currentTag && [kMXRoomTagFavourite isEqualToString:currentTag.name]);
UIContextualAction *favouriteAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive
title:title
handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
NSString *favouriteTag = isFavourite ? nil : kMXRoomTagFavourite;
[self updateEditedRoomTag:favouriteTag];
completionHandler(YES);
}];
favouriteAction.backgroundColor = actionBackgroundColor;
UIImage *favouriteImage = AssetImages.roomActionFavourite.image;
favouriteImage = [favouriteImage vc_tintedImageUsingColor:isFavourite ? selectedColor : unselectedColor];
favouriteAction.image = [favouriteImage vc_notRenderedImage];
// Priority toggle
BOOL isInLowPriority = (currentTag && [kMXRoomTagLowPriority isEqualToString:currentTag.name]);
UIContextualAction *priorityAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive
title:title
handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
NSString *priorityTag = isInLowPriority ? nil : kMXRoomTagLowPriority;
[self updateEditedRoomTag:priorityTag];
completionHandler(YES);
}];
priorityAction.backgroundColor = actionBackgroundColor;
UIImage *priorityImage = isInLowPriority ? AssetImages.roomActionPriorityHigh.image : AssetImages.roomActionPriorityLow.image;
priorityImage = [priorityImage vc_tintedImageUsingColor:unselectedColor];
priorityAction.image = [priorityImage vc_notRenderedImage];
// Leave action
UIContextualAction *leaveAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive
title:title
handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
[self leaveEditedRoom];
completionHandler(YES);
}];
leaveAction.backgroundColor = actionBackgroundColor;
UIImage *leaveImage = AssetImages.roomActionLeave.image;
leaveImage = [leaveImage vc_tintedImageUsingColor:unselectedColor];
leaveAction.image = [leaveImage vc_notRenderedImage];
// Create swipe action configuration
NSArray<UIContextualAction*> *actions = @[
leaveAction,
priorityAction,
favouriteAction,
muteAction,
directChatAction
];
UISwipeActionsConfiguration *swipeActionConfiguration = [UISwipeActionsConfiguration configurationWithActions:actions];
swipeActionConfiguration.performsFirstActionWithFullSwipe = NO;
return swipeActionConfiguration;
}
- (void)leaveEditedRoom
{
if (editedRoomId)