add count to month view header

clean up spacing on day view
This commit is contained in:
Trey t
2022-04-14 22:55:33 -05:00
parent 61a5f71a2e
commit 7712f70f03
2 changed files with 73 additions and 52 deletions

View File

@@ -125,12 +125,31 @@ extension MonthView {
// view that make up the list body
extension MonthView {
private func monthCountView(forMonth month: Int, year: Int) -> [MoodMetrics] {
let (startDate, endDate) = Date.dateRange(monthInt: month, yearInt: year)
let entries = PersistenceController.shared.getData(startDate: startDate, endDate: endDate, includedDays: [1,2,3,4,5,6,7])
return Random.createTotalPerc(fromEntries: entries)
}
private func homeViewTwoSectionHeaderView(month: Int, year: Int) -> some View {
ZStack {
Text("\(Random.monthName(fromMonthInt: month)) \(String(year))")
.font(.body)
.foregroundColor(textColor)
.frame(maxWidth: .infinity, alignment: .leading)
HStack {
Text("\(Random.monthName(fromMonthInt: month)) \(String(year))")
.font(.body)
.foregroundColor(textColor)
.frame(maxWidth: .infinity, alignment: .leading)
Spacer()
ForEach(monthCountView(forMonth: month, year: year)) {
Text("\($0.total)")
.font(.body)
.fontWeight(.bold)
.foregroundColor($0.mood.color)
}
}
Text(String(customMoodTintUpdateNumber))
.hidden()
}