Made theme colour projects persist across theme changes
This commit is contained in:
parent
1f23a55b51
commit
3edd8cf6a9
@ -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 {
|
||||
// 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) {
|
||||
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")")
|
||||
}
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ struct SettingsView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.scrollIndicators(.hidden)
|
||||
}
|
||||
Toggle("Show Timers", isOn: $showTimers)
|
||||
} header: { Text("General") }
|
||||
|
Loading…
x
Reference in New Issue
Block a user