mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various Fixes
This commit is contained in:
parent
31ee543790
commit
4cb8d4320c
@ -1070,7 +1070,7 @@ public class TextNode: ASDisplayNode {
|
|||||||
|
|
||||||
var headIndent: CGFloat = 0.0
|
var headIndent: CGFloat = 0.0
|
||||||
attributedString.enumerateAttributes(in: NSMakeRange(brokenLineRange.location, brokenLineRange.length), options: []) { attributes, range, _ in
|
attributedString.enumerateAttributes(in: NSMakeRange(brokenLineRange.location, brokenLineRange.length), options: []) { attributes, range, _ in
|
||||||
if let _ = attributes[NSAttributedString.Key.init(rawValue: "TelegramSpoiler")] {
|
if attributes[NSAttributedString.Key(rawValue: "TelegramSpoiler")] != nil || attributes[NSAttributedString.Key(rawValue: "Attribute__Spoiler")] != nil {
|
||||||
var ascent: CGFloat = 0.0
|
var ascent: CGFloat = 0.0
|
||||||
var descent: CGFloat = 0.0
|
var descent: CGFloat = 0.0
|
||||||
CTLineGetTypographicBounds(coreTextLine, &ascent, &descent, nil)
|
CTLineGetTypographicBounds(coreTextLine, &ascent, &descent, nil)
|
||||||
@ -1151,7 +1151,7 @@ public class TextNode: ASDisplayNode {
|
|||||||
|
|
||||||
var headIndent: CGFloat = 0.0
|
var headIndent: CGFloat = 0.0
|
||||||
attributedString.enumerateAttributes(in: NSMakeRange(lineRange.location, lineRange.length), options: []) { attributes, range, _ in
|
attributedString.enumerateAttributes(in: NSMakeRange(lineRange.location, lineRange.length), options: []) { attributes, range, _ in
|
||||||
if let _ = attributes[NSAttributedString.Key.init(rawValue: "TelegramSpoiler")] {
|
if attributes[NSAttributedString.Key(rawValue: "TelegramSpoiler")] != nil || attributes[NSAttributedString.Key(rawValue: "Attribute__Spoiler")] != nil {
|
||||||
var ascent: CGFloat = 0.0
|
var ascent: CGFloat = 0.0
|
||||||
var descent: CGFloat = 0.0
|
var descent: CGFloat = 0.0
|
||||||
CTLineGetTypographicBounds(coreTextLine, &ascent, &descent, nil)
|
CTLineGetTypographicBounds(coreTextLine, &ascent, &descent, nil)
|
||||||
|
@ -101,6 +101,9 @@ class CaptionScrollWrapperNode: ASDisplayNode {
|
|||||||
if let subnodes = subnode.subnodes {
|
if let subnodes = subnode.subnodes {
|
||||||
for node in subnodes.reversed() {
|
for node in subnodes.reversed() {
|
||||||
if node.frame.contains(convertedPoint) && node.isUserInteractionEnabled {
|
if node.frame.contains(convertedPoint) && node.isUserInteractionEnabled {
|
||||||
|
if let dustNode = node as? InvisibleInkDustNode, dustNode.isRevealed {
|
||||||
|
continue
|
||||||
|
}
|
||||||
return node.view
|
return node.view
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,8 +245,6 @@ public class InvisibleInkDustNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
property?.writeBlock = { node, values in
|
property?.writeBlock = { node, values in
|
||||||
if let values = values, let color = CGColor(colorSpace: colorSpace, components: values) {
|
if let values = values, let color = CGColor(colorSpace: colorSpace, components: values) {
|
||||||
let uicolor = UIColor(cgColor: color)
|
|
||||||
print(uicolor)
|
|
||||||
(node as! InvisibleInkDustNode).animColor = color
|
(node as! InvisibleInkDustNode).animColor = color
|
||||||
(node as! InvisibleInkDustNode).updateEmitter()
|
(node as! InvisibleInkDustNode).updateEmitter()
|
||||||
}
|
}
|
||||||
|
@ -123,6 +123,7 @@ class PeerSelectionTextInputPanelNode: ChatInputPanelNode, TGCaptionPanelView, A
|
|||||||
var textInputNode: CaptionEditableTextNode?
|
var textInputNode: CaptionEditableTextNode?
|
||||||
var dustNode: InvisibleInkDustNode?
|
var dustNode: InvisibleInkDustNode?
|
||||||
private var oneLineNode: ImmediateTextNode
|
private var oneLineNode: ImmediateTextNode
|
||||||
|
private var oneLineDustNode: InvisibleInkDustNode?
|
||||||
|
|
||||||
let textInputBackgroundNode: ASDisplayNode
|
let textInputBackgroundNode: ASDisplayNode
|
||||||
let textInputBackgroundImageNode: ASImageNode
|
let textInputBackgroundImageNode: ASImageNode
|
||||||
@ -633,17 +634,23 @@ class PeerSelectionTextInputPanelNode: ChatInputPanelNode, TGCaptionPanelView, A
|
|||||||
panelHeight = minimalHeight
|
panelHeight = minimalHeight
|
||||||
|
|
||||||
transition.updateAlpha(node: self.oneLineNode, alpha: inputHasText ? 1.0 : 0.0)
|
transition.updateAlpha(node: self.oneLineNode, alpha: inputHasText ? 1.0 : 0.0)
|
||||||
|
if let oneLineDustNode = self.oneLineDustNode {
|
||||||
|
transition.updateAlpha(node: oneLineDustNode, alpha: inputHasText ? 1.0 : 0.0)
|
||||||
|
}
|
||||||
if let textInputNode = self.textInputNode {
|
if let textInputNode = self.textInputNode {
|
||||||
transition.updateAlpha(node: textInputNode, alpha: inputHasText ? 0.0 : 1.0)
|
transition.updateAlpha(node: textInputNode, alpha: inputHasText ? 0.0 : 1.0)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.oneLineNode.alpha = 0.0
|
self.oneLineNode.alpha = 0.0
|
||||||
|
self.oneLineDustNode?.alpha = 0.0
|
||||||
self.textInputNode?.alpha = 1.0
|
self.textInputNode?.alpha = 1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
let oneLineSize = self.oneLineNode.updateLayout(CGSize(width: baseWidth - textFieldInsets.left - textFieldInsets.right, height: CGFloat.greatestFiniteMagnitude))
|
let oneLineSize = self.oneLineNode.updateLayout(CGSize(width: baseWidth - textFieldInsets.left - textFieldInsets.right, height: CGFloat.greatestFiniteMagnitude))
|
||||||
let oneLineFrame = CGRect(origin: CGPoint(x: leftInset + textFieldInsets.left + self.textInputViewInternalInsets.left, y: textFieldInsets.top + self.textInputViewInternalInsets.top + textInputViewRealInsets.top + UIScreenPixel), size: oneLineSize)
|
let oneLineFrame = CGRect(origin: CGPoint(x: leftInset + textFieldInsets.left + self.textInputViewInternalInsets.left, y: textFieldInsets.top + self.textInputViewInternalInsets.top + textInputViewRealInsets.top + UIScreenPixel), size: oneLineSize)
|
||||||
self.oneLineNode.frame = oneLineFrame
|
self.oneLineNode.frame = oneLineFrame
|
||||||
|
|
||||||
|
self.updateOneLineSpoiler()
|
||||||
}
|
}
|
||||||
self.textPlaceholderNode.isHidden = inputHasText
|
self.textPlaceholderNode.isHidden = inputHasText
|
||||||
|
|
||||||
@ -925,13 +932,19 @@ class PeerSelectionTextInputPanelNode: ChatInputPanelNode, TGCaptionPanelView, A
|
|||||||
self.textPlaceholderNode.isHidden = inputHasText
|
self.textPlaceholderNode.isHidden = inputHasText
|
||||||
}
|
}
|
||||||
|
|
||||||
if let attributedText = self.textInputNode?.attributedText, let presentationInterfaceState = self.presentationInterfaceState {
|
if let presentationInterfaceState = self.presentationInterfaceState {
|
||||||
|
let textColor = presentationInterfaceState.theme.chat.inputPanel.inputTextColor
|
||||||
|
let baseFontSize = max(minInputFontSize, presentationInterfaceState.fontSize.baseDisplaySize)
|
||||||
|
let textFont = Font.regular(baseFontSize)
|
||||||
|
let accentTextColor = presentationInterfaceState.theme.chat.inputPanel.panelControlAccentColor
|
||||||
|
|
||||||
|
let attributedText = textAttributedStringForStateText(self.inputTextState.inputText, fontSize: baseFontSize, textColor: textColor, accentTextColor: accentTextColor, writingDirection: nil, spoilersRevealed: false)
|
||||||
|
|
||||||
let range = (attributedText.string as NSString).range(of: "\n")
|
let range = (attributedText.string as NSString).range(of: "\n")
|
||||||
if range.location != NSNotFound {
|
if range.location != NSNotFound {
|
||||||
let textColor = presentationInterfaceState.theme.chat.inputPanel.inputTextColor
|
|
||||||
let textFont = Font.regular(max(minInputFontSize, presentationInterfaceState.fontSize.baseDisplaySize))
|
|
||||||
let trimmedText = NSMutableAttributedString(attributedString: attributedText.attributedSubstring(from: NSMakeRange(0, range.location)))
|
let trimmedText = NSMutableAttributedString(attributedString: attributedText.attributedSubstring(from: NSMakeRange(0, range.location)))
|
||||||
trimmedText.append(NSAttributedString(string: "\u{2026}", font: textFont, textColor: textColor))
|
trimmedText.append(NSAttributedString(string: "\u{2026}", font: textFont, textColor: textColor))
|
||||||
|
|
||||||
self.oneLineNode.attributedText = trimmedText
|
self.oneLineNode.attributedText = trimmedText
|
||||||
} else {
|
} else {
|
||||||
self.oneLineNode.attributedText = attributedText
|
self.oneLineNode.attributedText = attributedText
|
||||||
@ -943,6 +956,28 @@ class PeerSelectionTextInputPanelNode: ChatInputPanelNode, TGCaptionPanelView, A
|
|||||||
self.updateTextHeight(animated: animated)
|
self.updateTextHeight(animated: animated)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func updateOneLineSpoiler() {
|
||||||
|
if let textLayout = self.oneLineNode.cachedLayout, !textLayout.spoilers.isEmpty {
|
||||||
|
if self.oneLineDustNode == nil {
|
||||||
|
let oneLineDustNode = InvisibleInkDustNode(textNode: nil)
|
||||||
|
self.oneLineDustNode = oneLineDustNode
|
||||||
|
self.oneLineNode.supernode?.insertSubnode(oneLineDustNode, aboveSubnode: self.oneLineNode)
|
||||||
|
|
||||||
|
}
|
||||||
|
if let oneLineDustNode = self.oneLineDustNode {
|
||||||
|
let textFrame = self.oneLineNode.frame.insetBy(dx: 0.0, dy: -3.0)
|
||||||
|
|
||||||
|
oneLineDustNode.update(size: textFrame.size, color: .white, rects: textLayout.spoilers.map { $0.1.offsetBy(dx: 0.0, dy: 3.0) }, wordRects: textLayout.spoilerWords.map { $0.1.offsetBy(dx: 0.0, dy: 3.0) })
|
||||||
|
oneLineDustNode.frame = textFrame
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if let oneLineDustNode = self.oneLineDustNode {
|
||||||
|
self.oneLineDustNode = nil
|
||||||
|
oneLineDustNode.removeFromSupernode()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func updateTextHeight(animated: Bool) {
|
private func updateTextHeight(animated: Bool) {
|
||||||
if let (width, leftInset, rightInset, additionalSideInsets, maxHeight, metrics, _) = self.validLayout {
|
if let (width, leftInset, rightInset, additionalSideInsets, maxHeight, metrics, _) = self.validLayout {
|
||||||
let (_, textFieldHeight) = self.calculateTextFieldMetrics(width: width - leftInset - rightInset - additionalSideInsets.right, maxHeight: maxHeight, metrics: metrics)
|
let (_, textFieldHeight) = self.calculateTextFieldMetrics(width: width - leftInset - rightInset - additionalSideInsets.right, maxHeight: maxHeight, metrics: metrics)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user