diff --git a/Schedule ICTIS.xcodeproj/xcuserdata/g412.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Schedule ICTIS.xcodeproj/xcuserdata/g412.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..f13775b --- /dev/null +++ b/Schedule ICTIS.xcodeproj/xcuserdata/g412.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,6 @@ + + + diff --git a/Schedule ICTIS/Assets.xcassets/grayForFields.colorset/Contents.json b/Schedule ICTIS/Assets.xcassets/grayForFields.colorset/Contents.json new file mode 100644 index 0000000..58b6ec3 --- /dev/null +++ b/Schedule ICTIS/Assets.xcassets/grayForFields.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x84", + "green" : "0x80", + "red" : "0x80" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x84", + "green" : "0x80", + "red" : "0x80" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Schedule ICTIS/Main/Views/CommentView.swift b/Schedule ICTIS/Main/Views/CommentView.swift new file mode 100644 index 0000000..78fa257 --- /dev/null +++ b/Schedule ICTIS/Main/Views/CommentView.swift @@ -0,0 +1,46 @@ +// +// CommentView.swift +// Schedule ICTIS +// +// Created by G412 on 17.12.2024. +// + +import SwiftUI + +struct CommentView: View { + @Binding var textForComment: String + @FocusState private var isFocused: Bool + + var body: some View { + HStack { + TextField("Комментарий", text: $textForComment) + .submitLabel(.done) + .multilineTextAlignment(.leading) + .focused($isFocused) + .padding(.top, 6) + .padding(.bottom, 6) + + if isFocused { + Button { + textForComment = "" + self.isFocused = false + } label: { + Image(systemName: "xmark.circle.fill") + .padding(.trailing, 20) + .offset(x: 10) + .foregroundColor(.gray) + } + } + } + .frame(minHeight: 40) + .padding(.horizontal) + .background( + RoundedRectangle(cornerRadius: 10) + .fill(.white) + ) + } +} + +#Preview { + SheetCreateClassView(isShowingSheet: .constant(true)) +} diff --git a/Schedule ICTIS/Main/Views/FieldView.swift b/Schedule ICTIS/Main/Views/FieldView.swift new file mode 100644 index 0000000..ce6c3ad --- /dev/null +++ b/Schedule ICTIS/Main/Views/FieldView.swift @@ -0,0 +1,48 @@ +// +// Field.swift +// Schedule ICTIS +// +// Created by G412 on 16.12.2024. +// + +import SwiftUI + +struct FieldView: View { + @Binding var text: String + var nameOfImage: String + var labelForField: String + @FocusState private var isFocused: Bool + var body: some View { + HStack(spacing: 0) { + Image(systemName: nameOfImage) + .foregroundColor(Color.gray) + .padding(.leading, 12) + .padding(.trailing, 7) + TextField(labelForField, text: $text) + .font(.system(size: 18, weight: .regular)) + .disableAutocorrection(true) + .submitLabel(.done) + .focused($isFocused) + if isFocused { + Button { + self.text = "" + self.isFocused = false + } label: { + Image(systemName: "xmark.circle.fill") + .padding(.trailing, 20) + .offset(x: 10) + .foregroundColor(.gray) + } + } + } + .frame(height: 40) + .background( + RoundedRectangle(cornerRadius: 10) + .fill(.white) + ) + } +} + +#Preview { + ContentView() +} diff --git a/Schedule ICTIS/Main/Views/SearchBarView.swift b/Schedule ICTIS/Main/Views/SearchBarView.swift index d58b265..80cba82 100644 --- a/Schedule ICTIS/Main/Views/SearchBarView.swift +++ b/Schedule ICTIS/Main/Views/SearchBarView.swift @@ -47,7 +47,7 @@ struct SearchBarView: View { .background( ) } - .background(Color.white) + .background(Color.red) } } .frame(height: 40) diff --git a/Schedule ICTIS/Main/Views/SheetChangeClassView.swift b/Schedule ICTIS/Main/Views/SheetChangeClassView.swift index 05998ef..ac27068 100644 --- a/Schedule ICTIS/Main/Views/SheetChangeClassView.swift +++ b/Schedule ICTIS/Main/Views/SheetChangeClassView.swift @@ -2,7 +2,7 @@ // SheetView.swift // Schedule ICTIS // -// Created by G412 on 12.12.2024. +// Created by Mironov Egor on 12.12.2024. // import SwiftUI diff --git a/Schedule ICTIS/Main/Views/SheetCreateClassView.swift b/Schedule ICTIS/Main/Views/SheetCreateClassView.swift index 213370b..89ea1d0 100644 --- a/Schedule ICTIS/Main/Views/SheetCreateClassView.swift +++ b/Schedule ICTIS/Main/Views/SheetCreateClassView.swift @@ -2,33 +2,98 @@ // SheetCreateClassView.swift // Schedule ICTIS // -// Created by G412 on 12.12.2024. +// Created by Mironov Egor on 12.12.2024. // import SwiftUI struct SheetCreateClassView: View { @Binding var isShowingSheet: Bool - @State private var isEditingClass: Bool = false - @State private var isEditingAuditory: Bool = false - @State private var isEditingProfessor: Bool = false @State private var textForNameOfClass = "" @State private var textForNameOfAuditory = "" @State private var textForNameOfProfessor = "" + @State private var isShowingDatePickerForDate: Bool = false + @State private var selectedDay: Date = Date() + @State private var selectedStartTime: Date = Date() + @State private var selectedEndTime: Date = Date() + @State private var isImportant: Bool = false + @State private var selectedOption: String = "Нет" + @State private var textForComment: String = "" - var body: some View { NavigationView { - VStack { - FieldView(isEditing: $isEditingClass, text: $textForNameOfClass, nameOfImage: "book", labelForField: "Предмет") + ScrollView(.vertical, showsIndicators: false) { + VStack { + FieldView(text: $textForNameOfClass, nameOfImage: "book", labelForField: "Предмет") + .padding(.bottom, 10) + FieldView(text: $textForNameOfAuditory, nameOfImage: "mappin.and.ellipse", labelForField: "Корпус-аудитория") + .padding(.bottom, 10) + FieldView(text: $textForNameOfProfessor, nameOfImage: "book", labelForField: "Преподаватель") + .padding(.bottom, 10) + HStack { + Image(systemName: "calendar") + .foregroundColor(Color.gray) + .padding(.leading, 12) + .padding(.trailing, 7) + Text("Дата") + .foregroundColor(Color("grayForFields").opacity(0.5)) + .font(.system(size: 18, weight: .regular)) + Spacer() + Text("\(selectedDay, formatter: dateFormatter)") + .foregroundColor(.black) + .font(.system(size: 18, weight: .medium)) + .padding(.trailing, 20) + } + .frame(height: 40) + .background( + RoundedRectangle(cornerRadius: 10) + .fill(.white) + ) + .overlay { + DatePicker("", selection: $selectedDay, in: Date()..., displayedComponents: .date) + .blendMode(.destinationOver) + } .padding(.bottom, 10) - FieldView(isEditing: $isEditingAuditory, text: $textForNameOfAuditory, nameOfImage: "mappin.and.ellipse", labelForField: "Корпус-аудитория") + HStack { + StartEndTimeView(selectedTime: $selectedStartTime, imageName: "clock", text: "Начало") + Spacer() + StartEndTimeView(selectedTime: $selectedEndTime, imageName: "clock.badge.xmark", text: "Конец") + } + .frame(height: 40) .padding(.bottom, 10) - FieldView(isEditing: $isEditingProfessor, text: $textForNameOfProfessor, nameOfImage: "book", labelForField: "Преподаватель") - Spacer() + Toggle("Пометить как важную", isOn: $isImportant) + .frame(height: 40) + .padding(.horizontal) + .background( + RoundedRectangle(cornerRadius: 10) + .fill(.white) + ) + .padding(.bottom, 10) + + HStack { + Text("Напоминанние") + Spacer() + Picker("Напоминание", selection: $selectedOption, content: { + ForEach(MockData.notifications, id: \.self) { + Text($0) + } + }) + .accentColor(Color("grayForFields")) + } + .frame(height: 40) + .padding(.horizontal) + .background( + RoundedRectangle(cornerRadius: 10) + .fill(.white) + ) + .padding(.bottom, 10) + + CommentView(textForComment: $textForComment) + Spacer() + } + .padding(.horizontal) + .padding(.bottom, 60) } - .padding() - .background(Color("background")) .toolbar { ToolbarItem(placement: .navigationBarLeading) { Button("Отменить") { @@ -41,49 +106,18 @@ struct SheetCreateClassView: View { } } } + .navigationTitle("Новая пара") + .background(Color("background")) } - .background(Color("background")) // Фон для всего sheet + } + private var dateFormatter: DateFormatter { + let formatter = DateFormatter() + formatter.dateStyle = .medium + formatter.timeStyle = .none + return formatter } } #Preview { SheetCreateClassView(isShowingSheet: .constant(true)) } - -struct FieldView: View { - @Binding var isEditing: Bool - @Binding var text: String - var nameOfImage: String - var labelForField: String - var body: some View { - HStack(spacing: 0) { - Image(systemName: nameOfImage) - .foregroundColor(Color.gray) - .padding(.leading, 12) - .padding(.trailing, 7) - TextField(labelForField, text: $text) - .disableAutocorrection(true) - .onTapGesture { - self.isEditing = true - } - .submitLabel(.search) - if isEditing { - Button { - self.text = "" - self.isEditing = false - UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil) - } label: { - Image(systemName: "xmark.circle.fill") - .padding(.trailing, 20) - .offset(x: 10) - .foregroundColor(.gray) - } - } - } - .frame(height: 40) - .background( - RoundedRectangle(cornerRadius: 10) - .fill(.white) - ) - } -} diff --git a/Schedule ICTIS/Main/Views/StartEndTimeView.swift b/Schedule ICTIS/Main/Views/StartEndTimeView.swift new file mode 100644 index 0000000..b036af6 --- /dev/null +++ b/Schedule ICTIS/Main/Views/StartEndTimeView.swift @@ -0,0 +1,59 @@ +// +// StartEndTimeView.swift +// Schedule ICTIS +// +// Created by Mironov Egor on 17.12.2024. +// + +import SwiftUI + +struct StartEndTimeView: View { + @Binding var selectedTime: Date + var imageName: String + var text: String + @State private var isTimeSelected: Bool = false + var body: some View { + HStack { + Image(systemName: imageName) + .foregroundColor(Color("grayForFields")) + .padding(.leading, 12) + + if !isTimeSelected { + Text(text) + .font(.system(size: 17, weight: .regular)) + .foregroundColor(.gray.opacity(0.5)) + } + + if isTimeSelected { + Text("\(selectedTime, formatter: timeFormatter)") + .foregroundColor(.black) + .font(.system(size: 17, weight: .medium)) + .padding(.trailing, 10) + } + Spacer() + } + .frame(width: (UIScreen.main.bounds.width / 2) - 22, height: 40) + .background( + RoundedRectangle(cornerRadius: 10) + .fill(.white) + ) + .overlay { + DatePicker("", selection: $selectedTime, in: Date()..., displayedComponents: .hourAndMinute) + .padding(.trailing, 35) + .blendMode(.destinationOver) + .onChange(of: selectedTime) { newValue, oldValue in + isTimeSelected = true + } + } + } + + private var timeFormatter: DateFormatter { + let formatter = DateFormatter() + formatter.dateFormat = "HH:mm" + return formatter + } +} + +#Preview { + StartEndTimeView(selectedTime: .constant(Date()), imageName: "clock", text: "Начало") +} diff --git a/Schedule ICTIS/Main/Views/TextFiledView.swift b/Schedule ICTIS/Main/Views/TextFiledView.swift new file mode 100644 index 0000000..6abf975 --- /dev/null +++ b/Schedule ICTIS/Main/Views/TextFiledView.swift @@ -0,0 +1,58 @@ +// +// TextFiledView.swift +// Schedule ICTIS +// +// Created by G412 on 17.12.2024. +// + +import SwiftUI + +struct TextFiledView: View { + @State private var isEditing: Bool = false + @State private var text: String = "" + @State private var nameOfImage: String = "calendar" + @State private var labelForField: String = "Преподаватель" + + @FocusState private var isTextFieldFocused: Bool + + var body: some View { + HStack(spacing: 0) { + Image(systemName: nameOfImage) + .foregroundColor(Color.gray) + .padding(.leading, 12) + .padding(.trailing, 7) + + TextField(labelForField, text: $text) + .font(.system(size: 18, weight: .regular)) + .disableAutocorrection(true) + .focused($isTextFieldFocused) + .onChange(of: isTextFieldFocused) { newValue, oldValue in + isEditing = newValue + } + .submitLabel(.done) + + if isTextFieldFocused { + Button { + self.text = "" + self.isEditing = false + isTextFieldFocused = false + } label: { + Image(systemName: "xmark.circle.fill") + .padding() + .padding(.trailing, 20) + .offset(x: 10) + .foregroundColor(.red) + } + } + } + .frame(height: 40) + .background( + RoundedRectangle(cornerRadius: 10) + .fill(.white) + ) + } +} + +#Preview { + TextFiledView() +} diff --git a/Schedule ICTIS/MockData.swift b/Schedule ICTIS/MockData.swift index 7dd0c08..3a34855 100644 --- a/Schedule ICTIS/MockData.swift +++ b/Schedule ICTIS/MockData.swift @@ -10,13 +10,5 @@ import Foundation struct MockData { static let daysOfWeek = ["Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс"] - static let onlineClasses: [String] = [ - "пр.Академический курс иностранного языка Янкаускас Е. С. LMS", - "пр.Академический курс иностранного языка Янкаускас Е. С. LMS-3", - "пр.Введение в инженерную деятельность 1 п/г Михайлова В. Д. LMS 2 п/г Романенко К. С. 3 п/г Козловский А. В. 4 п/г Компаниец В. С. 5 п/г Олейников К. А. 6 п/г Прудников В. А. 7 п/г Петров Д. А. 8 п/г Григорян К. С.", - "пр.Иностранный язык Иностранный язык LMS", - "лек.Операционные системы 1 п/г Шкурко А. Н. Г-309 АКТРУ 2 п/г Дроздов С. Н. Г-333 3 п/г Нужнов Е. В. Г-301 Operating systems(Операционные системы) 4 п/г Самойлов А. Н. LMS", - "пр.Введение в инженерную деятельность 1 п/г Плёнкин А. П. LMS-1 2 п/г Кучеров С. А. 3 п/г Шкурко А. Н. 4 п/г Механцев Б. Е.", - "лек.Операционные системы 1 п/г Шкурко А. Н. Г-309 АКТРУ 2 п/г Дроздов С. Н. Г-333 3 п/г Нужнов Е. В. Г-301 Operating systems(Операционные системы) 4 п/г Самойлов А. Н. LMS" - ] + static let notifications = ["Нет", "За 10 минут", "За 30 миннут", "За 1 час"] } diff --git a/Schedule ICTIS/Utilities/Extensions/View+Extensions.swift b/Schedule ICTIS/Utilities/Extensions/View+Extensions.swift index 7b883dc..6ee27db 100644 --- a/Schedule ICTIS/Utilities/Extensions/View+Extensions.swift +++ b/Schedule ICTIS/Utilities/Extensions/View+Extensions.swift @@ -70,4 +70,8 @@ extension View { return Color("greenForOffline") } } + + func hideKeyboard() { + UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil) + } }