mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-29 11:25:38 +00:00
Input message preview improvements
This commit is contained in:
parent
104e1ede45
commit
784e20a993
@ -262,6 +262,18 @@ final class ChatSendMessageActionSheetControllerNode: ViewControllerTracingNode,
|
|||||||
|
|
||||||
if let attributedText = textInputView.attributedText, !attributedText.string.isEmpty {
|
if let attributedText = textInputView.attributedText, !attributedText.string.isEmpty {
|
||||||
self.animateInputField = true
|
self.animateInputField = true
|
||||||
|
if let textInputView = self.textInputView as? ChatInputTextView {
|
||||||
|
self.fromMessageTextNode.textView.theme = textInputView.theme
|
||||||
|
|
||||||
|
let mainColor = presentationData.theme.chat.message.outgoing.accentControlColor
|
||||||
|
self.toMessageTextNode.textView.theme = ChatInputTextView.Theme(
|
||||||
|
quote: ChatInputTextView.Theme.Quote(
|
||||||
|
background: mainColor.withMultipliedAlpha(0.1),
|
||||||
|
foreground: mainColor,
|
||||||
|
isDashed: textInputView.theme?.quote.isDashed == true
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
self.fromMessageTextNode.attributedText = attributedText
|
self.fromMessageTextNode.attributedText = attributedText
|
||||||
|
|
||||||
if let toAttributedText = self.fromMessageTextNode.attributedText?.mutableCopy() as? NSMutableAttributedString {
|
if let toAttributedText = self.fromMessageTextNode.attributedText?.mutableCopy() as? NSMutableAttributedString {
|
||||||
@ -702,6 +714,9 @@ final class ChatSendMessageActionSheetControllerNode: ViewControllerTracingNode,
|
|||||||
messageFrame.size.width += 32.0
|
messageFrame.size.width += 32.0
|
||||||
messageFrame.origin.x -= 13.0
|
messageFrame.origin.x -= 13.0
|
||||||
messageFrame.origin.y = layout.size.height - messageFrame.origin.y - messageFrame.size.height - 1.0
|
messageFrame.origin.y = layout.size.height - messageFrame.origin.y - messageFrame.size.height - 1.0
|
||||||
|
|
||||||
|
let messageHeightAddition: CGFloat = max(0.0, 35.0 - messageFrame.size.height)
|
||||||
|
|
||||||
if inputHeight.isZero || layout.isNonExclusive {
|
if inputHeight.isZero || layout.isNonExclusive {
|
||||||
messageFrame.origin.y += menuHeightWithInset
|
messageFrame.origin.y += menuHeightWithInset
|
||||||
}
|
}
|
||||||
@ -732,17 +747,26 @@ final class ChatSendMessageActionSheetControllerNode: ViewControllerTracingNode,
|
|||||||
let clipFrame = messageFrame
|
let clipFrame = messageFrame
|
||||||
transition.updateFrame(node: self.messageClipNode, frame: clipFrame)
|
transition.updateFrame(node: self.messageClipNode, frame: clipFrame)
|
||||||
|
|
||||||
let backgroundFrame = CGRect(origin: CGPoint(), size: messageFrame.size)
|
var backgroundFrame = CGRect(origin: CGPoint(), size: messageFrame.size)
|
||||||
|
backgroundFrame.origin.y -= messageHeightAddition * 0.5
|
||||||
|
backgroundFrame.size.height += messageHeightAddition
|
||||||
transition.updateFrame(node: self.messageBackgroundNode, frame: backgroundFrame)
|
transition.updateFrame(node: self.messageBackgroundNode, frame: backgroundFrame)
|
||||||
|
|
||||||
var textFrame = self.textFieldFrame
|
var textFrame = self.textFieldFrame
|
||||||
textFrame.origin = CGPoint(x: 13.0, y: 6.0 - UIScreenPixel)
|
textFrame.origin = CGPoint(x: 13.0, y: 6.0 - UIScreenPixel)
|
||||||
textFrame.size.height = self.textInputView.contentSize.height
|
textFrame.size.height = self.textInputView.contentSize.height
|
||||||
|
|
||||||
if let textInputView = self.textInputView as? ChatInputTextView {
|
if let textInputView = self.textInputView as? ChatInputTextView {
|
||||||
|
textFrame.origin.y -= 5.0
|
||||||
|
|
||||||
|
self.fromMessageTextNode.textView.defaultTextContainerInset = textInputView.defaultTextContainerInset
|
||||||
|
self.toMessageTextNode.textView.defaultTextContainerInset = textInputView.defaultTextContainerInset
|
||||||
|
}
|
||||||
|
/*if let textInputView = self.textInputView as? ChatInputTextView {
|
||||||
textFrame.size.width -= textInputView.defaultTextContainerInset.right
|
textFrame.size.width -= textInputView.defaultTextContainerInset.right
|
||||||
} else {
|
} else {
|
||||||
textFrame.size.width -= self.textInputView.textContainerInset.right
|
textFrame.size.width -= self.textInputView.textContainerInset.right
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if self.textInputView.isRTL {
|
if self.textInputView.isRTL {
|
||||||
textFrame.origin.x -= messageOriginDelta
|
textFrame.origin.x -= messageOriginDelta
|
||||||
|
|||||||
@ -553,6 +553,8 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll
|
|||||||
return false
|
return false
|
||||||
} else if let _ = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] as? String {
|
} else if let _ = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] as? String {
|
||||||
return false
|
return false
|
||||||
|
} else if let _ = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.Timecode)] {
|
||||||
|
return false
|
||||||
} else if let _ = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention)] as? TelegramPeerMention {
|
} else if let _ = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention)] as? TelegramPeerMention {
|
||||||
return false
|
return false
|
||||||
} else if let _ = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerTextMention)] as? String {
|
} else if let _ = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerTextMention)] as? String {
|
||||||
|
|||||||
@ -319,6 +319,9 @@ public final class ChatInputTextView: ChatInputTextViewImpl, NSLayoutManagerDele
|
|||||||
private let measurementTextStorage: NSTextStorage
|
private let measurementTextStorage: NSTextStorage
|
||||||
private let measurementLayoutManager: NSLayoutManager
|
private let measurementLayoutManager: NSLayoutManager
|
||||||
|
|
||||||
|
private var validLayoutSize: CGSize?
|
||||||
|
private var isUpdatingLayout: Bool = false
|
||||||
|
|
||||||
private var blockQuotes: [Int: QuoteBackgroundView] = [:]
|
private var blockQuotes: [Int: QuoteBackgroundView] = [:]
|
||||||
|
|
||||||
public var defaultTextContainerInset: UIEdgeInsets = UIEdgeInsets() {
|
public var defaultTextContainerInset: UIEdgeInsets = UIEdgeInsets() {
|
||||||
@ -346,6 +349,12 @@ public final class ChatInputTextView: ChatInputTextViewImpl, NSLayoutManagerDele
|
|||||||
return super.textInputMode
|
return super.textInputMode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override public var bounds: CGRect {
|
||||||
|
didSet {
|
||||||
|
assert(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public init() {
|
public init() {
|
||||||
self.customTextContainer = ChatInputTextContainer(size: CGSize(width: 100.0, height: 100000.0))
|
self.customTextContainer = ChatInputTextContainer(size: CGSize(width: 100.0, height: 100000.0))
|
||||||
self.customLayoutManager = NSLayoutManager()
|
self.customLayoutManager = NSLayoutManager()
|
||||||
@ -407,6 +416,20 @@ public final class ChatInputTextView: ChatInputTextViewImpl, NSLayoutManagerDele
|
|||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override public func scrollRectToVisible(_ rect: CGRect, animated: Bool) {
|
||||||
|
var rect = rect
|
||||||
|
if rect.maxY > self.contentSize.height - 8.0 {
|
||||||
|
rect = CGRect(origin: CGPoint(x: rect.minX, y: self.contentSize.height - 1.0), size: CGSize(width: rect.width, height: 1.0))
|
||||||
|
}
|
||||||
|
|
||||||
|
var animated = animated
|
||||||
|
if self.isUpdatingLayout {
|
||||||
|
animated = false
|
||||||
|
}
|
||||||
|
|
||||||
|
super.scrollRectToVisible(rect, animated: animated)
|
||||||
|
}
|
||||||
|
|
||||||
@objc public func layoutManager(_ layoutManager: NSLayoutManager, paragraphSpacingBeforeGlyphAt glyphIndex: Int, withProposedLineFragmentRect rect: CGRect) -> CGFloat {
|
@objc public func layoutManager(_ layoutManager: NSLayoutManager, paragraphSpacingBeforeGlyphAt glyphIndex: Int, withProposedLineFragmentRect rect: CGRect) -> CGFloat {
|
||||||
guard let textStorage = layoutManager.textStorage else {
|
guard let textStorage = layoutManager.textStorage else {
|
||||||
return 0.0
|
return 0.0
|
||||||
@ -536,7 +559,14 @@ public final class ChatInputTextView: ChatInputTextViewImpl, NSLayoutManagerDele
|
|||||||
}
|
}
|
||||||
|
|
||||||
override public func layoutSubviews() {
|
override public func layoutSubviews() {
|
||||||
|
let isLayoutUpdated = self.validLayoutSize != self.bounds.size
|
||||||
|
self.validLayoutSize = self.bounds.size
|
||||||
|
|
||||||
|
self.isUpdatingLayout = isLayoutUpdated
|
||||||
|
|
||||||
super.layoutSubviews()
|
super.layoutSubviews()
|
||||||
|
|
||||||
|
self.isUpdatingLayout = false
|
||||||
}
|
}
|
||||||
|
|
||||||
public func updateTextElements() {
|
public func updateTextElements() {
|
||||||
|
|||||||
@ -2284,7 +2284,8 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate, Ch
|
|||||||
textInputNode.textContainerInset = textInputViewRealInsets
|
textInputNode.textContainerInset = textInputViewRealInsets
|
||||||
let textFieldFrame = CGRect(origin: CGPoint(x: self.textInputViewInternalInsets.left, y: self.textInputViewInternalInsets.top), size: CGSize(width: textInputFrame.size.width - (self.textInputViewInternalInsets.left + self.textInputViewInternalInsets.right), height: textInputFrame.size.height - self.textInputViewInternalInsets.top - textInputViewInternalInsets.bottom))
|
let textFieldFrame = CGRect(origin: CGPoint(x: self.textInputViewInternalInsets.left, y: self.textInputViewInternalInsets.top), size: CGSize(width: textInputFrame.size.width - (self.textInputViewInternalInsets.left + self.textInputViewInternalInsets.right), height: textInputFrame.size.height - self.textInputViewInternalInsets.top - textInputViewInternalInsets.bottom))
|
||||||
let shouldUpdateLayout = textFieldFrame.size != textInputNode.frame.size
|
let shouldUpdateLayout = textFieldFrame.size != textInputNode.frame.size
|
||||||
transition.updateFrame(node: textInputNode, frame: textFieldFrame)
|
//transition.updateFrame(node: textInputNode, frame: textFieldFrame)
|
||||||
|
textInputNode.frame = textFieldFrame
|
||||||
textInputNode.updateLayout(size: textFieldFrame.size)
|
textInputNode.updateLayout(size: textFieldFrame.size)
|
||||||
self.updateInputField(textInputFrame: textFieldFrame, transition: Transition(transition))
|
self.updateInputField(textInputFrame: textFieldFrame, transition: Transition(transition))
|
||||||
if shouldUpdateLayout {
|
if shouldUpdateLayout {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user