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 = ""
|
@State private var searchText = ""
|
||||||
|
|
||||||
@AppStorage(Preferences.themeColour) var themeColor = Color.blue.toHex()!
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationSplitView {
|
NavigationSplitView {
|
||||||
List {
|
List {
|
||||||
@ -56,11 +54,12 @@ struct MainView: View {
|
|||||||
withAnimation {
|
withAnimation {
|
||||||
var newProject: OCProject
|
var newProject: OCProject
|
||||||
|
|
||||||
if color == Color.clear.toHex()! {
|
// if color == Color.clear.toHex()! {
|
||||||
newProject = OCProject(name: name, color: themeColor)
|
// newProject = OCProject(name: name, color: themeColor)
|
||||||
} else {
|
// } else {
|
||||||
|
// newProject = OCProject(name: name, color: color)
|
||||||
|
// }
|
||||||
newProject = OCProject(name: name, color: color)
|
newProject = OCProject(name: name, color: color)
|
||||||
}
|
|
||||||
modelContext.insert(newProject)
|
modelContext.insert(newProject)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,6 +69,8 @@ private struct ProjectListView: View {
|
|||||||
@Environment(\.modelContext) private var modelContext
|
@Environment(\.modelContext) private var modelContext
|
||||||
@Query private var projects: [OCProject]
|
@Query private var projects: [OCProject]
|
||||||
|
|
||||||
|
@AppStorage(Preferences.themeColour) var themeColor = Color.blue.toHex()!
|
||||||
|
|
||||||
init(sort: SortDescriptor<OCProject>, searchString: String, color: String) {
|
init(sort: SortDescriptor<OCProject>, searchString: String, color: String) {
|
||||||
_projects = Query(filter: #Predicate {
|
_projects = Query(filter: #Predicate {
|
||||||
if searchString.isEmpty {
|
if searchString.isEmpty {
|
||||||
@ -86,10 +87,17 @@ private struct ProjectListView: View {
|
|||||||
CardsView(project: project)
|
CardsView(project: project)
|
||||||
} label: {
|
} label: {
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
|
if (project.color == Color.clear.toHex()!) {
|
||||||
|
Text("\(project.name)")
|
||||||
|
.bold()
|
||||||
|
.font(.title2)
|
||||||
|
.foregroundStyle(Color(hex: themeColor) ?? .blue)
|
||||||
|
} else {
|
||||||
Text("\(project.name)")
|
Text("\(project.name)")
|
||||||
.bold()
|
.bold()
|
||||||
.font(.title2)
|
.font(.title2)
|
||||||
.foregroundStyle(Color(hex: project.color) ?? .white)
|
.foregroundStyle(Color(hex: project.color) ?? .white)
|
||||||
|
}
|
||||||
Text("\(project.cards.count) \(project.cards.count == 1 ? "Card" : "Cards")")
|
Text("\(project.cards.count) \(project.cards.count == 1 ? "Card" : "Cards")")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,7 @@ struct SettingsView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.scrollIndicators(.hidden)
|
||||||
}
|
}
|
||||||
Toggle("Show Timers", isOn: $showTimers)
|
Toggle("Show Timers", isOn: $showTimers)
|
||||||
} header: { Text("General") }
|
} header: { Text("General") }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user