Commit
This commit is contained in:
46
Schedule ICTIS/Main/Views/CommentView.swift
Normal file
46
Schedule ICTIS/Main/Views/CommentView.swift
Normal file
@ -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))
|
||||
}
|
48
Schedule ICTIS/Main/Views/FieldView.swift
Normal file
48
Schedule ICTIS/Main/Views/FieldView.swift
Normal file
@ -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()
|
||||
}
|
@ -47,7 +47,7 @@ struct SearchBarView: View {
|
||||
.background(
|
||||
)
|
||||
}
|
||||
.background(Color.white)
|
||||
.background(Color.red)
|
||||
}
|
||||
}
|
||||
.frame(height: 40)
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
59
Schedule ICTIS/Main/Views/StartEndTimeView.swift
Normal file
59
Schedule ICTIS/Main/Views/StartEndTimeView.swift
Normal file
@ -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: "Начало")
|
||||
}
|
58
Schedule ICTIS/Main/Views/TextFiledView.swift
Normal file
58
Schedule ICTIS/Main/Views/TextFiledView.swift
Normal file
@ -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()
|
||||
}
|
Reference in New Issue
Block a user