This commit is contained in:
Vladimir Dubovik
2025-02-25 15:25:45 +03:00
parent 9c6515a2f5
commit b719ab300d
21 changed files with 305 additions and 74 deletions

View File

@ -0,0 +1,91 @@
//
// GeneralGroupSettings.swift
// Schedule ICTIS
//
// Created by G412 on 25.02.2025.
//
import SwiftUI
struct GeneralGroupSettings: View {
@Binding var selectedTheme: String
@Binding var selectedLanguage: String
var body: some View {
VStack {
HStack {
Text("Тема")
.font(.custom("Montserrat-Medium", fixedSize: 17))
.foregroundColor(.black)
Spacer()
HStack {
Text(selectedTheme)
.font(.custom("Montserrat-Medium", fixedSize: 17))
.foregroundColor(Color("customGray3"))
Image("upDownArrows")
.resizable()
.scaledToFit()
.frame(width: 15, height: 15)
}
.padding(.horizontal)
}
.padding(.horizontal)
.padding(.top, 17)
.padding(.bottom, 7)
.overlay {
HStack {
Spacer()
Picker("", selection: $selectedTheme, content: {
ForEach(MockData.themes, id: \.self) {
Text($0)
}
})
.padding(.trailing, 35)
.blendMode(.destinationOver)
}
.frame(width: UIScreen.main.bounds.width)
}
Rectangle()
.foregroundColor(Color("customGray1"))
.frame(height: 1)
.padding(.horizontal)
HStack {
Text("Язык")
.font(.custom("Montserrat-Medium", fixedSize: 17))
.foregroundColor(.black)
Spacer()
HStack {
Text(selectedLanguage)
.font(.custom("Montserrat-Medium", fixedSize: 17))
.foregroundColor(Color("customGray3"))
Image("upDownArrows")
.resizable()
.scaledToFit()
.frame(width: 15, height: 15)
}
.padding(.horizontal)
}
.padding(.horizontal)
.padding(.top, 7)
.padding(.bottom, 17)
.overlay {
HStack {
Spacer()
Picker("", selection: $selectedLanguage, content: {
ForEach(MockData.languages, id: \.self) {
Text($0)
}
})
.padding(.trailing, 35)
.blendMode(.destinationOver)
}
.frame(width: UIScreen.main.bounds.width)
}
}
.background(Color.white)
.cornerRadius(20)
}
}
#Preview {
GeneralGroupSettings(selectedTheme: .constant("Темная"), selectedLanguage: .constant("Русский"))
}

View File

@ -0,0 +1,54 @@
//
// ScheduleGroupSettings.swift
// Schedule ICTIS
//
// Created by G412 on 25.02.2025.
//
import SwiftUI
struct ScheduleGroupSettings: View {
@AppStorage("group") private var favGroup = ""
@AppStorage("vpk") private var favVPK = ""
@ObservedObject var vm: ScheduleViewModel
var body: some View {
VStack {
NavigationLink(destination: SelectingGroupView(vm: vm)) {
HStack {
Text("Избранное расписание")
.font(.custom("Montserrat-Medium", fixedSize: 17))
.foregroundColor(.black)
Spacer()
Text(favGroup)
.font(.custom("Montserrat-Medium", fixedSize: 17))
.foregroundColor(Color("customGray3"))
Image("arrowRight")
}
.padding(.horizontal)
.padding(.top, 12)
.padding(.bottom, 3)
}
Rectangle()
.foregroundColor(Color("customGray1"))
.frame(height: 1)
.padding(.horizontal)
NavigationLink(destination: SelectingVPKView(vm: vm)) {
HStack {
Text("ВПК")
.font(.custom("Montserrat-Medium", fixedSize: 17))
.foregroundColor(.black)
Spacer()
Text(favVPK)
.font(.custom("Montserrat-Medium", fixedSize: 17))
.foregroundColor(Color("customGray3"))
Image("arrowRight")
}
.padding(.horizontal)
.padding(.top, 3)
.padding(.bottom, 12)
}
}
.background(Color.white)
.cornerRadius(20)
}
}

View File

@ -14,6 +14,7 @@ struct SelectingGroupView: View {
@ObservedObject var vm: ScheduleViewModel
@State private var isLoading = false
@State private var searchTask: DispatchWorkItem?
@AppStorage("group") private var favGroup = ""
var body: some View {
NavigationView {
VStack {
@ -31,6 +32,9 @@ struct SelectingGroupView: View {
if !text.isEmpty {
vm.fetchGroups(group: text)
}
else {
vm.fetchGroups(group: "кт")
}
}
searchTask = task
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: task)
@ -93,7 +97,7 @@ struct SelectingGroupView: View {
HStack {
Text(item.name)
.foregroundColor(.black)
.font(.custom("Montserrat-SemiBold", size: 15))
.font(.custom("Montserrat-SemiBold", fixedSize: 15))
Spacer()
}
.padding(.horizontal, 10)
@ -112,6 +116,27 @@ struct SelectingGroupView: View {
}
}
}
if !isFocused {
if favGroup != "" {
Button {
UserDefaults.standard.removeObject(forKey: "group")
dismiss()
} label: {
HStack {
Spacer()
Image(systemName: "trash")
Text("Удалить группу")
.font(.custom("Montserrat-Medium", fixedSize: 17))
Spacer()
}
.frame(height: 40)
.background(Color.white)
.foregroundColor(Color.red)
.cornerRadius(10)
.padding(.bottom, UIScreen.main.bounds.height / 11)
}
}
}
}
.padding(.horizontal, 10)
.background(Color("background"))
@ -121,3 +146,8 @@ struct SelectingGroupView: View {
}
}
}
#Preview {
@Previewable @StateObject var vm = ScheduleViewModel()
SelectingGroupView(vm: vm)
}

View File

@ -14,6 +14,7 @@ struct SelectingVPKView: View {
@ObservedObject var vm: ScheduleViewModel
@State private var isLoading = false
@State private var searchTask: DispatchWorkItem?
@AppStorage("vpk") private var favVPK = ""
var body: some View {
NavigationView {
VStack {
@ -31,6 +32,9 @@ struct SelectingVPKView: View {
if !text.isEmpty {
vm.fetchGroups(group: text)
}
else {
vm.fetchGroups(group: "впк")
}
}
searchTask = task
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: task)
@ -93,7 +97,7 @@ struct SelectingVPKView: View {
HStack {
Text(item.name)
.foregroundColor(.black)
.font(.custom("Montserrat-SemiBold", size: 15))
.font(.custom("Montserrat-SemiBold", fixedSize: 15))
Spacer()
}
.padding(.horizontal, 10)
@ -112,6 +116,27 @@ struct SelectingVPKView: View {
}
}
}
if !isFocused {
if favVPK != "" {
Button {
UserDefaults.standard.removeObject(forKey: "vpk")
dismiss()
} label: {
HStack {
Spacer()
Image(systemName: "trash")
Text("Удалить ВПК")
.font(.custom("Montserrat-Medium", fixedSize: 17))
Spacer()
}
.frame(height: 40)
.background(Color.white)
.foregroundColor(Color.red)
.cornerRadius(10)
.padding(.bottom, UIScreen.main.bounds.height / 11)
}
}
}
}
.padding(.horizontal, 10)
.background(Color("background"))
@ -121,3 +146,8 @@ struct SelectingVPKView: View {
}
}
}
#Preview {
@Previewable @StateObject var vm = ScheduleViewModel()
SelectingVPKView(vm: vm)
}

View File

@ -1,8 +1,8 @@
//
// SettingsView.swift
// SettingsView2.swift
// Schedule ICTIS
//
// Created by Mironov Egor on 30.01.2025.
// Created by G412 on 25.02.2025.
//
import SwiftUI
@ -11,42 +11,30 @@ struct SettingsView: View {
@ObservedObject var vm: ScheduleViewModel
@State private var selectedTheme = "Светлая"
@State private var selectedLanguage = "Русский"
@AppStorage("group") private var favGroup = ""
@AppStorage("vpk") private var favVPK = ""
var body: some View {
NavigationView {
VStack {
List {
Section("Общие") {
Picker("Тема", selection: $selectedTheme, content: {
ForEach(MockData.themes, id: \.self) {
Text($0)
}
})
Picker("Язык", selection: $selectedLanguage, content: {
ForEach(MockData.languages, id: \.self) {
Text($0)
}
})
ScrollView (.vertical, showsIndicators: false) {
VStack (alignment: .leading) {
Text("Общие")
.font(.custom("Montserrat-Medium", fixedSize: 18))
.foregroundColor(Color("customGray3"))
.padding(.horizontal)
GeneralGroupSettings(selectedTheme: $selectedTheme, selectedLanguage: $selectedLanguage)
}
Section("Расписание") {
NavigationLink(destination: SelectingGroupView(vm: vm)) {
LabeledContent {
Text(favGroup)
} label: {
Text("Избранное расписание")
}
}
NavigationLink(destination: SelectingVPKView(vm: vm)) {
LabeledContent {
Text(favVPK)
} label: {
Text("Избранное ВПК")
}
}
.padding(.top, 20)
VStack (alignment: .leading) {
Text("Расписание")
.font(.custom("Montserrat-Medium", fixedSize: 18))
.foregroundColor(Color("customGray3"))
.padding(.horizontal)
ScheduleGroupSettings(vm: vm)
}
.padding(.top, 20)
}
.padding(.horizontal)
}
.background(Color("background"))
.navigationTitle("Настройки")
}
}