Groups: self-management of membership of groups

- Prepare Group Details screen

vector-im/riot-meta#114
This commit is contained in:
Giom Foret
2017-12-14 16:05:11 +01:00
parent 99d5e26d04
commit c3c65bd97d
25 changed files with 2491 additions and 472 deletions
+64 -5
View File
@@ -203,6 +203,8 @@
}];
[AppDelegate theDelegate].masterTabBarController.navigationItem.title = NSLocalizedStringFromTable(@"title_groups", @"Vector", nil);
[AppDelegate theDelegate].masterTabBarController.navigationController.navigationBar.tintColor = kRiotColorBlue;
[AppDelegate theDelegate].masterTabBarController.tabBar.tintColor = kRiotColorBlue;
}
- (void)viewWillDisappear:(BOOL)animated
@@ -217,6 +219,13 @@
[[NSNotificationCenter defaultCenter] removeObserver:kAppDelegateDidTapStatusBarNotificationObserver];
kAppDelegateDidTapStatusBarNotificationObserver = nil;
}
if ([AppDelegate theDelegate].masterTabBarController.tabBar.tintColor == kRiotColorBlue)
{
// Restore default tintColor
[AppDelegate theDelegate].masterTabBarController.navigationController.navigationBar.tintColor = kRiotColorGreen;
[AppDelegate theDelegate].masterTabBarController.tabBar.tintColor = kRiotColorGreen;
}
}
- (void)viewDidAppear:(BOOL)animated
@@ -251,10 +260,20 @@
isRefreshPending = NO;
if (self.groupsTableView.isEditing || self.isEditing)
if (editedGroupId)
{
isRefreshPending = YES;
return;
// Check whether the user didn't leave the room
if ([self.dataSource cellIndexPathWithGroupId:editedGroupId])
{
isRefreshPending = YES;
return;
}
else
{
// Cancel the editing mode, a new refresh will be triggered.
[self cancelEditionMode:YES];
return;
}
}
[self.groupsTableView reloadData];
@@ -339,6 +358,9 @@
}
else if (forceRefresh)
{
// Clean
editedGroupId = nil;
[self refreshGroupsTable];
}
}
@@ -430,7 +452,12 @@
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 30.0f;
if (tableView.numberOfSections > 1)
{
return 30.0f;
}
return 0;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
@@ -448,6 +475,38 @@
}
}
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSMutableArray* actions;
// add the swipe to delete only on joined group
if (indexPath.section == self.dataSource.joinedGroupsSection)
{
// Store the identifier of the room related to the edited cell.
id<MXKGroupCellDataStoring> cellData = [self.dataSource cellDataAtIndex:indexPath];
editedGroupId = cellData.group.groupId;
actions = [[NSMutableArray alloc] init];
// Patch: Force the width of the button by adding whitespace characters into the title string.
UITableViewRowAction *leaveAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@" " handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
[self.dataSource leaveGroupAtIndexPath:indexPath];
}];
leaveAction.backgroundColor = [MXKTools convertImageToPatternColor:@"remove_icon" backgroundColor:kRiotSecondaryBgColor patternSize:CGSizeMake(74, 74) resourceSize:CGSizeMake(25, 24)];
[actions insertObject:leaveAction atIndex:0];
}
return actions;
}
- (void)tableView:(UITableView*)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
[self cancelEditionMode:isRefreshPending];
}
#pragma mark - UIScrollViewDelegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
@@ -481,7 +540,7 @@
plusButtonImageView.backgroundColor = [UIColor clearColor];
plusButtonImageView.contentMode = UIViewContentModeCenter;
plusButtonImageView.image = [UIImage imageNamed:@"create_room"];
plusButtonImageView.image = [UIImage imageNamed:@"create_group"];
plusButtonImageView.layer.shadowOpacity = 0.3;
plusButtonImageView.layer.shadowOffset = CGSizeMake(0, 3);