This commit is contained in:
Vladimir Dubovik
2025-03-13 12:26:41 +03:00
parent 5946cd3ec0
commit 8bc7425e2a
10 changed files with 126 additions and 104 deletions

View File

@ -25,9 +25,8 @@ struct FavGroupsView: View {
.cornerRadius(10)
.swipeActions(edge: .trailing) {
Button(role: .destructive) {
vm.removeFromSchedule(group: firstFavGroup)
UserDefaults.standard.set("", forKey: "group")
vm.updateArrayOfGroups()
vm.fetchWeekSchedule()
} label: {
Label("Удалить", systemImage: "trash")
}
@ -43,9 +42,8 @@ struct FavGroupsView: View {
.cornerRadius(10)
.swipeActions(edge: .trailing) {
Button(role: .destructive) {
vm.removeFromSchedule(group: secondFavGroup)
UserDefaults.standard.set("", forKey: "group2")
vm.updateArrayOfGroups()
vm.fetchWeekSchedule()
} label: {
Label("Удалить", systemImage: "trash")
}
@ -61,9 +59,8 @@ struct FavGroupsView: View {
.cornerRadius(10)
.swipeActions(edge: .trailing) {
Button(role: .destructive) {
vm.removeFromSchedule(group: thirdFavGroup)
UserDefaults.standard.set("", forKey: "group3")
vm.updateArrayOfGroups()
vm.fetchWeekSchedule()
} label: {
Label("Удалить", systemImage: "trash")
}

View File

@ -25,9 +25,8 @@ struct FavVPKView: View {
.cornerRadius(10)
.swipeActions(edge: .trailing) {
Button(role: .destructive) {
vm.removeFromSchedule(group: firstFavVPK)
UserDefaults.standard.set("", forKey: "vpk1")
vm.updateArrayOfGroups()
vm.fetchWeekSchedule()
} label: {
Label("Удалить", systemImage: "trash")
}
@ -43,9 +42,8 @@ struct FavVPKView: View {
.cornerRadius(10)
.swipeActions(edge: .trailing) {
Button(role: .destructive) {
vm.removeFromSchedule(group: secondFavVPK)
UserDefaults.standard.set("", forKey: "vpk2")
vm.updateArrayOfGroups()
vm.fetchWeekSchedule()
} label: {
Label("Удалить", systemImage: "trash")
}
@ -61,9 +59,8 @@ struct FavVPKView: View {
.cornerRadius(10)
.swipeActions(edge: .trailing) {
Button(role: .destructive) {
vm.removeFromSchedule(group: thirdFavVPK)
UserDefaults.standard.set("", forKey: "vpk3")
vm.updateArrayOfGroups()
vm.fetchWeekSchedule()
} label: {
Label("Удалить", systemImage: "trash")
}

View 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()
}
}
}
}
}
}
}

View File

@ -51,12 +51,14 @@ struct SelectingGroupView: View {
vm.errorInNetwork = nil
if firstFavGroup == "" {
UserDefaults.standard.set(text, forKey: "group")
vm.nameToHtml[text] = ""
} else if secondFavGroup == "" {
UserDefaults.standard.set(text, forKey: "group2")
vm.nameToHtml[text] = ""
} else {
UserDefaults.standard.set(text, forKey: "group3")
vm.nameToHtml[text] = ""
}
vm.updateArrayOfGroups()
vm.fetchWeekSchedule()
self.isLoading = false
self.text = ""
@ -116,12 +118,14 @@ struct SelectingGroupView: View {
.onTapGesture {
if firstFavGroup == "" {
UserDefaults.standard.set(item.name, forKey: "group")
vm.nameToHtml[item.name] = ""
} else if secondFavGroup == "" {
UserDefaults.standard.set(item.name, forKey: "group2")
vm.nameToHtml[item.name] = ""
} else {
UserDefaults.standard.set(item.name, forKey: "group3")
vm.nameToHtml[item.name] = ""
}
vm.updateArrayOfGroups()
vm.fetchWeekSchedule()
dismiss()
}

View File

@ -56,7 +56,7 @@ struct SelectingVPKView: View {
} else {
UserDefaults.standard.set(text, forKey: "vpk3")
}
vm.updateArrayOfGroups()
vm.nameToHtml[text] = ""
vm.fetchWeekSchedule()
self.isLoading = false
self.text = ""
@ -95,41 +95,7 @@ struct SelectingVPKView: View {
LoadingView(isLoading: $isLoading)
}
if isFocused {
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.updateArrayOfGroups()
vm.fetchWeekSchedule()
dismiss()
}
}
}
}
}
ListOfGroupsView(vm: vm, serchGroupsVM: serchGroupsVM, firstFavVPK: firstFavVPK, secondFavVPK: secondFavVPK, thirdFavVPK: thirdFavVPK)
}
}
.padding(.horizontal, 10)