mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
63 lines
2.2 KiB
Swift
63 lines
2.2 KiB
Swift
import Foundation
|
|
import UIKit
|
|
import Postbox
|
|
import TelegramCore
|
|
import AsyncDisplayKit
|
|
import TelegramPresentationData
|
|
import TelegramUIPreferences
|
|
import AccountContext
|
|
import ContextUI
|
|
|
|
final class InstantPageWebEmbedItem: InstantPageItem {
|
|
var frame: CGRect
|
|
let wantsNode: Bool = true
|
|
let separatesTiles: Bool = false
|
|
let medias: [InstantPageMedia] = []
|
|
|
|
let url: String?
|
|
let html: String?
|
|
let enableScrolling: Bool
|
|
|
|
init(frame: CGRect, url: String?, html: String?, enableScrolling: Bool) {
|
|
self.frame = frame
|
|
self.url = url
|
|
self.html = html
|
|
self.enableScrolling = enableScrolling
|
|
}
|
|
|
|
func node(context: AccountContext, strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder, theme: InstantPageTheme, sourcePeerType: MediaAutoDownloadPeerType, openMedia: @escaping (InstantPageMedia) -> Void, longPressMedia: @escaping (InstantPageMedia) -> Void, activatePinchPreview: ((PinchSourceContainerNode) -> Void)?, pinchPreviewFinished: ((InstantPageNode) -> Void)?, openPeer: @escaping (PeerId) -> Void, openUrl: @escaping (InstantPageUrlItem) -> Void, updateWebEmbedHeight: @escaping (CGFloat) -> Void, updateDetailsExpanded: @escaping (Bool) -> Void, currentExpandedDetails: [Int : Bool]?) -> InstantPageNode? {
|
|
return InstantPageWebEmbedNode(frame: self.frame, url: self.url, html: self.html, enableScrolling: self.enableScrolling, updateWebEmbedHeight: updateWebEmbedHeight)
|
|
}
|
|
|
|
func matchesAnchor(_ anchor: String) -> Bool {
|
|
return false
|
|
}
|
|
|
|
func matchesNode(_ node: InstantPageNode) -> Bool {
|
|
if let node = node as? InstantPageWebEmbedNode {
|
|
return self.url == node.url && self.html == node.html
|
|
} else {
|
|
return false
|
|
}
|
|
}
|
|
|
|
func distanceThresholdGroup() -> Int? {
|
|
return 6
|
|
}
|
|
|
|
func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat {
|
|
if count > 3 {
|
|
return 1000.0
|
|
} else {
|
|
return CGFloat.greatestFiniteMagnitude
|
|
}
|
|
}
|
|
|
|
func linkSelectionRects(at point: CGPoint) -> [CGRect] {
|
|
return []
|
|
}
|
|
|
|
func drawInTile(context: CGContext) {
|
|
}
|
|
}
|