diff --git a/submodules/GradientBackground/Sources/SoftwareGradientBackground.swift b/submodules/GradientBackground/Sources/SoftwareGradientBackground.swift index 21fcde858a..4b4eb1ae2c 100644 --- a/submodules/GradientBackground/Sources/SoftwareGradientBackground.swift +++ b/submodules/GradientBackground/Sources/SoftwareGradientBackground.swift @@ -232,7 +232,7 @@ public final class GradientBackgroundNode: ASDisplayNode { if let current = self._dimmedImage { return current } else if let (size, colors, positions) = self.dimmedImageParams { - self._dimmedImage = generateGradient(size: size, colors: colors, positions: positions, adjustSaturation: 1.7) + self._dimmedImage = generateGradient(size: size, colors: colors, positions: positions, adjustSaturation: self.saturation) return self._dimmedImage } else { return nil @@ -245,8 +245,11 @@ public final class GradientBackgroundNode: ASDisplayNode { private let useSharedAnimationPhase: Bool static var sharedPhase: Int = 0 - public init(colors: [UIColor]? = nil, useSharedAnimationPhase: Bool = false) { + private let saturation: CGFloat + + public init(colors: [UIColor]? = nil, useSharedAnimationPhase: Bool = false, adjustSaturation: Bool = true) { self.useSharedAnimationPhase = useSharedAnimationPhase + self.saturation = adjustSaturation ? 1.7 : 1.0 self.contentView = UIImageView() let defaultColors: [UIColor] = [ UIColor(rgb: 0x7FA381), @@ -345,7 +348,7 @@ public final class GradientBackgroundNode: ASDisplayNode { images.append(generateGradient(size: imageSize, colors: self.colors, positions: morphedPositions)) if needDimmedImages { - dimmedImages.append(generateGradient(size: imageSize, colors: self.colors, positions: morphedPositions, adjustSaturation: 1.7)) + dimmedImages.append(generateGradient(size: imageSize, colors: self.colors, positions: morphedPositions, adjustSaturation: self.saturation)) } } @@ -393,7 +396,7 @@ public final class GradientBackgroundNode: ASDisplayNode { let image = generateGradient(size: imageSize, colors: self.colors, positions: positions) self.contentView.image = image - let dimmedImage = generateGradient(size: imageSize, colors: self.colors, positions: positions, adjustSaturation: 1.7) + let dimmedImage = generateGradient(size: imageSize, colors: self.colors, positions: positions, adjustSaturation: self.saturation) self._dimmedImage = dimmedImage self.dimmedImageParams = (imageSize, self.colors, positions) @@ -406,7 +409,7 @@ public final class GradientBackgroundNode: ASDisplayNode { let image = generateGradient(size: imageSize, colors: self.colors, positions: positions) self.contentView.image = image - let dimmedImage = generateGradient(size: imageSize, colors: self.colors, positions: positions, adjustSaturation: 1.7) + let dimmedImage = generateGradient(size: imageSize, colors: self.colors, positions: positions, adjustSaturation: self.saturation) self.dimmedImageParams = (imageSize, self.colors, positions) for cloneNode in self.cloneNodes { diff --git a/submodules/SettingsUI/Sources/Themes/EditThemeController.swift b/submodules/SettingsUI/Sources/Themes/EditThemeController.swift index 7d1c27992f..92d95f8309 100644 --- a/submodules/SettingsUI/Sources/Themes/EditThemeController.swift +++ b/submodules/SettingsUI/Sources/Themes/EditThemeController.swift @@ -268,6 +268,7 @@ public func editThemeController(context: AccountContext, mode: EditThemeControll let previewThemePromise = Promise() let settingsPromise = Promise(nil) let hasSettings: Bool + let mayHaveSettings: Bool let presentationData = context.sharedContext.currentPresentationData.with { $0 } switch mode { case let .create(existingTheme, settings): @@ -278,16 +279,19 @@ public func editThemeController(context: AccountContext, mode: EditThemeControll wallpaper = theme.chat.defaultWallpaper settingsPromise.set(.single(settings)) hasSettings = settings != nil + mayHaveSettings = settings != nil } else { theme = presentationData.theme wallpaper = presentationData.chatWallpaper settingsPromise.set(.single(nil)) hasSettings = false + mayHaveSettings = true } initialState = EditThemeControllerState(mode: mode, title: generateThemeName(accentColor: theme.rootController.navigationBar.buttonColor), slug: "", updatedTheme: nil, updating: false) previewThemePromise.set(.single(theme.withUpdated(name: "", defaultWallpaper: wallpaper))) case let .edit(info): hasSettings = info.theme.settings != nil + mayHaveSettings = hasSettings settingsPromise.set(.single(info.theme.settings)) if let file = info.theme.file, let path = context.sharedContext.accountManager.mediaBox.completedResourcePath(file.resource), let data = try? Data(contentsOf: URL(fileURLWithPath: path)), let theme = makePresentationTheme(data: data, resolvedWallpaper: info.resolvedWallpaper) { if case let .file(file) = theme.chat.defaultWallpaper, file.id == 0 { @@ -323,6 +327,8 @@ public func editThemeController(context: AccountContext, mode: EditThemeControll var generalThemeReference: PresentationThemeReference? if case let .edit(cloudTheme) = mode { generalThemeReference = PresentationThemeReference.cloud(cloudTheme).generalThemeReference + } else if case let .create(existingTheme, _) = mode, existingTheme == nil { + generalThemeReference = PresentationThemeReference.builtin(presentationData.theme.referenceTheme) } let arguments = EditThemeControllerArguments(context: context, updateState: { f in @@ -338,7 +344,7 @@ public func editThemeController(context: AccountContext, mode: EditThemeControll state.updatedTheme = updatedTheme return state } - if previousSettings != nil { + if previousSettings != nil || mayHaveSettings { settingsPromise.set(.single(settings)) } controllerDismissImpl?() diff --git a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift index 1c6ad0ad5e..f516e14ee9 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift @@ -186,8 +186,8 @@ final class ThemeAccentColorController: ViewController { if case let .edit(theme, _, generalThemeReference, _, _, completion) = strongSelf.mode { let _ = (prepareWallpaper - |> deliverOnMainQueue).start(completed: { let updatedTheme: PresentationTheme - + |> deliverOnMainQueue).start(completed: { + let updatedTheme: PresentationTheme var settings: TelegramThemeSettings? var hasSettings = false var baseTheme: TelegramBaseTheme? diff --git a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift index cdfd7766a4..03c9295db2 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift @@ -944,7 +944,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate snapshot.frame = itemNode.bounds itemNode.view.addSubview(snapshot) - snapshot.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, completion: { [weak snapshot] _ in + snapshot.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false, completion: { [weak snapshot] _ in snapshot?.removeFromSuperview() }) } diff --git a/submodules/SettingsUI/Sources/Themes/ThemeSettingsChatPreviewItem.swift b/submodules/SettingsUI/Sources/Themes/ThemeSettingsChatPreviewItem.swift index e0c3989f8a..e115dc5dc7 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeSettingsChatPreviewItem.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeSettingsChatPreviewItem.swift @@ -141,7 +141,7 @@ class ThemeSettingsChatPreviewItemNode: ListViewItemNode { currentBackgroundNode = WallpaperBackgroundNode(context: item.context) } currentBackgroundNode?.update(wallpaper: item.wallpaper) - currentBackgroundNode?.updateBubbleTheme(bubbleTheme: item.theme, bubbleCorners: item.chatBubbleCorners) + currentBackgroundNode?.updateBubbleTheme(bubbleTheme: item.componentTheme, bubbleCorners: item.chatBubbleCorners) let insets: UIEdgeInsets let separatorHeight = UIScreenPixel @@ -261,13 +261,13 @@ class ThemeSettingsChatPreviewItemNode: ListViewItemNode { strongSelf.bottomStripeNode.isHidden = hasCorners } - strongSelf.maskNode.image = hasCorners ? PresentationResourcesItemList.cornersImage(item.theme, top: hasTopCorners, bottom: hasBottomCorners) : nil + strongSelf.maskNode.image = hasCorners ? PresentationResourcesItemList.cornersImage(item.componentTheme, top: hasTopCorners, bottom: hasBottomCorners) : nil let backgroundFrame = CGRect(origin: CGPoint(x: 0.0, y: -min(insets.top, separatorHeight)), size: CGSize(width: params.width, height: contentSize.height + min(insets.top, separatorHeight) + min(insets.bottom, separatorHeight))) if let backgroundNode = strongSelf.backgroundNode { backgroundNode.frame = backgroundFrame.insetBy(dx: 0.0, dy: -100.0) backgroundNode.update(wallpaper: item.wallpaper) - backgroundNode.updateBubbleTheme(bubbleTheme: item.theme, bubbleCorners: item.chatBubbleCorners) + backgroundNode.updateBubbleTheme(bubbleTheme: item.componentTheme, bubbleCorners: item.chatBubbleCorners) backgroundNode.updateLayout(size: backgroundNode.bounds.size, transition: .immediate) } strongSelf.maskNode.frame = backgroundFrame.insetBy(dx: params.leftInset, dy: 0.0) diff --git a/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift b/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift index b9f62a7428..b1e9a99a11 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift @@ -115,7 +115,7 @@ extension TelegramWallpaper: Codable { colors.append(value.rgb) } else if component.count <= 3, let value = Int32(component) { if intensity == nil { - if value >= 0 && value <= 100 { + if value >= -100 && value <= 100 { intensity = value } else { intensity = 50 diff --git a/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift b/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift index 61ec3cac11..38b4842493 100644 --- a/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift +++ b/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift @@ -775,7 +775,7 @@ public final class WallpaperBackgroundNode: ASDisplayNode { if bubbleTheme.chat.message.outgoing.bubble.withoutWallpaper.fill.count >= 3 && bubbleTheme.chat.animateMessageColors { if self.outgoingBubbleGradientBackgroundNode == nil { - let outgoingBubbleGradientBackgroundNode = GradientBackgroundNode() + let outgoingBubbleGradientBackgroundNode = GradientBackgroundNode(adjustSaturation: false) if let size = self.validLayout { outgoingBubbleGradientBackgroundNode.frame = CGRect(origin: CGPoint(), size: size) outgoingBubbleGradientBackgroundNode.updateLayout(size: size, transition: .immediate)