Commit
This commit is contained in:
parent
92b125927d
commit
def9175c20
@ -8,6 +8,7 @@
|
||||
import SwiftUI
|
||||
|
||||
struct ScheduleView: View {
|
||||
@State private var isShowingSheet: Bool = false
|
||||
@ObservedObject var vm: ViewModel
|
||||
var body: some View {
|
||||
if vm.isLoading {
|
||||
@ -50,6 +51,9 @@ struct ScheduleView: View {
|
||||
.background(Color.white)
|
||||
.cornerRadius(20)
|
||||
.shadow(color: .black.opacity(0.25), radius: 4, x: 2, y: 2)
|
||||
.onTapGesture {
|
||||
isShowingSheet = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -64,6 +68,9 @@ struct ScheduleView: View {
|
||||
}
|
||||
.frame(width: UIScreen.main.bounds.width, height: 15)
|
||||
}
|
||||
.sheet(isPresented: $isShowingSheet) {
|
||||
SheetChangeClassView(isShowingSheet: $isShowingSheet)
|
||||
}
|
||||
}
|
||||
else {
|
||||
NoScheduleView()
|
||||
|
@ -10,6 +10,7 @@ import SwiftUI
|
||||
struct SearchBarView: View {
|
||||
@Binding var text: String
|
||||
@State private var isEditing = false
|
||||
@State private var isShowingSheet: Bool = false
|
||||
@ObservedObject var vm: ViewModel
|
||||
|
||||
var body: some View {
|
||||
@ -56,6 +57,7 @@ struct SearchBarView: View {
|
||||
)
|
||||
if (!vm.isFirstStartOffApp) {
|
||||
Button {
|
||||
isShowingSheet = true
|
||||
} label: {
|
||||
ZStack {
|
||||
Rectangle()
|
||||
@ -75,6 +77,9 @@ struct SearchBarView: View {
|
||||
.padding(.top, 5)
|
||||
.frame(height: 40)
|
||||
.accentColor(.blue)
|
||||
.sheet(isPresented: $isShowingSheet) {
|
||||
SheetCreateClassView(isShowingSheet: $isShowingSheet)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
37
Schedule ICTIS/Main/Views/SheetChangeClassView.swift
Normal file
37
Schedule ICTIS/Main/Views/SheetChangeClassView.swift
Normal file
@ -0,0 +1,37 @@
|
||||
//
|
||||
// SheetView.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by G412 on 12.12.2024.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct SheetChangeClassView: View {
|
||||
@Binding var isShowingSheet: Bool
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
VStack {
|
||||
Spacer()
|
||||
Text("Создание новой пары")
|
||||
Spacer()
|
||||
}
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
Button("Отменить") {
|
||||
isShowingSheet = false
|
||||
}
|
||||
}
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
Button("Сохранить") {
|
||||
isShowingSheet = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
SheetChangeClassView(isShowingSheet: .constant(true))
|
||||
}
|
89
Schedule ICTIS/Main/Views/SheetCreateClassView.swift
Normal file
89
Schedule ICTIS/Main/Views/SheetCreateClassView.swift
Normal file
@ -0,0 +1,89 @@
|
||||
//
|
||||
// SheetCreateClassView.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by G412 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 = ""
|
||||
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
VStack {
|
||||
FieldView(isEditing: $isEditingClass, text: $textForNameOfClass, nameOfImage: "book", labelForField: "Предмет")
|
||||
.padding(.bottom, 10)
|
||||
FieldView(isEditing: $isEditingAuditory, text: $textForNameOfAuditory, nameOfImage: "mappin.and.ellipse", labelForField: "Корпус-аудитория")
|
||||
.padding(.bottom, 10)
|
||||
FieldView(isEditing: $isEditingProfessor, text: $textForNameOfProfessor, nameOfImage: "book", labelForField: "Преподаватель")
|
||||
Spacer()
|
||||
}
|
||||
.padding()
|
||||
.background(Color("background"))
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
Button("Отменить") {
|
||||
isShowingSheet = false
|
||||
}
|
||||
}
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
Button("Сохранить") {
|
||||
isShowingSheet = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.background(Color("background")) // Фон для всего sheet
|
||||
}
|
||||
}
|
||||
|
||||
#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)
|
||||
)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user