mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 18:21:00 +00:00
Fix Theme not overriding UserInterfaceStyle when not following system theme (#508)
This commit is contained in:
parent
e5b6e79fa9
commit
329e21f43c
1 changed files with 24 additions and 0 deletions
|
@ -38,6 +38,7 @@ struct ThemeApplier: ViewModifier {
|
||||||
theme.selectedSet = colorScheme == .dark ? sets.dark.name : sets.light.name
|
theme.selectedSet = colorScheme == .dark ? sets.dark.name : sets.light.name
|
||||||
}
|
}
|
||||||
setWindowTint(theme.tintColor)
|
setWindowTint(theme.tintColor)
|
||||||
|
setWindowUserInterfaceStyle(from: theme.selectedScheme)
|
||||||
setBarsColor(theme.primaryBackgroundColor)
|
setBarsColor(theme.primaryBackgroundColor)
|
||||||
}
|
}
|
||||||
.onChange(of: theme.tintColor) { newValue in
|
.onChange(of: theme.tintColor) { newValue in
|
||||||
|
@ -46,6 +47,9 @@ struct ThemeApplier: ViewModifier {
|
||||||
.onChange(of: theme.primaryBackgroundColor) { newValue in
|
.onChange(of: theme.primaryBackgroundColor) { newValue in
|
||||||
setBarsColor(newValue)
|
setBarsColor(newValue)
|
||||||
}
|
}
|
||||||
|
.onChange(of: theme.selectedScheme) { newValue in
|
||||||
|
setWindowUserInterfaceStyle(from: newValue)
|
||||||
|
}
|
||||||
.onChange(of: colorScheme) { newColorScheme in
|
.onChange(of: colorScheme) { newColorScheme in
|
||||||
if theme.followSystemColorScheme,
|
if theme.followSystemColorScheme,
|
||||||
let sets = availableColorsSets
|
let sets = availableColorsSets
|
||||||
|
@ -58,6 +62,26 @@ struct ThemeApplier: ViewModifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if canImport(UIKit)
|
#if canImport(UIKit)
|
||||||
|
private func setWindowUserInterfaceStyle(from colorScheme: ColorScheme) {
|
||||||
|
guard !theme.followSystemColorScheme else {
|
||||||
|
setWindowUserInterfaceStyle(.unspecified)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch colorScheme {
|
||||||
|
case .dark:
|
||||||
|
setWindowUserInterfaceStyle(.dark)
|
||||||
|
case .light:
|
||||||
|
setWindowUserInterfaceStyle(.light)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func setWindowUserInterfaceStyle(_ userInterfaceStyle: UIUserInterfaceStyle) {
|
||||||
|
allWindows()
|
||||||
|
.forEach {
|
||||||
|
$0.overrideUserInterfaceStyle = userInterfaceStyle
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func setWindowTint(_ color: Color) {
|
private func setWindowTint(_ color: Color) {
|
||||||
allWindows()
|
allWindows()
|
||||||
.forEach {
|
.forEach {
|
||||||
|
|
Loading…
Reference in a new issue