Alomost done with CreateClassView
This commit is contained in:
@ -1,17 +1,17 @@
|
||||
//
|
||||
// Field.swift
|
||||
// AuditoryFieldView.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by G412 on 16.12.2024.
|
||||
// Created by G412 on 23.01.2025.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ProfessorAuditoryClassFieldView: View {
|
||||
struct AuditoryFieldView: View {
|
||||
@Binding var text: String
|
||||
var nameOfImage: String
|
||||
var labelForField: String
|
||||
@FocusState private var isFocused: Bool
|
||||
@FocusState var isFocused: Bool
|
||||
var body: some View {
|
||||
HStack(spacing: 0) {
|
||||
Image(systemName: nameOfImage)
|
@ -9,7 +9,7 @@ import SwiftUI
|
||||
|
||||
struct CommentFieldView: View {
|
||||
@Binding var textForComment: String
|
||||
@FocusState private var isFocused: Bool
|
||||
@FocusState var isFocused: Bool
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
|
48
Schedule ICTIS/Main/Views/Fields/ProfessorFieldView.swift
Normal file
48
Schedule ICTIS/Main/Views/Fields/ProfessorFieldView.swift
Normal file
@ -0,0 +1,48 @@
|
||||
//
|
||||
// ProfessorFieldView.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by G412 on 23.01.2025.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ProfessorFieldView: View {
|
||||
@Binding var text: String
|
||||
var nameOfImage: String
|
||||
var labelForField: String
|
||||
@FocusState 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()
|
||||
}
|
@ -13,20 +13,19 @@ struct StartEndTimeFieldView: View {
|
||||
@Binding var selectedTime: Date
|
||||
var imageName: String
|
||||
var text: String
|
||||
@State private var isTimeSelected: Bool = false
|
||||
@Binding var isTimeSelected: Bool
|
||||
var body: some View {
|
||||
HStack {
|
||||
Image(systemName: imageName)
|
||||
.foregroundColor(isIncorrectDate ? .red : Color("grayForFields"))
|
||||
.padding(.leading, 12)
|
||||
|
||||
if !isTimeSelected {
|
||||
if !isTimeSelected || isIncorrectDate {
|
||||
Text(text)
|
||||
.font(.system(size: 17, weight: .regular))
|
||||
.foregroundColor(.gray.opacity(0.5))
|
||||
}
|
||||
|
||||
if isTimeSelected {
|
||||
else {
|
||||
Text("\(selectedTime, formatter: timeFormatter)")
|
||||
.foregroundColor(isIncorrectDate ? .red : .black)
|
||||
.font(.system(size: 17, weight: .medium))
|
||||
@ -40,7 +39,7 @@ struct StartEndTimeFieldView: View {
|
||||
.fill(.white)
|
||||
)
|
||||
.overlay {
|
||||
if isSameDate(selectedTime, selectedDay) {
|
||||
if selectedDay.isToday {
|
||||
DatePicker("", selection: $selectedTime, in: Date()..., displayedComponents: .hourAndMinute)
|
||||
.padding(.trailing, 35)
|
||||
.blendMode(.destinationOver)
|
||||
|
66
Schedule ICTIS/Main/Views/Fields/SubjectFieldView.swift
Normal file
66
Schedule ICTIS/Main/Views/Fields/SubjectFieldView.swift
Normal file
@ -0,0 +1,66 @@
|
||||
//
|
||||
// Field.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by G412 on 16.12.2024.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct SubjectFieldView: View {
|
||||
@Binding var text: String
|
||||
@Binding var isShowingSubjectFieldRed: Bool
|
||||
var nameOfImage: String
|
||||
@Binding var labelForField: String
|
||||
@FocusState 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)
|
||||
.onChange(of: isFocused, initial: false) { oldValue, newValue in
|
||||
if newValue {
|
||||
self.isShowingSubjectFieldRed = false
|
||||
self.labelForField = "Предмет"
|
||||
}
|
||||
}
|
||||
.background {
|
||||
Group {
|
||||
if isShowingSubjectFieldRed {
|
||||
Text("Поле должно быть заполнено!")
|
||||
.font(.system(size: 18, weight: .regular))
|
||||
.foregroundColor(.red)
|
||||
.frame(width: 290)
|
||||
.padding(.leading, -42)
|
||||
}
|
||||
}
|
||||
}
|
||||
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()
|
||||
}
|
Reference in New Issue
Block a user