Swiftgram/submodules/InstantPageUI/Sources/InstantPagePlayableVideoItem.swift
2024-08-29 11:44:05 +04:00

67 lines
2.4 KiB
Swift

import Foundation
import UIKit
import TelegramCore
import AsyncDisplayKit
import TelegramPresentationData
import TelegramUIPreferences
import AccountContext
import ContextUI
public final class InstantPagePlayableVideoItem: InstantPageItem {
public var frame: CGRect
let webPage: TelegramMediaWebpage
let media: InstantPageMedia
public var medias: [InstantPageMedia] {
return [self.media]
}
public let interactive: Bool
public let wantsNode: Bool = true
public let separatesTiles: Bool = false
init(frame: CGRect, webPage: TelegramMediaWebpage, media: InstantPageMedia, interactive: Bool) {
self.frame = frame
self.webPage = webPage
self.media = media
self.interactive = interactive
}
public func node(context: AccountContext, strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder, theme: InstantPageTheme, sourceLocation: InstantPageSourceLocation, openMedia: @escaping (InstantPageMedia) -> Void, longPressMedia: @escaping (InstantPageMedia) -> Void, activatePinchPreview: ((PinchSourceContainerNode) -> Void)?, pinchPreviewFinished: ((InstantPageNode) -> Void)?, openPeer: @escaping (EnginePeer) -> Void, openUrl: @escaping (InstantPageUrlItem) -> Void, updateWebEmbedHeight: @escaping (CGFloat) -> Void, updateDetailsExpanded: @escaping (Bool) -> Void, currentExpandedDetails: [Int : Bool]?, getPreloadedResource: @escaping (String) -> Data?) -> InstantPageNode? {
return InstantPagePlayableVideoNode(context: context, userLocation: sourceLocation.userLocation, webPage: self.webPage, theme: theme, media: self.media, interactive: self.interactive, openMedia: openMedia)
}
public func matchesAnchor(_ anchor: String) -> Bool {
return false
}
public func matchesNode(_ node: InstantPageNode) -> Bool {
if let node = node as? InstantPagePlayableVideoNode {
return node.media == self.media
} else {
return false
}
}
public func distanceThresholdGroup() -> Int? {
return 2
}
public func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat {
if count > 3 {
return 200.0
} else {
return CGFloat.greatestFiniteMagnitude
}
}
public func drawInTile(context: CGContext) {
}
public func linkSelectionRects(at point: CGPoint) -> [CGRect] {
return []
}
}