diff --git a/Riot/Modules/Communities/GroupsViewController.m b/Riot/Modules/Communities/GroupsViewController.m index 306a4e55c..fb1ac9552 100644 --- a/Riot/Modules/Communities/GroupsViewController.m +++ b/Riot/Modules/Communities/GroupsViewController.m @@ -21,7 +21,7 @@ #import "GeneratedInterface-Swift.h" -@interface GroupsViewController () +@interface GroupsViewController () { // Tell whether a groups refresh is pending (suspended during editing mode). BOOL isRefreshPending; @@ -224,8 +224,6 @@ [self scrollToTop:YES]; }]; - - [AppDelegate theDelegate].masterTabBarController.navigationItem.title = [VectorL10n titleGroups]; [AppDelegate theDelegate].masterTabBarController.tabBar.tintColor = ThemeService.shared.theme.tintColor; } @@ -644,4 +642,11 @@ [self.groupsSearchBar setShowsCancelButton:NO animated:NO]; } +#pragma mark - MasterTabBarItemDisplayProtocol + +- (NSString *)masterTabBarItemTitle +{ + return [VectorL10n titleGroups]; +} + @end diff --git a/Riot/Modules/Favorites/FavouritesViewController.m b/Riot/Modules/Favorites/FavouritesViewController.m index 62ef8cd8f..da680c7ee 100644 --- a/Riot/Modules/Favorites/FavouritesViewController.m +++ b/Riot/Modules/Favorites/FavouritesViewController.m @@ -19,7 +19,7 @@ #import "RecentsDataSource.h" #import "GeneratedInterface-Swift.h" -@interface FavouritesViewController () +@interface FavouritesViewController () { RecentsDataSource *recentsDataSource; } @@ -62,8 +62,6 @@ - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - - [AppDelegate theDelegate].masterTabBarController.navigationItem.title = [VectorL10n titleFavourites]; [AppDelegate theDelegate].masterTabBarController.tabBar.tintColor = ThemeService.shared.theme.tintColor; if (recentsDataSource) @@ -163,4 +161,11 @@ } } +#pragma mark - MasterTabBarItemDisplayProtocol + +- (NSString *)masterTabBarItemTitle +{ + return [VectorL10n titleFavourites]; +} + @end diff --git a/Riot/Modules/Home/HomeViewController.m b/Riot/Modules/Home/HomeViewController.m index e94b4c472..95a489e3b 100644 --- a/Riot/Modules/Home/HomeViewController.m +++ b/Riot/Modules/Home/HomeViewController.m @@ -103,8 +103,6 @@ - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - - [AppDelegate theDelegate].masterTabBarController.navigationItem.title = [VectorL10n titleHome]; [ThemeService.shared.theme applyStyleOnNavigationBar:[AppDelegate theDelegate].masterTabBarController.navigationController.navigationBar]; diff --git a/Riot/Modules/Home/VersionCheck/HomeViewControllerWithBannerWrapperViewController.swift b/Riot/Modules/Home/VersionCheck/HomeViewControllerWithBannerWrapperViewController.swift index 1c6c24173..0a9fbcee8 100644 --- a/Riot/Modules/Home/VersionCheck/HomeViewControllerWithBannerWrapperViewController.swift +++ b/Riot/Modules/Home/VersionCheck/HomeViewControllerWithBannerWrapperViewController.swift @@ -16,7 +16,7 @@ import Foundation -class HomeViewControllerWithBannerWrapperViewController: UIViewController, MXKViewControllerActivityHandling, BannerPresentationProtocol { +class HomeViewControllerWithBannerWrapperViewController: UIViewController, MXKViewControllerActivityHandling, BannerPresentationProtocol, MasterTabBarItemDisplayProtocol { @objc let homeViewController: HomeViewController private var bannerContainerView: UIView! @@ -107,4 +107,10 @@ class HomeViewControllerWithBannerWrapperViewController: UIViewController, MXKVi func stopActivityIndicator() { homeViewController.stopActivityIndicator() } + + // MARK: - MasterTabBarItemDisplayProtocol + + var masterTabBarItemTitle: String { + return VectorL10n.titleHome + } } diff --git a/Riot/Modules/People/PeopleViewController.m b/Riot/Modules/People/PeopleViewController.m index 028ec8eef..4c3203774 100644 --- a/Riot/Modules/People/PeopleViewController.m +++ b/Riot/Modules/People/PeopleViewController.m @@ -26,7 +26,7 @@ #import "GeneratedInterface-Swift.h" -@interface PeopleViewController () +@interface PeopleViewController () { NSInteger directRoomsSectionNumber; RecentsDataSource *recentsDataSource; @@ -83,8 +83,6 @@ - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - - [AppDelegate theDelegate].masterTabBarController.navigationItem.title = [VectorL10n titlePeople]; [AppDelegate theDelegate].masterTabBarController.tabBar.tintColor = ThemeService.shared.theme.tintColor; if ([self.dataSource isKindOfClass:RecentsDataSource.class]) @@ -194,4 +192,11 @@ }]; } +#pragma mark - MasterTabBarItemDisplayProtocol + +- (NSString *)masterTabBarItemTitle +{ + return [VectorL10n titlePeople]; +} + @end diff --git a/Riot/Modules/Rooms/RoomsViewController.m b/Riot/Modules/Rooms/RoomsViewController.m index 6e2adfc62..4b4afa3db 100644 --- a/Riot/Modules/Rooms/RoomsViewController.m +++ b/Riot/Modules/Rooms/RoomsViewController.m @@ -20,7 +20,7 @@ #import "GeneratedInterface-Swift.h" -@interface RoomsViewController () +@interface RoomsViewController () { RecentsDataSource *recentsDataSource; } @@ -66,8 +66,6 @@ - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - - [AppDelegate theDelegate].masterTabBarController.navigationItem.title = [VectorL10n titleRooms]; [AppDelegate theDelegate].masterTabBarController.tabBar.tintColor = ThemeService.shared.theme.tintColor; if ([self.dataSource isKindOfClass:RecentsDataSource.class]) @@ -165,4 +163,11 @@ } } +#pragma mark - MasterTabBarItemDisplayProtocol + +- (NSString *)masterTabBarItemTitle +{ + return [VectorL10n titleRooms]; +} + @end diff --git a/Riot/Modules/TabBar/MasterTabBarController.m b/Riot/Modules/TabBar/MasterTabBarController.m index 65ed41122..1a08218b9 100644 --- a/Riot/Modules/TabBar/MasterTabBarController.m +++ b/Riot/Modules/TabBar/MasterTabBarController.m @@ -316,7 +316,7 @@ } } - titleView.titleLabel.text = self.selectedViewController.accessibilityLabel; + titleView.titleLabel.text = [self getTitleForItemViewController:self.selectedViewController]; // Need to be called in case of the controllers have been replaced [self.selectedViewController viewDidAppear:NO]; @@ -336,6 +336,8 @@ { NSInteger index = [self indexOfTabItemWithTag:tabBarIndex]; self.selectedIndex = index; + + titleView.titleLabel.text = [self getTitleForItemViewController:self.selectedViewController]; } #pragma mark - @@ -825,6 +827,17 @@ self.navigationController.navigationBar.hidden = hidden; } +- (NSString*)getTitleForItemViewController:(UIViewController*)itemViewController +{ + if ([itemViewController conformsToProtocol:@protocol(MasterTabBarItemDisplayProtocol)]) + { + UIViewController *masterTabBarItem = (UIViewController*)itemViewController; + return masterTabBarItem.masterTabBarItemTitle; + } + + return nil; +} + #pragma mark - - (void)refreshTabBarBadges @@ -1115,7 +1128,7 @@ - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { - titleView.titleLabel.text = viewController.accessibilityLabel; + titleView.titleLabel.text = [self getTitleForItemViewController:viewController]; } @end diff --git a/Riot/Modules/TabBar/MasterTabBarItemDisplayProtocol.swift b/Riot/Modules/TabBar/MasterTabBarItemDisplayProtocol.swift new file mode 100644 index 000000000..c71fbdfe6 --- /dev/null +++ b/Riot/Modules/TabBar/MasterTabBarItemDisplayProtocol.swift @@ -0,0 +1,21 @@ +// +// 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 + +@objc protocol MasterTabBarItemDisplayProtocol { + var masterTabBarItemTitle: String { get } +}