Created basic main view, dates missing

This commit is contained in:
2024-01-13 01:10:20 +01:00
parent 01381f9f25
commit f7a0d5edc8
6 changed files with 139 additions and 29 deletions

View File

@@ -26,15 +26,16 @@ struct TrashModel {
init() {
self.trashTypes = [
Trash(type: "plastic", color: Color.orange, image: "waterbottle"),
Trash(type: "paper", color: Color.orange, image: "newspaper"),
Trash(type: "bio", color: Color.orange, image: "tree"),
Trash(type: "residual", color: Color.orange, image: "trash")
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")
]
self.trashEvents = []
let numberOfEvents = 3
for i in 0..<numberOfEvents {
let numberOfEvents = 10
let start = 1
for i in start..<numberOfEvents {
self.trashEvents.append(
TrashEvent(
id: i,
@@ -44,7 +45,7 @@ struct TrashModel {
)
}
for i in 0..<numberOfEvents {
for i in start..<numberOfEvents {
self.trashEvents.append(
TrashEvent(
id: i + 4 + 7,
@@ -54,7 +55,7 @@ struct TrashModel {
)
}
for i in 0..<numberOfEvents {
for i in start..<numberOfEvents {
self.trashEvents.append(
TrashEvent(
id: i + 5,
@@ -64,7 +65,7 @@ struct TrashModel {
)
}
for i in 0..<numberOfEvents {
for i in start..<numberOfEvents {
self.trashEvents.append(
TrashEvent(
id: i + 6 + 7,
@@ -74,7 +75,18 @@ struct TrashModel {
)
}
print(self.trashEvents)
for i in 1..<30 {
if !self.trashEvents.contains(where: { $0.id == i }) {
self.trashEvents.append(
TrashEvent(
id: i,
trash: self.trashTypes[3],
date: Calendar.current.date(byAdding: .day, value: 6 + 7 + 7*i, to: Date())!
)
)
}
}
self.trashEvents.sort(by: { $0.id < $1.id })
}
func getTrashEvents() -> [TrashEvent] {