From 3edd8cf6a9d3f94c126b55470e998e2eb68f53b9 Mon Sep 17 00:00:00 2001 From: breadone Date: Thu, 27 Jun 2024 10:30:26 +1200 Subject: [PATCH] Made theme colour projects persist across theme changes --- OnCue/View/MainView.swift | 30 +++++++++++++++++++----------- OnCue/View/SettingsView.swift | 1 + 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/OnCue/View/MainView.swift b/OnCue/View/MainView.swift index 3313f11..b69e388 100644 --- a/OnCue/View/MainView.swift +++ b/OnCue/View/MainView.swift @@ -18,8 +18,6 @@ struct MainView: View { @State private var searchText = "" - @AppStorage(Preferences.themeColour) var themeColor = Color.blue.toHex()! - var body: some View { NavigationSplitView { List { @@ -56,11 +54,12 @@ struct MainView: View { withAnimation { var newProject: OCProject - if color == Color.clear.toHex()! { - newProject = OCProject(name: name, color: themeColor) - } else { - newProject = OCProject(name: name, color: color) - } +// if color == Color.clear.toHex()! { +// newProject = OCProject(name: name, color: themeColor) +// } else { +// newProject = OCProject(name: name, color: color) +// } + newProject = OCProject(name: name, color: color) modelContext.insert(newProject) } } @@ -70,6 +69,8 @@ private struct ProjectListView: View { @Environment(\.modelContext) private var modelContext @Query private var projects: [OCProject] + @AppStorage(Preferences.themeColour) var themeColor = Color.blue.toHex()! + init(sort: SortDescriptor, searchString: String, color: String) { _projects = Query(filter: #Predicate { if searchString.isEmpty { @@ -86,10 +87,17 @@ private struct ProjectListView: View { CardsView(project: project) } label: { VStack(alignment: .leading) { - Text("\(project.name)") - .bold() - .font(.title2) - .foregroundStyle(Color(hex: project.color) ?? .white) + if (project.color == Color.clear.toHex()!) { + Text("\(project.name)") + .bold() + .font(.title2) + .foregroundStyle(Color(hex: themeColor) ?? .blue) + } else { + Text("\(project.name)") + .bold() + .font(.title2) + .foregroundStyle(Color(hex: project.color) ?? .white) + } Text("\(project.cards.count) \(project.cards.count == 1 ? "Card" : "Cards")") } } diff --git a/OnCue/View/SettingsView.swift b/OnCue/View/SettingsView.swift index ead28e8..7d3e202 100644 --- a/OnCue/View/SettingsView.swift +++ b/OnCue/View/SettingsView.swift @@ -69,6 +69,7 @@ struct SettingsView: View { } } } + .scrollIndicators(.hidden) } Toggle("Show Timers", isOn: $showTimers) } header: { Text("General") }