From 26f89fedef516a768e7d64ae90f440c6f01c96c8 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sun, 15 Dec 2019 20:13:04 +0400 Subject: [PATCH] Fix pattern wallpaper preview & setup interface --- .../Themes/WallpaperPatternPanelNode.swift | 17 +++++++++++++---- .../Sources/WallpaperResources.swift | 1 - 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/submodules/SettingsUI/Sources/Themes/WallpaperPatternPanelNode.swift b/submodules/SettingsUI/Sources/Themes/WallpaperPatternPanelNode.swift index 1ae6a7e093..9e8ff0bfc8 100644 --- a/submodules/SettingsUI/Sources/Themes/WallpaperPatternPanelNode.swift +++ b/submodules/SettingsUI/Sources/Themes/WallpaperPatternPanelNode.swift @@ -42,7 +42,9 @@ final class WallpaperPatternPanelNode: ASDisplayNode { var backgroundColors: (UIColor, UIColor?)? = nil { didSet { - self.updateWallpapers() + if oldValue?.0.rgb != self.backgroundColors?.0.rgb || oldValue?.1?.rgb != self.backgroundColors?.1?.rgb { + self.updateWallpapers() + } } } @@ -136,7 +138,11 @@ final class WallpaperPatternPanelNode: ASDisplayNode { let backgroundColors = self.backgroundColors ?? (UIColor(rgb: 0xd6e2ee), nil) - var selected = true + var selectedFileId: Int64? + if let currentWallpaper = self.currentWallpaper, case let .file(file) = currentWallpaper { + selectedFileId = file.id + } + for wallpaper in wallpapers { let node = SettingsThemeWallpaperNode(overlayBackgroundColor: self.serviceBackgroundColor.withAlphaComponent(0.4)) node.clipsToBounds = true @@ -148,6 +154,11 @@ final class WallpaperPatternPanelNode: ASDisplayNode { updatedWallpaper = .file(id: file.id, accessHash: file.accessHash, isCreator: file.isCreator, isDefault: file.isDefault, isPattern: file.isPattern, isDark: file.isDark, slug: file.slug, file: file.file, settings: settings) } + var selected = false + if case let .file(file) = wallpaper, file.id == selectedFileId { + selected = true + } + node.setWallpaper(context: self.context, wallpaper: updatedWallpaper, selected: selected, size: itemSize) node.pressed = { [weak self, weak node] in if let strongSelf = self { @@ -163,8 +174,6 @@ final class WallpaperPatternPanelNode: ASDisplayNode { } } self.scrollNode.addSubnode(node) - - selected = false } self.scrollNode.view.contentSize = CGSize(width: (itemSize.width + inset) * CGFloat(wallpapers.count) + inset, height: 112.0) diff --git a/submodules/WallpaperResources/Sources/WallpaperResources.swift b/submodules/WallpaperResources/Sources/WallpaperResources.swift index fd84461012..ad593d4c3d 100644 --- a/submodules/WallpaperResources/Sources/WallpaperResources.swift +++ b/submodules/WallpaperResources/Sources/WallpaperResources.swift @@ -480,7 +480,6 @@ public func patternWallpaperImageInternal(thumbnailData: Data?, fullSizeData: Da if colors.count == 1 { c.setFillColor(patternColor(for: color, intensity: intensity, prominent: prominent).cgColor) - c.fill(arguments.drawingRect) c.fill(arguments.drawingRect) } else { let gradientColors = colors.map { patternColor(for: $0, intensity: intensity, prominent: prominent).cgColor } as CFArray