mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-07 01:10:09 +00:00
Various improvements
This commit is contained in:
parent
ae3d0be81f
commit
526f09aff7
@ -2950,8 +2950,9 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
||||
offset = (self.visibleSize.height - insets.bottom) - itemNode.apparentFrame.maxY
|
||||
case let .custom(getOverflow):
|
||||
let overflow = getOverflow(itemNode)
|
||||
offset = (self.visibleSize.height - insets.bottom) - itemNode.apparentFrame.maxY
|
||||
offset += floor(overflow - (self.visibleSize.height - insets.bottom - insets.top) * 0.5)
|
||||
offset = (self.visibleSize.height - insets.bottom) - itemNode.apparentFrame.maxY + itemNode.insets.top
|
||||
offset += overflow
|
||||
offset += 0.0 * floor(overflow - (self.visibleSize.height - insets.bottom - insets.top) * 0.5)
|
||||
//offset += 100.0
|
||||
|
||||
//offset = (self.visibleSize.height - insets.bottom) - itemNode.apparentFrame.maxY + getOverflow(itemNode)
|
||||
|
||||
@ -38,6 +38,18 @@ private func rtfStringWithAppliedEntities(_ text: String, entities: [MessageText
|
||||
}
|
||||
}
|
||||
|
||||
struct AppSpecificPasteboardString: Codable {
|
||||
var text: String
|
||||
var entities: [MessageTextEntity]
|
||||
}
|
||||
|
||||
private func appSpecificStringWithAppliedEntities(_ text: String, entities: [MessageTextEntity]) -> Data {
|
||||
guard let data = try? JSONEncoder().encode(AppSpecificPasteboardString(text: text, entities: entities)) else {
|
||||
return Data()
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
private func chatInputStateString(attributedString: NSAttributedString) -> NSAttributedString? {
|
||||
let string = NSMutableAttributedString(string: attributedString.string)
|
||||
attributedString.enumerateAttributes(in: NSRange(location: 0, length: attributedString.length), options: [], using: { attributes, range, _ in
|
||||
@ -100,12 +112,20 @@ public func chatInputStateStringFromRTF(_ data: Data, type: NSAttributedString.D
|
||||
return nil
|
||||
}
|
||||
|
||||
public func chatInputStateStringFromAppSpecificString(data: Data) -> NSAttributedString? {
|
||||
guard let string = try? JSONDecoder().decode(AppSpecificPasteboardString.self, from: data) else {
|
||||
return nil
|
||||
}
|
||||
return chatInputStateStringWithAppliedEntities(string.text, entities: string.entities)
|
||||
}
|
||||
|
||||
public func storeMessageTextInPasteboard(_ text: String, entities: [MessageTextEntity]?) {
|
||||
var items: [String: Any] = [:]
|
||||
items[kUTTypeUTF8PlainText as String] = text
|
||||
|
||||
if let entities = entities {
|
||||
items[kUTTypeRTF as String] = rtfStringWithAppliedEntities(text, entities: entities)
|
||||
items["private.telegramtext"] = appSpecificStringWithAppliedEntities(text, entities: entities)
|
||||
}
|
||||
UIPasteboard.general.items = [items]
|
||||
}
|
||||
|
||||
@ -722,8 +722,8 @@ public final class ChatMessageAttachedContentNode: ASDisplayNode {
|
||||
actualSize.height += textBottomSpacing
|
||||
|
||||
if let (_, inlineMediaSize) = inlineMediaAndSize {
|
||||
if actualSize.height < insets.top + inlineMediaEdgeInset + inlineMediaSize.height + inlineMediaEdgeInset {
|
||||
actualSize.height = insets.top + inlineMediaEdgeInset + inlineMediaSize.height + inlineMediaEdgeInset
|
||||
if actualSize.height < backgroundInsets.top + inlineMediaEdgeInset + inlineMediaSize.height + inlineMediaEdgeInset {
|
||||
actualSize.height = backgroundInsets.top + inlineMediaEdgeInset + inlineMediaSize.height + inlineMediaEdgeInset
|
||||
}
|
||||
}
|
||||
case .media:
|
||||
|
||||
@ -3920,7 +3920,9 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate, Ch
|
||||
let pasteboard = UIPasteboard.general
|
||||
|
||||
var attributedString: NSAttributedString?
|
||||
if let data = pasteboard.data(forPasteboardType: kUTTypeRTF as String) {
|
||||
if let data = pasteboard.data(forPasteboardType: "private.telegramtext"), let value = chatInputStateStringFromAppSpecificString(data: data) {
|
||||
attributedString = value
|
||||
} else if let data = pasteboard.data(forPasteboardType: kUTTypeRTF as String) {
|
||||
attributedString = chatInputStateStringFromRTF(data, type: NSAttributedString.DocumentType.rtf)
|
||||
} else if let data = pasteboard.data(forPasteboardType: "com.apple.flat-rtfd") {
|
||||
attributedString = chatInputStateStringFromRTF(data, type: NSAttributedString.DocumentType.rtfd)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user