mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
34 lines
919 B
Swift
34 lines
919 B
Swift
import Foundation
|
|
import AsyncDisplayKit
|
|
|
|
public final class TextFieldNodeView: UITextField {
|
|
public var didDeleteBackwardWhileEmpty: (() -> Void)?
|
|
|
|
override public func editingRect(forBounds bounds: CGRect) -> CGRect {
|
|
return bounds.offsetBy(dx: 0.0, dy: -UIScreenPixel)
|
|
}
|
|
|
|
override public func placeholderRect(forBounds bounds: CGRect) -> CGRect {
|
|
return self.editingRect(forBounds: bounds)
|
|
}
|
|
|
|
override public func deleteBackward() {
|
|
if self.text == nil || self.text!.isEmpty {
|
|
self.didDeleteBackwardWhileEmpty?()
|
|
}
|
|
super.deleteBackward()
|
|
}
|
|
}
|
|
|
|
public class TextFieldNode: ASDisplayNode {
|
|
public var textField: TextFieldNodeView {
|
|
return self.view as! TextFieldNodeView
|
|
}
|
|
|
|
override public init() {
|
|
super.init(viewBlock: {
|
|
return TextFieldNodeView()
|
|
}, didLoad: nil)
|
|
}
|
|
}
|