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

@@ -42,6 +42,10 @@ struct DayView: View {
@ObservedObject var viewModel: DayViewViewModel
var body: some View {
ZStack {
Text(String(customMoodTintUpdateNumber))
.hidden()
mainView
.onAppear(perform: {
EventLogger.log(event: "show_home_view")
@@ -76,30 +80,28 @@ struct DayView: View {
})
}
}
}
// MARK: Views
public var mainView: some View {
VStack {
settingsButtonView
.padding(.top)
if viewModel.hasNoData {
Spacer()
EmptyHomeView(showVote: true, viewModel: viewModel)
Spacer()
} else {
ZStack {
Text(String(customMoodTintUpdateNumber))
.hidden()
VStack {
headerView
}
}
listView
.padding(.top, 5)
}
}
.padding()
.padding(.bottom, 5)
}
.padding([.leading, .trailing, .bottom])
.background(
theme.currentTheme.bg
.edgesIgnoringSafeArea(.all)
@@ -186,7 +188,7 @@ extension DayView {
return $0.forDate! > $1.forDate!
}), id: \.self) { entry in
if filteredDays.currentFilters.contains(Int(entry.weekDay)) {
// let _ = print(entry.forDate, entry.weekDay, filteredDays.currentFilters)
// let _ = print(entry.forDate, entry.weekDay, filteredDays.currentFilters)
EntryListView(entry: entry)
.contentShape(Rectangle())
.onTapGesture(perform: {

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 {
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()
}