mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
no message
This commit is contained in:
@@ -26,11 +26,11 @@ struct InstantPageGalleryEntry: Equatable {
|
||||
return lhs.index == rhs.index && lhs.pageId == rhs.pageId && lhs.media == rhs.media && lhs.caption == rhs.caption && lhs.location == rhs.location
|
||||
}
|
||||
|
||||
func item(account: Account, theme: PresentationTheme, strings: PresentationStrings) -> GalleryItem {
|
||||
func item(account: Account, webPage: TelegramMediaWebpage, theme: PresentationTheme, strings: PresentationStrings) -> GalleryItem {
|
||||
if let image = self.media.media as? TelegramMediaImage {
|
||||
return InstantImageGalleryItem(account: account, theme: theme, strings: strings, image: image, caption: self.caption, location: self.location)
|
||||
return InstantImageGalleryItem(account: account, theme: theme, strings: strings, imageReference: .webPage(webPage: WebpageReference(webPage), media: image), caption: self.caption, location: self.location)
|
||||
} else if let file = self.media.media as? TelegramMediaFile, file.isVideo {
|
||||
return UniversalVideoGalleryItem(account: account, theme: theme, strings: strings, content: NativeVideoContent(id: .instantPage(self.pageId, file.fileId), file: file), originData: nil, indexData: GalleryItemIndexData(position: self.location.position, totalCount: self.location.totalCount), contentInfo: nil, caption: self.caption)
|
||||
return UniversalVideoGalleryItem(account: account, theme: theme, strings: strings, content: NativeVideoContent(id: .instantPage(self.pageId, file.fileId), fileReference: .webPage(webPage: WebpageReference(webPage), media: file)), originData: nil, indexData: GalleryItemIndexData(position: self.location.position, totalCount: self.location.totalCount), contentInfo: .webPage(webPage, file), caption: self.caption)
|
||||
} else {
|
||||
preconditionFailure()
|
||||
}
|
||||
@@ -51,6 +51,7 @@ class InstantPageGalleryController: ViewController {
|
||||
}
|
||||
|
||||
private let account: Account
|
||||
private let webPage: TelegramMediaWebpage
|
||||
private var presentationData: PresentationData
|
||||
|
||||
private let _ready = Promise<Bool>()
|
||||
@@ -77,8 +78,9 @@ class InstantPageGalleryController: ViewController {
|
||||
|
||||
private let replaceRootController: (ViewController, ValuePromise<Bool>?) -> Void
|
||||
|
||||
init(account: Account, entries: [InstantPageGalleryEntry], centralIndex: Int, replaceRootController: @escaping (ViewController, ValuePromise<Bool>?) -> Void) {
|
||||
init(account: Account, webPage: TelegramMediaWebpage, entries: [InstantPageGalleryEntry], centralIndex: Int, replaceRootController: @escaping (ViewController, ValuePromise<Bool>?) -> Void) {
|
||||
self.account = account
|
||||
self.webPage = webPage
|
||||
self.replaceRootController = replaceRootController
|
||||
|
||||
self.presentationData = account.telegramApplicationContext.currentPresentationData.with { $0 }
|
||||
@@ -98,7 +100,7 @@ class InstantPageGalleryController: ViewController {
|
||||
strongSelf.centralEntryIndex = centralIndex
|
||||
if strongSelf.isViewLoaded {
|
||||
strongSelf.galleryNode.pager.replaceItems(strongSelf.entries.map({
|
||||
$0.item(account: account, theme: strongSelf.presentationData.theme, strings: strongSelf.presentationData.strings)
|
||||
$0.item(account: account, webPage: webPage, theme: strongSelf.presentationData.theme, strings: strongSelf.presentationData.strings)
|
||||
}), centralItemIndex: centralIndex, keepFirst: false)
|
||||
|
||||
let ready = strongSelf.galleryNode.pager.ready() |> timeout(2.0, queue: Queue.mainQueue(), alternate: .single(Void())) |> afterNext { [weak strongSelf] _ in
|
||||
@@ -200,7 +202,7 @@ class InstantPageGalleryController: ViewController {
|
||||
}
|
||||
|
||||
self.galleryNode.pager.replaceItems(self.entries.map({
|
||||
$0.item(account: account, theme: self.presentationData.theme, strings: self.presentationData.strings)
|
||||
$0.item(account: account, webPage: self.webPage, theme: self.presentationData.theme, strings: self.presentationData.strings)
|
||||
}), centralItemIndex: self.centralEntryIndex)
|
||||
|
||||
self.galleryNode.pager.centralItemIndexUpdated = { [weak self] index in
|
||||
|
||||
Reference in New Issue
Block a user