UX rework: Directory section: plug publicRoomsDirectoryDataSource

This commit is contained in:
manuroe 2017-04-07 14:09:15 +02:00
parent 4b93d26f64
commit 361eb2a139
2 changed files with 36 additions and 13 deletions

View file

@ -121,6 +121,7 @@
"room_recents_conversations" = "ROOMS";
"room_recents_low_priority" = "LOW PRIORITY";
"room_recents_invites" = "INVITES";
"room_recents_directory" = "ROOM DIRECTORY";
"room_recents_start_chat_with" = "Start chat";
"room_recents_create_empty_room" = "Create room";

View file

@ -23,6 +23,8 @@
#import "MXRoom+Riot.h"
#import "DirectoryRecentTableViewCell.h"
#define RECENTSDATASOURCE_SECTION_DIRECTORY 0x01
#define RECENTSDATASOURCE_SECTION_INVITES 0x02
#define RECENTSDATASOURCE_SECTION_FAVORITES 0x04
@ -136,7 +138,11 @@
{
if (dataSource == _publicRoomsDirectoryDataSource)
{
[self forceRefresh];
if (-1 != directorySection)
{
// TODO: We should only update the directory section
[self.delegate dataSource:self didCellChange:nil];
}
}
else
{
@ -202,9 +208,7 @@
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSUInteger count = 0;
//TODO: directorySection
if (section == favoritesSection && !(shrinkedSectionsBitMask & RECENTSDATASOURCE_SECTION_FAVORITES))
{
count = favoriteCellDataArray.count;
@ -213,6 +217,10 @@
{
count = conversationCellDataArray.count;
}
else if (section == directorySection && !(shrinkedSectionsBitMask & RECENTSDATASOURCE_SECTION_DIRECTORY))
{
count = [_publicRoomsDirectoryDataSource tableView:tableView numberOfRowsInSection:section];
}
else if (section == lowPrioritySection && !(shrinkedSectionsBitMask & RECENTSDATASOURCE_SECTION_LOWPRIORITY))
{
count = lowPriorityCellDataArray.count;
@ -240,8 +248,6 @@
{
UIView *sectionHeader = nil;
// TODO header for directorySection
if (section < sectionsCount)
{
NSString* sectionTitle = @"";
@ -258,6 +264,11 @@
sectionTitle = NSLocalizedStringFromTable(@"room_recents_conversations", @"Vector", nil);
sectionBitwise = _areSectionsShrinkable ? RECENTSDATASOURCE_SECTION_CONVERSATIONS : 0;
}
else if (section == directorySection)
{
sectionTitle = NSLocalizedStringFromTable(@"room_recents_directory", @"Vector", nil);
sectionBitwise = _areSectionsShrinkable ? RECENTSDATASOURCE_SECTION_CONVERSATIONS : 0;
}
else if (section == lowPrioritySection)
{
sectionTitle = NSLocalizedStringFromTable(@"room_recents_low_priority", @"Vector", nil);
@ -322,9 +333,11 @@
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// TODO: cell for directorySection
if (self.droppingCellIndexPath && [indexPath isEqual:self.droppingCellIndexPath])
if (indexPath.section == directorySection)
{
return [_publicRoomsDirectoryDataSource tableView:tableView cellForRowAtIndexPath:indexPath];
}
else if (self.droppingCellIndexPath && [indexPath isEqual:self.droppingCellIndexPath])
{
static NSString* cellIdentifier = @"RiotRecentsMovingCell";
@ -405,8 +418,10 @@
- (CGFloat)cellHeightAtIndexPath:(NSIndexPath *)indexPath
{
// TODO: cell height for directorySection
if (indexPath.section == directorySection)
{
return DirectoryRecentTableViewCell.cellHeight;
}
if (self.droppingCellIndexPath && [indexPath isEqual:self.droppingCellIndexPath])
{
return self.droppingCellBackGroundView.frame.size.height;
@ -611,8 +626,6 @@
[conversationCellDataArray addObject:recentCellDataStoring];
}
}
// TODO: Add Directory section.
}
if (invitesCellDataArray.count > 0)
@ -634,6 +647,15 @@
if (conversationCellDataArray.count > 0)
{
conversationSection = sectionsCount++;
if (_recentsDataSourceMode == RecentsDataSourceModeRooms)
{
// Add the directory section after "ROOMS"
directorySection = sectionsCount++;
// Make _publicRoomsDirectoryDataSource start loading data
_publicRoomsDirectoryDataSource.searchPattern = nil;
}
}
if (lowPriorityCellDataArray.count > 0)