diff --git a/Swiftgram/SGSettingsUI/Sources/SGSettingsController.swift b/Swiftgram/SGSettingsUI/Sources/SGSettingsController.swift index 3030f4aac0..9c6bd5481c 100644 --- a/Swiftgram/SGSettingsUI/Sources/SGSettingsController.swift +++ b/Swiftgram/SGSettingsUI/Sources/SGSettingsController.swift @@ -89,6 +89,7 @@ private enum SGBoolSetting: String { case wideChannelPosts case forceEmojiTab case forceBuiltInMic + case hideChannelBottomButton } private enum SGOneFromManySetting: String { @@ -239,6 +240,7 @@ private func SGControllerEntries(presentationData: PresentationData, callListSet id.increment(10000) entries.append(.header(id: id.count, section: .other, text: presentationData.strings.Appearance_Other.uppercased(), badge: nil)) + entries.append(.toggle(id: id.count, section: .other, settingName: .hideChannelBottomButton, value: SGSimpleSettings.shared.hideChannelBottomButton, text: i18n("Settings.hideChannelBottomButton", lang), enabled: true)) entries.append(.toggle(id: id.count, section: .other, settingName: .wideChannelPosts, value: SGSimpleSettings.shared.wideChannelPosts, text: i18n("Settings.wideChannelPosts", lang), enabled: true)) entries.append(.toggle(id: id.count, section: .other, settingName: .forceBuiltInMic, value: SGSimpleSettings.shared.forceBuiltInMic, text: i18n("Settings.forceBuiltInMic", lang), enabled: true)) entries.append(.notice(id: id.count, section: .other, text: i18n("Settings.forceBuiltInMic.Notice", lang))) @@ -435,6 +437,8 @@ public func sgSettingsController(context: AccountContext/*, focusOnItemTag: Int? SGSimpleSettings.shared.forceEmojiTab = value case .forceBuiltInMic: SGSimpleSettings.shared.forceBuiltInMic = value + case .hideChannelBottomButton: + SGSimpleSettings.shared.hideChannelBottomButton = value } }, updateSliderValue: { setting, value in switch (setting) { diff --git a/Swiftgram/SGSimpleSettings/Sources/SimpleSettings.swift b/Swiftgram/SGSimpleSettings/Sources/SimpleSettings.swift index ea4508593b..b6f02fe12b 100644 --- a/Swiftgram/SGSimpleSettings/Sources/SimpleSettings.swift +++ b/Swiftgram/SGSimpleSettings/Sources/SimpleSettings.swift @@ -101,6 +101,7 @@ public class SGSimpleSettings { case wideChannelPosts case forceEmojiTab case forceBuiltInMic + case hideChannelBottomButton } public enum DownloadSpeedBoostValues: String, CaseIterable { @@ -186,6 +187,7 @@ public class SGSimpleSettings { Keys.messageDoubleTapActionOutgoing.rawValue: MessageDoubleTapAction.default.rawValue, Keys.wideChannelPosts.rawValue: false, Keys.forceEmojiTab.rawValue: false, + Keys.hideChannelBottomButton.rawValue: false ] @UserDefault(key: Keys.hidePhoneInSettings.rawValue) @@ -345,6 +347,9 @@ public class SGSimpleSettings { @UserDefault(key: Keys.forceBuiltInMic.rawValue) public var forceBuiltInMic: Bool + + @UserDefault(key: Keys.hideChannelBottomButton.rawValue) + public var hideChannelBottomButton: Bool } extension SGSimpleSettings { diff --git a/Swiftgram/SGStrings/Strings/en.lproj/SGLocalizable.strings b/Swiftgram/SGStrings/Strings/en.lproj/SGLocalizable.strings index b2456b601d..c76c94ff73 100644 --- a/Swiftgram/SGStrings/Strings/en.lproj/SGLocalizable.strings +++ b/Swiftgram/SGStrings/Strings/en.lproj/SGLocalizable.strings @@ -131,4 +131,6 @@ "Settings.ForceEmojiTab" = "Emoji keyboard by default"; "Settings.forceBuiltInMic" = "Force Device Microphone"; -"Settings.forceBuiltInMic.Notice" = "If enabled, app will use only device microphone even if headphones are connected."; \ No newline at end of file +"Settings.forceBuiltInMic.Notice" = "If enabled, app will use only device microphone even if headphones are connected."; + +"Settings.hideChannelBottomButton" = "Hide Channel Bottom Panel"; \ No newline at end of file diff --git a/submodules/TelegramUI/Sources/ChatControllerNode.swift b/submodules/TelegramUI/Sources/ChatControllerNode.swift index 33d49ba476..5cbaef5476 100644 --- a/submodules/TelegramUI/Sources/ChatControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatControllerNode.swift @@ -1,4 +1,5 @@ import Foundation +import SGSimpleSettings import UIKit import AsyncDisplayKit import Postbox @@ -1480,8 +1481,19 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate { var dismissedAccessoryPanelNode: AccessoryPanelNode? var dismissedInputContextPanelNode: ChatInputContextPanelNode? var dismissedOverlayContextPanelNode: ChatInputContextPanelNode? + // MARK: Swiftgram + var inputPanelNodes = inputPanelForChatPresentationIntefaceState(self.chatPresentationInterfaceState, context: self.context, currentPanel: self.inputPanelNode, currentSecondaryPanel: self.secondaryInputPanelNode, textInputPanelNode: self.textInputPanelNode, interfaceInteraction: self.interfaceInteraction) - let inputPanelNodes = inputPanelForChatPresentationIntefaceState(self.chatPresentationInterfaceState, context: self.context, currentPanel: self.inputPanelNode, currentSecondaryPanel: self.secondaryInputPanelNode, textInputPanelNode: self.textInputPanelNode, interfaceInteraction: self.interfaceInteraction) + if (inputPanelNodes.primary != nil || inputPanelNodes.secondary != nil) && SGSimpleSettings.shared.hideChannelBottomButton { + // So there should be some panel, but user don't want it. Let's check if our logic will hide it + inputPanelNodes = inputPanelForChatPresentationIntefaceState(self.chatPresentationInterfaceState, context: self.context, currentPanel: self.inputPanelNode, currentSecondaryPanel: self.secondaryInputPanelNode, textInputPanelNode: self.textInputPanelNode, interfaceInteraction: self.interfaceInteraction, forceHideChannelButton: true) + if inputPanelNodes.primary == nil && inputPanelNodes.secondary == nil { + // Looks like we're eligible to hide the panel, let's remove safe area fill as well + self.inputPanelBackgroundSeparatorNode.removeFromSupernode() + self.inputPanelBottomBackgroundSeparatorNode.removeFromSupernode() + self.inputPanelBackgroundNode.removeFromSupernode() + } + } let inputPanelBottomInset = max(insets.bottom, inputPanelBottomInsetTerm) diff --git a/submodules/TelegramUI/Sources/ChatInterfaceStateInputPanels.swift b/submodules/TelegramUI/Sources/ChatInterfaceStateInputPanels.swift index 467dedcb39..2b2ae8bd39 100644 --- a/submodules/TelegramUI/Sources/ChatInterfaceStateInputPanels.swift +++ b/submodules/TelegramUI/Sources/ChatInterfaceStateInputPanels.swift @@ -19,7 +19,7 @@ func canBypassRestrictions(chatPresentationInterfaceState: ChatPresentationInter return false } -func inputPanelForChatPresentationIntefaceState(_ chatPresentationInterfaceState: ChatPresentationInterfaceState, context: AccountContext, currentPanel: ChatInputPanelNode?, currentSecondaryPanel: ChatInputPanelNode?, textInputPanelNode: ChatTextInputPanelNode?, interfaceInteraction: ChatPanelInterfaceInteraction?) -> (primary: ChatInputPanelNode?, secondary: ChatInputPanelNode?) { +func inputPanelForChatPresentationIntefaceState(_ chatPresentationInterfaceState: ChatPresentationInterfaceState, context: AccountContext, currentPanel: ChatInputPanelNode?, currentSecondaryPanel: ChatInputPanelNode?, textInputPanelNode: ChatTextInputPanelNode?, interfaceInteraction: ChatPanelInterfaceInteraction?, forceHideChannelButton: Bool = false) -> (primary: ChatInputPanelNode?, secondary: ChatInputPanelNode?) { if let renderedPeer = chatPresentationInterfaceState.renderedPeer, renderedPeer.peer?.restrictionText(platform: "ios", contentSettings: context.currentContentSettings.with { $0 }) != nil { return (nil, nil) } @@ -281,6 +281,10 @@ func inputPanelForChatPresentationIntefaceState(_ chatPresentationInterfaceState if chatPresentationInterfaceState.interfaceState.editMessage != nil, channel.hasPermission(.editAllMessages) { displayInputTextPanel = true } else if !channel.hasPermission(.sendSomething) || !isMember { + // MARK: Swiftgram + if isMember && forceHideChannelButton { + return (nil, nil) + } if let currentPanel = (currentPanel as? ChatChannelSubscriberInputPanelNode) ?? (currentSecondaryPanel as? ChatChannelSubscriberInputPanelNode) { return (currentPanel, nil) } else {