Made theme colour projects persist across theme changes

This commit is contained in:
breadone 2024-06-27 10:30:26 +12:00
parent 1f23a55b51
commit 3edd8cf6a9
No known key found for this signature in database
2 changed files with 20 additions and 11 deletions

View File

@ -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<OCProject>, 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")")
}
}

View File

@ -69,6 +69,7 @@ struct SettingsView: View {
}
}
}
.scrollIndicators(.hidden)
}
Toggle("Show Timers", isOn: $showTimers)
} header: { Text("General") }