Commit
This commit is contained in:
20
Schedule ICTIS/Main/Views/FirstLaunchScheduleView.swift
Normal file
20
Schedule ICTIS/Main/Views/FirstLaunchScheduleView.swift
Normal file
@ -0,0 +1,20 @@
|
||||
//
|
||||
// FirstLaunchScheduleView.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by G412 on 06.12.2024.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct FirstLaunchScheduleView: View {
|
||||
var body: some View {
|
||||
VStack () {
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
FirstLaunchScheduleView()
|
||||
}
|
25
Schedule ICTIS/Main/Views/LoadingView.swift
Normal file
25
Schedule ICTIS/Main/Views/LoadingView.swift
Normal file
@ -0,0 +1,25 @@
|
||||
//
|
||||
// LoadingView.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by G412 on 11.12.2024.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct LoadingView: View {
|
||||
@Binding var isLoading: Bool
|
||||
var body: some View {
|
||||
ZStack {
|
||||
Color("background")
|
||||
.ignoresSafeArea()
|
||||
ProgressView()
|
||||
.progressViewStyle(CircularProgressViewStyle(tint: .secondary))
|
||||
.scaleEffect(1.2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
LoadingView(isLoading: .constant(true))
|
||||
}
|
91
Schedule ICTIS/Main/Views/MainView.swift
Normal file
91
Schedule ICTIS/Main/Views/MainView.swift
Normal file
@ -0,0 +1,91 @@
|
||||
//
|
||||
// ScheduleView.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by Mironov Egor on 13.11.2024.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct MainView: View {
|
||||
@State private var searchText: String = ""
|
||||
@State private var isShowingMonthSlider: Bool = false
|
||||
@State private var isFirstAppearence = true
|
||||
@ObservedObject var vm: ViewModel
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
SearchBarView(text: $searchText, vm: vm)
|
||||
|
||||
if (vm.isFirstStartOffApp && vm.isLoading) {
|
||||
LoadingView(isLoading: $vm.isLoading)
|
||||
}
|
||||
else if (vm.isFirstStartOffApp) {
|
||||
FirstLaunchScheduleView()
|
||||
}
|
||||
else {
|
||||
CurrentDateView()
|
||||
ScheduleView(vm: vm)
|
||||
}
|
||||
}
|
||||
.alert(isPresented: $vm.isShowingAlertForIncorrectGroup, error: vm.errorInNetwork) { error in
|
||||
|
||||
} message: { error in
|
||||
Text(error.failureReason)
|
||||
}
|
||||
.background(Color("background"))
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
func CurrentDateView() -> some View {
|
||||
VStack (alignment: .leading, spacing: 6) {
|
||||
HStack {
|
||||
VStack (alignment: .leading, spacing: 0) {
|
||||
Text(vm.selectedDay.format("EEEE"))
|
||||
.font(.system(size: 40, weight: .semibold))
|
||||
.foregroundStyle(.black)
|
||||
HStack (spacing: 5) {
|
||||
Text(vm.selectedDay.format("dd"))
|
||||
.font(.system(size: 20, weight: .bold))
|
||||
.foregroundStyle(Color("grayForDate"))
|
||||
Text(vm.selectedDay.format("MMMM"))
|
||||
.font(.system(size: 20, weight: .bold))
|
||||
.foregroundStyle(Color("grayForDate"))
|
||||
Spacer()
|
||||
Button(action: {
|
||||
withAnimation(.easeInOut(duration: 0.5)) {
|
||||
isShowingMonthSlider.toggle()
|
||||
}
|
||||
}) {
|
||||
HStack(spacing: 2) {
|
||||
Text(isShowingMonthSlider ? "Свернуть" : "Развернуть")
|
||||
.font(.system(size: 16, weight: .light))
|
||||
.foregroundStyle(Color.blue)
|
||||
Image(isShowingMonthSlider ? "arrowup" : "arrowdown")
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
.frame(width: 15, height: 15) // Установите размер изображения
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.top, 8)
|
||||
.padding(.leading, 5)
|
||||
Spacer()
|
||||
}
|
||||
if (!isShowingMonthSlider) {
|
||||
WeekTabView(vm: vm)
|
||||
.transition(.opacity)
|
||||
}
|
||||
else {
|
||||
MonthTabView(vm: vm)
|
||||
.transition(.opacity)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal)
|
||||
.animation(.easeInOut(duration: 0.25), value: isShowingMonthSlider)
|
||||
}
|
||||
}
|
||||
#Preview {
|
||||
ContentView()
|
||||
}
|
23
Schedule ICTIS/Main/Views/NoScheduleView.swift
Normal file
23
Schedule ICTIS/Main/Views/NoScheduleView.swift
Normal file
@ -0,0 +1,23 @@
|
||||
//
|
||||
// NoScheduleView.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by G412 on 12.12.2024.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct NoScheduleView: View {
|
||||
var body: some View {
|
||||
VStack {
|
||||
ScrollView (showsIndicators: false) {
|
||||
Text("Пока расписания нет")
|
||||
.padding(.top, 20)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
NoScheduleView()
|
||||
}
|
77
Schedule ICTIS/Main/Views/ScheduleView.swift
Normal file
77
Schedule ICTIS/Main/Views/ScheduleView.swift
Normal file
@ -0,0 +1,77 @@
|
||||
//
|
||||
// ScheduleView.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by G412 on 05.12.2024.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ScheduleView: View {
|
||||
@ObservedObject var vm: ViewModel
|
||||
var body: some View {
|
||||
if vm.isLoading {
|
||||
LoadingView(isLoading: $vm.isLoading)
|
||||
}
|
||||
else {
|
||||
if vm.errorInNetwork != .invalidResponse {
|
||||
ZStack (alignment: .top) {
|
||||
ScrollView(.vertical, showsIndicators: false) {
|
||||
VStack (spacing: 20) {
|
||||
ForEach(vm.classes.indices, id: \.self) { index in
|
||||
if index != 0 && index != 1 && index == vm.selectedIndex {
|
||||
let daySchedule = vm.classes[index] // Это массив строк для дня
|
||||
ForEach(daySchedule.indices.dropFirst(), id: \.self) { lessonIndex in
|
||||
let lesson = daySchedule[lessonIndex] // Это строка с расписанием одной пары
|
||||
if !lesson.isEmpty {
|
||||
HStack(spacing: 10) {
|
||||
VStack {
|
||||
Text(convertTimeString(vm.classes[1][lessonIndex])[0])
|
||||
.font(.system(size: 15, weight: .regular))
|
||||
Text(convertTimeString(vm.classes[1][lessonIndex])[1])
|
||||
.font(.system(size: 15, weight: .regular))
|
||||
}
|
||||
.padding(.top, 7)
|
||||
.padding(.bottom, 7)
|
||||
.padding(.leading, 10)
|
||||
Rectangle()
|
||||
.frame(width: 2)
|
||||
.frame(maxHeight: UIScreen.main.bounds.height - 18)
|
||||
.padding(.top, 7)
|
||||
.padding(.bottom, 7)
|
||||
.foregroundColor(getColorForClass(lesson))
|
||||
Text(lesson)
|
||||
.font(.system(size: 18, weight: .regular))
|
||||
.padding(.top, 7)
|
||||
.padding(.bottom, 7)
|
||||
Spacer()
|
||||
}
|
||||
.frame(maxWidth: UIScreen.main.bounds.width - 40, maxHeight: 230)
|
||||
.background(Color.white)
|
||||
.cornerRadius(20)
|
||||
.shadow(color: .black.opacity(0.25), radius: 4, x: 2, y: 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(width: UIScreen.main.bounds.width)
|
||||
.padding(.bottom, 100)
|
||||
.padding(.top, 30)
|
||||
}
|
||||
VStack {
|
||||
LinearGradient(gradient: Gradient(colors: [Color("background").opacity(0.95), Color.white.opacity(0.1)]), startPoint: .top, endPoint: .bottom)
|
||||
}
|
||||
.frame(width: UIScreen.main.bounds.width, height: 15)
|
||||
}
|
||||
}
|
||||
else {
|
||||
NoScheduleView()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
ContentView()
|
||||
}
|
83
Schedule ICTIS/Main/Views/SearchBarView.swift
Normal file
83
Schedule ICTIS/Main/Views/SearchBarView.swift
Normal file
@ -0,0 +1,83 @@
|
||||
//
|
||||
// SearchBarView.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by Mironov Egor on 13.11.2024.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct SearchBarView: View {
|
||||
@Binding var text: String
|
||||
@State private var isEditing = false
|
||||
@ObservedObject var vm: ViewModel
|
||||
|
||||
var body: some View {
|
||||
HStack (spacing: 11) {
|
||||
HStack (spacing: 0) {
|
||||
Image(systemName: "magnifyingglass")
|
||||
.foregroundColor(Color.gray)
|
||||
.padding(.leading, 12)
|
||||
.padding(.trailing, 7)
|
||||
TextField("Поиск группы", text: $text)
|
||||
.disableAutocorrection(true)
|
||||
.onTapGesture {
|
||||
self.isEditing = true
|
||||
}
|
||||
.onSubmit {
|
||||
self.isEditing = false
|
||||
if (!text.isEmpty) {
|
||||
vm.fetchWeekSchedule(text)
|
||||
vm.group = text
|
||||
}
|
||||
self.text = ""
|
||||
}
|
||||
.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)
|
||||
.background(
|
||||
)
|
||||
}
|
||||
.background(Color.white)
|
||||
}
|
||||
}
|
||||
.frame(height: 40)
|
||||
.background(
|
||||
RoundedRectangle(cornerRadius: 10)
|
||||
.fill(.white)
|
||||
)
|
||||
if (!vm.isFirstStartOffApp) {
|
||||
Button {
|
||||
} label: {
|
||||
ZStack {
|
||||
Rectangle()
|
||||
.frame(width: 40, height: 40)
|
||||
.foregroundStyle(Color("blueColor"))
|
||||
.cornerRadius(15)
|
||||
Image(systemName: "plus")
|
||||
.resizable()
|
||||
.foregroundStyle(.white)
|
||||
.scaledToFit()
|
||||
.frame(width: 16)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.horizontal)
|
||||
.padding(.top, 5)
|
||||
.frame(height: 40)
|
||||
.accentColor(.blue)
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
ContentView()
|
||||
}
|
Reference in New Issue
Block a user