Search button

This commit is contained in:
Kylmakalle
2026-01-10 00:46:18 +02:00
parent 4cf33d7567
commit 9d5841348c
6 changed files with 17 additions and 1 deletions

View File

@@ -104,6 +104,7 @@ private enum SGBoolSetting: String {
case enableVoipTcp
case nyStyleSnow
case nyStyleLightning
case tabBarSearchEnabled
}
private enum SGOneFromManySetting: String {
@@ -171,6 +172,7 @@ 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: .tabBarSearchEnabled, value: SGSimpleSettings.shared.tabBarSearchEnabled, text: i18n("Settings.Tabs.SearchButton", 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)))
@@ -378,6 +380,8 @@ public func sgSettingsController(context: AccountContext/*, focusOnItemTag: Int?
accountManager: context.sharedContext.accountManager, { $0.withUpdatedShowTab(value) }
)
).start()
case .tabBarSearchEnabled:
SGSimpleSettings.shared.tabBarSearchEnabled = value
case .wideTabBar:
SGSimpleSettings.shared.wideTabBar = value
askForRestart?()

View File

@@ -41,6 +41,7 @@ public class SGSimpleSettings {
let tasks = [
// { let _ = self.allChatsFolderPositionOverride },
{ let _ = self.tabBarSearchEnabled },
{ let _ = self.allChatsHidden },
{ let _ = self.hideTabBar },
{ let _ = self.bottomTabStyle },
@@ -155,6 +156,7 @@ public class SGSimpleSettings {
case canUseNY
case nyStyle
case wideTabBar
case tabBarSearchEnabled
}
public enum DownloadSpeedBoostValues: String, CaseIterable {
@@ -294,6 +296,7 @@ public class SGSimpleSettings {
Keys.canUseNY.rawValue: false,
Keys.nyStyle.rawValue: NYStyle.default.rawValue,
Keys.wideTabBar.rawValue: false,
Keys.tabBarSearchEnabled.rawValue: true
]
public static let groupDefaultValues: [String: Any] = [
@@ -539,6 +542,9 @@ public class SGSimpleSettings {
@UserDefault(key: Keys.wideTabBar.rawValue)
public var wideTabBar: Bool
@UserDefault(key: Keys.tabBarSearchEnabled.rawValue)
public var tabBarSearchEnabled: Bool
}
extension SGSimpleSettings {

View File

@@ -4,6 +4,7 @@
"Settings.Tabs.HideTabBar" = "Hide Tab bar";
"Settings.Tabs.ShowContacts" = "Show Contacts Tab";
"Settings.Tabs.ShowNames" = "Show Tab Names";
"Settings.Tabs.SearchButton" = "Search Button";
"Settings.Tabs.WideTabBar" = "Wide Tab bar";
"Settings.Tabs.WideTabBar.Notice" = "Keeps the full width of Tab bar when some tabs are hidden.";

View File

@@ -4,6 +4,7 @@
"Settings.Tabs.HideTabBar" = "Скрыть панель вкладок";
"Settings.Tabs.ShowContacts" = "Вкладка «Контакты»";
"Settings.Tabs.ShowNames" = "Имена вкладок";
"Settings.Tabs.SearchButton" = "Кнопка поиска";
"Settings.Tabs.WideTabBar" = "Широкая панель";
"Settings.Tabs.WideTabBar.Notice" = "Сохраняет полную ширину панели вкладок, когда некоторые вкладки скрыты.";

View File

@@ -251,7 +251,7 @@ final class TabBarControllerNode: ASDisplayNode {
}
)
},
search: self.currentController?.tabBarSearchState.flatMap { tabBarSearchState in
search: (!SGSimpleSettings.shared.tabBarSearchEnabled) ? nil : self.currentController?.tabBarSearchState.flatMap { tabBarSearchState in
return TabBarComponent.Search(
isActive: tabBarSearchState.isActive,
activate: { [weak self] in

View File

@@ -573,6 +573,10 @@ public final class TabBarComponent: Component {
widthReducer = 1.0
}
availableSize.width = availableSize.width / widthReducer
if !SGSimpleSettings.shared.tabBarSearchEnabled {
availableSize.width -= 48.0
availableSize.width -= innerInset * 2.0
}
}
let previousComponent = self.component