From 62d962e25e5e7d3b29c9c6429fe8141282df6627 Mon Sep 17 00:00:00 2001 From: mvsrcdst <43897151+mvsrcdst@users.noreply.github.com> Date: Fri, 24 Jul 2026 16:06:15 +0300 Subject: [PATCH] feat: add option to hide AI rewrite button --- Swiftgram/SGSettingsUI/Sources/SGSettingsController.swift | 4 ++++ Swiftgram/SGSimpleSettings/Sources/SimpleSettings.swift | 5 +++++ Swiftgram/SGStrings/Strings/en.lproj/SGLocalizable.strings | 1 + .../Sources/ChatTextInputPanelNode.swift | 4 ++-- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Swiftgram/SGSettingsUI/Sources/SGSettingsController.swift b/Swiftgram/SGSettingsUI/Sources/SGSettingsController.swift index da487fa1c98..5c439c080ae 100644 --- a/Swiftgram/SGSettingsUI/Sources/SGSettingsController.swift +++ b/Swiftgram/SGSettingsUI/Sources/SGSettingsController.swift @@ -82,6 +82,7 @@ private enum SGBoolSetting: String { case disableGalleryCamera case disableGalleryCameraPreview case disableSendAsButton + case disableAIChatButton case disableSnapDeletionEffect case stickerTimestamp case hideRecordingButton @@ -314,6 +315,7 @@ private func SGControllerEntries(presentationData: PresentationData, callListSet entries.append(.toggle(id: id.count, section: .other, settingName: .hideRecordingButton, value: !SGSimpleSettings.shared.hideRecordingButton, text: i18n("Settings.RecordingButton", lang), enabled: true)) entries.append(.toggle(id: id.count, section: .other, settingName: .disableSnapDeletionEffect, value: !SGSimpleSettings.shared.disableSnapDeletionEffect, text: i18n("Settings.SnapDeletionEffect", lang), enabled: true)) entries.append(.toggle(id: id.count, section: .other, settingName: .disableSendAsButton, value: !SGSimpleSettings.shared.disableSendAsButton, text: i18n("Settings.SendAsButton", lang, strings.Conversation_SendMesageAs), enabled: true)) + entries.append(.toggle(id: id.count, section: .other, settingName: .disableAIChatButton, value: !SGSimpleSettings.shared.disableAIChatButton, text: i18n("Settings.AIChatButton", lang), enabled: true)) entries.append(.toggle(id: id.count, section: .other, settingName: .disableGalleryCamera, value: !SGSimpleSettings.shared.disableGalleryCamera, text: i18n("Settings.GalleryCamera", lang), enabled: true)) entries.append(.toggle(id: id.count, section: .other, settingName: .disableGalleryCameraPreview, value: !SGSimpleSettings.shared.disableGalleryCameraPreview, text: i18n("Settings.GalleryCameraPreview", lang), enabled: !SGSimpleSettings.shared.disableGalleryCamera)) entries.append(.toggle(id: id.count, section: .other, settingName: .disableScrollToNextChannel, value: !SGSimpleSettings.shared.disableScrollToNextChannel, text: i18n("Settings.PullToNextChannel", lang), enabled: true)) @@ -448,6 +450,8 @@ public func sgSettingsController(context: AccountContext/*, focusOnItemTag: Int? SGSimpleSettings.shared.disableGalleryCameraPreview = !value case .disableSendAsButton: SGSimpleSettings.shared.disableSendAsButton = !value + case .disableAIChatButton: + SGSimpleSettings.shared.disableAIChatButton = !value case .disableSnapDeletionEffect: SGSimpleSettings.shared.disableSnapDeletionEffect = !value case .contextShowReport: diff --git a/Swiftgram/SGSimpleSettings/Sources/SimpleSettings.swift b/Swiftgram/SGSimpleSettings/Sources/SimpleSettings.swift index 2db47deb514..097addae5b1 100644 --- a/Swiftgram/SGSimpleSettings/Sources/SimpleSettings.swift +++ b/Swiftgram/SGSimpleSettings/Sources/SimpleSettings.swift @@ -131,6 +131,7 @@ public class SGSimpleSettings { case disableGalleryCamera case disableGalleryCameraPreview case disableSendAsButton + case disableAIChatButton case disableSnapDeletionEffect case stickerSize case stickerTimestamp @@ -289,6 +290,7 @@ public class SGSimpleSettings { Keys.disableGalleryCamera.rawValue: false, Keys.disableGalleryCameraPreview.rawValue: false, Keys.disableSendAsButton.rawValue: false, + Keys.disableAIChatButton.rawValue: false, Keys.disableSnapDeletionEffect.rawValue: false, Keys.stickerSize.rawValue: 100, Keys.stickerTimestamp.rawValue: true, @@ -464,6 +466,9 @@ public class SGSimpleSettings { @UserDefault(key: Keys.disableSendAsButton.rawValue) public var disableSendAsButton: Bool + @UserDefault(key: Keys.disableAIChatButton.rawValue) + public var disableAIChatButton: Bool + @UserDefault(key: Keys.disableSnapDeletionEffect.rawValue) public var disableSnapDeletionEffect: Bool diff --git a/Swiftgram/SGStrings/Strings/en.lproj/SGLocalizable.strings b/Swiftgram/SGStrings/Strings/en.lproj/SGLocalizable.strings index 0383460b65f..6648e4017b7 100644 --- a/Swiftgram/SGStrings/Strings/en.lproj/SGLocalizable.strings +++ b/Swiftgram/SGStrings/Strings/en.lproj/SGLocalizable.strings @@ -135,6 +135,7 @@ "Settings.GalleryCameraPreview" = "Camera Preview in Gallery"; /* "Send Message As..." button */ "Settings.SendAsButton" = "\"%@\" Button"; +"Settings.AIChatButton" = "AI Rewrite Button"; "Settings.SnapDeletionEffect" = "Message Deletion Effects"; "Settings.Stickers.Size" = "SIZE"; diff --git a/submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelNode.swift b/submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelNode.swift index b101ec668de..2d57d176032 100644 --- a/submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelNode.swift @@ -3578,7 +3578,7 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg var isAIButtonVisible = false var attachmentPillHeight: CGFloat = 40.0 let inputHasNonWhitespaceText = !(self.richTextInputNode?.inputContentIsEmptyWhitespaceTrimmed ?? true) - if self.isAIEnabled, inputHasNonWhitespaceText, let node = self.richTextInputNode { + if self.isAIEnabled && !SGSimpleSettings.shared.disableAIChatButton, inputHasNonWhitespaceText, let node = self.richTextInputNode { let threeLineHeight = self.threeLineFieldHeight(forWidth: baseWidth, node: node, metrics: metrics, bottomInset: bottomInset, textFieldInsets: textFieldInsets) if textInputHeight >= threeLineHeight - 0.5 { isAIButtonVisible = true @@ -3600,7 +3600,7 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg } // AI button in the TOP 40x40 slot of the capsule (fades in with the 3-line rule). - if self.isAIEnabled { + if self.isAIEnabled && !SGSimpleSettings.shared.disableAIChatButton { let aiButton: (button: HighlightTrackingButton, icon: UIImageView) if let current = self.attachmentAIButton { aiButton = current