mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Stories
This commit is contained in:
@@ -90,6 +90,7 @@ public final class TextFieldComponent: Component {
|
||||
public let textColor: UIColor
|
||||
public let insets: UIEdgeInsets
|
||||
public let hideKeyboard: Bool
|
||||
public let resetText: NSAttributedString?
|
||||
public let formatMenuAvailability: FormatMenuAvailability
|
||||
public let lockedFormatAction: () -> Void
|
||||
public let present: (ViewController) -> Void
|
||||
@@ -103,6 +104,7 @@ public final class TextFieldComponent: Component {
|
||||
textColor: UIColor,
|
||||
insets: UIEdgeInsets,
|
||||
hideKeyboard: Bool,
|
||||
resetText: NSAttributedString?,
|
||||
formatMenuAvailability: FormatMenuAvailability,
|
||||
lockedFormatAction: @escaping () -> Void,
|
||||
present: @escaping (ViewController) -> Void,
|
||||
@@ -115,6 +117,7 @@ public final class TextFieldComponent: Component {
|
||||
self.textColor = textColor
|
||||
self.insets = insets
|
||||
self.hideKeyboard = hideKeyboard
|
||||
self.resetText = resetText
|
||||
self.formatMenuAvailability = formatMenuAvailability
|
||||
self.lockedFormatAction = lockedFormatAction
|
||||
self.present = present
|
||||
@@ -140,6 +143,9 @@ public final class TextFieldComponent: Component {
|
||||
if lhs.hideKeyboard != rhs.hideKeyboard {
|
||||
return false
|
||||
}
|
||||
if lhs.resetText != rhs.resetText {
|
||||
return false
|
||||
}
|
||||
if lhs.formatMenuAvailability != rhs.formatMenuAvailability {
|
||||
return false
|
||||
}
|
||||
@@ -523,11 +529,13 @@ public final class TextFieldComponent: Component {
|
||||
return self.inputState.inputText
|
||||
}
|
||||
|
||||
public func setAttributedText(_ string: NSAttributedString) {
|
||||
public func setAttributedText(_ string: NSAttributedString, updateState: Bool) {
|
||||
self.updateInputState { _ in
|
||||
return TextFieldComponent.InputState(inputText: string, selectionRange: string.length ..< string.length)
|
||||
}
|
||||
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(kind: .textChanged)))
|
||||
if updateState {
|
||||
self.state?.updated(transition: Transition(animation: .curve(duration: 0.4, curve: .spring)).withUserData(AnimationHint(kind: .textChanged)))
|
||||
}
|
||||
}
|
||||
|
||||
public func activateInput() {
|
||||
@@ -783,6 +791,10 @@ public final class TextFieldComponent: Component {
|
||||
self.updateInputState { _ in
|
||||
return TextFieldComponent.InputState(inputText: initialText)
|
||||
}
|
||||
} else if let resetText = component.resetText {
|
||||
self.updateInputState { _ in
|
||||
return TextFieldComponent.InputState(inputText: resetText)
|
||||
}
|
||||
}
|
||||
|
||||
if self.emojiViewProvider == nil {
|
||||
|
||||
Reference in New Issue
Block a user