mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-03 05:03:45 +00:00
Open .svgbg files as background preview
This commit is contained in:
parent
7c6413ec4a
commit
93885589a0
@ -106,7 +106,10 @@ private func updatedFileWallpaper(wallpaper: TelegramWallpaper, firstColor: UICo
|
||||
}
|
||||
|
||||
private func updatedFileWallpaper(id: Int64? = nil, accessHash: Int64? = nil, slug: String, file: TelegramMediaFile, firstColor: UIColor?, secondColor: UIColor?, intensity: Int32?, rotation: Int32?) -> TelegramWallpaper {
|
||||
let isPattern = ["image/png", "image/svg+xml"].contains(file.mimeType)
|
||||
var isPattern = ["image/png", "image/svg+xml"].contains(file.mimeType)
|
||||
if let fileName = file.fileName, fileName.hasSuffix(".svgbg") {
|
||||
isPattern = true
|
||||
}
|
||||
var firstColorValue: UInt32?
|
||||
var secondColorValue: UInt32?
|
||||
var intensityValue: Int32?
|
||||
@ -340,8 +343,23 @@ public class WallpaperGalleryController: ViewController {
|
||||
self.overlayNode = overlayNode
|
||||
self.galleryNode.overlayNode = overlayNode
|
||||
self.galleryNode.addSubnode(overlayNode)
|
||||
|
||||
var doneButtonType: WallpaperGalleryToolbarDoneButtonType = .set
|
||||
switch self.source {
|
||||
case let .wallpaper(wallpaper):
|
||||
switch wallpaper.0 {
|
||||
case let .file(file):
|
||||
if file.id == 0 {
|
||||
doneButtonType = .none
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
let toolbarNode = WallpaperGalleryToolbarNode(theme: presentationData.theme, strings: presentationData.strings, doneButtonType: .set)
|
||||
let toolbarNode = WallpaperGalleryToolbarNode(theme: presentationData.theme, strings: presentationData.strings, doneButtonType: doneButtonType)
|
||||
self.toolbarNode = toolbarNode
|
||||
overlayNode.addSubnode(toolbarNode)
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ enum WallpaperGalleryToolbarDoneButtonType {
|
||||
case set
|
||||
case proceed
|
||||
case apply
|
||||
case none
|
||||
}
|
||||
|
||||
final class WallpaperGalleryToolbarNode: ASDisplayNode {
|
||||
@ -107,6 +108,9 @@ final class WallpaperGalleryToolbarNode: ASDisplayNode {
|
||||
doneTitle = strings.Theme_Colors_Proceed
|
||||
case .apply:
|
||||
doneTitle = strings.WallpaperPreview_PatternPaternApply
|
||||
case .none:
|
||||
doneTitle = ""
|
||||
self.doneButton.isUserInteractionEnabled = false
|
||||
}
|
||||
self.cancelButton.setTitle(cancelTitle, with: Font.regular(17.0), with: theme.list.itemPrimaryTextColor, for: [])
|
||||
self.doneButton.setTitle(doneTitle, with: Font.regular(17.0), with: theme.list.itemPrimaryTextColor, for: [])
|
||||
|
||||
@ -339,7 +339,12 @@ func openChatMessageImpl(_ params: OpenChatMessageParams) -> Bool {
|
||||
let controller = ShareController(context: params.context, subject: .media(.standalone(media: file)), immediateExternalShare: true)
|
||||
params.present(controller, nil)
|
||||
} else if let rootController = params.navigationController?.view.window?.rootViewController {
|
||||
presentDocumentPreviewController(rootController: rootController, theme: presentationData.theme, strings: presentationData.strings, postbox: params.context.account.postbox, file: file)
|
||||
if let fileName = file.fileName, fileName.hasSuffix(".svgbg") {
|
||||
let controller = WallpaperGalleryController(context: params.context, source: .wallpaper(.file(id: 0, accessHash: 0, isCreator: false, isDefault: false, isPattern: true, isDark: false, slug: "", file: file, settings: WallpaperSettings()), nil, nil, nil, nil, nil, nil))
|
||||
params.present(controller, nil)
|
||||
} else {
|
||||
presentDocumentPreviewController(rootController: rootController, theme: presentationData.theme, strings: presentationData.strings, postbox: params.context.account.postbox, file: file)
|
||||
}
|
||||
}
|
||||
return true
|
||||
case let .audio(file):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user