Done with createClassView

This commit is contained in:
Vladimir Dubovik 2025-01-28 12:54:52 +03:00
parent 4a295b9b88
commit 4ee81cf2ea
35 changed files with 141 additions and 34 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -9,12 +9,11 @@ import SwiftUI
struct AuditoryFieldView: View { struct AuditoryFieldView: View {
@Binding var text: String @Binding var text: String
var nameOfImage: String
var labelForField: String var labelForField: String
@FocusState var isFocused: Bool @FocusState var isFocused: Bool
var body: some View { var body: some View {
HStack(spacing: 0) { HStack(spacing: 0) {
Image(systemName: nameOfImage) Image(systemName: "mappin.and.ellipse")
.foregroundColor(Color.gray) .foregroundColor(Color.gray)
.padding(.leading, 12) .padding(.leading, 12)
.padding(.trailing, 7) .padding(.trailing, 7)
@ -44,5 +43,5 @@ struct AuditoryFieldView: View {
} }
#Preview { #Preview {
ContentView() AuditoryFieldView(text: .constant(""), labelForField: "Корпус-аудитория")
} }

View File

@ -9,12 +9,11 @@ import SwiftUI
struct ProfessorFieldView: View { struct ProfessorFieldView: View {
@Binding var text: String @Binding var text: String
var nameOfImage: String
var labelForField: String var labelForField: String
@FocusState var isFocused: Bool @FocusState var isFocused: Bool
var body: some View { var body: some View {
HStack(spacing: 0) { HStack(spacing: 0) {
Image(systemName: nameOfImage) Image(systemName: "graduationcap")
.foregroundColor(Color.gray) .foregroundColor(Color.gray)
.padding(.leading, 12) .padding(.leading, 12)
.padding(.trailing, 7) .padding(.trailing, 7)
@ -44,5 +43,5 @@ struct ProfessorFieldView: View {
} }
#Preview { #Preview {
ContentView() ProfessorFieldView(text: .constant(""), labelForField: "Преподаватель")
} }

View File

@ -10,12 +10,11 @@ import SwiftUI
struct SubjectFieldView: View { struct SubjectFieldView: View {
@Binding var text: String @Binding var text: String
@Binding var isShowingSubjectFieldRed: Bool @Binding var isShowingSubjectFieldRed: Bool
var nameOfImage: String
@Binding var labelForField: String @Binding var labelForField: String
@FocusState var isFocused: Bool @FocusState var isFocused: Bool
var body: some View { var body: some View {
HStack(spacing: 0) { HStack(spacing: 0) {
Image(systemName: nameOfImage) Image(systemName: "book")
.foregroundColor(Color.gray) .foregroundColor(Color.gray)
.padding(.leading, 12) .padding(.leading, 12)
.padding(.trailing, 7) .padding(.trailing, 7)
@ -62,5 +61,5 @@ struct SubjectFieldView: View {
} }
#Preview { #Preview {
ContentView() SubjectFieldView(text: .constant(""), isShowingSubjectFieldRed: .constant(false), labelForField: .constant("Предмет"))
} }

View File

@ -11,10 +11,11 @@ struct MainView: View {
@State private var searchText: String = "" @State private var searchText: String = ""
@State private var isShowingMonthSlider: Bool = false @State private var isShowingMonthSlider: Bool = false
@ObservedObject var vm: ScheduleViewModel @ObservedObject var vm: ScheduleViewModel
@FocusState private var isFocusedSearchBar: Bool
var body: some View { var body: some View {
VStack { VStack {
SearchBarView(text: $searchText, vm: vm) SearchBarView(text: $searchText, isFocused: _isFocusedSearchBar, vm: vm)
if (vm.isFirstStartOffApp && vm.isLoading) { if (vm.isFirstStartOffApp && vm.isLoading) {
LoadingView(isLoading: $vm.isLoading) LoadingView(isLoading: $vm.isLoading)
@ -33,6 +34,9 @@ struct MainView: View {
Text(error.failureReason) Text(error.failureReason)
} }
.background(Color("background")) .background(Color("background"))
.onTapGesture {
isFocusedSearchBar = false
}
} }
@ViewBuilder @ViewBuilder

View File

@ -9,7 +9,7 @@ import SwiftUI
struct SearchBarView: View { struct SearchBarView: View {
@Binding var text: String @Binding var text: String
@FocusState private var isFocused: Bool @FocusState var isFocused: Bool
@State private var isShowingSheet: Bool = false @State private var isShowingSheet: Bool = false
@ObservedObject var vm: ScheduleViewModel @ObservedObject var vm: ScheduleViewModel

View File

@ -27,7 +27,7 @@ struct CreateEditClassView: View {
NavigationView { NavigationView {
ScrollView(.vertical, showsIndicators: false) { ScrollView(.vertical, showsIndicators: false) {
VStack { VStack {
SubjectFieldView(text: $vm._class.subject, isShowingSubjectFieldRed: $isShowingSubjectFieldRed, nameOfImage: "book", labelForField: $textForLabelInSubjectField, isFocused: _isFocusedSubject) SubjectFieldView(text: $vm._class.subject, isShowingSubjectFieldRed: $isShowingSubjectFieldRed, labelForField: $textForLabelInSubjectField, isFocused: _isFocusedSubject)
.padding(.bottom, 10) .padding(.bottom, 10)
HStack { HStack {
Text("Тип") Text("Тип")
@ -50,7 +50,7 @@ struct CreateEditClassView: View {
ZStack { ZStack {
if vm._class.online == "Оффлайн" { if vm._class.online == "Оффлайн" {
AuditoryFieldView(text: $vm._class.auditory, nameOfImage: "mappin.and.ellipse", labelForField: "Корпус-аудитория", isFocused: _isFocusedAuditory) AuditoryFieldView(text: $vm._class.auditory, labelForField: "Корпус-аудитория", isFocused: _isFocusedAuditory)
.padding(.bottom, 10) .padding(.bottom, 10)
.transition(.asymmetric( .transition(.asymmetric(
insertion: .offset(y: -50).combined(with: .identity), insertion: .offset(y: -50).combined(with: .identity),
@ -65,7 +65,7 @@ struct CreateEditClassView: View {
value: vm._class.online value: vm._class.online
) )
ProfessorFieldView(text: $vm._class.professor, nameOfImage: "book", labelForField: "Преподаватель", isFocused: _isFocusedProfessor) ProfessorFieldView(text: $vm._class.professor, labelForField: "Преподаватель", isFocused: _isFocusedProfessor)
.padding(.bottom, 10) .padding(.bottom, 10)
HStack { HStack {
@ -108,14 +108,6 @@ struct CreateEditClassView: View {
self.isIncorrectDate2 = false self.isIncorrectDate2 = false
} }
} }
// .overlay {
// if isIncorrectDate1 {
// Rectangle()
// .frame(maxWidth: 300, maxHeight: 1)
// .foregroundColor(.red)
// .padding(.horizontal)
// }
// }
Spacer() Spacer()
StartEndTimeFieldView(isIncorrectDate: $isIncorrectDate2, selectedDay: $vm._class.day, selectedTime: $vm._class.endtime, imageName: "clock.badge.xmark", text: "Конец", isTimeSelected: $isSelectedTime2) StartEndTimeFieldView(isIncorrectDate: $isIncorrectDate2, selectedDay: $vm._class.day, selectedTime: $vm._class.endtime, imageName: "clock.badge.xmark", text: "Конец", isTimeSelected: $isSelectedTime2)
.onChange(of: vm._class.endtime) { oldValue, newValue in .onChange(of: vm._class.endtime) { oldValue, newValue in
@ -131,14 +123,6 @@ struct CreateEditClassView: View {
self.isIncorrectDate2 = false self.isIncorrectDate2 = false
} }
} }
// .overlay {
// if isIncorrectDate2 {
// Rectangle()
// .frame(maxWidth: 300, maxHeight: 1)
// .foregroundColor(.red)
// .padding(.horizontal)
// }
// }
} }
.frame(height: 40) .frame(height: 40)
.padding(.bottom, 10) .padding(.bottom, 10)
@ -238,8 +222,20 @@ struct CreateEditClassView: View {
.navigationTitle(vm.isNew ? "Новая пара" : "Изменить данные") .navigationTitle(vm.isNew ? "Новая пара" : "Изменить данные")
.background(Color("background")) .background(Color("background"))
.onAppear { .onAppear {
if day >= Calendar.current.startOfDay(for: Date()) { let temp = Calendar.current.date(byAdding: .hour, value: 1, to: Date.init())
if let endTime = temp {
if (!hoursMinutesAreEqual(date1: vm._class.starttime, isEqualTo: Date()) && !hoursMinutesAreEqual(date1: vm._class.endtime, isEqualTo: endTime)) {
self.isSelectedTime1 = true
self.isSelectedTime2 = true
print(vm._class.starttime)
print(vm._class.endtime)
print(endTime)
print(Date())
}
}
if day > Calendar.current.startOfDay(for: Date()) {
vm._class.day = day vm._class.day = day
print(34)
} }
} }
.onTapGesture { .onTapGesture {

View File

@ -2,7 +2,7 @@
// WeekTabView.swift // WeekTabView.swift
// Schedule ICTIS // Schedule ICTIS
// //
// Created by G412 on 10.12.2024. // Created by Mironov Egor on 10.12.2024.
// //
import SwiftUI import SwiftUI

View File

@ -2,7 +2,7 @@
// WeekViewForMonth.swift // WeekViewForMonth.swift
// Schedule ICTIS // Schedule ICTIS
// //
// Created by G412 on 20.12.2024. // Created by Mironov Egor on 20.12.2024.
// //
import SwiftUI import SwiftUI

View File

@ -2,7 +2,7 @@
// WeekView.swift // WeekView.swift
// Schedule ICTIS // Schedule ICTIS
// //
// Created by G412 on 20.12.2024. // Created by Mironov Egor on 20.12.2024.
// //
import SwiftUI import SwiftUI

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "auditoryImage.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 549 B

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "bookImage.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 466 B

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "professorHatImage.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 716 B

View File

@ -71,6 +71,15 @@ extension View {
} }
} }
func hoursMinutesAreEqual(date1: Date, isEqualTo date2: Date) -> Bool {
let calendar = Calendar.current
let components1 = calendar.dateComponents([.day, .hour, .minute], from: date1)
let components2 = calendar.dateComponents([.day, .hour, .minute], from: date2)
return components1.day == components2.day && components1.hour == components2.hour && components1.minute == components2.minute
}
// MARK: ScheduleView // MARK: ScheduleView
func daysAreEqual(_ date1: Date, _ date2: Date) -> Bool { func daysAreEqual(_ date1: Date, _ date2: Date) -> Bool {
let calendar = Calendar.current let calendar = Calendar.current

38
Schedule-ICTIS-Info.plist Normal file
View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIAppFonts</key>
<array>
<string>Montserrat-Black.ttf</string>
<string>Montserrat-BlackItalic.ttf</string>
<string>Montserrat-Bold.ttf</string>
<string>Montserrat-BoldItalic.ttf</string>
<string>Montserrat-ExtraBold.ttf</string>
<string>Montserrat-ExtraBoldItalic.ttf</string>
<string>Montserrat-ExtraLight.ttf</string>
<string>Montserrat-ExtraLightItalic.ttf</string>
<string>Montserrat-Italic.ttf</string>
<string>Montserrat-Light.ttf</string>
<string>Montserrat-LightItalic.ttf</string>
<string>Montserrat-Medium.ttf</string>
<string>Montserrat-MediumItalic.ttf</string>
<string>Montserrat-Regular.ttf</string>
<string>Montserrat-SemiBold.ttf</string>
<string>Montserrat-SemiBoldItalic.ttf</string>
<string>Montserrat-Thin.ttf</string>
<string>Montserrat-ThinItalic.ttf</string>
</array>
<key>UTImportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeIconFiles</key>
<array/>
<key>UTTypeIdentifier</key>
<string></string>
<key>UTTypeTagSpecification</key>
<dict/>
</dict>
</array>
</dict>
</plist>