Header chart view on main page
change layout of main page rows
This commit is contained in:
@@ -57,25 +57,40 @@ struct ContentView: View {
|
||||
}
|
||||
}
|
||||
|
||||
private func weekdayName(fromDate date: Date) -> String {
|
||||
let weekday = Calendar.current.component(.weekday, from: date)
|
||||
let calendar = Calendar.current
|
||||
let dayIndex = ((weekday - 1) + (calendar.firstWeekday - 1)) % 7
|
||||
return calendar.shortWeekdaySymbols[dayIndex]
|
||||
}
|
||||
|
||||
private var listView: some View {
|
||||
List {
|
||||
ForEach(items) { item in
|
||||
HStack {
|
||||
item.mood.icon
|
||||
.resizable()
|
||||
.frame(width: 50, height: 50, alignment: .center)
|
||||
.frame(width: 40, height: 40, alignment: .center)
|
||||
.foregroundColor(item.mood.color)
|
||||
VStack {
|
||||
HStack {
|
||||
Text(weekdayName(fromDate:item.forDate!))
|
||||
.font(.title3)
|
||||
.foregroundColor(Color(UIColor.label))
|
||||
.frame(maxWidth: 40, alignment: .leading)
|
||||
Text(" - ")
|
||||
.padding([.leading, .trailing], -10)
|
||||
Text(item.forDate ?? Date(), style: .date)
|
||||
.font(.title3)
|
||||
.foregroundColor(Color(UIColor.label))
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
Text("\(item.moodString)")
|
||||
.font(.title)
|
||||
.font(.body)
|
||||
.foregroundColor(Color(UIColor.systemGray))
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
Text(item.forDate ?? Date(), style: .date)
|
||||
.font(.body)
|
||||
.foregroundColor(Color(UIColor.label))
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
.padding(.leading)
|
||||
|
||||
}
|
||||
}
|
||||
.onDelete(perform: deleteItems)
|
||||
@@ -90,15 +105,13 @@ struct ContentView: View {
|
||||
.frame(minHeight: 85, maxHeight: 180)
|
||||
.frame(minWidth: 0, maxWidth: .infinity)
|
||||
} else {
|
||||
HeaderStatsView(entries: [
|
||||
//x - position of a bar, y - height of a bar
|
||||
BarChartDataEntry(x: 1, y: 1),
|
||||
BarChartDataEntry(x: 2, y: 5),
|
||||
BarChartDataEntry(x: 3, y: 2),
|
||||
BarChartDataEntry(x: 4, y: 4),
|
||||
BarChartDataEntry(x: 5, y: 1)
|
||||
])
|
||||
HeaderStatsView(fakeData: false, backDays: 30)
|
||||
.frame(minHeight: 85, maxHeight: 180)
|
||||
// should match backDays above
|
||||
Text("Past \(30) days")
|
||||
.font(.body)
|
||||
.foregroundColor(Color(UIColor.systemGray))
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
}
|
||||
listView
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user