WIP - a lot of uncommitted work

This commit is contained in:
Trey t
2022-01-15 12:03:31 -06:00
parent 80690e4a8c
commit 64dd1855ac
31 changed files with 1024 additions and 154 deletions

View File

@@ -16,7 +16,7 @@ struct ContentView: View {
@State private var showTodayInput = true
@FetchRequest(
sortDescriptors: [NSSortDescriptor(keyPath: \MoodEntry.date, ascending: false)],
sortDescriptors: [NSSortDescriptor(keyPath: \MoodEntry.forDate, ascending: false)],
animation: .spring())
private var items: FetchedResults<MoodEntry>
@@ -29,10 +29,16 @@ struct ContentView: View {
Label("Main", systemImage: "list.dash")
}
FilterView()
.tabItem {
Label("Filter", systemImage: "calendar.circle")
}
GraphView()
.tabItem {
Label("Graph", systemImage: "chart.line.uptrend.xyaxis")
Label("Stats", systemImage: "chart.line.uptrend.xyaxis")
}
}
}
@@ -56,13 +62,15 @@ struct ContentView: View {
ForEach(items) { item in
HStack {
item.mood.icon
.font(.system(size: 50))
.resizable()
.frame(width: 50, height: 50, alignment: .center)
.foregroundColor(item.mood.color)
VStack {
Text("\(item.moodString)")
.font(.title)
.foregroundColor(Color(UIColor.systemGray))
.frame(maxWidth: .infinity, alignment: .leading)
Text(item.date!, style: .date)
Text(item.forDate ?? Date(), style: .date)
.font(.body)
.foregroundColor(Color(UIColor.label))
.frame(maxWidth: .infinity, alignment: .leading)
@@ -123,8 +131,8 @@ struct ContentView: View {
// Note: Times are printed in UTC. Depending on where you live it won't print 00:00:00 but it will work with UTC times which can be converted to local time
// Set predicate as date being today's date
let fromPredicate = NSPredicate(format: "%@ <= %K", dateFrom as NSDate, #keyPath(MoodEntry.date))
let toPredicate = NSPredicate(format: "%K < %@", #keyPath(MoodEntry.date), dateTo as NSDate)
let fromPredicate = NSPredicate(format: "%@ <= %K", dateFrom as NSDate, #keyPath(MoodEntry.forDate))
let toPredicate = NSPredicate(format: "%K < %@", #keyPath(MoodEntry.forDate), dateTo as NSDate)
let datePredicate = NSCompoundPredicate(andPredicateWithSubpredicates: [fromPredicate, toPredicate])
fetchRequest.predicate = datePredicate
let entries = try! self.viewContext.count(for: fetchRequest)