diff --git a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryController.swift b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryController.swift index d9bef27d75..2fc1b29a5e 100644 --- a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryController.swift +++ b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryController.swift @@ -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) diff --git a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryToolbarNode.swift b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryToolbarNode.swift index b3f22d94dc..2e66ab7dba 100644 --- a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryToolbarNode.swift +++ b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryToolbarNode.swift @@ -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: []) diff --git a/submodules/TelegramUI/TelegramUI/OpenChatMessage.swift b/submodules/TelegramUI/TelegramUI/OpenChatMessage.swift index 4f028eda14..555695bf70 100644 --- a/submodules/TelegramUI/TelegramUI/OpenChatMessage.swift +++ b/submodules/TelegramUI/TelegramUI/OpenChatMessage.swift @@ -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):