This commit is contained in:
Vladimir Dubovik
2024-12-11 13:33:35 +03:00
parent 57e241292f
commit 1de531abc8
13 changed files with 325 additions and 132 deletions

View File

@ -26,9 +26,11 @@ final class ViewModel: ObservableObject {
@Published var isFirstStartOffApp = true
@Published var isShowingAlertForIncorrectGroup: Bool = false
@Published var errorInNetwork: NetworkError?
@Published var isLoading: Bool = false
//MARK: Methods
func fetchWeekSchedule(_ group: String, _ num: Int = 0) {
isLoading = true
Task {
do {
var schedule: Schedule
@ -45,6 +47,7 @@ final class ViewModel: ObservableObject {
classes = weekSchedule.table
self.isFirstStartOffApp = false
self.isShowingAlertForIncorrectGroup = false
isLoading = false
}
catch {
if let error = error as? NetworkError {
@ -57,15 +60,15 @@ final class ViewModel: ObservableObject {
default:
print(2)
}
isLoading = false
print(error)
}
}
}
}
func updateSelectedDayIndex(_ date: Date) {
selectedDay = date
switch date.format("E") {
func updateSelectedDayIndex() {
switch selectedDay.format("E") {
case "Пн":
selectedIndex = 2
case "Вт":
@ -81,7 +84,6 @@ final class ViewModel: ObservableObject {
default:
selectedIndex = 8
}
print(selectedIndex)
}
}