From 9da9963eb62fa35328b6094e0798550eea8a648e Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Mon, 11 Nov 2019 21:35:18 +0400 Subject: [PATCH 1/2] Fix chat bubble file icon color --- .../Sources/PresentationThemeEssentialGraphics.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/submodules/TelegramPresentationData/Sources/PresentationThemeEssentialGraphics.swift b/submodules/TelegramPresentationData/Sources/PresentationThemeEssentialGraphics.swift index 7f9e7971d0..ff1f33c495 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationThemeEssentialGraphics.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationThemeEssentialGraphics.swift @@ -362,8 +362,8 @@ public final class PrincipalThemeEssentialGraphics { context.fillEllipse(in: CGRect(origin: CGPoint(), size: size)) })!.stretchableImage(withLeftCapWidth: Int(chatDateSize) / 2, topCapHeight: Int(chatDateSize) / 2) - self.radialIndicatorFileIconIncoming = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/RadialProgressIconDocument"), color: incoming.fill)! - self.radialIndicatorFileIconOutgoing = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/RadialProgressIconDocument"), color: outgoing.fill)! + self.radialIndicatorFileIconIncoming = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/RadialProgressIconDocument"), color: theme.message.incoming.mediaControlInnerBackgroundColor)! + self.radialIndicatorFileIconOutgoing = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/RadialProgressIconDocument"), color: theme.message.outgoing.mediaControlInnerBackgroundColor)! } } } From 8e2e88272679db7fb7b07fe0f8fc6b1a0f679775 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Tue, 12 Nov 2019 10:17:02 +0400 Subject: [PATCH 2/2] Fix accent color selection when auto-night mode is triggered --- .../Themes/ThemeAccentColorController.swift | 18 +++++++++++++----- .../Themes/ThemeSettingsController.swift | 14 ++++++++++---- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift index e3470bac21..0c23275db4 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift @@ -65,18 +65,26 @@ final class ThemeAccentColorController: ViewController { if let strongSelf = self { let context = strongSelf.context let _ = (updatePresentationThemeSettingsInteractively(accountManager: context.sharedContext.accountManager, { current in - var themeSpecificAccentColors = current.themeSpecificAccentColors let color = PresentationThemeAccentColor(baseColor: .custom, value: Int32(bitPattern: strongSelf.controllerNode.color)) - themeSpecificAccentColors[current.theme.index] = color + + let autoNightModeTriggered = context.sharedContext.currentPresentationData.with { $0 }.autoNightModeTriggered + + var currentTheme = current.theme + if autoNightModeTriggered { + currentTheme = current.automaticThemeSwitchSetting.theme + } + + var themeSpecificAccentColors = current.themeSpecificAccentColors + themeSpecificAccentColors[currentTheme.index] = color var themeSpecificChatWallpapers = current.themeSpecificChatWallpapers - let theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: strongSelf.currentTheme, accentColor: UIColor(rgb: strongSelf.controllerNode.color), serviceBackgroundColor: defaultServiceBackgroundColor, baseColor: color.baseColor) ?? defaultPresentationTheme + let theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: currentTheme, accentColor: UIColor(rgb: strongSelf.controllerNode.color), serviceBackgroundColor: defaultServiceBackgroundColor, baseColor: color.baseColor) ?? defaultPresentationTheme var chatWallpaper = current.chatWallpaper - if let wallpaper = current.themeSpecificChatWallpapers[current.theme.index], wallpaper.hasWallpaper { + if let wallpaper = current.themeSpecificChatWallpapers[currentTheme.index], wallpaper.hasWallpaper { } else { chatWallpaper = theme.chat.defaultWallpaper - themeSpecificChatWallpapers[current.theme.index] = chatWallpaper + themeSpecificChatWallpapers[currentTheme.index] = chatWallpaper } return PresentationThemeSettings(chatWallpaper: chatWallpaper, theme: strongSelf.currentTheme, themeSpecificAccentColors: themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations) diff --git a/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift b/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift index 9c90bff6f7..b38119f87a 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift @@ -442,18 +442,24 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The pushControllerImpl?(ThemeGridController(context: context)) }, selectAccentColor: { color in let _ = updatePresentationThemeSettingsInteractively(accountManager: context.sharedContext.accountManager, { current in - guard let theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: current.theme, accentColor: color.color, serviceBackgroundColor: defaultServiceBackgroundColor, baseColor: color.baseColor) else { + let autoNightModeTriggered = context.sharedContext.currentPresentationData.with { $0 }.autoNightModeTriggered + var currentTheme = current.theme + if autoNightModeTriggered { + currentTheme = current.automaticThemeSwitchSetting.theme + } + + guard let theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: currentTheme, accentColor: color.color, serviceBackgroundColor: defaultServiceBackgroundColor, baseColor: color.baseColor) else { return current } var themeSpecificAccentColors = current.themeSpecificAccentColors - themeSpecificAccentColors[current.theme.index] = color + themeSpecificAccentColors[currentTheme.index] = color var themeSpecificChatWallpapers = current.themeSpecificChatWallpapers var chatWallpaper = current.chatWallpaper - if let wallpaper = current.themeSpecificChatWallpapers[current.theme.index], wallpaper.hasWallpaper { + if let wallpaper = current.themeSpecificChatWallpapers[currentTheme.index], wallpaper.hasWallpaper { } else { chatWallpaper = theme.chat.defaultWallpaper - themeSpecificChatWallpapers[current.theme.index] = chatWallpaper + themeSpecificChatWallpapers[currentTheme.index] = chatWallpaper } return PresentationThemeSettings(chatWallpaper: chatWallpaper, theme: current.theme, themeSpecificAccentColors: themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, fontSize: current.fontSize, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations)