mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Fix stickers search cancellation
This commit is contained in:
parent
da3aa46f87
commit
cb5685a095
7 changed files with 45 additions and 11 deletions
|
|
@ -135,7 +135,7 @@ class PaneSearchBarNode: ASDisplayNode, UITextFieldDelegate {
|
|||
private let iconNode: ASImageNode
|
||||
private let textField: PaneSearchBarTextField
|
||||
private let clearButton: HighlightableButtonNode
|
||||
private let cancelButton: ASButtonNode
|
||||
private let cancelButton: HighlightableButtonNode
|
||||
|
||||
var placeholderString: NSAttributedString? {
|
||||
get {
|
||||
|
|
@ -228,7 +228,7 @@ class PaneSearchBarNode: ASDisplayNode, UITextFieldDelegate {
|
|||
self.clearButton.displaysAsynchronously = false
|
||||
self.clearButton.isHidden = true
|
||||
|
||||
self.cancelButton = ASButtonNode()
|
||||
self.cancelButton = HighlightableButtonNode()
|
||||
self.cancelButton.hitTestSlop = UIEdgeInsets(top: -8.0, left: -8.0, bottom: -8.0, right: -8.0)
|
||||
self.cancelButton.displaysAsynchronously = false
|
||||
|
||||
|
|
@ -285,7 +285,7 @@ class PaneSearchBarNode: ASDisplayNode, UITextFieldDelegate {
|
|||
let contentFrame = CGRect(origin: CGPoint(x: leftInset, y: 0.0), size: CGSize(width: boundingSize.width - leftInset - rightInset, height: boundingSize.height))
|
||||
|
||||
let cancelButtonSize = self.cancelButton.measure(CGSize(width: 100.0, height: CGFloat.infinity))
|
||||
transition.updateFrame(node: self.cancelButton, frame: CGRect(origin: CGPoint(x: contentFrame.maxX - 8.0 - cancelButtonSize.width, y: verticalOffset + 34.0), size: cancelButtonSize))
|
||||
transition.updateFrame(node: self.cancelButton, frame: CGRect(origin: CGPoint(x: contentFrame.maxX - 8.0 - cancelButtonSize.width, y: verticalOffset + 36.0), size: cancelButtonSize))
|
||||
|
||||
let textBackgroundFrame = CGRect(origin: CGPoint(x: contentFrame.minX + 8.0, y: verticalOffset + 28.0), size: CGSize(width: contentFrame.width - 16.0 - cancelButtonSize.width - 11.0, height: 36.0))
|
||||
transition.updateFrame(node: self.textBackgroundNode, frame: textBackgroundFrame)
|
||||
|
|
|
|||
|
|
@ -60,6 +60,10 @@ public final class EntitySearchContainerController: ViewController {
|
|||
super.init()
|
||||
|
||||
self.addSubnode(containerNode)
|
||||
|
||||
containerNode.onCancel = { [weak self] in
|
||||
self?.controller?.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
||||
|
|
|
|||
|
|
@ -1071,6 +1071,7 @@ final class MediaEditorScreenComponent: Component {
|
|||
strings: environment.strings,
|
||||
style: .editor,
|
||||
placeholder: "Add a caption...",
|
||||
queryTypes: [.mention],
|
||||
alwaysDarkWhenHasText: false,
|
||||
nextInputMode: { _ in return nextInputMode },
|
||||
areVoiceMessagesAvailable: false,
|
||||
|
|
|
|||
|
|
@ -250,6 +250,7 @@ final class StoryPreviewComponent: Component {
|
|||
strings: presentationData.strings,
|
||||
style: .story,
|
||||
placeholder: "Reply Privately...",
|
||||
queryTypes: [],
|
||||
alwaysDarkWhenHasText: false,
|
||||
nextInputMode: { _ in return .stickers },
|
||||
areVoiceMessagesAvailable: false,
|
||||
|
|
|
|||
|
|
@ -38,14 +38,9 @@ func inputContextQueries(_ inputState: TextFieldComponent.InputState) -> [ChatPr
|
|||
return result
|
||||
}
|
||||
|
||||
func contextQueryResultState(context: AccountContext, inputState: TextFieldComponent.InputState, currentQueryStates: inout [ChatPresentationInputQueryKind: (ChatPresentationInputQuery, Disposable)]) -> [ChatPresentationInputQueryKind: ChatContextQueryUpdate] {
|
||||
func contextQueryResultState(context: AccountContext, inputState: TextFieldComponent.InputState, availableTypes: [ChatPresentationInputQueryKind], currentQueryStates: inout [ChatPresentationInputQueryKind: (ChatPresentationInputQuery, Disposable)]) -> [ChatPresentationInputQueryKind: ChatContextQueryUpdate] {
|
||||
let inputQueries = inputContextQueries(inputState).filter({ query in
|
||||
switch query {
|
||||
case .contextRequest, .command:
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
}
|
||||
return availableTypes.contains(query.kind)
|
||||
})
|
||||
|
||||
var updates: [ChatPresentationInputQueryKind: ChatContextQueryUpdate] = [:]
|
||||
|
|
|
|||
|
|
@ -17,6 +17,22 @@ import EmojiSuggestionsComponent
|
|||
import AudioToolbox
|
||||
|
||||
public final class MessageInputPanelComponent: Component {
|
||||
public struct ContextQueryTypes: OptionSet {
|
||||
public var rawValue: Int32
|
||||
|
||||
public init() {
|
||||
self.rawValue = 0
|
||||
}
|
||||
|
||||
public init(rawValue: Int32) {
|
||||
self.rawValue = rawValue
|
||||
}
|
||||
|
||||
public static let emoji = ContextQueryTypes(rawValue: (1 << 0))
|
||||
public static let hashtag = ContextQueryTypes(rawValue: (1 << 1))
|
||||
public static let mention = ContextQueryTypes(rawValue: (1 << 2))
|
||||
}
|
||||
|
||||
public enum Style {
|
||||
case story
|
||||
case editor
|
||||
|
|
@ -48,6 +64,7 @@ public final class MessageInputPanelComponent: Component {
|
|||
public let strings: PresentationStrings
|
||||
public let style: Style
|
||||
public let placeholder: String
|
||||
public let queryTypes: ContextQueryTypes
|
||||
public let alwaysDarkWhenHasText: Bool
|
||||
public let nextInputMode: (Bool) -> InputMode?
|
||||
public let areVoiceMessagesAvailable: Bool
|
||||
|
|
@ -85,6 +102,7 @@ public final class MessageInputPanelComponent: Component {
|
|||
strings: PresentationStrings,
|
||||
style: Style,
|
||||
placeholder: String,
|
||||
queryTypes: ContextQueryTypes,
|
||||
alwaysDarkWhenHasText: Bool,
|
||||
nextInputMode: @escaping (Bool) -> InputMode?,
|
||||
areVoiceMessagesAvailable: Bool,
|
||||
|
|
@ -122,6 +140,7 @@ public final class MessageInputPanelComponent: Component {
|
|||
self.style = style
|
||||
self.nextInputMode = nextInputMode
|
||||
self.placeholder = placeholder
|
||||
self.queryTypes = queryTypes
|
||||
self.alwaysDarkWhenHasText = alwaysDarkWhenHasText
|
||||
self.areVoiceMessagesAvailable = areVoiceMessagesAvailable
|
||||
self.presentController = presentController
|
||||
|
|
@ -171,6 +190,9 @@ public final class MessageInputPanelComponent: Component {
|
|||
if lhs.placeholder != rhs.placeholder {
|
||||
return false
|
||||
}
|
||||
if lhs.queryTypes != rhs.queryTypes {
|
||||
return false
|
||||
}
|
||||
if lhs.alwaysDarkWhenHasText != rhs.alwaysDarkWhenHasText {
|
||||
return false
|
||||
}
|
||||
|
|
@ -352,7 +374,17 @@ public final class MessageInputPanelComponent: Component {
|
|||
let context = component.context
|
||||
let inputState = textFieldView.getInputState()
|
||||
|
||||
let contextQueryUpdates = contextQueryResultState(context: context, inputState: inputState, currentQueryStates: &self.contextQueryStates)
|
||||
var availableTypes: [ChatPresentationInputQueryKind] = []
|
||||
if component.queryTypes.contains(.mention) {
|
||||
availableTypes.append(.mention)
|
||||
}
|
||||
if component.queryTypes.contains(.hashtag) {
|
||||
availableTypes.append(.hashtag)
|
||||
}
|
||||
if component.queryTypes.contains(.emoji) {
|
||||
availableTypes.append(.emoji)
|
||||
}
|
||||
let contextQueryUpdates = contextQueryResultState(context: context, inputState: inputState, availableTypes: availableTypes, currentQueryStates: &self.contextQueryStates)
|
||||
|
||||
for (kind, update) in contextQueryUpdates {
|
||||
switch update {
|
||||
|
|
|
|||
|
|
@ -1663,6 +1663,7 @@ public final class StoryItemSetContainerComponent: Component {
|
|||
strings: component.strings,
|
||||
style: .story,
|
||||
placeholder: "Reply Privately...",
|
||||
queryTypes: [.mention, .emoji],
|
||||
alwaysDarkWhenHasText: component.metrics.widthClass == .regular,
|
||||
nextInputMode: { [weak self] hasText in
|
||||
if case .media = self?.sendMessageContext.currentInputMode {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue