diff --git a/Schedule ICTIS/Main/Views/CreatedClassView.swift b/Schedule ICTIS/Main/Views/CreatedClassView.swift index 2caf64b..7ae1fad 100644 --- a/Schedule ICTIS/Main/Views/CreatedClassView.swift +++ b/Schedule ICTIS/Main/Views/CreatedClassView.swift @@ -16,10 +16,10 @@ struct CreatedClassView: View { HStack(spacing: 15) { VStack { Text(getTimeString(_class.starttime)) - .font(.custom("Montserrat-Regular", size: 15)) + .font(.custom("Montserrat-Regular", fixedSize: 15)) .padding(.bottom, 1) Text(getTimeString(_class.endtime)) - .font(.custom("Montserrat-Regular", size: 15)) + .font(.custom("Montserrat-Regular", fixedSize: 15)) .padding(.top, 1) } .frame(width: 48) @@ -33,7 +33,7 @@ struct CreatedClassView: View { .padding(.bottom, 7) .foregroundColor(_class.important ? Color("redForImportant") : onlineOrNot(_class.online)) Text(getSubjectName(_class.subject, _class.professor, _class.auditory)) - .font(.custom("Montserrat-Medium", size: 15)) + .font(.custom("Montserrat-Medium", fixedSize: 15)) .lineSpacing(3) .padding(.top, 9) .padding(.bottom, 9) diff --git a/Schedule ICTIS/Main/Views/Fields/AuditoryFieldView.swift b/Schedule ICTIS/Main/Views/Fields/AuditoryFieldView.swift index 8b76759..2fc69bb 100644 --- a/Schedule ICTIS/Main/Views/Fields/AuditoryFieldView.swift +++ b/Schedule ICTIS/Main/Views/Fields/AuditoryFieldView.swift @@ -18,7 +18,7 @@ struct AuditoryFieldView: View { .padding(.leading, 12) .padding(.trailing, 14) TextField(labelForField, text: $text) - .font(.custom("Montserrat-Meduim", size: 17)) + .font(.custom("Montserrat-Meduim", fixedSize: 17)) .disableAutocorrection(true) .submitLabel(.done) .focused($isFocused) diff --git a/Schedule ICTIS/Main/Views/Fields/CommentFieldView.swift b/Schedule ICTIS/Main/Views/Fields/CommentFieldView.swift index 71aa3f2..fb64d55 100644 --- a/Schedule ICTIS/Main/Views/Fields/CommentFieldView.swift +++ b/Schedule ICTIS/Main/Views/Fields/CommentFieldView.swift @@ -14,7 +14,7 @@ struct CommentFieldView: View { var body: some View { HStack { TextField("Комментарий", text: $textForComment) - .font(.custom("Montserrat-Medium", size: 17)) + .font(.custom("Montserrat-Medium", fixedSize: 17)) .submitLabel(.done) .multilineTextAlignment(.leading) .focused($isFocused) diff --git a/Schedule ICTIS/Main/Views/Fields/ProfessorFieldView.swift b/Schedule ICTIS/Main/Views/Fields/ProfessorFieldView.swift index 72fa104..a34ae66 100644 --- a/Schedule ICTIS/Main/Views/Fields/ProfessorFieldView.swift +++ b/Schedule ICTIS/Main/Views/Fields/ProfessorFieldView.swift @@ -18,7 +18,7 @@ struct ProfessorFieldView: View { .padding(.leading, 12) .padding(.trailing, 7) TextField(labelForField, text: $text) - .font(.custom("Montserrat-Meduim", size: 17)) + .font(.custom("Montserrat-Meduim", fixedSize: 17)) .disableAutocorrection(true) .submitLabel(.done) .focused($isFocused) diff --git a/Schedule ICTIS/Main/Views/Fields/StartEndTimeFieldView.swift b/Schedule ICTIS/Main/Views/Fields/StartEndTimeFieldView.swift index afa90be..5ef69ed 100644 --- a/Schedule ICTIS/Main/Views/Fields/StartEndTimeFieldView.swift +++ b/Schedule ICTIS/Main/Views/Fields/StartEndTimeFieldView.swift @@ -23,13 +23,13 @@ struct StartEndTimeFieldView: View { if !isTimeSelected || isIncorrectDate { Text(text) - .font(.custom("Montserrat-Meduim", size: 17)) + .font(.custom("Montserrat-Meduim", fixedSize: 17)) .foregroundColor(.gray.opacity(0.5)) } else { Text("\(selectedTime, formatter: timeFormatter)") .foregroundColor(isIncorrectDate ? .red : .black) - .font(.custom("Montserrat-Medium", size: 17)) + .font(.custom("Montserrat-Medium", fixedSize: 17)) .padding(.trailing, 10) } Spacer() diff --git a/Schedule ICTIS/Main/Views/Fields/SubjectFieldView.swift b/Schedule ICTIS/Main/Views/Fields/SubjectFieldView.swift index c5f30bf..60ab5b0 100644 --- a/Schedule ICTIS/Main/Views/Fields/SubjectFieldView.swift +++ b/Schedule ICTIS/Main/Views/Fields/SubjectFieldView.swift @@ -19,7 +19,7 @@ struct SubjectFieldView: View { .padding(.leading, 12) .padding(.trailing, 9) TextField(labelForField, text: $text) - .font(.custom("Montserrat-Meduim", size: 17)) + .font(.custom("Montserrat-Meduim", fixedSize: 17)) .disableAutocorrection(true) .submitLabel(.done) .focused($isFocused) @@ -33,7 +33,7 @@ struct SubjectFieldView: View { Group { if isShowingSubjectFieldRed { Text("Поле должно быть заполнено!") - .font(.custom("Montserrat-Meduim", size: 17)) + .font(.custom("Montserrat-Meduim", fixedSize: 17)) .foregroundColor(.red) .frame(width: 290) .padding(.leading, -38) diff --git a/Schedule ICTIS/Main/Views/MainView.swift b/Schedule ICTIS/Main/Views/MainView.swift index e8e1d56..06e5f2f 100644 --- a/Schedule ICTIS/Main/Views/MainView.swift +++ b/Schedule ICTIS/Main/Views/MainView.swift @@ -13,6 +13,7 @@ struct MainView: View { @ObservedObject var vm: ScheduleViewModel @FocusState private var isFocusedSearchBar: Bool @State private var isScrolling: Bool = false + @State private var isShowingVPKLabel = false var body: some View { VStack { @@ -27,7 +28,7 @@ struct MainView: View { LoadingScheduleView() } else { - ScheduleView(vm: vm, isScrolling: $isScrolling) + ScheduleView(vm: vm, isScrolling: $isScrolling, isShowingVPKLabel: $isShowingVPKLabel) } } .alert(isPresented: $vm.isShowingAlertForIncorrectGroup, error: vm.errorInNetwork) { error in @@ -48,14 +49,14 @@ struct MainView: View { HStack { VStack (alignment: .leading, spacing: 0) { Text(vm.selectedDay.format("EEEE")) - .font(.custom("Montserrat-SemiBold", size: 30)) + .font(.custom("Montserrat-SemiBold", fixedSize: 30)) .foregroundStyle(.black) HStack (spacing: 5) { Text(vm.selectedDay.format("dd")) - .font(.custom("Montserrat-Bold", size: 17)) + .font(.custom("Montserrat-Bold", fixedSize: 17)) .foregroundStyle(Color("grayForDate")) Text(vm.selectedDay.format("MMMM")) - .font(.custom("Montserrat-Bold", size: 17)) + .font(.custom("Montserrat-Bold", fixedSize: 17)) .foregroundStyle(Color("grayForDate")) Spacer() Button(action: { @@ -65,7 +66,7 @@ struct MainView: View { }) { HStack(spacing: 2) { Text(isShowingMonthSlider ? "Свернуть" : "Развернуть") - .font(.custom("Montserrat-Regular", size: 15)) + .font(.custom("Montserrat-Regular", fixedSize: 15)) .foregroundStyle(Color.blue) Image(isShowingMonthSlider ? "arrowup" : "arrowdown") .resizable() @@ -80,11 +81,11 @@ struct MainView: View { Spacer() } if (!isShowingMonthSlider) { - WeekTabView(vm: vm) + WeekTabView(vm: vm, isShowingVPKLabel: $isShowingVPKLabel) .transition(.opacity) } else { - MonthTabView(vm: vm) + MonthTabView(vm: vm, isShowingVPKLabel: $isShowingVPKLabel) .transition(.opacity) } } diff --git a/Schedule ICTIS/Main/Views/NoScheduleView.swift b/Schedule ICTIS/Main/Views/NoScheduleView.swift index ded9e01..b9feea1 100644 --- a/Schedule ICTIS/Main/Views/NoScheduleView.swift +++ b/Schedule ICTIS/Main/Views/NoScheduleView.swift @@ -13,7 +13,7 @@ struct NoScheduleView: View { ScrollView (showsIndicators: false) { Text("Пока что расписания нет😪") .padding(.top, 100) - .font(.custom("Montserrat-SemiBold", size: 17)) + .font(.custom("Montserrat-SemiBold", fixedSize: 17)) } } } diff --git a/Schedule ICTIS/Main/Views/ScheduleView.swift b/Schedule ICTIS/Main/Views/ScheduleView.swift index 5a958d8..74b10e9 100644 --- a/Schedule ICTIS/Main/Views/ScheduleView.swift +++ b/Schedule ICTIS/Main/Views/ScheduleView.swift @@ -15,6 +15,7 @@ struct ScheduleView: View { @State private var scrollTimer: Timer? = nil @State private var isShowingMyPairs = false @Binding var isScrolling: Bool + @Binding var isShowingVPKLabel: Bool var provider = ClassProvider.shared var body: some View { if vm.isLoading { @@ -27,7 +28,7 @@ struct ScheduleView: View { VStack (spacing: 30) { VStack (alignment: .leading, spacing: 20 ) { Text("Учебное расписание") - .font(.custom("Montserrat-Bold", size: 20)) + .font(.custom("Montserrat-Bold", fixedSize: 20)) ForEach(vm.classes.indices, id: \.self) { index in if index != 0 && index != 1 && index == vm.selectedIndex { let daySchedule = vm.classes[index] // Это массив строк для дня @@ -37,10 +38,10 @@ struct ScheduleView: View { HStack(spacing: 15) { VStack { Text(convertTimeString(vm.classes[1][lessonIndex])[0]) - .font(.custom("Montserrat-Regular", size: 15)) + .font(.custom("Montserrat-Regular", fixedSize: 15)) .padding(.bottom, 1) Text(convertTimeString(vm.classes[1][lessonIndex])[1]) - .font(.custom("Montserrat-Regular", size: 15)) + .font(.custom("Montserrat-Regular", fixedSize: 15)) .padding(.top, 1) } .frame(width: 48) @@ -54,7 +55,7 @@ struct ScheduleView: View { .padding(.bottom, 7) .foregroundColor(getColorForClass(lesson)) Text(lesson) - .font(.custom("Montserrat-Medium", size: 15)) + .font(.custom("Montserrat-Medium", fixedSize: 16)) .lineSpacing(3) .padding(.top, 9) .padding(.bottom, 9) @@ -72,7 +73,7 @@ struct ScheduleView: View { if classes.contains(where: { daysAreEqual($0.day, vm.selectedDay) }) { VStack(alignment: .leading, spacing: 20) { Text("Мои пары") - .font(.custom("Montserrat-Bold", size: 20)) + .font(.custom("Montserrat-Bold", fixedSize: 20)) ForEach(classes) { _class in if daysAreEqual(_class.day, vm.selectedDay) { CreatedClassView(_class: _class) @@ -85,8 +86,10 @@ struct ScheduleView: View { } if UserDefaults.standard.string(forKey: "vpk") != nil { VStack (alignment: .leading, spacing: 20 ) { - Text("ВПК") - .font(.custom("Montserrat-Bold", size: 20)) + if isShowingVPKLabel { + Text("ВПК") + .font(.custom("Montserrat-Bold", fixedSize: 20)) + } ForEach(vm.vpks.indices, id: \.self) { index in if index != 0 && index != 1 && index == vm.selectedIndex { let dayVPK = vm.vpks[index] // Это массив строк для дня @@ -96,10 +99,10 @@ struct ScheduleView: View { HStack(spacing: 15) { VStack { Text(convertTimeString(vm.vpks[1][lessonIndex])[0]) - .font(.custom("Montserrat-Regular", size: 15)) + .font(.custom("Montserrat-Regular", fixedSize: 15)) .padding(.bottom, 1) Text(convertTimeString(vm.vpks[1][lessonIndex])[1]) - .font(.custom("Montserrat-Regular", size: 15)) + .font(.custom("Montserrat-Regular", fixedSize: 15)) .padding(.top, 1) } .frame(width: 48) @@ -113,7 +116,7 @@ struct ScheduleView: View { .padding(.bottom, 7) .foregroundColor(getColorForClass(lesson)) Text(lesson) - .font(.custom("Montserrat-Medium", size: 15)) + .font(.custom("Montserrat-Medium", fixedSize: 16)) .lineSpacing(3) .padding(.top, 9) .padding(.bottom, 9) @@ -123,6 +126,9 @@ struct ScheduleView: View { .background(Color.white) .cornerRadius(20) .shadow(color: .black.opacity(0.25), radius: 4, x: 2, y: 2) + .onAppear { + isShowingVPKLabel = true + } } } } diff --git a/Schedule ICTIS/Main/Views/Sheets/CreateEditClassView.swift b/Schedule ICTIS/Main/Views/Sheets/CreateEditClassView.swift index 4f25b3f..8e0cb57 100644 --- a/Schedule ICTIS/Main/Views/Sheets/CreateEditClassView.swift +++ b/Schedule ICTIS/Main/Views/Sheets/CreateEditClassView.swift @@ -31,7 +31,7 @@ struct CreateEditClassView: View { .padding(.bottom, 10) HStack { Text("Тип") - .font(.custom("Montserrat-Medium", size: 17)) + .font(.custom("Montserrat-Medium", fixedSize: 17)) Spacer() Picker("Тип", selection: $vm._class.online, content: { ForEach(MockData.onlineOrOffline, id: \.self) { @@ -76,11 +76,11 @@ struct CreateEditClassView: View { .padding(.trailing, 5) Text("Дата") .foregroundColor(Color("grayForFields").opacity(0.5)) - .font(.custom("Montserrat-Meduim", size: 17)) + .font(.custom("Montserrat-Meduim", fixedSize: 17)) Spacer() Text("\(vm._class.day, formatter: dateFormatter)") .foregroundColor(.black) - .font(.custom("Montserrat-Medium", size: 17)) + .font(.custom("Montserrat-Medium", fixedSize: 17)) .padding(.trailing, 20) } .frame(height: 40) @@ -128,7 +128,7 @@ struct CreateEditClassView: View { .frame(height: 40) .padding(.bottom, 10) Toggle("Пометить как важную", isOn: $vm._class.important) - .font(.custom("Montserrat-Medium", size: 17)) + .font(.custom("Montserrat-Medium", fixedSize: 17)) .frame(height: 40) .padding(.horizontal) .background( @@ -136,14 +136,14 @@ struct CreateEditClassView: View { .fill(.white) ) .padding(.bottom, 10) - HStack { Text("Напоминанние") - .font(.custom("Montserrat-Medium", size: 17)) + .font(.custom("Montserrat-Medium", fixedSize: 17)) Spacer() Picker("Напоминание", selection: $vm._class.notification, content: { ForEach(MockData.notifications, id: \.self) { Text($0) + .font(.custom("Montserrat-Medium", fixedSize: 17)) } }) .accentColor(Color("grayForFields")) @@ -173,7 +173,7 @@ struct CreateEditClassView: View { Spacer() Image(systemName: "trash") Text("Удалить занятие") - .font(.custom("Montserrat-Medium", size: 17)) + .font(.custom("Montserrat-Medium", fixedSize: 17)) Spacer() } .frame(height: 40) diff --git a/Schedule ICTIS/Main/Views/TabViews/MonthTabView.swift b/Schedule ICTIS/Main/Views/TabViews/MonthTabView.swift index 4340c7e..5bcf60e 100644 --- a/Schedule ICTIS/Main/Views/TabViews/MonthTabView.swift +++ b/Schedule ICTIS/Main/Views/TabViews/MonthTabView.swift @@ -13,12 +13,13 @@ struct MonthTabView: View { @State private var createMonth: Bool = false @State private var currentWeekIndex: Int = 0 @ObservedObject var vm: ScheduleViewModel + @Binding var isShowingVPKLabel: Bool var body: some View { VStack { HStack (spacing: 34) { ForEach(MockData.daysOfWeek.indices, id: \.self) { index in Text(MockData.daysOfWeek[index]) - .font(.custom("Montserrat-SemiBold", size: 14)) + .font(.custom("Montserrat-SemiBold", fixedSize: 15)) .foregroundColor(MockData.daysOfWeek[index] == "Вс" ? Color(.red) : Color("customGray2")) .padding(.top, 13) .foregroundColor(.gray) @@ -60,7 +61,7 @@ struct MonthTabView: View { VStack (spacing: 10) { ForEach(month.indices, id: \.self) { index in let week = month[index].week - WeekViewForMonth(week: week, vm: vm) + WeekViewForMonth(week: week, vm: vm, isShowingVPKLabel: $isShowingVPKLabel) } } .background { diff --git a/Schedule ICTIS/Main/Views/TabViews/WeekTabView.swift b/Schedule ICTIS/Main/Views/TabViews/WeekTabView.swift index da58428..f27225b 100644 --- a/Schedule ICTIS/Main/Views/TabViews/WeekTabView.swift +++ b/Schedule ICTIS/Main/Views/TabViews/WeekTabView.swift @@ -12,12 +12,13 @@ struct WeekTabView: View { @State var weekSlider: [[Date.WeekDay]] = [] @State private var createWeek: Bool = false @ObservedObject var vm: ScheduleViewModel + @Binding var isShowingVPKLabel: Bool var body: some View { HStack { TabView(selection: $currentWeekIndex) { ForEach(weekSlider.indices, id: \.self) { index in let week = weekSlider[index] - WeekViewForWeek(weekSlider: $weekSlider, currentWeekIndex: $currentWeekIndex, createWeek: $createWeek, week: week, vm: vm) + WeekViewForWeek(weekSlider: $weekSlider, currentWeekIndex: $currentWeekIndex, createWeek: $createWeek, week: week, vm: vm, isShowingVPKLabel: $isShowingVPKLabel) .padding(.horizontal, 15) .tag(index) } diff --git a/Schedule ICTIS/Main/Views/TabViews/WeekViewForMonth.swift b/Schedule ICTIS/Main/Views/TabViews/WeekViewForMonth.swift index a108b12..e2b7bbb 100644 --- a/Schedule ICTIS/Main/Views/TabViews/WeekViewForMonth.swift +++ b/Schedule ICTIS/Main/Views/TabViews/WeekViewForMonth.swift @@ -10,13 +10,14 @@ import SwiftUI struct WeekViewForMonth: View { let week: [Date.WeekDay] @ObservedObject var vm: ScheduleViewModel + @Binding var isShowingVPKLabel: Bool var body: some View { HStack(spacing: 23) { ForEach(week) { day in VStack { Text(day.date.format("dd")) - .font(.custom("Montserrat-SemiBold", size: 14)) + .font(.custom("Montserrat-SemiBold", fixedSize: 15)) .foregroundStyle(getForegroundColor(day: day)) } .frame(width: 30, height: 30, alignment: .center) @@ -25,6 +26,7 @@ struct WeekViewForMonth: View { .cornerRadius(15) .onTapGesture { handleTap(day: day) + isShowingVPKLabel = false } } } diff --git a/Schedule ICTIS/Main/Views/TabViews/WeekViewForWeek.swift b/Schedule ICTIS/Main/Views/TabViews/WeekViewForWeek.swift index d7b430b..5af8799 100644 --- a/Schedule ICTIS/Main/Views/TabViews/WeekViewForWeek.swift +++ b/Schedule ICTIS/Main/Views/TabViews/WeekViewForWeek.swift @@ -13,17 +13,18 @@ struct WeekViewForWeek: View { @Binding var createWeek: Bool let week: [Date.WeekDay] @ObservedObject var vm: ScheduleViewModel + @Binding var isShowingVPKLabel: Bool var body: some View { HStack (spacing: 10) { ForEach(week) { day in VStack (spacing: 1) { Text(day.date.format("E")) - .font(.custom("Montserrat-SemiBold", size: 14)) + .font(.custom("Montserrat-SemiBold", fixedSize: 15)) .foregroundColor(day.date.format("E") == "Вс" ? Color(.red) : isSameDate(day.date, vm.selectedDay) ? Color("customGray1") : Color("customGray3")) .padding(.top, 13) .foregroundColor(.gray) Text(day.date.format("dd")) - .font(.custom("Montserrat-Semibold", size: 14)) + .font(.custom("Montserrat-Semibold", fixedSize: 15)) .foregroundStyle(isSameDate(day.date, vm.selectedDay) ? .white : .black) .padding(.bottom, 13) } @@ -52,6 +53,7 @@ struct WeekViewForWeek: View { ) .cornerRadius(15) .onTapGesture { + isShowingVPKLabel = false vm.selectedDay = day.date vm.updateSelectedDayIndex() } diff --git a/Schedule ICTIS/Preview Content/Assets.xcassets/upDownArrows.imageset/Contents.json b/Schedule ICTIS/Preview Content/Assets.xcassets/upDownArrows.imageset/Contents.json new file mode 100644 index 0000000..0e744ce --- /dev/null +++ b/Schedule ICTIS/Preview Content/Assets.xcassets/upDownArrows.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "upDownArrows.svg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Schedule ICTIS/Preview Content/Assets.xcassets/upDownArrows.imageset/upDownArrows.svg b/Schedule ICTIS/Preview Content/Assets.xcassets/upDownArrows.imageset/upDownArrows.svg new file mode 100644 index 0000000..5c4964b --- /dev/null +++ b/Schedule ICTIS/Preview Content/Assets.xcassets/upDownArrows.imageset/upDownArrows.svg @@ -0,0 +1,4 @@ + + + + diff --git a/Schedule ICTIS/Settings/GeneralGroupSettings.swift b/Schedule ICTIS/Settings/GeneralGroupSettings.swift new file mode 100644 index 0000000..725cb2e --- /dev/null +++ b/Schedule ICTIS/Settings/GeneralGroupSettings.swift @@ -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("Русский")) +} diff --git a/Schedule ICTIS/Settings/ScheduleGroupSettings.swift b/Schedule ICTIS/Settings/ScheduleGroupSettings.swift new file mode 100644 index 0000000..fef8661 --- /dev/null +++ b/Schedule ICTIS/Settings/ScheduleGroupSettings.swift @@ -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) + } +} diff --git a/Schedule ICTIS/Settings/SelectingGroupView.swift b/Schedule ICTIS/Settings/SelectingGroupView.swift index fd4fc11..c8e9ca7 100644 --- a/Schedule ICTIS/Settings/SelectingGroupView.swift +++ b/Schedule ICTIS/Settings/SelectingGroupView.swift @@ -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) +} diff --git a/Schedule ICTIS/Settings/SelectingVPKView.swift b/Schedule ICTIS/Settings/SelectingVPKView.swift index 3003a23..66100e2 100644 --- a/Schedule ICTIS/Settings/SelectingVPKView.swift +++ b/Schedule ICTIS/Settings/SelectingVPKView.swift @@ -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) +} diff --git a/Schedule ICTIS/Settings/SettingsView.swift b/Schedule ICTIS/Settings/SettingsView.swift index 8d1e1f8..3c71262 100644 --- a/Schedule ICTIS/Settings/SettingsView.swift +++ b/Schedule ICTIS/Settings/SettingsView.swift @@ -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("Настройки") } }