Skip to content

Commit

Permalink
[Spaces] M10.6.1 Handle space link #4498
Browse files Browse the repository at this point in the history
- Change (+) button behaviour in home screen according to current space
  • Loading branch information
gileluard committed Sep 23, 2021
1 parent ca7bf18 commit 2ad094b
Showing 1 changed file with 78 additions and 2 deletions.
80 changes: 78 additions & 2 deletions Riot/Modules/Home/HomeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#import "MXRoom+Riot.h"

@interface HomeViewController () <SecureBackupSetupCoordinatorBridgePresenterDelegate>
@interface HomeViewController () <SecureBackupSetupCoordinatorBridgePresenterDelegate, SpaceMembersCoordinatorBridgePresenterDelegate>
{
RecentsDataSource *recentsDataSource;

Expand All @@ -48,6 +48,8 @@ @interface HomeViewController () <SecureBackupSetupCoordinatorBridgePresenterDel

@property (nonatomic, assign, readwrite) BOOL roomListDataReady;

@property(nonatomic) SpaceMembersCoordinatorBridgePresenter *spaceMembersCoordinatorBridgePresenter;

@end

@implementation HomeViewController
Expand Down Expand Up @@ -254,7 +256,72 @@ - (void)onPlusButtonPressed
[self cancelEditionMode:YES];
}

[super onPlusButtonPressed];
if (recentsDataSource.currentSpace != nil)
{
[self showPlusMenuForSpace];
}
else
{
[super onPlusButtonPressed];
}
}

- (void)showPlusMenuForSpace
{
__weak typeof(self) weakSelf = self;

[currentAlert dismissViewControllerAnimated:NO completion:nil];

currentAlert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];

[currentAlert addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"spaces_explore_rooms", @"Vector", nil)
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {

if (weakSelf)
{
typeof(self) self = weakSelf;
self->currentAlert = nil;

[self showRoomDirectory];
}

}]];

[currentAlert addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"room_details_people", @"Vector", nil)
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {

if (weakSelf)
{
typeof(self) self = weakSelf;
self->currentAlert = nil;

self.spaceMembersCoordinatorBridgePresenter = [[SpaceMembersCoordinatorBridgePresenter alloc] initWithUserSessionsService:[UserSessionsService shared] session:self.mainSession spaceId:self.dataSource.currentSpace.spaceId];
self.spaceMembersCoordinatorBridgePresenter.delegate = self;
[self.spaceMembersCoordinatorBridgePresenter presentFrom:self animated:YES];
}

}]];


[currentAlert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"]
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {

if (weakSelf)
{
typeof(self) self = weakSelf;
self->currentAlert = nil;
}

}]];

[currentAlert popoverPresentationController].sourceView = plusButtonImageView;
[currentAlert popoverPresentationController].sourceRect = plusButtonImageView.bounds;

[currentAlert mxk_setAccessibilityIdentifier:@"RecentsVCCreateRoomAlert"];
[self presentViewController:currentAlert animated:YES completion:nil];
}

- (void)cancelEditionMode:(BOOL)forceRefresh
Expand Down Expand Up @@ -872,4 +939,13 @@ - (NSUInteger)totalItemCounts
+ recentsDataSource.suggestedRoomCellDataArray.count;
}

#pragma mark - SpaceMembersCoordinatorBridgePresenterDelegate

- (void)spaceMembersCoordinatorBridgePresenterDelegateDidComplete:(SpaceMembersCoordinatorBridgePresenter *)coordinatorBridgePresenter
{
[coordinatorBridgePresenter dismissWithAnimated:YES completion:^{
self.spaceMembersCoordinatorBridgePresenter = nil;
}];
}

@end

0 comments on commit 2ad094b

Please sign in to comment.