a lot of theme work
This commit is contained in:
@@ -10,6 +10,10 @@ import SwiftUI
|
||||
struct MainTabView: View {
|
||||
@AppStorage(UserDefaultsStore.Keys.needsOnboarding.rawValue, store: GroupUserDefaults.groupDefaults) private var needsOnboarding = true
|
||||
|
||||
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
|
||||
|
||||
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default
|
||||
|
||||
let onboardingData = OnboardingDataDataManager.shared.savedOnboardingData
|
||||
|
||||
var body: some View {
|
||||
@@ -38,7 +42,9 @@ struct MainTabView: View {
|
||||
.tabItem {
|
||||
Label(String(localized: "content_view_tab_customize"), systemImage: "pencil")
|
||||
}
|
||||
}.sheet(isPresented: $needsOnboarding, onDismiss: {
|
||||
}
|
||||
.accentColor(moodTint.color(forMood: .average))
|
||||
.sheet(isPresented: $needsOnboarding, onDismiss: {
|
||||
|
||||
}, content: {
|
||||
OnboardingMain(onboardingData: onboardingData,
|
||||
@@ -47,6 +53,31 @@ struct MainTabView: View {
|
||||
OnboardingDataDataManager.shared.updateOnboardingData(onboardingData: onboardingData)
|
||||
})
|
||||
})
|
||||
.onAppear(perform: {
|
||||
switch theme {
|
||||
case .system:
|
||||
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = .unspecified
|
||||
case .iFeel:
|
||||
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = .unspecified
|
||||
case .dark:
|
||||
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = .dark
|
||||
case .light:
|
||||
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = .light
|
||||
}
|
||||
})
|
||||
.onChange(of: theme, perform: { value in
|
||||
print("changed to ", value)
|
||||
switch theme {
|
||||
case .system:
|
||||
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = .unspecified
|
||||
case .iFeel:
|
||||
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = .unspecified
|
||||
case .dark:
|
||||
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = .dark
|
||||
case .light:
|
||||
UIApplication.shared.windows.first?.overrideUserInterfaceStyle = .light
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user