Move invites to dedicated sections and enable section collapse (#5683)

* Display invites in dedicated sections

* Activate shrinkable and fix home number of rows for section

* Rework section header

* Display badge in people and room tabs

* Add changelog & remove useless todo

* Improve isSectionShrinked condition, remove useless import and shrinkable sets

* Restore invitation count in tab bar badge

* Display badge for invites section

* Add comment on invites count

* Update right accessory view on data source update

Co-authored-by: Arnaud Ringenbach <arnaud.ringenbach@niji.fr>
This commit is contained in:
aringenbach
2022-02-28 13:48:07 +01:00
committed by GitHub
parent 20fb5d2aee
commit 60f2355e54
12 changed files with 206 additions and 70 deletions

View File

@@ -78,7 +78,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
[self resetSectionIndexes];
_areSectionsShrinkable = NO;
_areSectionsShrinkable = YES;
shrinkedSectionsBitMask = 0;
roomTagsListenerByUserId = [[NSMutableDictionary alloc] init];
@@ -660,7 +660,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
title = [VectorL10n roomRecentsSuggestedRoomsSection];
}
if (count)
if (count && !(section == invitesSection))
{
NSString *roomCount = [NSString stringWithFormat:@" %tu", count];
@@ -683,12 +683,16 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
return sectionTitle;
}
- (UIView *)badgeViewForHeaderTitleInHomeSection:(NSInteger)section
- (UIView *)badgeViewForHeaderTitleInSection:(NSInteger)section
{
// Prepare a badge to display the total of missed notifications in this section.
id<MXRoomListDataCounts> counts = nil;
UIView *missedNotifAndUnreadBadgeBgView = nil;
if (section == invitesSection)
{
counts = self.recentsListService.invitedRoomListData.counts;
}
if (section == favoritesSection)
{
counts = self.recentsListService.favoritedRoomListData.counts;
@@ -714,8 +718,9 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
counts = self.recentsListService.suggestedRoomListData.counts;
}
NSUInteger numberOfNotifications = counts.total.numberOfNotifications;
NSUInteger numberOfHighlights = counts.total.numberOfHighlights;
// Invites are counted as highlights for the badge view display.
NSUInteger numberOfNotifications = counts.total.numberOfNotifications + counts.total.numberOfInvitedRooms;
NSUInteger numberOfHighlights = counts.total.numberOfHighlights + counts.total.numberOfInvitedRooms;
if (numberOfNotifications)
{
@@ -832,14 +837,16 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
chevronView.contentMode = UIViewContentModeCenter;
sectionHeader.accessoryView = chevronView;
}
else if (_recentsDataSourceMode == RecentsDataSourceModeHome)
if (_recentsDataSourceMode == RecentsDataSourceModeHome
|| _recentsDataSourceMode == RecentsDataSourceModePeople
|| _recentsDataSourceMode == RecentsDataSourceModeRooms)
{
// Add a badge to display the total of missed notifications by section.
UIView *badgeView = [self badgeViewForHeaderTitleInHomeSection:section];
UIView *badgeView = [self badgeViewForHeaderTitleInSection:section];
if (badgeView)
{
sectionHeader.accessoryView = badgeView;
sectionHeader.rightAccessoryView = badgeView;
}
}
@@ -1509,4 +1516,55 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
[self.delegate dataSource:self didCellChange:update];
}
#pragma mark - Shrinkable
- (BOOL)isSectionShrinkedAt:(NSInteger)section
{
if (_areSectionsShrinkable == NO)
{
return NO;
}
if (section == favoritesSection && (shrinkedSectionsBitMask & RECENTSDATASOURCE_SECTION_FAVORITES))
{
return YES;
}
if (section == peopleSection && (shrinkedSectionsBitMask & RECENTSDATASOURCE_SECTION_PEOPLE))
{
return YES;
}
if (section == conversationSection && (shrinkedSectionsBitMask & RECENTSDATASOURCE_SECTION_CONVERSATIONS))
{
return YES;
}
if (section == directorySection && (shrinkedSectionsBitMask & RECENTSDATASOURCE_SECTION_DIRECTORY))
{
return YES;
}
if (section == lowPrioritySection && (shrinkedSectionsBitMask & RECENTSDATASOURCE_SECTION_LOWPRIORITY))
{
return YES;
}
if (section == serverNoticeSection && (shrinkedSectionsBitMask & RECENTSDATASOURCE_SECTION_SERVERNOTICE))
{
return YES;
}
if (section == invitesSection && (shrinkedSectionsBitMask & RECENTSDATASOURCE_SECTION_INVITES))
{
return YES;
}
if (section == suggestedRoomsSection && (shrinkedSectionsBitMask & RECENTSDATASOURCE_SECTION_SUGGESTED))
{
return YES;
}
return NO;
}
@end