mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
WIP Attachment toolbar
This commit is contained in:
@@ -289,6 +289,9 @@ public final class TextFieldComponent: Component {
|
||||
return InputState(inputText: stateAttributedStringForText(self.textView.attributedText ?? NSAttributedString()), selectionRange: selectionRange)
|
||||
}
|
||||
|
||||
// MARK: Swiftgram
|
||||
var sgToolbarActionObserver: NSObjectProtocol? = nil
|
||||
|
||||
private var component: TextFieldComponent?
|
||||
private weak var state: EmptyComponentState?
|
||||
private var isUpdating: Bool = false
|
||||
@@ -367,6 +370,21 @@ public final class TextFieldComponent: Component {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Swiftgram
|
||||
self.sgToolbarActionObserver = NotificationCenter.default.addObserver(forName: Notification.Name("sgToolbarAction"), object: nil, queue: .main, using: { [weak self] notification in
|
||||
guard let self = self else { return }
|
||||
if let action = notification.userInfo?["action"] as? String {
|
||||
self.sgToolbarAction(action)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// MARK: Swiftgram
|
||||
deinit {
|
||||
if let sgToolbarActionObserver = self.sgToolbarActionObserver {
|
||||
NotificationCenter.default.removeObserver(sgToolbarActionObserver)
|
||||
}
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
@@ -1681,3 +1699,16 @@ extension TextFieldComponent.InputState {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extension TextFieldComponent.View {
|
||||
|
||||
func sgToolbarAction(_ action: String) {
|
||||
|
||||
switch action {
|
||||
default:
|
||||
print("action: \(action)")
|
||||
// assert(false, "Unhandled action \(action)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user