Swiftgram/submodules/InstantPageUI/Sources/InstantPageSlideshowItem.swift
2023-04-19 23:47:38 +04:00

59 lines
2.2 KiB
Swift

import Foundation
import UIKit
import TelegramCore
import AsyncDisplayKit
import TelegramPresentationData
import TelegramUIPreferences
import AccountContext
import ContextUI
final class InstantPageSlideshowItem: InstantPageItem {
var frame: CGRect
let webPage: TelegramMediaWebpage
let wantsNode: Bool = true
let separatesTiles: Bool = false
let medias: [InstantPageMedia]
init(frame: CGRect, webPage: TelegramMediaWebpage, medias: [InstantPageMedia]) {
self.frame = frame
self.webPage = webPage
self.medias = medias
}
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]?) -> InstantPageNode? {
return InstantPageSlideshowNode(context: context, sourceLocation: sourceLocation, theme: theme, webPage: webPage, medias: self.medias, openMedia: openMedia, longPressMedia: longPressMedia, activatePinchPreview: activatePinchPreview, pinchPreviewFinished: pinchPreviewFinished)
}
func matchesAnchor(_ anchor: String) -> Bool {
return false
}
func matchesNode(_ node: InstantPageNode) -> Bool {
if let node = node as? InstantPageSlideshowNode {
return self.medias == node.medias
} else {
return false
}
}
func distanceThresholdGroup() -> Int? {
return 3
}
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) {
}
}