Various Fixes

This commit is contained in:
Ilya Laktyushin 2021-08-27 02:36:32 +03:00
parent 7f192986e8
commit 09179b81d1
3 changed files with 69 additions and 44 deletions

View File

@ -5486,11 +5486,16 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
if let strongSelf = self, case let .peer(peerId) = strongSelf.chatLocation { if let strongSelf = self, case let .peer(peerId) = strongSelf.chatLocation {
let presentationData = strongSelf.presentationData let presentationData = strongSelf.presentationData
let hideNames = strongSelf.presentationInterfaceStatePromise.get() let hideNames: Signal<Bool, NoError>
|> map { state -> Bool in if peerId.namespace == Namespaces.Peer.SecretChat {
return state.interfaceState.forwardOptionsState?.hideNames ?? false hideNames = .single(true)
} else {
hideNames = strongSelf.presentationInterfaceStatePromise.get()
|> map { state -> Bool in
return state.interfaceState.forwardOptionsState?.hideNames ?? false
}
|> distinctUntilChanged
} }
|> distinctUntilChanged
let hideCaptions = strongSelf.presentationInterfaceStatePromise.get() let hideCaptions = strongSelf.presentationInterfaceStatePromise.get()
|> map { state -> Bool in |> map { state -> Bool in
@ -5520,41 +5525,14 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
} }
} }
let hideNames = presentationInterfaceState.interfaceState.forwardOptionsState?.hideNames == true
let hideCaptions = presentationInterfaceState.interfaceState.forwardOptionsState?.hideNames == true
items.append(.action(ContextMenuActionItem(text: uniquePeerIds.count == 1 ? presentationData.strings.Conversation_ForwardOptions_ShowSendersName : presentationData.strings.Conversation_ForwardOptions_ShowSendersNames, icon: { theme in if case let .peer(peerId) = strongSelf.chatLocation, peerId.namespace == Namespaces.Peer.SecretChat {
if presentationInterfaceState.interfaceState.forwardOptionsState?.hideNames == true {
return nil
} else {
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Check"), color: theme.contextMenu.primaryColor)
}
}, action: { [weak self] _, f in
self?.interfaceInteraction?.updateForwardOptionsState({ current in
var updated = current
updated.hideNames = false
updated.hideCaptions = false
return updated
})
})))
items.append(.action(ContextMenuActionItem(text: uniquePeerIds.count == 1 ? presentationData.strings.Conversation_ForwardOptions_HideSendersName : presentationData.strings.Conversation_ForwardOptions_HideSendersNames, icon: { theme in
if presentationInterfaceState.interfaceState.forwardOptionsState?.hideNames == true {
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Check"), color: theme.contextMenu.primaryColor)
} else {
return nil
}
}, action: { _, f in
self?.interfaceInteraction?.updateForwardOptionsState({ current in
var updated = current
updated.hideNames = true
return updated
})
})))
if hasCaptions { } else {
items.append(.separator) items.append(.action(ContextMenuActionItem(text: uniquePeerIds.count == 1 ? presentationData.strings.Conversation_ForwardOptions_ShowSendersName : presentationData.strings.Conversation_ForwardOptions_ShowSendersNames, icon: { theme in
if hideNames {
items.append(.action(ContextMenuActionItem(text: presentationData.strings.Conversation_ForwardOptions_ShowCaption, icon: { theme in
if presentationInterfaceState.interfaceState.forwardOptionsState?.hideCaptions == true {
return nil return nil
} else { } else {
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Check"), color: theme.contextMenu.primaryColor) return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Check"), color: theme.contextMenu.primaryColor)
@ -5562,14 +5540,14 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
}, action: { [weak self] _, f in }, action: { [weak self] _, f in
self?.interfaceInteraction?.updateForwardOptionsState({ current in self?.interfaceInteraction?.updateForwardOptionsState({ current in
var updated = current var updated = current
updated.hideNames = false
updated.hideCaptions = false updated.hideCaptions = false
return updated return updated
}) })
}))) })))
items.append(.action(ContextMenuActionItem(text: presentationData.strings.Conversation_ForwardOptions_HideCaption, icon: { theme in items.append(.action(ContextMenuActionItem(text: uniquePeerIds.count == 1 ? presentationData.strings.Conversation_ForwardOptions_HideSendersName : presentationData.strings.Conversation_ForwardOptions_HideSendersNames, icon: { theme in
if presentationInterfaceState.interfaceState.forwardOptionsState?.hideCaptions == true { if hideNames {
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Check"), color: theme.contextMenu.primaryColor) return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Check"), color: theme.contextMenu.primaryColor)
} else { } else {
return nil return nil
@ -5577,14 +5555,47 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
}, action: { _, f in }, action: { _, f in
self?.interfaceInteraction?.updateForwardOptionsState({ current in self?.interfaceInteraction?.updateForwardOptionsState({ current in
var updated = current var updated = current
updated.hideCaptions = true
updated.hideNames = true updated.hideNames = true
return updated return updated
}) })
}))) })))
}
items.append(.separator) items.append(.separator)
if hasCaptions {
items.append(.separator)
items.append(.action(ContextMenuActionItem(text: presentationData.strings.Conversation_ForwardOptions_ShowCaption, icon: { theme in
if hideCaptions {
return nil
} else {
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Check"), color: theme.contextMenu.primaryColor)
}
}, action: { [weak self] _, f in
self?.interfaceInteraction?.updateForwardOptionsState({ current in
var updated = current
updated.hideCaptions = false
return updated
})
})))
items.append(.action(ContextMenuActionItem(text: presentationData.strings.Conversation_ForwardOptions_HideCaption, icon: { theme in
if hideCaptions {
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Check"), color: theme.contextMenu.primaryColor)
} else {
return nil
}
}, action: { _, f in
self?.interfaceInteraction?.updateForwardOptionsState({ current in
var updated = current
updated.hideCaptions = true
updated.hideNames = true
return updated
})
})))
}
}
items.append(.action(ContextMenuActionItem(text: presentationData.strings.Conversation_ForwardOptions_ChangeRecipient, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Forward"), color: theme.contextMenu.primaryColor) }, action: { c, f in items.append(.action(ContextMenuActionItem(text: presentationData.strings.Conversation_ForwardOptions_ChangeRecipient, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Forward"), color: theme.contextMenu.primaryColor) }, action: { c, f in
self?.interfaceInteraction?.forwardCurrentForwardMessages() self?.interfaceInteraction?.forwardCurrentForwardMessages()

View File

@ -556,6 +556,15 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
if let _ = strongSelf.chatPresentationInterfaceState.inputTextPanelState.mediaRecordingState { if let _ = strongSelf.chatPresentationInterfaceState.inputTextPanelState.mediaRecordingState {
return true return true
} }
var hasChatThemeScreen = false
strongSelf.controller?.window?.forEachController { c in
if c is ChatThemeScreen {
hasChatThemeScreen = true
}
}
if hasChatThemeScreen {
return true
}
return false return false
} }

View File

@ -440,7 +440,10 @@ final class ChatThemeScreen: ViewController {
return return
} }
strongSelf.dismiss() strongSelf.dismiss()
strongSelf.completion(emoticon) if strongSelf.initiallySelectedEmoticon == nil && emoticon == nil {
} else {
strongSelf.completion(emoticon)
}
} }
self.controllerNode.dismiss = { [weak self] in self.controllerNode.dismiss = { [weak self] in
self?.presentingViewController?.dismiss(animated: false, completion: nil) self?.presentingViewController?.dismiss(animated: false, completion: nil)
@ -456,6 +459,8 @@ final class ChatThemeScreen: ViewController {
override public func loadView() { override public func loadView() {
super.loadView() super.loadView()
self.view.disablesInteractiveTransitionGestureRecognizer = true
} }
override public func viewDidAppear(_ animated: Bool) { override public func viewDidAppear(_ animated: Bool) {