GroupsViewController: Add space beta announce cell.

This commit is contained in:
SBiOSoftWhare
2021-05-06 12:09:12 +02:00
parent 404a57b369
commit 0cd3f9a5e6
3 changed files with 88 additions and 0 deletions
@@ -15,9 +15,77 @@
*/
#import "GroupsDataSource.h"
#import "Riot-Swift.h"
@interface GroupsDataSource() <BetaAnnounceCellDelegate>
@property (nonatomic) NSInteger betaAnnounceSection;
@property (nonatomic) BOOL showBetaAnnounce;
@end
@implementation GroupsDataSource
- (instancetype)initWithMatrixSession:(MXSession *)matrixSession
{
self = [super initWithMatrixSession:matrixSession];
if (self)
{
_showBetaAnnounce = !RiotSettings.shared.hideSpaceBetaAnnounce;
}
return self;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
NSInteger count = 0;
self.betaAnnounceSection = self.groupInvitesSection = self.joinedGroupsSection = -1;
// Check whether all data sources are ready before rendering groups.
if (self.state == MXKDataSourceStateReady)
{
if (self.showBetaAnnounce)
{
self.betaAnnounceSection = count++;
}
if (groupsInviteCellDataArray.count)
{
self.groupInvitesSection = count++;
}
if (groupsCellDataArray.count)
{
self.joinedGroupsSection = count++;
}
}
return count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == self.betaAnnounceSection)
{
BetaAnnounceCell *cell = [tableView dequeueReusableCellWithIdentifier:BetaAnnounceCell.reuseIdentifier forIndexPath:indexPath];
[cell vc_hideSeparator];
[cell updateWithTheme:ThemeService.shared.theme];
cell.delegate = self;
return cell;
}
return [super tableView:tableView cellForRowAtIndexPath:indexPath];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == self.betaAnnounceSection)
{
return 1;
}
return [super tableView:tableView numberOfRowsInSection:section];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
NSString* sectionTitle = nil;
@@ -44,4 +112,13 @@
return (indexPath.section == self.joinedGroupsSection);
}
#pragma mark - BetaAnnounceCellDelegate
- (void)betaAnnounceCellDidTapCloseButton:(BetaAnnounceCell *)cell
{
self.showBetaAnnounce = NO;
RiotSettings.shared.hideSpaceBetaAnnounce = YES;
[self.delegate dataSource:self didCellChange:nil];
}
@end