mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-04 13:38:21 +00:00
Merge commit 'f6e83ca5b1f4c0d05392bbada1108b189d8d493a'
This commit is contained in:
commit
a154aae943
@ -1070,7 +1070,7 @@ public class TextNode: ASDisplayNode {
|
||||
|
||||
var headIndent: CGFloat = 0.0
|
||||
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 descent: CGFloat = 0.0
|
||||
CTLineGetTypographicBounds(coreTextLine, &ascent, &descent, nil)
|
||||
@ -1151,7 +1151,7 @@ public class TextNode: ASDisplayNode {
|
||||
|
||||
var headIndent: CGFloat = 0.0
|
||||
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 descent: CGFloat = 0.0
|
||||
CTLineGetTypographicBounds(coreTextLine, &ascent, &descent, nil)
|
||||
|
||||
@ -101,6 +101,9 @@ class CaptionScrollWrapperNode: ASDisplayNode {
|
||||
if let subnodes = subnode.subnodes {
|
||||
for node in subnodes.reversed() {
|
||||
if node.frame.contains(convertedPoint) && node.isUserInteractionEnabled {
|
||||
if let dustNode = node as? InvisibleInkDustNode, dustNode.isRevealed {
|
||||
continue
|
||||
}
|
||||
return node.view
|
||||
}
|
||||
}
|
||||
@ -885,7 +888,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll
|
||||
transition.updateBounds(layer: scrubberView.layer, bounds: CGRect(origin: CGPoint(), size: scrubberFrame.size))
|
||||
transition.updatePosition(layer: scrubberView.layer, position: CGPoint(x: scrubberFrame.midX, y: scrubberFrame.midY))
|
||||
}
|
||||
transition.updateAlpha(node: self.textNode, alpha: displayCaption ? 1.0 : 0.0)
|
||||
transition.updateAlpha(node: self.scrollWrapperNode, alpha: displayCaption ? 1.0 : 0.0)
|
||||
|
||||
self.actionButton.frame = CGRect(origin: CGPoint(x: leftInset, y: panelHeight - bottomInset - 44.0), size: CGSize(width: 44.0, height: 44.0))
|
||||
|
||||
|
||||
@ -171,7 +171,7 @@ final class ChatVideoGalleryItemScrubberView: UIView {
|
||||
if let mappedStatus = mappedStatus {
|
||||
self.chapterDisposable.set((mappedStatus
|
||||
|> deliverOnMainQueue).start(next: { [weak self] status in
|
||||
if let strongSelf = self, status.duration > 1.0 {
|
||||
if let strongSelf = self, status.duration > 1.0, strongSelf.chapters.count > 0 {
|
||||
var text: String = ""
|
||||
|
||||
for chapter in strongSelf.chapters {
|
||||
@ -230,7 +230,7 @@ final class ChatVideoGalleryItemScrubberView: UIView {
|
||||
if let fetchStatus = fetchStatus {
|
||||
self.fetchStatusDisposable.set((fetchStatus
|
||||
|> deliverOnMainQueue).start(next: { [weak self] status in
|
||||
if let strongSelf = self {
|
||||
if let strongSelf = self, strongSelf.chapters.isEmpty {
|
||||
var text: String
|
||||
switch status {
|
||||
case .Remote:
|
||||
@ -247,10 +247,10 @@ final class ChatVideoGalleryItemScrubberView: UIView {
|
||||
}
|
||||
}
|
||||
}))
|
||||
} else {
|
||||
} else if self.chapters.isEmpty {
|
||||
self.infoNode.attributedText = NSAttributedString(string: dataSizeString(fileSize, forceDecimal: true, formatting: formatting), font: textFont, textColor: .white)
|
||||
}
|
||||
} else {
|
||||
} else if self.chapters.isEmpty {
|
||||
self.infoNode.attributedText = nil
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,8 +245,6 @@ public class InvisibleInkDustNode: ASDisplayNode {
|
||||
}
|
||||
property?.writeBlock = { node, values in
|
||||
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).updateEmitter()
|
||||
}
|
||||
|
||||
@ -123,6 +123,7 @@ class PeerSelectionTextInputPanelNode: ChatInputPanelNode, TGCaptionPanelView, A
|
||||
var textInputNode: CaptionEditableTextNode?
|
||||
var dustNode: InvisibleInkDustNode?
|
||||
private var oneLineNode: ImmediateTextNode
|
||||
private var oneLineDustNode: InvisibleInkDustNode?
|
||||
|
||||
let textInputBackgroundNode: ASDisplayNode
|
||||
let textInputBackgroundImageNode: ASImageNode
|
||||
@ -633,17 +634,23 @@ class PeerSelectionTextInputPanelNode: ChatInputPanelNode, TGCaptionPanelView, A
|
||||
panelHeight = minimalHeight
|
||||
|
||||
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 {
|
||||
transition.updateAlpha(node: textInputNode, alpha: inputHasText ? 0.0 : 1.0)
|
||||
}
|
||||
} else {
|
||||
self.oneLineNode.alpha = 0.0
|
||||
self.oneLineDustNode?.alpha = 0.0
|
||||
self.textInputNode?.alpha = 1.0
|
||||
}
|
||||
|
||||
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)
|
||||
self.oneLineNode.frame = oneLineFrame
|
||||
|
||||
self.updateOneLineSpoiler()
|
||||
}
|
||||
self.textPlaceholderNode.isHidden = inputHasText
|
||||
|
||||
@ -845,6 +852,8 @@ class PeerSelectionTextInputPanelNode: ChatInputPanelNode, TGCaptionPanelView, A
|
||||
let accentTextColor = presentationInterfaceState.theme.chat.inputPanel.panelControlAccentColor
|
||||
let baseFontSize = max(minInputFontSize, presentationInterfaceState.fontSize.baseDisplaySize)
|
||||
|
||||
textInputNode.textView.isScrollEnabled = false
|
||||
|
||||
refreshChatTextInputAttributes(textInputNode, theme: presentationInterfaceState.theme, baseFontSize: baseFontSize, spoilersRevealed: self.spoilersRevealed)
|
||||
|
||||
textInputNode.attributedText = textAttributedStringForStateText(self.inputTextState.inputText, fontSize: baseFontSize, textColor: textColor, accentTextColor: accentTextColor, writingDirection: nil, spoilersRevealed: self.spoilersRevealed)
|
||||
@ -853,14 +862,22 @@ class PeerSelectionTextInputPanelNode: ChatInputPanelNode, TGCaptionPanelView, A
|
||||
let containerView = textInputNode.textView.subviews[1]
|
||||
if let canvasView = containerView.subviews.first {
|
||||
if let snapshotView = canvasView.snapshotView(afterScreenUpdates: false) {
|
||||
snapshotView.frame = canvasView.frame.offsetBy(dx: 0.0, dy: -textInputNode.textView.contentOffset.y)
|
||||
textInputNode.view.insertSubview(snapshotView, at: 0)
|
||||
canvasView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
|
||||
snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false, completion: { [weak snapshotView] _ in
|
||||
snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false, completion: { [weak snapshotView, weak textInputNode] _ in
|
||||
textInputNode?.textView.isScrollEnabled = false
|
||||
snapshotView?.removeFromSuperview()
|
||||
Queue.mainQueue().after(0.1) {
|
||||
textInputNode?.textView.isScrollEnabled = true
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
Queue.mainQueue().after(0.1) {
|
||||
textInputNode.textView.isScrollEnabled = true
|
||||
}
|
||||
|
||||
if animated {
|
||||
if revealed {
|
||||
@ -925,13 +942,19 @@ class PeerSelectionTextInputPanelNode: ChatInputPanelNode, TGCaptionPanelView, A
|
||||
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")
|
||||
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)))
|
||||
trimmedText.append(NSAttributedString(string: "\u{2026}", font: textFont, textColor: textColor))
|
||||
|
||||
self.oneLineNode.attributedText = trimmedText
|
||||
} else {
|
||||
self.oneLineNode.attributedText = attributedText
|
||||
@ -943,6 +966,28 @@ class PeerSelectionTextInputPanelNode: ChatInputPanelNode, TGCaptionPanelView, A
|
||||
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) {
|
||||
if let (width, leftInset, rightInset, additionalSideInsets, maxHeight, metrics, _) = self.validLayout {
|
||||
let (_, textFieldHeight) = self.calculateTextFieldMetrics(width: width - leftInset - rightInset - additionalSideInsets.right, maxHeight: maxHeight, metrics: metrics)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user