Add option to hide labels from tab bar

This commit is contained in:
Daniele 2022-11-15 21:41:36 -08:00
parent 9bfc6c1449
commit 35feaa9f8c
7 changed files with 22 additions and 2 deletions

View file

@ -208,6 +208,7 @@
"preferences.blocked-domains" = "Blocked Domains"; "preferences.blocked-domains" = "Blocked Domains";
"preferences.blocked-users" = "Blocked Users"; "preferences.blocked-users" = "Blocked Users";
"preferences.media" = "Media"; "preferences.media" = "Media";
"preferences.show-labels-in-tab-bar" = "Show labels in tab bar (requires restart)";
"preferences.media.avatars" = "Avatars"; "preferences.media.avatars" = "Avatars";
"preferences.media.avatars.animate" = "Animate avatars"; "preferences.media.avatars.animate" = "Animate avatars";
"preferences.media.avatars.animate.everywhere" = "Everywhere"; "preferences.media.avatars.animate.everywhere" = "Everywhere";

View file

@ -201,6 +201,11 @@ public extension AppPreferences {
get { self[.useUniversalLinks] ?? true } get { self[.useUniversalLinks] ?? true }
set { self[.useUniversalLinks] = newValue } set { self[.useUniversalLinks] = newValue }
} }
var showLabelsInTabBar: Bool {
get { self[.showLabelsInTabBar] ?? true }
set { self[.showLabelsInTabBar] = newValue }
}
} }
private extension AppPreferences { private extension AppPreferences {
@ -223,6 +228,7 @@ private extension AppPreferences {
case notificationSounds case notificationSounds
case openLinksInDefaultBrowser case openLinksInDefaultBrowser
case useUniversalLinks case useUniversalLinks
case showLabelsInTabBar
} }
subscript<T>(index: Item) -> T? { subscript<T>(index: Item) -> T? {

View file

@ -20,8 +20,9 @@ final class ExploreViewController: UICollectionViewController {
super.init(collectionViewLayout: Self.layout()) super.init(collectionViewLayout: Self.layout())
let showTabBarLabel = viewModel.identityContext.appPreferences.showLabelsInTabBar
tabBarItem = UITabBarItem( tabBarItem = UITabBarItem(
title: NSLocalizedString("main-navigation.explore", comment: ""), title: showTabBarLabel ? NSLocalizedString("main-navigation.explore", comment: "") : nil,
image: UIImage(systemName: "magnifyingglass"), image: UIImage(systemName: "magnifyingglass"),
selectedImage: nil) selectedImage: nil)
} }

View file

@ -127,6 +127,10 @@ private extension MainNavigationViewController {
conversationsViewController.tabBarItem = NavigationViewModel.Tab.messages.tabBarItem conversationsViewController.tabBarItem = NavigationViewModel.Tab.messages.tabBarItem
conversationsViewController.navigationItem.title = NavigationViewModel.Tab.messages.title conversationsViewController.navigationItem.title = NavigationViewModel.Tab.messages.title
if !viewModel.identityContext.appPreferences.showLabelsInTabBar {
conversationsViewController.tabBarItem.title = nil
}
controllers.append(conversationsViewController) controllers.append(conversationsViewController)
setupNewStatusButton() setupNewStatusButton()

View file

@ -39,6 +39,11 @@ final class NotificationsViewController: UIPageViewController {
} }
tabBarItem = NavigationViewModel.Tab.notifications.tabBarItem tabBarItem = NavigationViewModel.Tab.notifications.tabBarItem
if !viewModel.identityContext.appPreferences.showLabelsInTabBar {
tabBarItem.title = nil
}
} }
@available(*, unavailable) @available(*, unavailable)

View file

@ -36,8 +36,9 @@ final class TimelinesViewController: UIPageViewController {
setViewControllers([firstViewController], direction: .forward, animated: false) setViewControllers([firstViewController], direction: .forward, animated: false)
} }
let showTabBarLabel = viewModel.identityContext.appPreferences.showLabelsInTabBar
tabBarItem = UITabBarItem( tabBarItem = UITabBarItem(
title: NSLocalizedString("main-navigation.timelines", comment: ""), title: showTabBarLabel ? NSLocalizedString("main-navigation.timelines", comment: "") : nil,
image: UIImage(systemName: "newspaper"), image: UIImage(systemName: "newspaper"),
selectedImage: nil) selectedImage: nil)

View file

@ -113,6 +113,8 @@ struct PreferencesView: View {
Toggle("preferences.links.use-universal-links", Toggle("preferences.links.use-universal-links",
isOn: $identityContext.appPreferences.useUniversalLinks) isOn: $identityContext.appPreferences.useUniversalLinks)
} }
Toggle("preferences.show-labels-in-tab-bar",
isOn: $identityContext.appPreferences.showLabelsInTabBar)
} }
Group { Group {
Picker("preferences.media.autoplay.gifs", Picker("preferences.media.autoplay.gifs",