diff --git a/Swiftgram/SGSettingsUI/Sources/SGSettingsController.swift b/Swiftgram/SGSettingsUI/Sources/SGSettingsController.swift index a8784f45e5..4f17f0245c 100644 --- a/Swiftgram/SGSettingsUI/Sources/SGSettingsController.swift +++ b/Swiftgram/SGSettingsUI/Sources/SGSettingsController.swift @@ -50,6 +50,7 @@ private enum SGBoolSetting: String { case showTabNames case showContactsTab case showCallsTab + case wideTabBar case foldersAtBottom case startTelescopeWithRearCam case hideStories @@ -166,6 +167,8 @@ private func SGControllerEntries(presentationData: PresentationData, callListSet entries.append(.toggle(id: id.count, section: .tabs, settingName: .showContactsTab, value: callListSettings.showContactsTab, text: i18n("Settings.Tabs.ShowContacts", lang), enabled: !SGSimpleSettings.shared.hideTabBar)) entries.append(.toggle(id: id.count, section: .tabs, settingName: .showCallsTab, value: callListSettings.showTab, text: strings.CallSettings_TabIcon, enabled: !SGSimpleSettings.shared.hideTabBar)) entries.append(.toggle(id: id.count, section: .tabs, settingName: .showTabNames, value: SGSimpleSettings.shared.showTabNames, text: i18n("Settings.Tabs.ShowNames", lang), enabled: !SGSimpleSettings.shared.hideTabBar)) + entries.append(.toggle(id: id.count, section: .tabs, settingName: .wideTabBar, value: SGSimpleSettings.shared.wideTabBar, text: i18n("Settings.Tabs.WideTabBar", lang), enabled: !SGSimpleSettings.shared.hideTabBar)) + entries.append(.notice(id: id.count, section: .tabs, text: i18n("Settings.Tabs.WideTabBar.Notice", lang))) entries.append(.header(id: id.count, section: .folders, text: strings.Settings_ChatFolders.uppercased(), badge: nil)) entries.append(.toggle(id: id.count, section: .folders, settingName: .foldersAtBottom, value: experimentalUISettings.foldersTabAtBottom, text: i18n("Settings.Folders.BottomTab", lang), enabled: true)) @@ -373,6 +376,9 @@ public func sgSettingsController(context: AccountContext/*, focusOnItemTag: Int? accountManager: context.sharedContext.accountManager, { $0.withUpdatedShowTab(value) } ) ).start() + case .wideTabBar: + SGSimpleSettings.shared.wideTabBar = value + askForRestart?() case .foldersAtBottom: let _ = ( updateExperimentalUISettingsInteractively(accountManager: context.sharedContext.accountManager, { settings in diff --git a/Swiftgram/SGSimpleSettings/Sources/SimpleSettings.swift b/Swiftgram/SGSimpleSettings/Sources/SimpleSettings.swift index e83e93d092..07cc91d976 100644 --- a/Swiftgram/SGSimpleSettings/Sources/SimpleSettings.swift +++ b/Swiftgram/SGSimpleSettings/Sources/SimpleSettings.swift @@ -154,6 +154,7 @@ public class SGSimpleSettings { case customAppBadge case canUseNY case nyStyle + case wideTabBar } public enum DownloadSpeedBoostValues: String, CaseIterable { @@ -292,6 +293,7 @@ public class SGSimpleSettings { Keys.customAppBadge.rawValue: "", Keys.canUseNY.rawValue: false, Keys.nyStyle.rawValue: NYStyle.default.rawValue, + Keys.wideTabBar.rawValue: false, ] public static let groupDefaultValues: [String: Any] = [ @@ -534,6 +536,9 @@ public class SGSimpleSettings { @UserDefault(key: Keys.nyStyle.rawValue) public var nyStyle: String + + @UserDefault(key: Keys.wideTabBar.rawValue) + public var wideTabBar: Bool } extension SGSimpleSettings { diff --git a/Swiftgram/SGStrings/Strings/en.lproj/SGLocalizable.strings b/Swiftgram/SGStrings/Strings/en.lproj/SGLocalizable.strings index af4901b978..944c174dfd 100644 --- a/Swiftgram/SGStrings/Strings/en.lproj/SGLocalizable.strings +++ b/Swiftgram/SGStrings/Strings/en.lproj/SGLocalizable.strings @@ -4,6 +4,8 @@ "Settings.Tabs.HideTabBar" = "Hide Tab bar"; "Settings.Tabs.ShowContacts" = "Show Contacts Tab"; "Settings.Tabs.ShowNames" = "Show Tab Names"; +"Settings.Tabs.WideTabBar" = "Wide Tab bar"; +"Settings.Tabs.WideTabBar.Notice" = "When enabled, the Tab bar keeps full width even when one or more tabs are hidden."; "Settings.Folders.BottomTab" = "Folders at Bottom"; "Settings.Folders.BottomTabStyle" = "Bottom Folders Style"; diff --git a/submodules/TelegramUI/Components/TabBarComponent/Sources/TabBarComponent.swift b/submodules/TelegramUI/Components/TabBarComponent/Sources/TabBarComponent.swift index 29fa974296..bbad06ade8 100644 --- a/submodules/TelegramUI/Components/TabBarComponent/Sources/TabBarComponent.swift +++ b/submodules/TelegramUI/Components/TabBarComponent/Sources/TabBarComponent.swift @@ -369,7 +369,8 @@ public final class TabBarComponent: Component { self.overrideUserInterfaceStyle = component.theme.overallDarkAppearance ? .dark : .light - let itemSize = CGSize(width: floor((availableSize.width - innerInset * 2.0) / CGFloat(component.items.count)), height: SGSimpleSettings.shared.showTabNames ? 56.0 : 40.0) + var itemSize = CGSize(width: floor((availableSize.width - innerInset * 2.0) / CGFloat(component.items.count)), height: SGSimpleSettings.shared.showTabNames ? 56.0 : 40.0) + if !SGSimpleSettings.shared.wideTabBar { itemSize.width = min(94.0, itemSize.width) } let contentWidth: CGFloat = innerInset * 2.0 + CGFloat(component.items.count) * itemSize.width let size = CGSize(width: min(availableSize.width, contentWidth), height: itemSize.height + innerInset * 2.0)