mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-06 20:54:04 +00:00
Hide channel bottom panel closes #27
Co-Authored-By: Lev Poznyakov <62802017+levochkaa@users.noreply.github.com>
This commit is contained in:
parent
6c631ee639
commit
3d8ffbaa56
@ -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) {
|
||||
|
@ -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 {
|
||||
|
@ -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.";
|
||||
"Settings.forceBuiltInMic.Notice" = "If enabled, app will use only device microphone even if headphones are connected.";
|
||||
|
||||
"Settings.hideChannelBottomButton" = "Hide Channel Bottom Panel";
|
@ -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)
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user