diff --git a/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m b/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m index d24863b16..809ef9329 100644 --- a/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m +++ b/Riot/Modules/Common/Recents/DataSources/RecentsDataSource.m @@ -432,8 +432,6 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou - (void)forceRefresh { - MXLogDebug(@"[Spaces] forceRefresh \n%@", [NSThread callStackSymbols]); - // Refresh is disabled during drag&drop animation" if (!self.droppingCellIndexPath) { @@ -1527,8 +1525,6 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou - (void)dataSource:(MXKDataSource*)dataSource didCellChange:(id)changes { - MXLogDebug(@"[Spaces] dataSource didCellChange"); - // Refresh is disabled during drag&drop animation if (self.droppingCellIndexPath) { diff --git a/Riot/Modules/Spaces/SpaceList/SpaceListViewModel.swift b/Riot/Modules/Spaces/SpaceList/SpaceListViewModel.swift index 922894404..eef829377 100644 --- a/Riot/Modules/Spaces/SpaceList/SpaceListViewModel.swift +++ b/Riot/Modules/Spaces/SpaceList/SpaceListViewModel.swift @@ -45,7 +45,6 @@ final class SpaceListViewModel: SpaceListViewModelType { deinit { self.cancelOperations() - NotificationCenter.default.removeObserver(self) } // MARK: - Public diff --git a/Riot/Modules/TabBar/MainTitleView.swift b/Riot/Modules/TabBar/MainTitleView.swift new file mode 100644 index 000000000..701dc4d90 --- /dev/null +++ b/Riot/Modules/TabBar/MainTitleView.swift @@ -0,0 +1,65 @@ +// +// Copyright 2021 New Vector Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import Foundation + +@objcMembers +class MainTitleView: UIStackView, Themable { + + // MARK: - Properties + + public private(set) var titleLabel: UILabel! + public private(set) var subtitleLabel: UILabel! + + // MARK: - Lifecycle + + override init(frame: CGRect) { + super.init(frame: frame) + setupView() + } + + required init(coder: NSCoder) { + super.init(coder: coder) + setupView() + } + + // MARK: - Themable + + func update(theme: Theme) { + self.titleLabel.textColor = theme.colors.primaryContent + self.titleLabel.font = theme.fonts.calloutSB + + self.subtitleLabel.textColor = theme.colors.tertiaryContent + self.subtitleLabel.font = theme.fonts.footnote + } + + // MARK: - Private + + private func setupView() { + self.titleLabel = UILabel(frame: .zero) + self.titleLabel.backgroundColor = .clear + + self.subtitleLabel = UILabel(frame: .zero) + self.subtitleLabel.backgroundColor = .clear + + self.addArrangedSubview(titleLabel) + self.addArrangedSubview(subtitleLabel) + self.distribution = .equalCentering + self.axis = .vertical + self.alignment = .center + self.spacing = 0.5 + } +} diff --git a/Riot/Modules/TabBar/MasterTabBarController.m b/Riot/Modules/TabBar/MasterTabBarController.m index 507c24d9d..7995ffe90 100644 --- a/Riot/Modules/TabBar/MasterTabBarController.m +++ b/Riot/Modules/TabBar/MasterTabBarController.m @@ -62,11 +62,8 @@ // The groups data source GroupsDataSource *groupsDataSource; - // Title label in the navigation bar - UILabel *titleLabel; - - // Subtitle label in the navigation bar - UILabel *subtitleLabel; + // Custom title view of the navigation bar + MainTitleView *titleView; } @property(nonatomic,getter=isHidden) BOOL hidden; @@ -119,7 +116,7 @@ [self vc_removeBackTitle]; [self setupTitleView]; - titleLabel.text = NSLocalizedStringFromTable(@"title_home", @"Vector", nil); + titleView.titleLabel.text = NSLocalizedStringFromTable(@"title_home", @"Vector", nil); childViewControllers = [NSMutableArray array]; } @@ -132,10 +129,7 @@ [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; + [titleView updateWithTheme:theme]; [self setNeedsStatusBarAppearanceUpdate]; } @@ -779,7 +773,7 @@ - (void)filterRoomsWithParentId:(NSString*)roomParentId inMatrixSession:(MXSession*)mxSession { - subtitleLabel.text = roomParentId ? [mxSession roomSummaryWithRoomId:roomParentId].displayname : nil; + titleView.subtitleLabel.text = roomParentId ? [mxSession roomSummaryWithRoomId:roomParentId].displayname : nil; recentsDataSource.currentSpace = [mxSession.spaceService getSpaceWithId:roomParentId]; } @@ -866,23 +860,8 @@ -(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; + titleView = [MainTitleView new]; + self.navigationItem.titleView = titleView; } - (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion @@ -1280,23 +1259,23 @@ { if ([viewController isKindOfClass:HomeViewController.class]) { - titleLabel.text = NSLocalizedStringFromTable(@"title_home", @"Vector", nil); + titleView.titleLabel.text = NSLocalizedStringFromTable(@"title_home", @"Vector", nil); } else if ([viewController isKindOfClass:FavouritesViewController.class]) { - titleLabel.text = NSLocalizedStringFromTable(@"title_favourites", @"Vector", nil); + titleView.titleLabel.text = NSLocalizedStringFromTable(@"title_favourites", @"Vector", nil); } else if ([viewController isKindOfClass:PeopleViewController.class]) { - titleLabel.text = NSLocalizedStringFromTable(@"title_people", @"Vector", nil); + titleView.titleLabel.text = NSLocalizedStringFromTable(@"title_people", @"Vector", nil); } else if ([viewController isKindOfClass:RoomsViewController.class]) { - titleLabel.text = NSLocalizedStringFromTable(@"title_rooms", @"Vector", nil); + titleView.titleLabel.text = NSLocalizedStringFromTable(@"title_rooms", @"Vector", nil); } else if ([viewController isKindOfClass:GroupsViewController.class]) { - titleLabel.text = NSLocalizedStringFromTable(@"title_groups", @"Vector", nil); + titleView.titleLabel.text = NSLocalizedStringFromTable(@"title_groups", @"Vector", nil); } }