mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Assorted fixes
This commit is contained in:
parent
a7282bf2fc
commit
7f02fb759a
32 changed files with 688 additions and 147 deletions
|
|
@ -68,6 +68,8 @@ final class ShareInputFieldNode: ASDisplayNode, ASEditableTextNodeDelegate {
|
|||
private let inputInsets = UIEdgeInsets(top: 10.0, left: 8.0, bottom: 10.0, right: 16.0)
|
||||
private let accessoryButtonsWidth: CGFloat = 10.0
|
||||
|
||||
private var selectTextOnce: Bool = false
|
||||
|
||||
var text: String {
|
||||
get {
|
||||
return self.textInputNode.attributedText?.string ?? ""
|
||||
|
|
@ -124,9 +126,15 @@ final class ShareInputFieldNode: ASDisplayNode, ASEditableTextNodeDelegate {
|
|||
self.addSubnode(self.placeholderNode)
|
||||
self.addSubnode(self.clearButton)
|
||||
|
||||
self.textInputNode.textView.showsVerticalScrollIndicator = false
|
||||
|
||||
self.clearButton.addTarget(self, action: #selector(self.clearPressed), forControlEvents: .touchUpInside)
|
||||
}
|
||||
|
||||
func preselectText() {
|
||||
self.selectTextOnce = true
|
||||
}
|
||||
|
||||
func updateLayout(width: CGFloat, transition: ContainedViewLayoutTransition) -> CGFloat {
|
||||
let backgroundInsets = self.backgroundInsets
|
||||
let inputInsets = self.inputInsets
|
||||
|
|
@ -165,6 +173,13 @@ final class ShareInputFieldNode: ASDisplayNode, ASEditableTextNodeDelegate {
|
|||
func editableTextNodeDidBeginEditing(_ editableTextNode: ASEditableTextNode) {
|
||||
self.placeholderNode.isHidden = true
|
||||
self.clearButton.isHidden = false
|
||||
|
||||
if self.selectTextOnce {
|
||||
self.selectTextOnce = false
|
||||
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.5, execute: {
|
||||
self.textInputNode.selectedRange = NSRange(self.text.startIndex ..< self.text.endIndex, in: self.text)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func editableTextNodeDidFinishEditing(_ editableTextNode: ASEditableTextNode) {
|
||||
|
|
@ -196,5 +211,6 @@ final class ShareInputFieldNode: ASDisplayNode, ASEditableTextNodeDelegate {
|
|||
@objc func clearPressed() {
|
||||
self.textInputNode.attributedText = nil
|
||||
self.deactivateInput()
|
||||
self.updateHeight?()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue