Added some more normal calendar places, played with the day and calendar view
This commit is contained in:
@@ -7,20 +7,23 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
extension Color {
|
||||
init(r: Double, g: Double, b: Double) {
|
||||
self.init(red: r / 255, green: g / 255, blue: b / 255)
|
||||
}
|
||||
}
|
||||
|
||||
struct CalendarView: View {
|
||||
var events: [TrashEvent]
|
||||
let columns: [GridItem] = Array(repeating: .init(.adaptive(minimum: 50, maximum: 50)), count: 7)
|
||||
let columns = [GridItem(), GridItem(), GridItem(), GridItem(), GridItem(), GridItem(), GridItem()]
|
||||
var body: some View {
|
||||
GeometryReader { geometry in
|
||||
VStack {
|
||||
let width: CGFloat = geometry.size.width / 8
|
||||
let width = geometry.size.width / 7.5
|
||||
LazyVGrid(columns: [adaptiveGridItem(width: width)], spacing: 0) {
|
||||
ForEach(0..<events.count) { i in
|
||||
let event = events[i]
|
||||
ForEach(events) { event in
|
||||
DayView(image: event.trash.image, dayOfTheWeek: "TBD", date: event.id, color: event.trash.color)
|
||||
// Text(String(event.id))
|
||||
.frame(minWidth: 50, minHeight: 50)
|
||||
.border(.black, width: 1)
|
||||
.border(Color(r: 217, g: 185, b: 155), width: 1)
|
||||
}
|
||||
}
|
||||
Spacer(minLength: 0)
|
||||
|
||||
@@ -16,19 +16,27 @@ struct DayView: View {
|
||||
var date: Int
|
||||
var color: Color
|
||||
var body: some View {
|
||||
ZStack {
|
||||
Color.init(color)
|
||||
.cornerRadius(10)
|
||||
.scaledToFit()
|
||||
.frame(maxWidth: .infinity)
|
||||
Image(systemName: image)
|
||||
.font(.caption)
|
||||
.frame(maxWidth: .infinity, alignment: .trailing)
|
||||
.padding(.trailing, 6)
|
||||
.padding(.top, 30)
|
||||
Text("\(date).")
|
||||
.font(.headline)
|
||||
GeometryReader { geometry in
|
||||
ZStack {
|
||||
Color.init(color)
|
||||
// .cornerRadius(10)
|
||||
.frame(maxWidth: .infinity)
|
||||
|
||||
Text("\(date).")
|
||||
.font(.headline)
|
||||
VStack {
|
||||
Spacer()
|
||||
HStack(alignment: .bottom) {
|
||||
Spacer()
|
||||
Image(systemName: image)
|
||||
// .padding([.bottom, .trailing])
|
||||
.font(.caption)
|
||||
.frame(maxWidth: .infinity, alignment: .trailing)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.aspectRatio(1.0, contentMode: .fit)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ struct MainView: View {
|
||||
GeometryReader { geometry in
|
||||
VStack {
|
||||
CalendarView(events: model.getTrashEvents())
|
||||
.padding()
|
||||
// .padding()
|
||||
let width: CGFloat = geometry.size.width / 2
|
||||
LazyVGrid(columns: [adaptiveGridItem(width: width)], spacing: 0) {
|
||||
DayView(image: "tree", dayOfTheWeek: "Mon", date: 31, color: .green)
|
||||
|
||||
@@ -29,7 +29,8 @@ struct TrashModel {
|
||||
Trash(type: "plastic", color: .orange, image: "waterbottle"),
|
||||
Trash(type: "paper", color: .blue, image: "newspaper"),
|
||||
Trash(type: "bio", color: .green, image: "tree"),
|
||||
Trash(type: "residual", color: .gray, image: "trash")
|
||||
Trash(type: "residual", color: .gray, image: "trash"),
|
||||
Trash(type: "none", color: .white, image: "")
|
||||
]
|
||||
|
||||
self.trashEvents = []
|
||||
@@ -80,8 +81,8 @@ struct TrashModel {
|
||||
self.trashEvents.append(
|
||||
TrashEvent(
|
||||
id: i,
|
||||
trash: self.trashTypes[3],
|
||||
date: Calendar.current.date(byAdding: .day, value: 6 + 7 + 7*i, to: Date())!
|
||||
trash: self.trashTypes[4],
|
||||
date: Calendar.current.date(byAdding: .day, value: 3 + 7 + 7*i, to: Date())!
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user