From 46df3bb7f91e70dbe8de109004017ae84e027cec Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Wed, 20 Sep 2023 07:28:04 +0200 Subject: [PATCH] Fix #1579 --- IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift | 1 + Packages/DesignSystem/Sources/DesignSystem/Theme.swift | 6 +----- .../DesignSystem/Sources/DesignSystem/ThemeApplier.swift | 3 +++ .../Sources/DesignSystem/Views/ThemePreviewView.swift | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift b/IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift index 5ecceaf5..66d8e75b 100644 --- a/IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift +++ b/IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift @@ -233,6 +233,7 @@ struct DisplaySettingsView: View { Button { theme.followSystemColorScheme = true theme.selectedSet = colorScheme == .dark ? .iceCubeDark : .iceCubeLight + theme.setColor(withName: theme.selectedSet) theme.avatarShape = .rounded theme.avatarPosition = .top theme.statusActionsDisplay = .full diff --git a/Packages/DesignSystem/Sources/DesignSystem/Theme.swift b/Packages/DesignSystem/Sources/DesignSystem/Theme.swift index 6fdbf151..092ea174 100644 --- a/Packages/DesignSystem/Sources/DesignSystem/Theme.swift +++ b/Packages/DesignSystem/Sources/DesignSystem/Theme.swift @@ -245,11 +245,7 @@ import SwiftUI } } - public var selectedSet: ColorSetName = .iceCubeDark { - didSet { - setColor(withName: selectedSet) - } - } + public var selectedSet: ColorSetName = .iceCubeDark public static let shared = Theme() diff --git a/Packages/DesignSystem/Sources/DesignSystem/ThemeApplier.swift b/Packages/DesignSystem/Sources/DesignSystem/ThemeApplier.swift index 4a0fe40a..bbf2e3c4 100644 --- a/Packages/DesignSystem/Sources/DesignSystem/ThemeApplier.swift +++ b/Packages/DesignSystem/Sources/DesignSystem/ThemeApplier.swift @@ -31,12 +31,14 @@ struct ThemeApplier: ViewModifier { // If theme is never set before set the default store. This should only execute once after install. if !theme.isThemePreviouslySet { theme.selectedSet = colorScheme == .dark ? .iceCubeDark : .iceCubeLight + theme.setColor(withName: theme.selectedSet) theme.isThemePreviouslySet = true } else if theme.followSystemColorScheme, theme.isThemePreviouslySet, let sets = availableColorsSets .first(where: { $0.light.name == theme.selectedSet || $0.dark.name == theme.selectedSet }) { theme.selectedSet = colorScheme == .dark ? sets.dark.name : sets.light.name + theme.setColor(withName: theme.selectedSet) } setWindowTint(theme.tintColor) setWindowUserInterfaceStyle(from: theme.selectedScheme) @@ -57,6 +59,7 @@ struct ThemeApplier: ViewModifier { .first(where: { $0.light.name == theme.selectedSet || $0.dark.name == theme.selectedSet }) { theme.selectedSet = newColorScheme == .dark ? sets.dark.name : sets.light.name + theme.setColor(withName: theme.selectedSet) } } #endif diff --git a/Packages/DesignSystem/Sources/DesignSystem/Views/ThemePreviewView.swift b/Packages/DesignSystem/Sources/DesignSystem/Views/ThemePreviewView.swift index 3776b917..1aa577d0 100644 --- a/Packages/DesignSystem/Sources/DesignSystem/Views/ThemePreviewView.swift +++ b/Packages/DesignSystem/Sources/DesignSystem/Views/ThemePreviewView.swift @@ -90,6 +90,7 @@ struct ThemeBoxView: View { theme.followSystemColorScheme = false } theme.selectedSet = color.name + theme.setColor(withName: theme.selectedSet) } } }