Commit
This commit is contained in:
parent
5946cd3ec0
commit
8bc7425e2a
@ -36,22 +36,37 @@ struct ContentView: View {
|
|||||||
}
|
}
|
||||||
.accentColor(Color("blueColor"))
|
.accentColor(Color("blueColor"))
|
||||||
.onAppear {
|
.onAppear {
|
||||||
let group1 = UserDefaults.standard.string(forKey: "group")
|
fillDictForVm()
|
||||||
let group2 = UserDefaults.standard.string(forKey: "group2")
|
|
||||||
let group3 = UserDefaults.standard.string(forKey: "group3")
|
|
||||||
if let nameGroup1 = group1, nameGroup1 != "" {
|
|
||||||
vm.nameGroups.append(nameGroup1)
|
|
||||||
}
|
|
||||||
if let nameGroup2 = group2, nameGroup2 != "" {
|
|
||||||
vm.nameGroups.append(nameGroup2)
|
|
||||||
}
|
|
||||||
if let nameGroup3 = group3, nameGroup3 != "" {
|
|
||||||
vm.nameGroups.append(nameGroup3)
|
|
||||||
}
|
|
||||||
print("\(group1) - \(group2) - \(group3)")
|
|
||||||
vm.fetchWeekSchedule()
|
vm.fetchWeekSchedule()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func fillDictForVm() {
|
||||||
|
let group1 = UserDefaults.standard.string(forKey: "group")
|
||||||
|
let group2 = UserDefaults.standard.string(forKey: "group2")
|
||||||
|
let group3 = UserDefaults.standard.string(forKey: "group3")
|
||||||
|
let vpk1 = UserDefaults.standard.string(forKey: "vpk1")
|
||||||
|
let vpk2 = UserDefaults.standard.string(forKey: "vpk2")
|
||||||
|
let vpk3 = UserDefaults.standard.string(forKey: "vpk3")
|
||||||
|
if let nameGroup1 = group1, nameGroup1 != "" {
|
||||||
|
vm.nameToHtml[nameGroup1] = ""
|
||||||
|
}
|
||||||
|
if let nameGroup2 = group2, nameGroup2 != "" {
|
||||||
|
vm.nameToHtml[nameGroup2] = ""
|
||||||
|
}
|
||||||
|
if let nameGroup3 = group3, nameGroup3 != "" {
|
||||||
|
vm.nameToHtml[nameGroup3] = ""
|
||||||
|
}
|
||||||
|
if let nameVpk1 = vpk1, nameVpk1 != "" {
|
||||||
|
vm.nameToHtml[nameVpk1] = ""
|
||||||
|
}
|
||||||
|
if let nameVpk2 = vpk2, nameVpk2 != "" {
|
||||||
|
vm.nameToHtml[nameVpk2] = ""
|
||||||
|
}
|
||||||
|
if let nameVpk3 = vpk3, nameVpk3 != "" {
|
||||||
|
vm.nameToHtml[nameVpk3] = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#Preview {
|
#Preview {
|
||||||
|
@ -16,9 +16,6 @@ struct ScheduleView: View {
|
|||||||
@State private var isShowingMyPairs = false
|
@State private var isShowingMyPairs = false
|
||||||
@Binding var isScrolling: Bool
|
@Binding var isScrolling: Bool
|
||||||
var provider = ClassProvider.shared
|
var provider = ClassProvider.shared
|
||||||
var hasVPK: Bool {
|
|
||||||
return vm.vpks.indices.contains(vm.selectedIndex) && vm.vpks[vm.selectedIndex].dropFirst().contains { !$0.isEmpty }
|
|
||||||
}
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
if vm.isLoading {
|
if vm.isLoading {
|
||||||
LoadingScheduleView()
|
LoadingScheduleView()
|
||||||
|
@ -29,8 +29,10 @@ struct SearchBarView: View {
|
|||||||
.onSubmit {
|
.onSubmit {
|
||||||
self.isFocused = false
|
self.isFocused = false
|
||||||
if (!text.isEmpty) {
|
if (!text.isEmpty) {
|
||||||
|
vm.nameToHtml[vm.searchingGroup] = nil
|
||||||
|
vm.removeFromSchedule(group: vm.searchingGroup)
|
||||||
vm.searchingGroup = text
|
vm.searchingGroup = text
|
||||||
vm.updateArrayOfGroups()
|
vm.nameToHtml[text] = ""
|
||||||
vm.fetchWeekSchedule()
|
vm.fetchWeekSchedule()
|
||||||
}
|
}
|
||||||
self.text = ""
|
self.text = ""
|
||||||
|
@ -25,9 +25,8 @@ struct FavGroupsView: View {
|
|||||||
.cornerRadius(10)
|
.cornerRadius(10)
|
||||||
.swipeActions(edge: .trailing) {
|
.swipeActions(edge: .trailing) {
|
||||||
Button(role: .destructive) {
|
Button(role: .destructive) {
|
||||||
|
vm.removeFromSchedule(group: firstFavGroup)
|
||||||
UserDefaults.standard.set("", forKey: "group")
|
UserDefaults.standard.set("", forKey: "group")
|
||||||
vm.updateArrayOfGroups()
|
|
||||||
vm.fetchWeekSchedule()
|
|
||||||
} label: {
|
} label: {
|
||||||
Label("Удалить", systemImage: "trash")
|
Label("Удалить", systemImage: "trash")
|
||||||
}
|
}
|
||||||
@ -43,9 +42,8 @@ struct FavGroupsView: View {
|
|||||||
.cornerRadius(10)
|
.cornerRadius(10)
|
||||||
.swipeActions(edge: .trailing) {
|
.swipeActions(edge: .trailing) {
|
||||||
Button(role: .destructive) {
|
Button(role: .destructive) {
|
||||||
|
vm.removeFromSchedule(group: secondFavGroup)
|
||||||
UserDefaults.standard.set("", forKey: "group2")
|
UserDefaults.standard.set("", forKey: "group2")
|
||||||
vm.updateArrayOfGroups()
|
|
||||||
vm.fetchWeekSchedule()
|
|
||||||
} label: {
|
} label: {
|
||||||
Label("Удалить", systemImage: "trash")
|
Label("Удалить", systemImage: "trash")
|
||||||
}
|
}
|
||||||
@ -61,9 +59,8 @@ struct FavGroupsView: View {
|
|||||||
.cornerRadius(10)
|
.cornerRadius(10)
|
||||||
.swipeActions(edge: .trailing) {
|
.swipeActions(edge: .trailing) {
|
||||||
Button(role: .destructive) {
|
Button(role: .destructive) {
|
||||||
|
vm.removeFromSchedule(group: thirdFavGroup)
|
||||||
UserDefaults.standard.set("", forKey: "group3")
|
UserDefaults.standard.set("", forKey: "group3")
|
||||||
vm.updateArrayOfGroups()
|
|
||||||
vm.fetchWeekSchedule()
|
|
||||||
} label: {
|
} label: {
|
||||||
Label("Удалить", systemImage: "trash")
|
Label("Удалить", systemImage: "trash")
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,8 @@ struct FavVPKView: View {
|
|||||||
.cornerRadius(10)
|
.cornerRadius(10)
|
||||||
.swipeActions(edge: .trailing) {
|
.swipeActions(edge: .trailing) {
|
||||||
Button(role: .destructive) {
|
Button(role: .destructive) {
|
||||||
|
vm.removeFromSchedule(group: firstFavVPK)
|
||||||
UserDefaults.standard.set("", forKey: "vpk1")
|
UserDefaults.standard.set("", forKey: "vpk1")
|
||||||
vm.updateArrayOfGroups()
|
|
||||||
vm.fetchWeekSchedule()
|
|
||||||
} label: {
|
} label: {
|
||||||
Label("Удалить", systemImage: "trash")
|
Label("Удалить", systemImage: "trash")
|
||||||
}
|
}
|
||||||
@ -43,9 +42,8 @@ struct FavVPKView: View {
|
|||||||
.cornerRadius(10)
|
.cornerRadius(10)
|
||||||
.swipeActions(edge: .trailing) {
|
.swipeActions(edge: .trailing) {
|
||||||
Button(role: .destructive) {
|
Button(role: .destructive) {
|
||||||
|
vm.removeFromSchedule(group: secondFavVPK)
|
||||||
UserDefaults.standard.set("", forKey: "vpk2")
|
UserDefaults.standard.set("", forKey: "vpk2")
|
||||||
vm.updateArrayOfGroups()
|
|
||||||
vm.fetchWeekSchedule()
|
|
||||||
} label: {
|
} label: {
|
||||||
Label("Удалить", systemImage: "trash")
|
Label("Удалить", systemImage: "trash")
|
||||||
}
|
}
|
||||||
@ -61,9 +59,8 @@ struct FavVPKView: View {
|
|||||||
.cornerRadius(10)
|
.cornerRadius(10)
|
||||||
.swipeActions(edge: .trailing) {
|
.swipeActions(edge: .trailing) {
|
||||||
Button(role: .destructive) {
|
Button(role: .destructive) {
|
||||||
|
vm.removeFromSchedule(group: thirdFavVPK)
|
||||||
UserDefaults.standard.set("", forKey: "vpk3")
|
UserDefaults.standard.set("", forKey: "vpk3")
|
||||||
vm.updateArrayOfGroups()
|
|
||||||
vm.fetchWeekSchedule()
|
|
||||||
} label: {
|
} label: {
|
||||||
Label("Удалить", systemImage: "trash")
|
Label("Удалить", systemImage: "trash")
|
||||||
}
|
}
|
||||||
|
54
Schedule ICTIS/Settings/ListOfGroupsView.swift
Normal file
54
Schedule ICTIS/Settings/ListOfGroupsView.swift
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
//
|
||||||
|
// ListOfGroupsView.swift
|
||||||
|
// Schedule ICTIS
|
||||||
|
//
|
||||||
|
// Created by G412 on 13.03.2025.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct ListOfGroupsView: View {
|
||||||
|
@Environment(\.dismiss) private var dismiss
|
||||||
|
@ObservedObject var vm: ScheduleViewModel
|
||||||
|
@ObservedObject var serchGroupsVM: SearchGroupsViewModel
|
||||||
|
var firstFavVPK: String
|
||||||
|
var secondFavVPK: String
|
||||||
|
var thirdFavVPK: String
|
||||||
|
var body: some View {
|
||||||
|
ScrollView(.vertical, showsIndicators: true) {
|
||||||
|
ForEach(serchGroupsVM.groups) { item in
|
||||||
|
if item.name.starts(with: "ВПК") {
|
||||||
|
VStack {
|
||||||
|
Rectangle()
|
||||||
|
.frame(height: 1)
|
||||||
|
.foregroundColor(Color("customGray1"))
|
||||||
|
.padding(.horizontal, 10)
|
||||||
|
HStack {
|
||||||
|
Text(item.name)
|
||||||
|
.foregroundColor(.black)
|
||||||
|
.font(.custom("Montserrat-SemiBold", fixedSize: 15))
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
.padding(.horizontal, 10)
|
||||||
|
.padding(.top, 2)
|
||||||
|
.padding(.bottom, 2)
|
||||||
|
.frame(width: UIScreen.main.bounds.width, height: 30)
|
||||||
|
.background(Color("background"))
|
||||||
|
.onTapGesture {
|
||||||
|
if firstFavVPK == "" {
|
||||||
|
UserDefaults.standard.set(item.name, forKey: "vpk1")
|
||||||
|
} else if secondFavVPK == "" {
|
||||||
|
UserDefaults.standard.set(item.name, forKey: "vpk2")
|
||||||
|
} else {
|
||||||
|
UserDefaults.standard.set(item.name, forKey: "vpk3")
|
||||||
|
}
|
||||||
|
vm.nameToHtml[item.name] = ""
|
||||||
|
vm.fetchWeekSchedule()
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -51,12 +51,14 @@ struct SelectingGroupView: View {
|
|||||||
vm.errorInNetwork = nil
|
vm.errorInNetwork = nil
|
||||||
if firstFavGroup == "" {
|
if firstFavGroup == "" {
|
||||||
UserDefaults.standard.set(text, forKey: "group")
|
UserDefaults.standard.set(text, forKey: "group")
|
||||||
|
vm.nameToHtml[text] = ""
|
||||||
} else if secondFavGroup == "" {
|
} else if secondFavGroup == "" {
|
||||||
UserDefaults.standard.set(text, forKey: "group2")
|
UserDefaults.standard.set(text, forKey: "group2")
|
||||||
|
vm.nameToHtml[text] = ""
|
||||||
} else {
|
} else {
|
||||||
UserDefaults.standard.set(text, forKey: "group3")
|
UserDefaults.standard.set(text, forKey: "group3")
|
||||||
|
vm.nameToHtml[text] = ""
|
||||||
}
|
}
|
||||||
vm.updateArrayOfGroups()
|
|
||||||
vm.fetchWeekSchedule()
|
vm.fetchWeekSchedule()
|
||||||
self.isLoading = false
|
self.isLoading = false
|
||||||
self.text = ""
|
self.text = ""
|
||||||
@ -116,12 +118,14 @@ struct SelectingGroupView: View {
|
|||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
if firstFavGroup == "" {
|
if firstFavGroup == "" {
|
||||||
UserDefaults.standard.set(item.name, forKey: "group")
|
UserDefaults.standard.set(item.name, forKey: "group")
|
||||||
|
vm.nameToHtml[item.name] = ""
|
||||||
} else if secondFavGroup == "" {
|
} else if secondFavGroup == "" {
|
||||||
UserDefaults.standard.set(item.name, forKey: "group2")
|
UserDefaults.standard.set(item.name, forKey: "group2")
|
||||||
|
vm.nameToHtml[item.name] = ""
|
||||||
} else {
|
} else {
|
||||||
UserDefaults.standard.set(item.name, forKey: "group3")
|
UserDefaults.standard.set(item.name, forKey: "group3")
|
||||||
|
vm.nameToHtml[item.name] = ""
|
||||||
}
|
}
|
||||||
vm.updateArrayOfGroups()
|
|
||||||
vm.fetchWeekSchedule()
|
vm.fetchWeekSchedule()
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ struct SelectingVPKView: View {
|
|||||||
} else {
|
} else {
|
||||||
UserDefaults.standard.set(text, forKey: "vpk3")
|
UserDefaults.standard.set(text, forKey: "vpk3")
|
||||||
}
|
}
|
||||||
vm.updateArrayOfGroups()
|
vm.nameToHtml[text] = ""
|
||||||
vm.fetchWeekSchedule()
|
vm.fetchWeekSchedule()
|
||||||
self.isLoading = false
|
self.isLoading = false
|
||||||
self.text = ""
|
self.text = ""
|
||||||
@ -95,41 +95,7 @@ struct SelectingVPKView: View {
|
|||||||
LoadingView(isLoading: $isLoading)
|
LoadingView(isLoading: $isLoading)
|
||||||
}
|
}
|
||||||
if isFocused {
|
if isFocused {
|
||||||
ScrollView(.vertical, showsIndicators: true) {
|
ListOfGroupsView(vm: vm, serchGroupsVM: serchGroupsVM, firstFavVPK: firstFavVPK, secondFavVPK: secondFavVPK, thirdFavVPK: thirdFavVPK)
|
||||||
ForEach(serchGroupsVM.groups) { item in
|
|
||||||
if item.name.starts(with: "ВПК") {
|
|
||||||
VStack {
|
|
||||||
Rectangle()
|
|
||||||
.frame(height: 1)
|
|
||||||
.foregroundColor(Color("customGray1"))
|
|
||||||
.padding(.horizontal, 10)
|
|
||||||
HStack {
|
|
||||||
Text(item.name)
|
|
||||||
.foregroundColor(.black)
|
|
||||||
.font(.custom("Montserrat-SemiBold", fixedSize: 15))
|
|
||||||
Spacer()
|
|
||||||
}
|
|
||||||
.padding(.horizontal, 10)
|
|
||||||
.padding(.top, 2)
|
|
||||||
.padding(.bottom, 2)
|
|
||||||
.frame(width: UIScreen.main.bounds.width, height: 30)
|
|
||||||
.background(Color("background"))
|
|
||||||
.onTapGesture {
|
|
||||||
if firstFavVPK == "" {
|
|
||||||
UserDefaults.standard.set(item.name, forKey: "vpk1")
|
|
||||||
} else if secondFavVPK == "" {
|
|
||||||
UserDefaults.standard.set(item.name, forKey: "vpk2")
|
|
||||||
} else {
|
|
||||||
UserDefaults.standard.set(item.name, forKey: "vpk3")
|
|
||||||
}
|
|
||||||
vm.updateArrayOfGroups()
|
|
||||||
vm.fetchWeekSchedule()
|
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding(.horizontal, 10)
|
.padding(.horizontal, 10)
|
||||||
|
@ -183,11 +183,12 @@ extension WeekTabView {
|
|||||||
extension WeekViewForWeek {
|
extension WeekViewForWeek {
|
||||||
func paginateWeek() {
|
func paginateWeek() {
|
||||||
let calendar = Calendar.current
|
let calendar = Calendar.current
|
||||||
|
let groupsKeys = Array (vm.nameToHtml.keys)
|
||||||
if weekSlider.indices.contains(currentWeekIndex) {
|
if weekSlider.indices.contains(currentWeekIndex) {
|
||||||
if let firstDate = weekSlider[currentWeekIndex].first?.date,
|
if let firstDate = weekSlider[currentWeekIndex].first?.date,
|
||||||
currentWeekIndex == 0 {
|
currentWeekIndex == 0 {
|
||||||
vm.week -= 1
|
vm.week -= 1
|
||||||
if !vm.nameGroups.isEmpty {
|
if !groupsKeys.isEmpty {
|
||||||
vm.fetchWeekSchedule(isOtherWeek: true)
|
vm.fetchWeekSchedule(isOtherWeek: true)
|
||||||
}
|
}
|
||||||
if UserDefaults.standard.string(forKey: "vpk") != nil {
|
if UserDefaults.standard.string(forKey: "vpk") != nil {
|
||||||
@ -203,7 +204,7 @@ extension WeekViewForWeek {
|
|||||||
if let lastDate = weekSlider[currentWeekIndex].last?.date,
|
if let lastDate = weekSlider[currentWeekIndex].last?.date,
|
||||||
currentWeekIndex == (weekSlider.count - 1) {
|
currentWeekIndex == (weekSlider.count - 1) {
|
||||||
vm.week += 1
|
vm.week += 1
|
||||||
if !vm.nameGroups.isEmpty {
|
if !groupsKeys.isEmpty {
|
||||||
vm.fetchWeekSchedule(isOtherWeek: true)
|
vm.fetchWeekSchedule(isOtherWeek: true)
|
||||||
}
|
}
|
||||||
weekSlider.append(lastDate.createNextWeek())
|
weekSlider.append(lastDate.createNextWeek())
|
||||||
@ -243,13 +244,14 @@ extension WeekViewForMonth {
|
|||||||
print("На одной неделе")
|
print("На одной неделе")
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
let groupsKeys = Array(vm.nameToHtml.keys)
|
||||||
var difBetweenWeeks = weeksBetween(startDate: vm.selectedDay, endDate: day.date)
|
var difBetweenWeeks = weeksBetween(startDate: vm.selectedDay, endDate: day.date)
|
||||||
if day.date < vm.selectedDay {
|
if day.date < vm.selectedDay {
|
||||||
difBetweenWeeks = difBetweenWeeks * -1
|
difBetweenWeeks = difBetweenWeeks * -1
|
||||||
}
|
}
|
||||||
print(difBetweenWeeks)
|
print(difBetweenWeeks)
|
||||||
vm.week += difBetweenWeeks
|
vm.week += difBetweenWeeks
|
||||||
if !vm.nameGroups.isEmpty {
|
if !groupsKeys.isEmpty {
|
||||||
vm.fetchWeekSchedule(isOtherWeek: true)
|
vm.fetchWeekSchedule(isOtherWeek: true)
|
||||||
}
|
}
|
||||||
if UserDefaults.standard.string(forKey: "vpk") != nil {
|
if UserDefaults.standard.string(forKey: "vpk") != nil {
|
||||||
@ -281,6 +283,7 @@ extension MonthTabView {
|
|||||||
|
|
||||||
func paginateMonth(_ indexOfWeek: Int = 0) {
|
func paginateMonth(_ indexOfWeek: Int = 0) {
|
||||||
let calendar = Calendar.current
|
let calendar = Calendar.current
|
||||||
|
let groupsKeys = Array (vm.nameToHtml.keys)
|
||||||
if monthSlider.indices.contains(currentMonthIndex) {
|
if monthSlider.indices.contains(currentMonthIndex) {
|
||||||
if let firstDate = monthSlider[currentMonthIndex].first?.week[0].date,
|
if let firstDate = monthSlider[currentMonthIndex].first?.week[0].date,
|
||||||
currentMonthIndex == 0 {
|
currentMonthIndex == 0 {
|
||||||
@ -290,7 +293,7 @@ extension MonthTabView {
|
|||||||
vm.selectedDay = calendar.date(byAdding: .weekOfYear, value: -5, to: vm.selectedDay) ?? Date.init()
|
vm.selectedDay = calendar.date(byAdding: .weekOfYear, value: -5, to: vm.selectedDay) ?? Date.init()
|
||||||
vm.updateSelectedDayIndex()
|
vm.updateSelectedDayIndex()
|
||||||
vm.week -= 5
|
vm.week -= 5
|
||||||
if !vm.nameGroups.isEmpty {
|
if !groupsKeys.isEmpty {
|
||||||
vm.fetchWeekSchedule(isOtherWeek: true)
|
vm.fetchWeekSchedule(isOtherWeek: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -303,7 +306,7 @@ extension MonthTabView {
|
|||||||
vm.selectedDay = calendar.date(byAdding: .weekOfYear, value: 5, to: vm.selectedDay) ?? Date.init()
|
vm.selectedDay = calendar.date(byAdding: .weekOfYear, value: 5, to: vm.selectedDay) ?? Date.init()
|
||||||
vm.updateSelectedDayIndex()
|
vm.updateSelectedDayIndex()
|
||||||
vm.week += 5
|
vm.week += 5
|
||||||
if !vm.nameGroups.isEmpty {
|
if !groupsKeys.isEmpty {
|
||||||
vm.fetchWeekSchedule(isOtherWeek: true)
|
vm.fetchWeekSchedule(isOtherWeek: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,7 @@ import SwiftUICore
|
|||||||
@MainActor
|
@MainActor
|
||||||
final class ScheduleViewModel: ObservableObject {
|
final class ScheduleViewModel: ObservableObject {
|
||||||
//MARK: Properties
|
//MARK: Properties
|
||||||
@Published var nameGroups: [String] = []
|
@Published var nameToHtml: [String : String] = [:]
|
||||||
@Published var numbersNTMLGroups: [String] = []
|
|
||||||
@Published var classesGroups: [[ClassInfo]] = []
|
@Published var classesGroups: [[ClassInfo]] = []
|
||||||
@Published var searchingGroup = ""
|
@Published var searchingGroup = ""
|
||||||
|
|
||||||
@ -44,7 +43,8 @@ final class ScheduleViewModel: ObservableObject {
|
|||||||
|
|
||||||
// Если другая неделя, запрашиваем расписание по неделе и номеру группу(в HTML формате)
|
// Если другая неделя, запрашиваем расписание по неделе и номеру группу(в HTML формате)
|
||||||
if isOtherWeek {
|
if isOtherWeek {
|
||||||
for groupHTML in numbersNTMLGroups {
|
let groupHTMLs = Array(self.nameToHtml.values)
|
||||||
|
for groupHTML in groupHTMLs {
|
||||||
let schedule = try await NetworkManager.shared.getScheduleForOtherWeek(self.week, groupHTML)
|
let schedule = try await NetworkManager.shared.getScheduleForOtherWeek(self.week, groupHTML)
|
||||||
let table = schedule.table.table
|
let table = schedule.table.table
|
||||||
let nameOfGroup = schedule.table.name
|
let nameOfGroup = schedule.table.name
|
||||||
@ -61,10 +61,11 @@ final class ScheduleViewModel: ObservableObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for groupName in nameGroups {
|
let groupNames = Array(self.nameToHtml.keys)
|
||||||
|
for groupName in groupNames {
|
||||||
let schedule = try await NetworkManager.shared.getSchedule(groupName)
|
let schedule = try await NetworkManager.shared.getSchedule(groupName)
|
||||||
let numberHTML = schedule.table.group
|
let numberHTML = schedule.table.group
|
||||||
self.numbersNTMLGroups.append(numberHTML)
|
self.nameToHtml[groupName] = numberHTML
|
||||||
let table = schedule.table.table
|
let table = schedule.table.table
|
||||||
self.week = schedule.table.week
|
self.week = schedule.table.week
|
||||||
|
|
||||||
@ -156,33 +157,19 @@ final class ScheduleViewModel: ObservableObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateArrayOfGroups() {
|
func removeFromSchedule(group: String) {
|
||||||
self.nameGroups.removeAll()
|
self.nameToHtml[group] = nil
|
||||||
self.numbersNTMLGroups.removeAll()
|
|
||||||
let group1 = UserDefaults.standard.string(forKey: "group")
|
for i in classesGroups.indices {
|
||||||
let group2 = UserDefaults.standard.string(forKey: "group2")
|
// Сначала находим индексы элементов для удаления
|
||||||
let group3 = UserDefaults.standard.string(forKey: "group3")
|
let indicesToRemove = classesGroups[i].indices.filter { j in
|
||||||
let vpk1 = UserDefaults.standard.string(forKey: "vpk1")
|
classesGroups[i][j].group.lowercased() == group.lowercased()
|
||||||
let vpk2 = UserDefaults.standard.string(forKey: "vpk2")
|
}
|
||||||
let vpk3 = UserDefaults.standard.string(forKey: "vpk3")
|
|
||||||
if let nameGroup1 = group1, nameGroup1 != "" {
|
// Удаляем элементы в обратном порядке, чтобы индексы оставались корректными
|
||||||
self.nameGroups.append(nameGroup1)
|
for j in indicesToRemove.reversed() {
|
||||||
|
classesGroups[i].remove(at: j)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if let nameGroup2 = group2, nameGroup2 != "" {
|
|
||||||
self.nameGroups.append(nameGroup2)
|
|
||||||
}
|
|
||||||
if let nameGroup3 = group3, nameGroup3 != "" {
|
|
||||||
self.nameGroups.append(nameGroup3)
|
|
||||||
}
|
|
||||||
if let nameVPK1 = vpk1, nameVPK1 != "" {
|
|
||||||
self.nameGroups.append(nameVPK1)
|
|
||||||
}
|
|
||||||
if let nameVPK2 = vpk2, nameVPK2 != "" {
|
|
||||||
self.nameGroups.append(nameVPK2)
|
|
||||||
}
|
|
||||||
if let nameVPK3 = vpk3, nameVPK3 != "" {
|
|
||||||
self.nameGroups.append(nameVPK3)
|
|
||||||
}
|
|
||||||
self.nameGroups.append(self.searchingGroup)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user