From d88c4e7a056c880d078f440e0d031112d9d9265f Mon Sep 17 00:00:00 2001 From: Trey t Date: Wed, 23 Feb 2022 00:39:20 -0600 Subject: [PATCH] a lot of theme work --- Shared/AppDelegate.swift | 8 +++-- Shared/Models/MoodTintable.swift | 22 ++++++------- Shared/Protocols/ChartDataBuildable.swift | 4 +-- Shared/views/FilterView/FilterView.swift | 3 +- Shared/views/HomeView/HomeView.swift | 1 + .../HomeView/HomeViewTwo/HomeViewTwo.swift | 1 + Shared/views/MainTabView.swift | 33 ++++++++++++++++++- Shared/views/SettingsView/SettingsView.swift | 19 ++++++++--- Shared/views/Sharing/SharingListView.swift | 12 ++++--- 9 files changed, 76 insertions(+), 27 deletions(-) diff --git a/Shared/AppDelegate.swift b/Shared/AppDelegate.swift index cbd4133..c478ad3 100644 --- a/Shared/AppDelegate.swift +++ b/Shared/AppDelegate.swift @@ -21,9 +21,13 @@ class AppDelegate: NSObject, UIApplicationDelegate { UNUserNotificationCenter.current().delegate = self let theme = UserDefaultsStore.theme() - UIPageControl.appearance().currentPageIndicatorTintColor = UIColor.label + UIPageControl.appearance().currentPageIndicatorTintColor = UIColor(theme.currentTheme.labelColor) UIPageControl.appearance().pageIndicatorTintColor = UIColor.systemGray - UITabBar.appearance().backgroundColor = UIColor(cgColor: theme.currentTheme.secondaryBGColor.cgColor ?? UIColor.secondarySystemBackground.cgColor) + + let appearance = UITabBarAppearance() + appearance.configureWithOpaqueBackground() + UITabBar.appearance().standardAppearance = appearance + UITabBar.appearance().scrollEdgeAppearance = appearance return true } diff --git a/Shared/Models/MoodTintable.swift b/Shared/Models/MoodTintable.swift index a237c49..d616719 100644 --- a/Shared/Models/MoodTintable.swift +++ b/Shared/Models/MoodTintable.swift @@ -79,9 +79,9 @@ final class DefaultMoodTint: MoodTintable { case .great: return Color(hex: "31d158") case .missing: - return Color(uiColor: UIColor.systemGray4) + return Color(uiColor: UIColor.lightGray) case .placeholder: - return Color(uiColor: UIColor.systemGray4) + return Color(uiColor: UIColor.lightGray) } } @@ -98,9 +98,9 @@ final class DefaultMoodTint: MoodTintable { case .great: return Color(hex: "208939") case .missing: - return Color(uiColor: UIColor.label) + return Color(uiColor: UIColor.lightGray) case .placeholder: - return Color(uiColor: UIColor.label) + return Color(uiColor: UIColor.lightGray) } } } @@ -189,19 +189,19 @@ final class MonoChromeTint: MoodTintable { static func color(forMood mood: Mood) -> Color { switch mood { case .horrible: - return .black + return Color(hex: "#000000") case .bad: - return Color(uiColor: UIColor.systemGray) + return Color(hex: "#47474a") case .average: - return Color(uiColor: UIColor.systemGray) + return Color(hex: "#7b7b81") case .good: - return Color(uiColor: UIColor.systemGray2) + return Color(hex: "#a3a3ab") case .great: - return Color(uiColor: UIColor.systemGray3) + return Color(hex: "#c2c1cb") case .missing: - return Color(uiColor: UIColor.systemGray2) + return Color(hex: "#ff0000") case .placeholder: - return Color(uiColor: UIColor.systemGray4) + return Color(hex: "#efeffb") } } diff --git a/Shared/Protocols/ChartDataBuildable.swift b/Shared/Protocols/ChartDataBuildable.swift index 78a4c2f..e05037a 100644 --- a/Shared/Protocols/ChartDataBuildable.swift +++ b/Shared/Protocols/ChartDataBuildable.swift @@ -85,7 +85,7 @@ extension ChartDataBuildable { filledOutArray.append(view) } else { let thisDate = Calendar.current.date(bySetting: .day, value: day, of: month)! - let view = ChartType(color: Mood.missing.color, + let view = ChartType(color: Mood.placeholder.color, weekDay: Calendar.current.component(.weekday, from: thisDate), viewType: .square) filledOutArray.append(view) @@ -93,7 +93,7 @@ extension ChartDataBuildable { } for _ in filledOutArray.count...32 { - let view = ChartType(color: Mood.missing.color, + let view = ChartType(color: Mood.placeholder.color, weekDay: 2, viewType: .cicle) filledOutArray.append(view) diff --git a/Shared/views/FilterView/FilterView.swift b/Shared/views/FilterView/FilterView.swift index 8237b9b..60ef46f 100644 --- a/Shared/views/FilterView/FilterView.swift +++ b/Shared/views/FilterView/FilterView.swift @@ -139,7 +139,7 @@ struct FilterView: View { .frame(minWidth: 0, maxWidth: .infinity, minHeight: 44, maxHeight: 44) .cornerRadius(10) .padding([.leading, .trailing]) - .foregroundColor(theme.currentTheme.labelColor) + .colorScheme(.light) ZStack { theme.currentTheme.secondaryBGColor @@ -156,6 +156,7 @@ struct FilterView: View { .cornerRadius(10) .padding([.leading, .trailing]) .foregroundColor(theme.currentTheme.labelColor) + .colorScheme(.light) ZStack { theme.currentTheme.secondaryBGColor diff --git a/Shared/views/HomeView/HomeView.swift b/Shared/views/HomeView/HomeView.swift index bf6798d..2e74d2f 100644 --- a/Shared/views/HomeView/HomeView.swift +++ b/Shared/views/HomeView/HomeView.swift @@ -318,6 +318,7 @@ extension HomeView { .foregroundColor(theme.currentTheme.labelColor) Text(" - ") .padding([.leading, .trailing], -10) + .foregroundColor(theme.currentTheme.labelColor) Text(Random.dayFormat(fromDate:entry.forDate!)) .font(.title3) .foregroundColor(theme.currentTheme.labelColor) diff --git a/Shared/views/HomeView/HomeViewTwo/HomeViewTwo.swift b/Shared/views/HomeView/HomeViewTwo/HomeViewTwo.swift index 7a7f992..a331a55 100644 --- a/Shared/views/HomeView/HomeViewTwo/HomeViewTwo.swift +++ b/Shared/views/HomeView/HomeViewTwo/HomeViewTwo.swift @@ -102,6 +102,7 @@ extension HomeViewTwo { Text("Vote") } Text("dis top") + .foregroundColor(theme.currentTheme.secondaryBGColor) } } diff --git a/Shared/views/MainTabView.swift b/Shared/views/MainTabView.swift index f52dd92..61ac48f 100644 --- a/Shared/views/MainTabView.swift +++ b/Shared/views/MainTabView.swift @@ -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 + } + }) } } diff --git a/Shared/views/SettingsView/SettingsView.swift b/Shared/views/SettingsView/SettingsView.swift index f875461..c9cbff4 100644 --- a/Shared/views/SettingsView/SettingsView.swift +++ b/Shared/views/SettingsView/SettingsView.swift @@ -84,11 +84,13 @@ struct SettingsView: View { } }, label: { Text(String(localized: "settings_view_special_thanks_to_title")) + .foregroundColor(theme.currentTheme.labelColor) }) .padding() if showSpecialThanks { Text(String(localized: "settings_view_special_thanks_to_body")) + .foregroundColor(theme.currentTheme.labelColor) .padding() } } @@ -105,6 +107,7 @@ struct SettingsView: View { editedDataClosure() }, label: { Text("Add test data") + .foregroundColor(theme.currentTheme.labelColor) }) .padding() } @@ -120,6 +123,7 @@ struct SettingsView: View { editedDataClosure() }, label: { Text("Clear DB") + .foregroundColor(theme.currentTheme.labelColor) }) .padding() } @@ -137,10 +141,12 @@ struct SettingsView: View { } }, label: { Text(String(localized: "settings_view_why_bg_mode_title")) + .foregroundColor(theme.currentTheme.labelColor) }) .padding() if showWhyBGMode { Text(String(localized: "settings_view_why_bg_mode_body")) + .foregroundColor(theme.currentTheme.labelColor) .padding() } } @@ -160,6 +166,7 @@ struct SettingsView: View { showOnboarding.toggle() }, label: { Text(String(localized: "settings_view_show_onboarding")) + .foregroundColor(theme.currentTheme.labelColor) }) .padding() } @@ -171,13 +178,13 @@ struct SettingsView: View { ZStack { theme.currentTheme.secondaryBGColor VStack { - Toggle(String(localized: "settings_use_cloudkit_title"), - isOn: $useCloudKit) - .onChange(of: useCloudKit) { value in - PersistenceController.shared.switchContainer() - } + Toggle(isOn: $useCloudKit, label: { + Text(String(localized: "settings_use_cloudkit_title")) + .foregroundColor(theme.currentTheme.labelColor) + }) .padding() Text(String(localized: "settings_use_cloudkit_body")) + .foregroundColor(theme.currentTheme.labelColor) } .padding(.bottom) } @@ -192,6 +199,7 @@ struct SettingsView: View { Image(systemName: syncMonitor.syncStateSummary.symbolName) .foregroundColor(syncMonitor.syncStateSummary.symbolColor) Text( syncMonitor.syncStateSummary.isBroken ? "cloudkit is broken" : "cloudkit is good") + .foregroundColor(theme.currentTheme.labelColor) } .padding() } @@ -205,6 +213,7 @@ struct SettingsView: View { VStack { Toggle(String(localized: "settings_use_delete_enable"), isOn: $deleteEnabled) + .foregroundColor(theme.currentTheme.labelColor) .padding() } } diff --git a/Shared/views/Sharing/SharingListView.swift b/Shared/views/Sharing/SharingListView.swift index d58b37b..f004448 100644 --- a/Shared/views/Sharing/SharingListView.swift +++ b/Shared/views/Sharing/SharingListView.swift @@ -118,7 +118,7 @@ struct SharingListView: View { .frame(minWidth: 0, maxWidth: .infinity) .frame(height: 44) .background( - Color(UIColor.secondarySystemBackground) + theme.currentTheme.secondaryBGColor ) .opacity(0.9) } @@ -132,15 +132,17 @@ struct SharingListView: View { }) } - }.background( - theme.currentTheme.bg - .edgesIgnoringSafeArea(.all) - ) + } } + .background( + theme.currentTheme.bg + .edgesIgnoringSafeArea(.top) + ) .sheet(isPresented: $selectedShare.showFuckingSheet, onDismiss: didDismiss) { selectedShare.fuckingWrappedShrable?.destination } + } }