diff --git a/submodules/InstantPageUI/Sources/InstantPageAnchorItem.swift b/submodules/InstantPageUI/Sources/InstantPageAnchorItem.swift index 5716720974..3fc1125c2a 100644 --- a/submodules/InstantPageUI/Sources/InstantPageAnchorItem.swift +++ b/submodules/InstantPageUI/Sources/InstantPageAnchorItem.swift @@ -8,43 +8,43 @@ import TelegramUIPreferences import AccountContext import ContextUI -final class InstantPageAnchorItem: InstantPageItem { - let wantsNode: Bool = false - let separatesTiles: Bool = false - let medias: [InstantPageMedia] = [] +public final class InstantPageAnchorItem: InstantPageItem { + public let wantsNode: Bool = false + public let separatesTiles: Bool = false + public let medias: [InstantPageMedia] = [] - let anchor: String - var frame: CGRect + public let anchor: String + public var frame: CGRect init(frame: CGRect, anchor: String) { self.frame = frame self.anchor = anchor } - func matchesAnchor(_ anchor: String) -> Bool { + public func matchesAnchor(_ anchor: String) -> Bool { return anchor == self.anchor } - func drawInTile(context: CGContext) { + public func drawInTile(context: CGContext) { } - 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? { + 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]?) -> InstantPageNode? { return nil } - func matchesNode(_ node: InstantPageNode) -> Bool { + public func matchesNode(_ node: InstantPageNode) -> Bool { return false } - func linkSelectionRects(at point: CGPoint) -> [CGRect] { + public func linkSelectionRects(at point: CGPoint) -> [CGRect] { return [] } - func distanceThresholdGroup() -> Int? { + public func distanceThresholdGroup() -> Int? { return nil } - func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat { + public func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat { return 0.0 } } diff --git a/submodules/InstantPageUI/Sources/InstantPageArticleItem.swift b/submodules/InstantPageUI/Sources/InstantPageArticleItem.swift index fb1b3f3f77..831d1082a1 100644 --- a/submodules/InstantPageUI/Sources/InstantPageArticleItem.swift +++ b/submodules/InstantPageUI/Sources/InstantPageArticleItem.swift @@ -8,11 +8,11 @@ import TelegramUIPreferences import AccountContext import ContextUI -final class InstantPageArticleItem: InstantPageItem { - var frame: CGRect - let wantsNode: Bool = true - let separatesTiles: Bool = false - let medias: [InstantPageMedia] = [] +public final class InstantPageArticleItem: InstantPageItem { + public var frame: CGRect + public let wantsNode: Bool = true + public let separatesTiles: Bool = false + public let medias: [InstantPageMedia] = [] let userLocation: MediaResourceUserLocation let webPage: TelegramMediaWebpage @@ -37,15 +37,15 @@ final class InstantPageArticleItem: InstantPageItem { self.hasRTL = hasRTL } - 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? { + 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]?) -> InstantPageNode? { return InstantPageArticleNode(context: context, item: self, webPage: self.webPage, strings: strings, theme: theme, contentItems: self.contentItems, contentSize: self.contentSize, cover: self.cover, url: self.url, webpageId: self.webpageId, openUrl: openUrl) } - func matchesAnchor(_ anchor: String) -> Bool { + public func matchesAnchor(_ anchor: String) -> Bool { return false } - func matchesNode(_ node: InstantPageNode) -> Bool { + public func matchesNode(_ node: InstantPageNode) -> Bool { if let node = node as? InstantPageArticleNode { return self === node.item } else { @@ -53,11 +53,11 @@ final class InstantPageArticleItem: InstantPageItem { } } - func distanceThresholdGroup() -> Int? { + public func distanceThresholdGroup() -> Int? { return 7 } - func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat { + public func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat { if count > 3 { return 1000.0 } else { @@ -65,10 +65,10 @@ final class InstantPageArticleItem: InstantPageItem { } } - func drawInTile(context: CGContext) { + public func drawInTile(context: CGContext) { } - func linkSelectionRects(at point: CGPoint) -> [CGRect] { + public func linkSelectionRects(at point: CGPoint) -> [CGRect] { return [] } } diff --git a/submodules/InstantPageUI/Sources/InstantPageAudioItem.swift b/submodules/InstantPageUI/Sources/InstantPageAudioItem.swift index 8a2ed3c11c..0d3005a60e 100644 --- a/submodules/InstantPageUI/Sources/InstantPageAudioItem.swift +++ b/submodules/InstantPageUI/Sources/InstantPageAudioItem.swift @@ -8,31 +8,31 @@ import TelegramUIPreferences import AccountContext import ContextUI -final class InstantPageAudioItem: InstantPageItem { - var frame: CGRect - let wantsNode: Bool = true - let separatesTiles: Bool = false - let medias: [InstantPageMedia] +public final class InstantPageAudioItem: InstantPageItem { + public var frame: CGRect + public let wantsNode: Bool = true + public let separatesTiles: Bool = false + public let medias: [InstantPageMedia] let media: InstantPageMedia let webpage: TelegramMediaWebpage - init(frame: CGRect, media: InstantPageMedia, webpage: TelegramMediaWebpage) { + public init(frame: CGRect, media: InstantPageMedia, webpage: TelegramMediaWebpage) { self.frame = frame self.media = media self.webpage = webpage self.medias = [media] } - 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? { + 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]?) -> InstantPageNode? { return InstantPageAudioNode(context: context, strings: strings, theme: theme, webPage: self.webpage, media: self.media, openMedia: openMedia) } - func matchesAnchor(_ anchor: String) -> Bool { + public func matchesAnchor(_ anchor: String) -> Bool { return false } - func matchesNode(_ node: InstantPageNode) -> Bool { + public func matchesNode(_ node: InstantPageNode) -> Bool { if let node = node as? InstantPageAudioNode { return self.media == node.media } else { @@ -40,11 +40,11 @@ final class InstantPageAudioItem: InstantPageItem { } } - func distanceThresholdGroup() -> Int? { + public func distanceThresholdGroup() -> Int? { return 4 } - func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat { + public func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat { if count > 3 { return 1000.0 } else { @@ -52,11 +52,11 @@ final class InstantPageAudioItem: InstantPageItem { } } - func linkSelectionRects(at point: CGPoint) -> [CGRect] { + public func linkSelectionRects(at point: CGPoint) -> [CGRect] { return [] } - func drawInTile(context: CGContext) { + public func drawInTile(context: CGContext) { } } diff --git a/submodules/InstantPageUI/Sources/InstantPageControllerNode.swift b/submodules/InstantPageUI/Sources/InstantPageControllerNode.swift index 5191046003..49beac3cff 100644 --- a/submodules/InstantPageUI/Sources/InstantPageControllerNode.swift +++ b/submodules/InstantPageUI/Sources/InstantPageControllerNode.swift @@ -51,6 +51,7 @@ final class InstantPageControllerNode: ASDisplayNode, UIScrollViewDelegate { private let scrollNodeFooter: ASDisplayNode private var linkHighlightingNode: LinkHighlightingNode? private var textSelectionNode: LinkHighlightingNode? + private var settingsNode: InstantPageSettingsNode? private var settingsDimNode: ASDisplayNode? diff --git a/submodules/InstantPageUI/Sources/InstantPageDetailsItem.swift b/submodules/InstantPageUI/Sources/InstantPageDetailsItem.swift index f14fac8f79..b3e93eb27a 100644 --- a/submodules/InstantPageUI/Sources/InstantPageDetailsItem.swift +++ b/submodules/InstantPageUI/Sources/InstantPageDetailsItem.swift @@ -9,11 +9,11 @@ import TelegramUIPreferences import AccountContext import ContextUI -final class InstantPageDetailsItem: InstantPageItem { - var frame: CGRect - let wantsNode: Bool = true - let separatesTiles: Bool = true - var medias: [InstantPageMedia] { +public final class InstantPageDetailsItem: InstantPageItem { + public var frame: CGRect + public let wantsNode: Bool = true + public let separatesTiles: Bool = true + public var medias: [InstantPageMedia] { var result: [InstantPageMedia] = [] for item in self.items { result.append(contentsOf: item.medias) @@ -21,13 +21,13 @@ final class InstantPageDetailsItem: InstantPageItem { return result } - let titleItems: [InstantPageItem] - let titleHeight: CGFloat - let items: [InstantPageItem] + public let titleItems: [InstantPageItem] + public let titleHeight: CGFloat + public let items: [InstantPageItem] let safeInset: CGFloat let rtl: Bool - let initiallyExpanded: Bool - let index: Int + public let initiallyExpanded: Bool + public let index: Int init(frame: CGRect, titleItems: [InstantPageItem], titleHeight: CGFloat, items: [InstantPageItem], safeInset: CGFloat, rtl: Bool, initiallyExpanded: Bool, index: Int) { self.frame = frame @@ -40,7 +40,7 @@ final class InstantPageDetailsItem: InstantPageItem { self.index = index } - 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? { + 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]?) -> InstantPageNode? { var expanded: Bool? if let expandedDetails = currentExpandedDetails, let currentlyExpanded = expandedDetails[self.index] { expanded = currentlyExpanded @@ -48,11 +48,11 @@ final class InstantPageDetailsItem: InstantPageItem { return InstantPageDetailsNode(context: context, sourceLocation: sourceLocation, strings: strings, nameDisplayOrder: nameDisplayOrder, theme: theme, item: self, openMedia: openMedia, longPressMedia: longPressMedia, activatePinchPreview: activatePinchPreview, pinchPreviewFinished: pinchPreviewFinished, openPeer: openPeer, openUrl: openUrl, currentlyExpanded: expanded, updateDetailsExpanded: updateDetailsExpanded) } - func matchesAnchor(_ anchor: String) -> Bool { + public func matchesAnchor(_ anchor: String) -> Bool { return false } - func matchesNode(_ node: InstantPageNode) -> Bool { + public func matchesNode(_ node: InstantPageNode) -> Bool { if let node = node as? InstantPageDetailsNode { return self === node.item } else { @@ -60,18 +60,18 @@ final class InstantPageDetailsItem: InstantPageItem { } } - func distanceThresholdGroup() -> Int? { + public func distanceThresholdGroup() -> Int? { return 8 } - func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat { + public func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat { return CGFloat.greatestFiniteMagnitude } - func drawInTile(context: CGContext) { + public func drawInTile(context: CGContext) { } - func linkSelectionRects(at point: CGPoint) -> [CGRect] { + public func linkSelectionRects(at point: CGPoint) -> [CGRect] { if point.y < self.titleHeight { for item in self.titleItems { if item.frame.contains(point) { diff --git a/submodules/InstantPageUI/Sources/InstantPageDetailsNode.swift b/submodules/InstantPageUI/Sources/InstantPageDetailsNode.swift index 03bd9253f8..d3fafb2a9c 100644 --- a/submodules/InstantPageUI/Sources/InstantPageDetailsNode.swift +++ b/submodules/InstantPageUI/Sources/InstantPageDetailsNode.swift @@ -32,9 +32,9 @@ public final class InstantPageDetailsNode: ASDisplayNode, InstantPageNode { private let updateExpanded: (Bool) -> Void var expanded: Bool - var previousNode: InstantPageDetailsNode? + public var previousNode: InstantPageDetailsNode? - var requestLayoutUpdate: ((Bool) -> Void)? + public var requestLayoutUpdate: ((Bool) -> Void)? init(context: AccountContext, sourceLocation: InstantPageSourceLocation, strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder, theme: InstantPageTheme, item: InstantPageDetailsItem, openMedia: @escaping (InstantPageMedia) -> Void, longPressMedia: @escaping (InstantPageMedia) -> Void, activatePinchPreview: ((PinchSourceContainerNode) -> Void)?, pinchPreviewFinished: ((InstantPageNode) -> Void)?, openPeer: @escaping (EnginePeer) -> Void, openUrl: @escaping (InstantPageUrlItem) -> Void, currentlyExpanded: Bool?, updateDetailsExpanded: @escaping (Bool) -> Void) { self.context = context @@ -120,10 +120,10 @@ public final class InstantPageDetailsNode: ASDisplayNode, InstantPageNode { self.arrowNode.setOpen(expanded, animated: animated) } - func updateLayout(size: CGSize, transition: ContainedViewLayoutTransition) { + public func updateLayout(size: CGSize, transition: ContainedViewLayoutTransition) { } - override func layout() { + public override func layout() { super.layout() let size = self.bounds.size @@ -139,31 +139,31 @@ public final class InstantPageDetailsNode: ASDisplayNode, InstantPageNode { self.separatorNode.frame = CGRect(origin: CGPoint(x: self.item.rtl ? 0.0 : inset, y: self.item.titleHeight - lineSize.height), size: lineSize) } - func updateIsVisible(_ isVisible: Bool) { + public func updateIsVisible(_ isVisible: Bool) { } - func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { + public func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { return self.contentNode.transitionNode(media: media) } - func updateHiddenMedia(media: InstantPageMedia?) { + public func updateHiddenMedia(media: InstantPageMedia?) { self.contentNode.updateHiddenMedia(media: media) } - func update(strings: PresentationStrings, theme: InstantPageTheme) { + public func update(strings: PresentationStrings, theme: InstantPageTheme) { self.arrowNode.color = theme.controlColor self.separatorNode.backgroundColor = theme.controlColor self.highlightedBackgroundNode.backgroundColor = theme.panelHighlightedBackgroundColor } - func updateVisibleItems(visibleBounds: CGRect, animated: Bool) { + public func updateVisibleItems(visibleBounds: CGRect, animated: Bool) { if self.bounds.height > self.item.titleHeight { self.contentNode.updateVisibleItems(visibleBounds: visibleBounds.offsetBy(dx: -self.contentNode.frame.minX, dy: -self.contentNode.frame.minY), animated: animated) } } - func textItemAtLocation(_ location: CGPoint) -> (InstantPageTextItem, CGPoint)? { + public func textItemAtLocation(_ location: CGPoint) -> (InstantPageTextItem, CGPoint)? { if self.titleTileNode.frame.contains(location) { for case let item as InstantPageTextItem in self.item.titleItems { if item.frame.contains(location) { @@ -177,7 +177,7 @@ public final class InstantPageDetailsNode: ASDisplayNode, InstantPageNode { return nil } - func tapActionAtPoint(_ point: CGPoint) -> TapLongTapOrDoubleTapGestureRecognizerAction { + public func tapActionAtPoint(_ point: CGPoint) -> TapLongTapOrDoubleTapGestureRecognizerAction { if self.titleTileNode.frame.contains(point) { if self.item.linkSelectionRects(at: point).isEmpty { return .fail @@ -188,11 +188,11 @@ public final class InstantPageDetailsNode: ASDisplayNode, InstantPageNode { return .waitForSingleTap } - var effectiveContentSize: CGSize { + public var effectiveContentSize: CGSize { return self.contentNode.effectiveContentSize } - func effectiveFrameForItem(_ item: InstantPageItem) -> CGRect { + public func effectiveFrameForItem(_ item: InstantPageItem) -> CGRect { return self.contentNode.effectiveFrameForItem(item).offsetBy(dx: 0.0, dy: self.item.titleHeight) } } diff --git a/submodules/InstantPageUI/Sources/InstantPageFeedbackItem.swift b/submodules/InstantPageUI/Sources/InstantPageFeedbackItem.swift index 7bdb399ccf..a6f4080321 100644 --- a/submodules/InstantPageUI/Sources/InstantPageFeedbackItem.swift +++ b/submodules/InstantPageUI/Sources/InstantPageFeedbackItem.swift @@ -8,11 +8,11 @@ import TelegramUIPreferences import AccountContext import ContextUI -final class InstantPageFeedbackItem: InstantPageItem { - var frame: CGRect - let wantsNode: Bool = true - let separatesTiles: Bool = false - let medias: [InstantPageMedia] = [] +public final class InstantPageFeedbackItem: InstantPageItem { + public var frame: CGRect + public let wantsNode: Bool = true + public let separatesTiles: Bool = false + public let medias: [InstantPageMedia] = [] let webPage: TelegramMediaWebpage @@ -21,33 +21,33 @@ final class InstantPageFeedbackItem: InstantPageItem { self.webPage = webPage } - 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? { + 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]?) -> InstantPageNode? { return InstantPageFeedbackNode(context: context, strings: strings, theme: theme, webPage: self.webPage, openUrl: openUrl) } - func matchesAnchor(_ anchor: String) -> Bool { + public func matchesAnchor(_ anchor: String) -> Bool { return false } - func matchesNode(_ node: InstantPageNode) -> Bool { + public func matchesNode(_ node: InstantPageNode) -> Bool { if let node = node as? InstantPageFeedbackNode, case let .Loaded(content) = node.webPage.content, case let .Loaded(updatedContent) = self.webPage.content, content.instantPage?.views == updatedContent.instantPage?.views { return true } return false } - func distanceThresholdGroup() -> Int? { + public func distanceThresholdGroup() -> Int? { return 8 } - func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat { + public func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat { return CGFloat.greatestFiniteMagnitude } - func linkSelectionRects(at point: CGPoint) -> [CGRect] { + public func linkSelectionRects(at point: CGPoint) -> [CGRect] { return [] } - func drawInTile(context: CGContext) { + public func drawInTile(context: CGContext) { } } diff --git a/submodules/InstantPageUI/Sources/InstantPageImageItem.swift b/submodules/InstantPageUI/Sources/InstantPageImageItem.swift index a08814737c..585b50cc1c 100644 --- a/submodules/InstantPageUI/Sources/InstantPageImageItem.swift +++ b/submodules/InstantPageUI/Sources/InstantPageImageItem.swift @@ -16,15 +16,15 @@ struct InstantPageMapAttribute: InstantPageImageAttribute { let dimensions: CGSize } -final class InstantPageImageItem: InstantPageItem { - var frame: CGRect +public final class InstantPageImageItem: InstantPageItem { + public var frame: CGRect let webPage: TelegramMediaWebpage let media: InstantPageMedia let attributes: [InstantPageImageAttribute] - var medias: [InstantPageMedia] { + public var medias: [InstantPageMedia] { return [self.media] } @@ -32,8 +32,8 @@ final class InstantPageImageItem: InstantPageItem { let roundCorners: Bool let fit: Bool - let wantsNode: Bool = true - let separatesTiles: Bool = false + public let wantsNode: Bool = true + public let separatesTiles: Bool = false init(frame: CGRect, webPage: TelegramMediaWebpage, media: InstantPageMedia, attributes: [InstantPageImageAttribute] = [], interactive: Bool, roundCorners: Bool, fit: Bool) { self.frame = frame @@ -45,15 +45,15 @@ final class InstantPageImageItem: InstantPageItem { self.fit = fit } - 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? { + 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]?) -> InstantPageNode? { return InstantPageImageNode(context: context, sourceLocation: sourceLocation, theme: theme, webPage: self.webPage, media: self.media, attributes: self.attributes, interactive: self.interactive, roundCorners: self.roundCorners, fit: self.fit, openMedia: openMedia, longPressMedia: longPressMedia, activatePinchPreview: activatePinchPreview, pinchPreviewFinished: pinchPreviewFinished) } - func matchesAnchor(_ anchor: String) -> Bool { + public func matchesAnchor(_ anchor: String) -> Bool { return false } - func matchesNode(_ node: InstantPageNode) -> Bool { + public func matchesNode(_ node: InstantPageNode) -> Bool { if let node = node as? InstantPageImageNode { return node.media == self.media } else { @@ -61,11 +61,11 @@ final class InstantPageImageItem: InstantPageItem { } } - func distanceThresholdGroup() -> Int? { + public func distanceThresholdGroup() -> Int? { return 1 } - func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat { + public func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat { if count > 3 { return 400.0 } else { @@ -73,10 +73,10 @@ final class InstantPageImageItem: InstantPageItem { } } - func drawInTile(context: CGContext) { + public func drawInTile(context: CGContext) { } - func linkSelectionRects(at point: CGPoint) -> [CGRect] { + public func linkSelectionRects(at point: CGPoint) -> [CGRect] { return [] } } diff --git a/submodules/InstantPageUI/Sources/InstantPageItem.swift b/submodules/InstantPageUI/Sources/InstantPageItem.swift index 6804e8bc44..ab26eabba9 100644 --- a/submodules/InstantPageUI/Sources/InstantPageItem.swift +++ b/submodules/InstantPageUI/Sources/InstantPageItem.swift @@ -8,7 +8,7 @@ import TelegramUIPreferences import AccountContext import ContextUI -protocol InstantPageItem { +public protocol InstantPageItem { var frame: CGRect { get set } var wantsNode: Bool { get } var medias: [InstantPageMedia] { get } diff --git a/submodules/InstantPageUI/Sources/InstantPageLayout.swift b/submodules/InstantPageUI/Sources/InstantPageLayout.swift index 3647452673..c91f2c9c83 100644 --- a/submodules/InstantPageUI/Sources/InstantPageLayout.swift +++ b/submodules/InstantPageUI/Sources/InstantPageLayout.swift @@ -8,18 +8,18 @@ import TelegramUIPreferences import TelegramStringFormatting import MosaicLayout -final class InstantPageLayout { - let origin: CGPoint - let contentSize: CGSize - let items: [InstantPageItem] +public final class InstantPageLayout { + public let origin: CGPoint + public let contentSize: CGSize + public let items: [InstantPageItem] - init(origin: CGPoint, contentSize: CGSize, items: [InstantPageItem]) { + public init(origin: CGPoint, contentSize: CGSize, items: [InstantPageItem]) { self.origin = origin self.contentSize = contentSize self.items = items } - func flattenedItemsWithOrigin(_ origin: CGPoint) -> [InstantPageItem] { + public func flattenedItemsWithOrigin(_ origin: CGPoint) -> [InstantPageItem] { return self.items.map({ item in var item = item let itemFrame = item.frame.offsetBy(dx: origin.x, dy: origin.y) @@ -48,7 +48,7 @@ private func setupStyleStack(_ stack: InstantPageTextStyleStack, theme: InstantP } } -func layoutInstantPageBlock(webpage: TelegramMediaWebpage, userLocation: MediaResourceUserLocation, rtl: Bool, block: InstantPageBlock, boundingWidth: CGFloat, horizontalInset: CGFloat, safeInset: CGFloat, isCover: Bool, previousItems: [InstantPageItem], fillToSize: CGSize?, media: [MediaId: Media], mediaIndexCounter: inout Int, embedIndexCounter: inout Int, detailsIndexCounter: inout Int, theme: InstantPageTheme, strings: PresentationStrings, dateTimeFormat: PresentationDateTimeFormat, webEmbedHeights: [Int : CGFloat] = [:], excludeCaptions: Bool) -> InstantPageLayout { +public func layoutInstantPageBlock(webpage: TelegramMediaWebpage, userLocation: MediaResourceUserLocation, rtl: Bool, block: InstantPageBlock, boundingWidth: CGFloat, horizontalInset: CGFloat, safeInset: CGFloat, isCover: Bool, previousItems: [InstantPageItem], fillToSize: CGSize?, media: [MediaId: Media], mediaIndexCounter: inout Int, embedIndexCounter: inout Int, detailsIndexCounter: inout Int, theme: InstantPageTheme, strings: PresentationStrings, dateTimeFormat: PresentationDateTimeFormat, webEmbedHeights: [Int : CGFloat] = [:], excludeCaptions: Bool) -> InstantPageLayout { let layoutCaption: (InstantPageCaption, CGSize) -> ([InstantPageItem], CGSize) = { caption, contentSize in var items: [InstantPageItem] = [] @@ -835,7 +835,7 @@ func layoutInstantPageBlock(webpage: TelegramMediaWebpage, userLocation: MediaRe } } -func instantPageLayoutForWebPage(_ webPage: TelegramMediaWebpage, userLocation: MediaResourceUserLocation, boundingWidth: CGFloat, safeInset: CGFloat, strings: PresentationStrings, theme: InstantPageTheme, dateTimeFormat: PresentationDateTimeFormat, webEmbedHeights: [Int : CGFloat] = [:]) -> InstantPageLayout { +public func instantPageLayoutForWebPage(_ webPage: TelegramMediaWebpage, userLocation: MediaResourceUserLocation, boundingWidth: CGFloat, safeInset: CGFloat, strings: PresentationStrings, theme: InstantPageTheme, dateTimeFormat: PresentationDateTimeFormat, webEmbedHeights: [Int : CGFloat] = [:]) -> InstantPageLayout { var maybeLoadedContent: TelegramMediaWebpageLoadedContent? if case let .Loaded(content) = webPage.content { maybeLoadedContent = content diff --git a/submodules/InstantPageUI/Sources/InstantPageNode.swift b/submodules/InstantPageUI/Sources/InstantPageNode.swift index 591d8693cc..c235614961 100644 --- a/submodules/InstantPageUI/Sources/InstantPageNode.swift +++ b/submodules/InstantPageUI/Sources/InstantPageNode.swift @@ -4,7 +4,7 @@ import AsyncDisplayKit import Display import TelegramPresentationData -protocol InstantPageNode: ASDisplayNode { +public protocol InstantPageNode: ASDisplayNode { func updateIsVisible(_ isVisible: Bool) func transitionNode(media: InstantPageMedia) -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? diff --git a/submodules/InstantPageUI/Sources/InstantPagePeerReferenceItem.swift b/submodules/InstantPageUI/Sources/InstantPagePeerReferenceItem.swift index 0bc839724f..5aa04bf6da 100644 --- a/submodules/InstantPageUI/Sources/InstantPagePeerReferenceItem.swift +++ b/submodules/InstantPageUI/Sources/InstantPagePeerReferenceItem.swift @@ -8,11 +8,11 @@ import TelegramUIPreferences import AccountContext import ContextUI -final class InstantPagePeerReferenceItem: InstantPageItem { - var frame: CGRect - let wantsNode: Bool = true - let separatesTiles: Bool = false - let medias: [InstantPageMedia] = [] +public final class InstantPagePeerReferenceItem: InstantPageItem { + public var frame: CGRect + public let wantsNode: Bool = true + public let separatesTiles: Bool = false + public let medias: [InstantPageMedia] = [] let initialPeer: Peer let safeInset: CGFloat @@ -27,15 +27,15 @@ final class InstantPagePeerReferenceItem: InstantPageItem { self.rtl = rtl } - 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? { + 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]?) -> InstantPageNode? { return InstantPagePeerReferenceNode(context: context, strings: strings, nameDisplayOrder: nameDisplayOrder, theme: theme, initialPeer: self.initialPeer, safeInset: self.safeInset, transparent: self.transparent, rtl: self.rtl, openPeer: openPeer) } - func matchesAnchor(_ anchor: String) -> Bool { + public func matchesAnchor(_ anchor: String) -> Bool { return false } - func matchesNode(_ node: InstantPageNode) -> Bool { + public func matchesNode(_ node: InstantPageNode) -> Bool { if let node = node as? InstantPagePeerReferenceNode { return self.initialPeer.id == node.peer?.id && self.safeInset == node.safeInset } else { @@ -43,11 +43,11 @@ final class InstantPagePeerReferenceItem: InstantPageItem { } } - func distanceThresholdGroup() -> Int? { + public func distanceThresholdGroup() -> Int? { return 5 } - func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat { + public func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat { if count > 3 { return 1000.0 } else { @@ -55,10 +55,10 @@ final class InstantPagePeerReferenceItem: InstantPageItem { } } - func linkSelectionRects(at point: CGPoint) -> [CGRect] { + public func linkSelectionRects(at point: CGPoint) -> [CGRect] { return [] } - func drawInTile(context: CGContext) { + public func drawInTile(context: CGContext) { } } diff --git a/submodules/InstantPageUI/Sources/InstantPagePlayableVideoItem.swift b/submodules/InstantPageUI/Sources/InstantPagePlayableVideoItem.swift index 79a32538c3..91e0442785 100644 --- a/submodules/InstantPageUI/Sources/InstantPagePlayableVideoItem.swift +++ b/submodules/InstantPageUI/Sources/InstantPagePlayableVideoItem.swift @@ -8,19 +8,19 @@ import TelegramUIPreferences import AccountContext import ContextUI -final class InstantPagePlayableVideoItem: InstantPageItem { - var frame: CGRect +public final class InstantPagePlayableVideoItem: InstantPageItem { + public var frame: CGRect let webPage: TelegramMediaWebpage let media: InstantPageMedia - var medias: [InstantPageMedia] { + public var medias: [InstantPageMedia] { return [self.media] } let interactive: Bool - let wantsNode: Bool = true - let separatesTiles: Bool = false + public let wantsNode: Bool = true + public let separatesTiles: Bool = false init(frame: CGRect, webPage: TelegramMediaWebpage, media: InstantPageMedia, interactive: Bool) { self.frame = frame @@ -29,15 +29,15 @@ final class InstantPagePlayableVideoItem: InstantPageItem { self.interactive = interactive } - 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? { + 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]?) -> InstantPageNode? { return InstantPagePlayableVideoNode(context: context, userLocation: sourceLocation.userLocation, webPage: self.webPage, theme: theme, media: self.media, interactive: self.interactive, openMedia: openMedia) } - func matchesAnchor(_ anchor: String) -> Bool { + public func matchesAnchor(_ anchor: String) -> Bool { return false } - func matchesNode(_ node: InstantPageNode) -> Bool { + public func matchesNode(_ node: InstantPageNode) -> Bool { if let node = node as? InstantPagePlayableVideoNode { return node.media == self.media } else { @@ -45,11 +45,11 @@ final class InstantPagePlayableVideoItem: InstantPageItem { } } - func distanceThresholdGroup() -> Int? { + public func distanceThresholdGroup() -> Int? { return 2 } - func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat { + public func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat { if count > 3 { return 200.0 } else { @@ -57,10 +57,10 @@ final class InstantPagePlayableVideoItem: InstantPageItem { } } - func drawInTile(context: CGContext) { + public func drawInTile(context: CGContext) { } - func linkSelectionRects(at point: CGPoint) -> [CGRect] { + public func linkSelectionRects(at point: CGPoint) -> [CGRect] { return [] } } diff --git a/submodules/InstantPageUI/Sources/InstantPageScrollableNode.swift b/submodules/InstantPageUI/Sources/InstantPageScrollableNode.swift index 30c1239ee8..27dd83326a 100644 --- a/submodules/InstantPageUI/Sources/InstantPageScrollableNode.swift +++ b/submodules/InstantPageUI/Sources/InstantPageScrollableNode.swift @@ -6,7 +6,7 @@ import Postbox import Display import TelegramPresentationData -protocol InstantPageScrollableItem: AnyObject, InstantPageItem { +public protocol InstantPageScrollableItem: AnyObject, InstantPageItem { var contentSize: CGSize { get } var horizontalInset: CGFloat { get } var isRTL: Bool { get } @@ -23,8 +23,8 @@ private final class InstantPageScrollableContentNodeParameters: NSObject { } } -final class InstantPageScrollableContentNode: ASDisplayNode { - let item: InstantPageScrollableItem +public final class InstantPageScrollableContentNode: ASDisplayNode { + public let item: InstantPageScrollableItem init(item: InstantPageScrollableItem, additionalNodes: [InstantPageNode]) { self.item = item @@ -38,7 +38,7 @@ final class InstantPageScrollableContentNode: ASDisplayNode { } } - override func drawParameters(forAsyncLayer layer: _ASDisplayLayer) -> NSObjectProtocol? { + public override func drawParameters(forAsyncLayer layer: _ASDisplayLayer) -> NSObjectProtocol? { return InstantPageScrollableContentNodeParameters(item: self.item) } diff --git a/submodules/InstantPageUI/Sources/InstantPageShapeItem.swift b/submodules/InstantPageUI/Sources/InstantPageShapeItem.swift index b5b354686f..4c99765ada 100644 --- a/submodules/InstantPageUI/Sources/InstantPageShapeItem.swift +++ b/submodules/InstantPageUI/Sources/InstantPageShapeItem.swift @@ -14,15 +14,15 @@ enum InstantPageShape { case roundLine } -final class InstantPageShapeItem: InstantPageItem { - var frame: CGRect +public final class InstantPageShapeItem: InstantPageItem { + public var frame: CGRect let shapeFrame: CGRect let shape: InstantPageShape let color: UIColor - let medias: [InstantPageMedia] = [] - let wantsNode: Bool = false - let separatesTiles: Bool = false + public let medias: [InstantPageMedia] = [] + public let wantsNode: Bool = false + public let separatesTiles: Bool = false init(frame: CGRect, shapeFrame: CGRect, shape: InstantPageShape, color: UIColor) { self.frame = frame @@ -31,7 +31,7 @@ final class InstantPageShapeItem: InstantPageItem { self.color = color } - func drawInTile(context: CGContext) { + public func drawInTile(context: CGContext) { context.setFillColor(self.color.cgColor) switch self.shape { @@ -54,27 +54,27 @@ final class InstantPageShapeItem: InstantPageItem { } } - func matchesAnchor(_ anchor: String) -> Bool { + public func matchesAnchor(_ anchor: String) -> Bool { return false } - func matchesNode(_ node: InstantPageNode) -> Bool { + public func matchesNode(_ node: InstantPageNode) -> Bool { return false } - 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? { + 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]?) -> InstantPageNode? { return nil } - func linkSelectionRects(at point: CGPoint) -> [CGRect] { + public func linkSelectionRects(at point: CGPoint) -> [CGRect] { return [] } - func distanceThresholdGroup() -> Int? { + public func distanceThresholdGroup() -> Int? { return nil } - func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat { + public func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat { return 0.0 } } diff --git a/submodules/InstantPageUI/Sources/InstantPageTableItem.swift b/submodules/InstantPageUI/Sources/InstantPageTableItem.swift index fe99459868..c94f059ab4 100644 --- a/submodules/InstantPageUI/Sources/InstantPageTableItem.swift +++ b/submodules/InstantPageUI/Sources/InstantPageTableItem.swift @@ -100,21 +100,21 @@ private let tableCellInsets = UIEdgeInsets(top: 14.0, left: 12.0, bottom: 14.0, private let tableBorderWidth: CGFloat = 1.0 private let tableCornerRadius: CGFloat = 5.0 -final class InstantPageTableItem: InstantPageScrollableItem { - var frame: CGRect +public final class InstantPageTableItem: InstantPageScrollableItem { + public var frame: CGRect let totalWidth: CGFloat - let horizontalInset: CGFloat - let medias: [InstantPageMedia] = [] - let wantsNode: Bool = true - let separatesTiles: Bool = false + public let horizontalInset: CGFloat + public let medias: [InstantPageMedia] = [] + public let wantsNode: Bool = true + public let separatesTiles: Bool = false let theme: InstantPageTheme - let isRTL: Bool + public let isRTL: Bool fileprivate let cells: [InstantPageTableCellItem] private let borderWidth: CGFloat - let anchors: [String: (CGFloat, Bool)] + public let anchors: [String: (CGFloat, Bool)] fileprivate init(frame: CGRect, totalWidth: CGFloat, horizontalInset: CGFloat, borderWidth: CGFloat, theme: InstantPageTheme, cells: [InstantPageTableCellItem], rtl: Bool) { self.frame = frame @@ -140,11 +140,11 @@ final class InstantPageTableItem: InstantPageScrollableItem { self.anchors = anchors } - var contentSize: CGSize { + public var contentSize: CGSize { return CGSize(width: self.totalWidth, height: self.frame.height) } - func drawInTile(context: CGContext) { + public func drawInTile(context: CGContext) { for cell in self.cells { if cell.cell.text == nil { continue @@ -196,11 +196,11 @@ final class InstantPageTableItem: InstantPageScrollableItem { } } - func matchesAnchor(_ anchor: String) -> Bool { + public func matchesAnchor(_ anchor: String) -> Bool { return false } - 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? { + 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]?) -> InstantPageNode? { var additionalNodes: [InstantPageNode] = [] for cell in self.cells { for item in cell.additionalItems { @@ -215,22 +215,22 @@ final class InstantPageTableItem: InstantPageScrollableItem { return InstantPageScrollableNode(item: self, additionalNodes: additionalNodes) } - func matchesNode(_ node: InstantPageNode) -> Bool { + public func matchesNode(_ node: InstantPageNode) -> Bool { if let node = node as? InstantPageScrollableNode { return node.item === self } return false } - func distanceThresholdGroup() -> Int? { + public func distanceThresholdGroup() -> Int? { return nil } - func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat { + public func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat { return 0.0 } - func linkSelectionRects(at point: CGPoint) -> [CGRect] { + public func linkSelectionRects(at point: CGPoint) -> [CGRect] { for cell in self.cells { if let item = cell.textItem, item.selectable, item.frame.insetBy(dx: -tableCellInsets.left, dy: -tableCellInsets.top).contains(point.offsetBy(dx: -cell.frame.minX - self.horizontalInset, dy: -cell.frame.minY)) { let rects = item.linkSelectionRects(at: point.offsetBy(dx: -cell.frame.minX - self.horizontalInset - item.frame.minX, dy: -cell.frame.minY - item.frame.minY)) @@ -240,7 +240,7 @@ final class InstantPageTableItem: InstantPageScrollableItem { return [] } - func textItemAtLocation(_ location: CGPoint) -> (InstantPageTextItem, CGPoint)? { + public func textItemAtLocation(_ location: CGPoint) -> (InstantPageTextItem, CGPoint)? { for cell in self.cells { if let item = cell.textItem, item.selectable, item.frame.insetBy(dx: -tableCellInsets.left, dy: -tableCellInsets.top).contains(location.offsetBy(dx: -cell.frame.minX - self.horizontalInset, dy: -cell.frame.minY)) { return (item, cell.frame.origin.offsetBy(dx: self.horizontalInset, dy: 0.0)) diff --git a/submodules/InstantPageUI/Sources/InstantPageTextItem.swift b/submodules/InstantPageUI/Sources/InstantPageTextItem.swift index e707cc6b53..bdf7262ebf 100644 --- a/submodules/InstantPageUI/Sources/InstantPageTextItem.swift +++ b/submodules/InstantPageUI/Sources/InstantPageTextItem.swift @@ -57,10 +57,10 @@ public struct InstantPageTextRangeRectEdge: Equatable { } } -final class InstantPageTextLine { +public final class InstantPageTextLine { let line: CTLine let range: NSRange - let frame: CGRect + public let frame: CGRect let strikethroughItems: [InstantPageTextStrikethroughItem] let markedItems: [InstantPageTextMarkedItem] let imageItems: [InstantPageTextImageItem] @@ -89,18 +89,18 @@ private func frameForLine(_ line: InstantPageTextLine, boundingWidth: CGFloat, a return lineFrame } -final class InstantPageTextItem: InstantPageItem { +public final class InstantPageTextItem: InstantPageItem { let attributedString: NSAttributedString - let lines: [InstantPageTextLine] + public let lines: [InstantPageTextLine] let rtlLineIndices: Set - var frame: CGRect + public var frame: CGRect let alignment: NSTextAlignment let opaqueBackground: Bool - let medias: [InstantPageMedia] = [] + public let medias: [InstantPageMedia] = [] let anchors: [String: (Int, Bool)] - let wantsNode: Bool = false - let separatesTiles: Bool = false - var selectable: Bool = true + public let wantsNode: Bool = false + public let separatesTiles: Bool = false + public var selectable: Bool = true var containsRTL: Bool { return !self.rtlLineIndices.isEmpty @@ -128,7 +128,7 @@ final class InstantPageTextItem: InstantPageItem { self.anchors = anchors } - func drawInTile(context: CGContext) { + public func drawInTile(context: CGContext) { context.saveGState() context.textMatrix = CGAffineTransform(scaleX: 1.0, y: -1.0) context.translateBy(x: self.frame.minX, y: self.frame.minY) @@ -251,7 +251,7 @@ final class InstantPageTextItem: InstantPageItem { return nil } - func linkSelectionRects(at point: CGPoint) -> [CGRect] { + public func linkSelectionRects(at point: CGPoint) -> [CGRect] { if let (index, dict) = self.attributesAtPoint(point) { if let _ = dict[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] { if let rects = self.attributeRects(name: NSAttributedString.Key(rawValue: TelegramTextAttributes.URL), at: index) { @@ -268,7 +268,7 @@ final class InstantPageTextItem: InstantPageItem { return [] } - func urlAttribute(at point: CGPoint) -> InstantPageUrlItem? { + public func urlAttribute(at point: CGPoint) -> InstantPageUrlItem? { if let (_, dict) = self.attributesAtPoint(point) { if let url = dict[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] as? InstantPageUrlItem { return url @@ -359,7 +359,7 @@ final class InstantPageTextItem: InstantPageItem { return nil } - func lineRects() -> [CGRect] { + public func lineRects() -> [CGRect] { let boundsWidth = self.frame.width var rects: [CGRect] = [] var topLeft = CGPoint(x: CGFloat.greatestFiniteMagnitude, y: 0.0) @@ -425,30 +425,30 @@ final class InstantPageTextItem: InstantPageItem { return ceil(width) } - func plainText() -> String { + public func plainText() -> String { if let first = self.lines.first, let last = self.lines.last { return self.attributedString.attributedSubstring(from: NSMakeRange(first.range.location, last.range.location + last.range.length - first.range.location)).string } return "" } - func matchesAnchor(_ anchor: String) -> Bool { + public func matchesAnchor(_ anchor: String) -> Bool { return false } - 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? { + 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]?) -> InstantPageNode? { return nil } - func matchesNode(_ node: InstantPageNode) -> Bool { + public func matchesNode(_ node: InstantPageNode) -> Bool { return false } - func distanceThresholdGroup() -> Int? { + public func distanceThresholdGroup() -> Int? { return nil } - func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat { + public func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat { return 0.0 } } diff --git a/submodules/InstantPageUI/Sources/InstantPageTheme.swift b/submodules/InstantPageUI/Sources/InstantPageTheme.swift index 70d3c600d7..0a9819a0f4 100644 --- a/submodules/InstantPageUI/Sources/InstantPageTheme.swift +++ b/submodules/InstantPageUI/Sources/InstantPageTheme.swift @@ -47,7 +47,7 @@ enum InstantPageTextCategoryType { case article } -struct InstantPageTextCategories { +public struct InstantPageTextCategories { let kicker: InstantPageTextAttributes let header: InstantPageTextAttributes let subheader: InstantPageTextAttributes @@ -83,7 +83,7 @@ struct InstantPageTextCategories { } } -final class InstantPageTheme { +public final class InstantPageTheme { let type: InstantPageThemeType let pageBackgroundColor: UIColor @@ -111,7 +111,7 @@ final class InstantPageTheme { let overlayPanelColor: UIColor - init(type: InstantPageThemeType, pageBackgroundColor: UIColor, textCategories: InstantPageTextCategories, serif: Bool, codeBlockBackgroundColor: UIColor, linkColor: UIColor, textHighlightColor: UIColor, linkHighlightColor: UIColor, markerColor: UIColor, panelBackgroundColor: UIColor, panelHighlightedBackgroundColor: UIColor, panelPrimaryColor: UIColor, panelSecondaryColor: UIColor, panelAccentColor: UIColor, tableBorderColor: UIColor, tableHeaderColor: UIColor, controlColor: UIColor, imageTintColor: UIColor?, overlayPanelColor: UIColor) { + public init(type: InstantPageThemeType, pageBackgroundColor: UIColor, textCategories: InstantPageTextCategories, serif: Bool, codeBlockBackgroundColor: UIColor, linkColor: UIColor, textHighlightColor: UIColor, linkHighlightColor: UIColor, markerColor: UIColor, panelBackgroundColor: UIColor, panelHighlightedBackgroundColor: UIColor, panelPrimaryColor: UIColor, panelSecondaryColor: UIColor, panelAccentColor: UIColor, tableBorderColor: UIColor, tableHeaderColor: UIColor, controlColor: UIColor, imageTintColor: UIColor?, overlayPanelColor: UIColor) { self.type = type self.pageBackgroundColor = pageBackgroundColor self.textCategories = textCategories @@ -133,7 +133,7 @@ final class InstantPageTheme { self.overlayPanelColor = overlayPanelColor } - func withUpdatedFontStyles(sizeMultiplier: CGFloat, forceSerif: Bool) -> InstantPageTheme { + public func withUpdatedFontStyles(sizeMultiplier: CGFloat, forceSerif: Bool) -> InstantPageTheme { return InstantPageTheme(type: type, pageBackgroundColor: pageBackgroundColor, textCategories: self.textCategories.withUpdatedFontStyles(sizeMultiplier: sizeMultiplier, forceSerif: forceSerif), serif: forceSerif, codeBlockBackgroundColor: codeBlockBackgroundColor, linkColor: linkColor, textHighlightColor: textHighlightColor, linkHighlightColor: linkHighlightColor, markerColor: markerColor, panelBackgroundColor: panelBackgroundColor, panelHighlightedBackgroundColor: panelHighlightedBackgroundColor, panelPrimaryColor: panelPrimaryColor, panelSecondaryColor: panelSecondaryColor, panelAccentColor: panelAccentColor, tableBorderColor: tableBorderColor, tableHeaderColor: tableHeaderColor, controlColor: controlColor, imageTintColor: imageTintColor, overlayPanelColor: overlayPanelColor) } } diff --git a/submodules/InstantPageUI/Sources/InstantPageTile.swift b/submodules/InstantPageUI/Sources/InstantPageTile.swift index e2d1783ae8..4bdded67b0 100644 --- a/submodules/InstantPageUI/Sources/InstantPageTile.swift +++ b/submodules/InstantPageUI/Sources/InstantPageTile.swift @@ -2,9 +2,9 @@ import Foundation import UIKit import Display -final class InstantPageTile { - let frame: CGRect - var items: [InstantPageItem] = [] +public final class InstantPageTile { + public let frame: CGRect + public var items: [InstantPageItem] = [] init(frame: CGRect) { self.frame = frame @@ -19,7 +19,7 @@ final class InstantPageTile { } } -func instantPageTilesFromLayout(_ layout: InstantPageLayout, boundingWidth: CGFloat) -> [InstantPageTile] { +public func instantPageTilesFromLayout(_ layout: InstantPageLayout, boundingWidth: CGFloat) -> [InstantPageTile] { var tileByOrigin: [Int : InstantPageTile] = [:] let tileHeight: CGFloat = 256.0 @@ -81,7 +81,7 @@ func instantPageTilesFromLayout(_ layout: InstantPageLayout, boundingWidth: CGFl }) } -func instantPageAccessibilityAreasFromLayout(_ layout: InstantPageLayout, boundingWidth: CGFloat) -> [AccessibilityAreaNode] { +public func instantPageAccessibilityAreasFromLayout(_ layout: InstantPageLayout, boundingWidth: CGFloat) -> [AccessibilityAreaNode] { var result: [AccessibilityAreaNode] = [] for item in layout.items { if let item = item as? InstantPageTextItem { diff --git a/submodules/InstantPageUI/Sources/InstantPageTileNode.swift b/submodules/InstantPageUI/Sources/InstantPageTileNode.swift index 715fc0b394..c16bcac1dd 100644 --- a/submodules/InstantPageUI/Sources/InstantPageTileNode.swift +++ b/submodules/InstantPageUI/Sources/InstantPageTileNode.swift @@ -14,10 +14,10 @@ private final class InstantPageTileNodeParameters: NSObject { } } -final class InstantPageTileNode: ASDisplayNode { +public final class InstantPageTileNode: ASDisplayNode { private let tile: InstantPageTile - init(tile: InstantPageTile, backgroundColor: UIColor) { + public init(tile: InstantPageTile, backgroundColor: UIColor) { self.tile = tile super.init() @@ -27,12 +27,11 @@ final class InstantPageTileNode: ASDisplayNode { self.backgroundColor = backgroundColor } - override func drawParameters(forAsyncLayer layer: _ASDisplayLayer) -> NSObjectProtocol? { + public override func drawParameters(forAsyncLayer layer: _ASDisplayLayer) -> NSObjectProtocol? { return InstantPageTileNodeParameters(tile: self.tile, backgroundColor: self.backgroundColor ?? UIColor.white) } @objc override public class func draw(_ bounds: CGRect, withParameters parameters: Any?, isCancelled: () -> Bool, isRasterizing: Bool) { - let context = UIGraphicsGetCurrentContext()! if let parameters = parameters as? InstantPageTileNodeParameters { diff --git a/submodules/InstantPageUI/Sources/InstantPageWebEmbedItem.swift b/submodules/InstantPageUI/Sources/InstantPageWebEmbedItem.swift index 4292366e7a..ec8ebdf9a8 100644 --- a/submodules/InstantPageUI/Sources/InstantPageWebEmbedItem.swift +++ b/submodules/InstantPageUI/Sources/InstantPageWebEmbedItem.swift @@ -8,11 +8,11 @@ import TelegramUIPreferences import AccountContext import ContextUI -final class InstantPageWebEmbedItem: InstantPageItem { - var frame: CGRect - let wantsNode: Bool = true - let separatesTiles: Bool = false - let medias: [InstantPageMedia] = [] +public final class InstantPageWebEmbedItem: InstantPageItem { + public var frame: CGRect + public let wantsNode: Bool = true + public let separatesTiles: Bool = false + public let medias: [InstantPageMedia] = [] let url: String? let html: String? @@ -25,15 +25,15 @@ final class InstantPageWebEmbedItem: InstantPageItem { self.enableScrolling = enableScrolling } - 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? { + 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]?) -> InstantPageNode? { return InstantPageWebEmbedNode(frame: self.frame, url: self.url, html: self.html, enableScrolling: self.enableScrolling, updateWebEmbedHeight: updateWebEmbedHeight) } - func matchesAnchor(_ anchor: String) -> Bool { + public func matchesAnchor(_ anchor: String) -> Bool { return false } - func matchesNode(_ node: InstantPageNode) -> Bool { + public func matchesNode(_ node: InstantPageNode) -> Bool { if let node = node as? InstantPageWebEmbedNode { return self.url == node.url && self.html == node.html } else { @@ -41,11 +41,11 @@ final class InstantPageWebEmbedItem: InstantPageItem { } } - func distanceThresholdGroup() -> Int? { + public func distanceThresholdGroup() -> Int? { return 6 } - func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat { + public func distanceThresholdWithGroupCount(_ count: Int) -> CGFloat { if count > 3 { return 1000.0 } else { @@ -53,10 +53,10 @@ final class InstantPageWebEmbedItem: InstantPageItem { } } - func linkSelectionRects(at point: CGPoint) -> [CGRect] { + public func linkSelectionRects(at point: CGPoint) -> [CGRect] { return [] } - func drawInTile(context: CGContext) { + public func drawInTile(context: CGContext) { } }