[Spaces] Show spaces in left panel #4509

- Display the none hierarchical list of spaces in the left panel
- Space switching when new space selected
- Refresh space list and recents data after sync
This commit is contained in:
Gil Eluard
2021-07-15 14:10:01 +02:00
parent fd277bad03
commit 18bc5f1b63
9 changed files with 158 additions and 33 deletions
+42 -6
View File
@@ -61,6 +61,12 @@
// The groups data source
GroupsDataSource *groupsDataSource;
// Title label in the navigation bar
UILabel *titleLabel;
// Subtitle label in the navigation bar
UILabel *subtitleLabel;
}
@property(nonatomic,getter=isHidden) BOOL hidden;
@@ -110,17 +116,25 @@
// Note: UITabBarViewController shoud not be embed in a UINavigationController (https://github.com/vector-im/riot-ios/issues/3086)
[self vc_removeBackTitle];
[self setupTitleView];
titleLabel.text = NSLocalizedStringFromTable(@"title_home", @"Vector", nil);
childViewControllers = [NSMutableArray array];
}
- (void)userInterfaceThemeDidChange
{
[ThemeService.shared.theme applyStyleOnNavigationBar:self.navigationController.navigationBar];
id<Theme> theme = ThemeService.shared.theme;
[theme applyStyleOnNavigationBar:self.navigationController.navigationBar];
[ThemeService.shared.theme applyStyleOnTabBar:self.tabBar];
self.view.backgroundColor = ThemeService.shared.theme.backgroundColor;
[theme applyStyleOnTabBar:self.tabBar];
self.view.backgroundColor = theme.backgroundColor;
titleLabel.textColor = theme.colors.primaryContent;
titleLabel.font = theme.fonts.calloutSB;
subtitleLabel.textColor = theme.colors.tertiaryContent;
subtitleLabel.font = theme.fonts.footnote;
[self setNeedsStatusBarAppearanceUpdate];
}
@@ -763,8 +777,9 @@
- (void)filterRoomsWithParentId:(NSString*)roomParentId
inMatrixSession:(MXSession*)mxSession
{
// TODO: Update recentsDataSource in order to keep only rooms with given parent id.
// When updating the data source, if needed, screens should also update their title view subtitle with the space name
subtitleLabel.text = roomParentId ? [mxSession roomSummaryWithRoomId:roomParentId].displayname : nil;
recentsDataSource.currentSpace = [mxSession.spaceService getSpaceWithId:roomParentId];
}
#pragma mark -
@@ -847,6 +862,27 @@
}
}
-(void)setupTitleView
{
titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
titleLabel.backgroundColor = UIColor.clearColor;
titleLabel.textColor = UIColor.grayColor;
titleLabel.font = [UIFont boldSystemFontOfSize:17];
subtitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
subtitleLabel.backgroundColor = UIColor.clearColor;
subtitleLabel.textColor = UIColor.blackColor;
subtitleLabel.font = [UIFont boldSystemFontOfSize:12];
UIStackView *stackView = [[UIStackView alloc] initWithArrangedSubviews:@[titleLabel, subtitleLabel]];
stackView.distribution = UIStackViewDistributionEqualCentering;
stackView.axis = UILayoutConstraintAxisVertical;
stackView.alignment = UIStackViewAlignmentCenter;
stackView.spacing = 0.5;
self.navigationItem.titleView = stackView;
}
- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion
{
// Keep ref on presented view controller