fix bug with text color and changing themes
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
import SwiftUI
|
||||
|
||||
struct ThemePickerView: View {
|
||||
@Environment(\.colorScheme) var colorScheme
|
||||
|
||||
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
|
||||
@AppStorage(UserDefaultsStore.Keys.textColor.rawValue, store: GroupUserDefaults.groupDefaults) private var textColor: Color = DefaultTextColor.textColor
|
||||
|
||||
@@ -19,8 +21,8 @@ struct ThemePickerView: View {
|
||||
Spacer()
|
||||
ForEach(Theme.allCases, id:\.rawValue) { aTheme in
|
||||
Button(action: {
|
||||
textColor = aTheme.currentTheme.labelColor
|
||||
theme = aTheme
|
||||
changeTextColor(forTheme: aTheme)
|
||||
EventLogger.log(event: "change_theme_id", withData: ["id": aTheme.rawValue])
|
||||
}, label: {
|
||||
VStack {
|
||||
@@ -51,6 +53,28 @@ struct ThemePickerView: View {
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
||||
}
|
||||
|
||||
private func changeTextColor(forTheme theme: Theme) {
|
||||
if [Theme.iFeel, Theme.system].contains(theme) {
|
||||
let currentSystemScheme = UITraitCollection.current.userInterfaceStyle
|
||||
switch currentSystemScheme {
|
||||
case .unspecified:
|
||||
textColor = .black
|
||||
case .light:
|
||||
textColor = .black
|
||||
case .dark:
|
||||
textColor = .white
|
||||
@unknown default:
|
||||
textColor = .black
|
||||
}
|
||||
}
|
||||
if theme == Theme.dark {
|
||||
textColor = .white
|
||||
}
|
||||
if theme == Theme.light {
|
||||
textColor = .black
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ThemePickerView_Previews: PreviewProvider {
|
||||
|
||||
Reference in New Issue
Block a user