mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-21 00:52:43 +02:00
GroupsViewController: Add space beta announce cell.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user