mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-03 21:16:35 +00:00
Don't show Spoiler format option in secret chats
This commit is contained in:
parent
80e2fc02ee
commit
d60d2beaa4
@ -9798,7 +9798,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
|
|
||||||
private func getCaptionPanelView() -> TGCaptionPanelView {
|
private func getCaptionPanelView() -> TGCaptionPanelView {
|
||||||
let presentationData = self.presentationData.withUpdated(theme: defaultDarkColorPresentationTheme)
|
let presentationData = self.presentationData.withUpdated(theme: defaultDarkColorPresentationTheme)
|
||||||
var presentationInterfaceState = ChatPresentationInterfaceState(chatWallpaper: .builtin(WallpaperSettings()), theme: presentationData.theme, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, limitsConfiguration: self.context.currentLimitsConfiguration.with { $0 }, fontSize: presentationData.chatFontSize, bubbleCorners: presentationData.chatBubbleCorners, accountPeerId: self.context.account.peerId, mode: .standard(previewing: false), chatLocation: .peer(PeerId(0)), subject: nil, peerNearbyData: nil, greetingData: nil, pendingUnpinnedAllMessages: false, activeGroupCallInfo: nil, hasActiveGroupCall: false, importState: nil)
|
var presentationInterfaceState = ChatPresentationInterfaceState(chatWallpaper: .builtin(WallpaperSettings()), theme: presentationData.theme, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, limitsConfiguration: self.context.currentLimitsConfiguration.with { $0 }, fontSize: presentationData.chatFontSize, bubbleCorners: presentationData.chatBubbleCorners, accountPeerId: self.context.account.peerId, mode: .standard(previewing: false), chatLocation: self.presentationInterfaceState.chatLocation, subject: nil, peerNearbyData: nil, greetingData: nil, pendingUnpinnedAllMessages: false, activeGroupCallInfo: nil, hasActiveGroupCall: false, importState: nil)
|
||||||
|
|
||||||
var updateChatPresentationInterfaceStateImpl: (((ChatPresentationInterfaceState) -> ChatPresentationInterfaceState) -> Void)?
|
var updateChatPresentationInterfaceStateImpl: (((ChatPresentationInterfaceState) -> ChatPresentationInterfaceState) -> Void)?
|
||||||
var ensureFocusedImpl: (() -> Void)?
|
var ensureFocusedImpl: (() -> Void)?
|
||||||
|
|||||||
@ -17,6 +17,8 @@ final class ChatTextInputMenu {
|
|||||||
private var stringUnderline: String = "Underline"
|
private var stringUnderline: String = "Underline"
|
||||||
private var stringSpoiler: String = "Spoiler"
|
private var stringSpoiler: String = "Spoiler"
|
||||||
|
|
||||||
|
private let hasSpoilers: Bool
|
||||||
|
|
||||||
private(set) var state: ChatTextInputMenuState = .inactive {
|
private(set) var state: ChatTextInputMenuState = .inactive {
|
||||||
didSet {
|
didSet {
|
||||||
if self.state != oldValue {
|
if self.state != oldValue {
|
||||||
@ -26,8 +28,7 @@ final class ChatTextInputMenu {
|
|||||||
case .general:
|
case .general:
|
||||||
UIMenuController.shared.menuItems = []
|
UIMenuController.shared.menuItems = []
|
||||||
case .format:
|
case .format:
|
||||||
UIMenuController.shared.menuItems = [
|
var menuItems: [UIMenuItem] = [
|
||||||
UIMenuItem(title: self.stringSpoiler, action: Selector(("formatAttributesSpoiler:"))),
|
|
||||||
UIMenuItem(title: self.stringBold, action: Selector(("formatAttributesBold:"))),
|
UIMenuItem(title: self.stringBold, action: Selector(("formatAttributesBold:"))),
|
||||||
UIMenuItem(title: self.stringItalic, action: Selector(("formatAttributesItalic:"))),
|
UIMenuItem(title: self.stringItalic, action: Selector(("formatAttributesItalic:"))),
|
||||||
UIMenuItem(title: self.stringMonospace, action: Selector(("formatAttributesMonospace:"))),
|
UIMenuItem(title: self.stringMonospace, action: Selector(("formatAttributesMonospace:"))),
|
||||||
@ -35,6 +36,10 @@ final class ChatTextInputMenu {
|
|||||||
UIMenuItem(title: self.stringStrikethrough, action: Selector(("formatAttributesStrikethrough:"))),
|
UIMenuItem(title: self.stringStrikethrough, action: Selector(("formatAttributesStrikethrough:"))),
|
||||||
UIMenuItem(title: self.stringUnderline, action: Selector(("formatAttributesUnderline:")))
|
UIMenuItem(title: self.stringUnderline, action: Selector(("formatAttributesUnderline:")))
|
||||||
]
|
]
|
||||||
|
if self.hasSpoilers {
|
||||||
|
menuItems.insert(UIMenuItem(title: self.stringSpoiler, action: Selector(("formatAttributesSpoiler:"))), at: 0)
|
||||||
|
}
|
||||||
|
UIMenuController.shared.menuItems = menuItems
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -43,7 +48,8 @@ final class ChatTextInputMenu {
|
|||||||
|
|
||||||
private var observer: NSObjectProtocol?
|
private var observer: NSObjectProtocol?
|
||||||
|
|
||||||
init() {
|
init(hasSpoilers: Bool = false) {
|
||||||
|
self.hasSpoilers = hasSpoilers
|
||||||
self.observer = NotificationCenter.default.addObserver(forName: UIMenuController.didHideMenuNotification, object: nil, queue: nil, using: { [weak self] _ in
|
self.observer = NotificationCenter.default.addObserver(forName: UIMenuController.didHideMenuNotification, object: nil, queue: nil, using: { [weak self] _ in
|
||||||
self?.back()
|
self?.back()
|
||||||
})
|
})
|
||||||
|
|||||||
@ -296,7 +296,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
|||||||
|
|
||||||
var isMediaDeleted: Bool = false
|
var isMediaDeleted: Bool = false
|
||||||
|
|
||||||
private let inputMenu = ChatTextInputMenu()
|
private let inputMenu: ChatTextInputMenu
|
||||||
|
|
||||||
private var theme: PresentationTheme?
|
private var theme: PresentationTheme?
|
||||||
private var strings: PresentationStrings?
|
private var strings: PresentationStrings?
|
||||||
@ -451,6 +451,12 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
|||||||
init(presentationInterfaceState: ChatPresentationInterfaceState, presentationContext: ChatPresentationContext?, presentController: @escaping (ViewController) -> Void) {
|
init(presentationInterfaceState: ChatPresentationInterfaceState, presentationContext: ChatPresentationContext?, presentController: @escaping (ViewController) -> Void) {
|
||||||
self.presentationInterfaceState = presentationInterfaceState
|
self.presentationInterfaceState = presentationInterfaceState
|
||||||
|
|
||||||
|
var hasSpoilers = true
|
||||||
|
if presentationInterfaceState.chatLocation.peerId.namespace == Namespaces.Peer.SecretChat {
|
||||||
|
hasSpoilers = false
|
||||||
|
}
|
||||||
|
self.inputMenu = ChatTextInputMenu(hasSpoilers: hasSpoilers)
|
||||||
|
|
||||||
self.clippingNode = ASDisplayNode()
|
self.clippingNode = ASDisplayNode()
|
||||||
self.clippingNode.clipsToBounds = true
|
self.clippingNode.clipsToBounds = true
|
||||||
|
|
||||||
|
|||||||
@ -141,7 +141,7 @@ class PeerSelectionTextInputPanelNode: ChatInputPanelNode, TGCaptionPanelView, A
|
|||||||
private var presentationInterfaceState: ChatPresentationInterfaceState?
|
private var presentationInterfaceState: ChatPresentationInterfaceState?
|
||||||
private var initializedPlaceholder = false
|
private var initializedPlaceholder = false
|
||||||
|
|
||||||
private let inputMenu = ChatTextInputMenu()
|
private let inputMenu: ChatTextInputMenu
|
||||||
|
|
||||||
private var theme: PresentationTheme?
|
private var theme: PresentationTheme?
|
||||||
private var strings: PresentationStrings?
|
private var strings: PresentationStrings?
|
||||||
@ -241,6 +241,12 @@ class PeerSelectionTextInputPanelNode: ChatInputPanelNode, TGCaptionPanelView, A
|
|||||||
self.presentationInterfaceState = presentationInterfaceState
|
self.presentationInterfaceState = presentationInterfaceState
|
||||||
self.isCaption = isCaption
|
self.isCaption = isCaption
|
||||||
|
|
||||||
|
var hasSpoilers = true
|
||||||
|
if presentationInterfaceState.chatLocation.peerId.namespace == Namespaces.Peer.SecretChat {
|
||||||
|
hasSpoilers = false
|
||||||
|
}
|
||||||
|
self.inputMenu = ChatTextInputMenu(hasSpoilers: hasSpoilers)
|
||||||
|
|
||||||
self.textInputContainerBackgroundNode = ASImageNode()
|
self.textInputContainerBackgroundNode = ASImageNode()
|
||||||
self.textInputContainerBackgroundNode.isUserInteractionEnabled = false
|
self.textInputContainerBackgroundNode.isUserInteractionEnabled = false
|
||||||
self.textInputContainerBackgroundNode.displaysAsynchronously = false
|
self.textInputContainerBackgroundNode.displaysAsynchronously = false
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user