Commit
This commit is contained in:
parent
1eb574e682
commit
8d973e7942
@ -1,8 +0,0 @@
|
||||
//
|
||||
// Class.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by G412 on 18.12.2024.
|
||||
//
|
||||
|
||||
import Foundation
|
@ -1,2 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="23605" systemVersion="24C101" minimumToolsVersion="Automatic" sourceLanguage="Swift" usedWithSwiftData="YES" userDefinedModelVersionIdentifier=""/>
|
||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="23605" systemVersion="24C101" minimumToolsVersion="Automatic" sourceLanguage="Swift" usedWithSwiftData="YES" userDefinedModelVersionIdentifier="">
|
||||
<entity name="ClassModel" representedClassName=".ClassModel" syncable="YES">
|
||||
<attribute name="auditory" optional="YES" attributeType="String"/>
|
||||
<attribute name="comment" optional="YES" attributeType="String"/>
|
||||
<attribute name="day" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
|
||||
<attribute name="endtime" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
|
||||
<attribute name="important" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
|
||||
<attribute name="notification" optional="YES" attributeType="String"/>
|
||||
<attribute name="online" optional="YES" attributeType="String"/>
|
||||
<attribute name="professor" optional="YES" attributeType="String"/>
|
||||
<attribute name="starttime" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
|
||||
<attribute name="subject" optional="YES" attributeType="String"/>
|
||||
</entity>
|
||||
</model>
|
@ -3,4 +3,22 @@
|
||||
uuid = "38CE0E1B-29C0-4785-BF18-FE1BA38F677F"
|
||||
type = "1"
|
||||
version = "2.0">
|
||||
<Breakpoints>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
uuid = "CF2C0E34-74B0-458B-AE66-E61DEB75A958"
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Schedule ICTIS/Main/Views/ProfessorAuditoryClassFieldView.swift"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "20"
|
||||
endingLineNumber = "20"
|
||||
landmarkName = "body"
|
||||
landmarkType = "24">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
</Breakpoints>
|
||||
</Bucket>
|
||||
|
@ -1,11 +0,0 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "ICTIS_logo.png",
|
||||
"idiom" : "universal",
|
||||
"platform" : "ios",
|
||||
"size" : "1024x1024"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 24 KiB |
@ -1,6 +0,0 @@
|
||||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "arrow.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 221 B |
@ -1,21 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "Vector.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 222 B |
@ -1,38 +0,0 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0xF6",
|
||||
"green" : "0xF0",
|
||||
"red" : "0xF1"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
},
|
||||
{
|
||||
"appearances" : [
|
||||
{
|
||||
"appearance" : "luminosity",
|
||||
"value" : "dark"
|
||||
}
|
||||
],
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0xFF",
|
||||
"green" : "0xFF",
|
||||
"red" : "0xFF"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0xA4",
|
||||
"green" : "0x60",
|
||||
"red" : "0x28"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
},
|
||||
{
|
||||
"appearances" : [
|
||||
{
|
||||
"appearance" : "luminosity",
|
||||
"value" : "dark"
|
||||
}
|
||||
],
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0xA4",
|
||||
"green" : "0x60",
|
||||
"red" : "0x28"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0xFF",
|
||||
"green" : "0x7A",
|
||||
"red" : "0x00"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
},
|
||||
{
|
||||
"appearances" : [
|
||||
{
|
||||
"appearance" : "luminosity",
|
||||
"value" : "dark"
|
||||
}
|
||||
],
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0xFF",
|
||||
"green" : "0xFF",
|
||||
"red" : "0xFF"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0xD9",
|
||||
"green" : "0xD9",
|
||||
"red" : "0xD9"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
},
|
||||
{
|
||||
"appearances" : [
|
||||
{
|
||||
"appearance" : "luminosity",
|
||||
"value" : "dark"
|
||||
}
|
||||
],
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0xD9",
|
||||
"green" : "0xD9",
|
||||
"red" : "0xD9"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0x7D",
|
||||
"green" : "0x7D",
|
||||
"red" : "0x7D"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
},
|
||||
{
|
||||
"appearances" : [
|
||||
{
|
||||
"appearance" : "luminosity",
|
||||
"value" : "dark"
|
||||
}
|
||||
],
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0x7D",
|
||||
"green" : "0x7D",
|
||||
"red" : "0x7D"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0x7D",
|
||||
"green" : "0x7D",
|
||||
"red" : "0x7D"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
},
|
||||
{
|
||||
"appearances" : [
|
||||
{
|
||||
"appearance" : "luminosity",
|
||||
"value" : "dark"
|
||||
}
|
||||
],
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0x7D",
|
||||
"green" : "0x7D",
|
||||
"red" : "0x7D"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0x7A",
|
||||
"green" : "0x7A",
|
||||
"red" : "0x7A"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
},
|
||||
{
|
||||
"appearances" : [
|
||||
{
|
||||
"appearance" : "luminosity",
|
||||
"value" : "dark"
|
||||
}
|
||||
],
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0x7A",
|
||||
"green" : "0x7A",
|
||||
"red" : "0x7A"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0x84",
|
||||
"green" : "0x80",
|
||||
"red" : "0x80"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
},
|
||||
{
|
||||
"appearances" : [
|
||||
{
|
||||
"appearance" : "luminosity",
|
||||
"value" : "dark"
|
||||
}
|
||||
],
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0x84",
|
||||
"green" : "0x80",
|
||||
"red" : "0x80"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0x0A",
|
||||
"green" : "0x97",
|
||||
"red" : "0x00"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
},
|
||||
{
|
||||
"appearances" : [
|
||||
{
|
||||
"appearance" : "luminosity",
|
||||
"value" : "dark"
|
||||
}
|
||||
],
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0xFF",
|
||||
"green" : "0xFF",
|
||||
"red" : "0xFF"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0x99",
|
||||
"green" : "0x99",
|
||||
"red" : "0x99"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
},
|
||||
{
|
||||
"appearances" : [
|
||||
{
|
||||
"appearance" : "luminosity",
|
||||
"value" : "dark"
|
||||
}
|
||||
],
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0x99",
|
||||
"green" : "0x99",
|
||||
"red" : "0x99"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0xDE",
|
||||
"green" : "0xE4",
|
||||
"red" : "0x22"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
},
|
||||
{
|
||||
"appearances" : [
|
||||
{
|
||||
"appearance" : "luminosity",
|
||||
"value" : "dark"
|
||||
}
|
||||
],
|
||||
"color" : {
|
||||
"color-space" : "srgb",
|
||||
"components" : {
|
||||
"alpha" : "1.000",
|
||||
"blue" : "0xDE",
|
||||
"green" : "0xE4",
|
||||
"red" : "0x22"
|
||||
}
|
||||
},
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ import SwiftUI
|
||||
|
||||
struct ContentView: View {
|
||||
@State private var selectedTab: Int = 1
|
||||
@StateObject var vm = ViewModel()
|
||||
@StateObject var vm = ScheduleViewModel()
|
||||
|
||||
var body: some View {
|
||||
TabView(selection: $selectedTab) {
|
||||
|
@ -41,6 +41,3 @@ struct CommentFieldView: View {
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
SheetCreateClassView(isShowingSheet: .constant(true))
|
||||
}
|
||||
|
@ -46,12 +46,6 @@ struct StartEndTimeFieldView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var timeFormatter: DateFormatter {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateFormat = "HH:mm"
|
||||
return formatter
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
|
@ -11,7 +11,7 @@ struct MainView: View {
|
||||
@State private var searchText: String = ""
|
||||
@State private var isShowingMonthSlider: Bool = false
|
||||
@State private var isFirstAppearence = true
|
||||
@ObservedObject var vm: ViewModel
|
||||
@ObservedObject var vm: ScheduleViewModel
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
@ -64,7 +64,7 @@ struct MainView: View {
|
||||
Image(isShowingMonthSlider ? "arrowup" : "arrowdown")
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
.frame(width: 15, height: 15) // Установите размер изображения
|
||||
.frame(width: 15, height: 15)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,8 @@ import SwiftUI
|
||||
|
||||
struct ScheduleView: View {
|
||||
@State private var isShowingSheet: Bool = false
|
||||
@ObservedObject var vm: ViewModel
|
||||
@ObservedObject var vm: ScheduleViewModel
|
||||
@FetchRequest(fetchRequest: ClassModel.all()) private var classes
|
||||
var body: some View {
|
||||
if vm.isLoading {
|
||||
LoadingView(isLoading: $vm.isLoading)
|
||||
@ -58,6 +59,39 @@ struct ScheduleView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
ForEach(classes) { _class in
|
||||
if datesAreEqual(_class.day, vm.selectedDay) {
|
||||
HStack(spacing: 10) {
|
||||
VStack {
|
||||
Text(getTimeString(_class.starttime))
|
||||
.font(.system(size: 15, weight: .regular))
|
||||
Text(getTimeString(_class.endtime))
|
||||
.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(_class.important ? Color("redForImportant") : onlineOrNot(_class.online))
|
||||
Text(getSubjectName(_class.subject, _class.professor, _class.auditory))
|
||||
.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)
|
||||
.onTapGesture {
|
||||
isShowingSheet = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(width: UIScreen.main.bounds.width)
|
||||
.padding(.bottom, 100)
|
||||
|
@ -11,7 +11,9 @@ struct SearchBarView: View {
|
||||
@Binding var text: String
|
||||
@State private var isEditing = false
|
||||
@State private var isShowingSheet: Bool = false
|
||||
@ObservedObject var vm: ViewModel
|
||||
@ObservedObject var vm: ScheduleViewModel
|
||||
|
||||
var provider = ClassProvider.shared
|
||||
|
||||
var body: some View {
|
||||
HStack (spacing: 11) {
|
||||
@ -28,6 +30,9 @@ struct SearchBarView: View {
|
||||
.onSubmit {
|
||||
self.isEditing = false
|
||||
if (!text.isEmpty) {
|
||||
if !vm.numOfGroup.isEmpty {
|
||||
|
||||
}
|
||||
vm.fetchWeekSchedule(text)
|
||||
vm.group = text
|
||||
}
|
||||
@ -78,7 +83,7 @@ struct SearchBarView: View {
|
||||
.frame(height: 40)
|
||||
.accentColor(.blue)
|
||||
.sheet(isPresented: $isShowingSheet) {
|
||||
SheetCreateClassView(isShowingSheet: $isShowingSheet)
|
||||
SheetCreateClassView(isShowingSheet: $isShowingSheet, vm: .init(provider: provider))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,22 +13,21 @@ struct SheetCreateClassView: View {
|
||||
@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 selectedOptionForNotification: String = "Нет"
|
||||
@State private var selectedOptionForOnline: String = "Оффлайн"
|
||||
@State private var textForComment: String = ""
|
||||
@ObservedObject var vm: EditClassViewModel
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
ScrollView(.vertical, showsIndicators: false) {
|
||||
VStack {
|
||||
ProfessorAuditoryClassFieldView(text: $textForNameOfClass, nameOfImage: "book", labelForField: "Предмет")
|
||||
ProfessorAuditoryClassFieldView(text: $vm._class.subject, nameOfImage: "book", labelForField: "Предмет")
|
||||
.padding(.bottom, 10)
|
||||
ProfessorAuditoryClassFieldView(text: $textForNameOfAuditory, nameOfImage: "mappin.and.ellipse", labelForField: "Корпус-аудитория")
|
||||
ProfessorAuditoryClassFieldView(text: $vm._class.auditory, nameOfImage: "mappin.and.ellipse", labelForField: "Корпус-аудитория")
|
||||
.padding(.bottom, 10)
|
||||
ProfessorAuditoryClassFieldView(text: $textForNameOfProfessor, nameOfImage: "book", labelForField: "Преподаватель")
|
||||
ProfessorAuditoryClassFieldView(text: $vm._class.professor, nameOfImage: "book", labelForField: "Преподаватель")
|
||||
.padding(.bottom, 10)
|
||||
HStack {
|
||||
Image(systemName: "calendar")
|
||||
@ -39,7 +38,7 @@ struct SheetCreateClassView: View {
|
||||
.foregroundColor(Color("grayForFields").opacity(0.5))
|
||||
.font(.system(size: 18, weight: .regular))
|
||||
Spacer()
|
||||
Text("\(selectedDay, formatter: dateFormatter)")
|
||||
Text("\(vm._class.day, formatter: dateFormatter)")
|
||||
.foregroundColor(.black)
|
||||
.font(.system(size: 18, weight: .medium))
|
||||
.padding(.trailing, 20)
|
||||
@ -50,18 +49,30 @@ struct SheetCreateClassView: View {
|
||||
.fill(.white)
|
||||
)
|
||||
.overlay {
|
||||
DatePicker("", selection: $selectedDay, in: Date()..., displayedComponents: .date)
|
||||
DatePicker("", selection: $vm._class.day, in: Date()..., displayedComponents: .date)
|
||||
.blendMode(.destinationOver)
|
||||
}
|
||||
.padding(.bottom, 10)
|
||||
HStack {
|
||||
StartEndTimeFieldView(selectedTime: $selectedStartTime, imageName: "clock", text: "Начало")
|
||||
StartEndTimeFieldView(selectedTime: $vm._class.starttime, imageName: "clock", text: "Начало")
|
||||
.onChange(of: vm._class.starttime) { oldValue, newValue in
|
||||
if !checkStartTimeLessThenEndTime(vm._class.starttime, vm._class.endtime) {
|
||||
print("Values \(oldValue) - \(newValue) 1")
|
||||
print(vm._class.starttime)
|
||||
vm._class.starttime = oldValue
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
StartEndTimeFieldView(selectedTime: $selectedEndTime, imageName: "clock.badge.xmark", text: "Конец")
|
||||
StartEndTimeFieldView(selectedTime: $vm._class.endtime, imageName: "clock.badge.xmark", text: "Конец")
|
||||
.onChange(of: vm._class.endtime) { oldValue, newValue in
|
||||
print("Values \(oldValue) - \(newValue) 2")
|
||||
print(vm._class.endtime)
|
||||
validateTime(old: oldValue, new: newValue, isStartChanged: false)
|
||||
}
|
||||
}
|
||||
.frame(height: 40)
|
||||
.padding(.bottom, 10)
|
||||
Toggle("Пометить как важную", isOn: $isImportant)
|
||||
Toggle("Пометить как важную", isOn: $vm._class.important)
|
||||
.frame(height: 40)
|
||||
.padding(.horizontal)
|
||||
.background(
|
||||
@ -73,7 +84,7 @@ struct SheetCreateClassView: View {
|
||||
HStack {
|
||||
Text("Напоминанние")
|
||||
Spacer()
|
||||
Picker("Напоминание", selection: $selectedOption, content: {
|
||||
Picker("Напоминание", selection: $vm._class.notification, content: {
|
||||
ForEach(MockData.notifications, id: \.self) {
|
||||
Text($0)
|
||||
}
|
||||
@ -87,8 +98,25 @@ struct SheetCreateClassView: View {
|
||||
.fill(.white)
|
||||
)
|
||||
.padding(.bottom, 10)
|
||||
HStack {
|
||||
Text("Тип")
|
||||
Spacer()
|
||||
Picker("Тип", selection: $vm._class.online, content: {
|
||||
ForEach(MockData.onlineOrOffline, id: \.self) {
|
||||
Text($0)
|
||||
}
|
||||
})
|
||||
.accentColor(Color("grayForFields"))
|
||||
}
|
||||
.frame(height: 40)
|
||||
.padding(.horizontal)
|
||||
.background(
|
||||
RoundedRectangle(cornerRadius: 10)
|
||||
.fill(.white)
|
||||
)
|
||||
.padding(.bottom, 10)
|
||||
|
||||
CommentFieldView(textForComment: $textForComment)
|
||||
CommentFieldView(textForComment: $vm._class.comment)
|
||||
Spacer()
|
||||
}
|
||||
.padding(.horizontal)
|
||||
@ -102,6 +130,11 @@ struct SheetCreateClassView: View {
|
||||
}
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
Button("Сохранить") {
|
||||
do {
|
||||
try vm.save()
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
isShowingSheet = false
|
||||
}
|
||||
}
|
||||
@ -110,14 +143,18 @@ struct SheetCreateClassView: View {
|
||||
.background(Color("background"))
|
||||
}
|
||||
}
|
||||
private var dateFormatter: DateFormatter {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateStyle = .medium
|
||||
formatter.timeStyle = .none
|
||||
return formatter
|
||||
func validateTime(old oldValue: Date, new newValue: Date, isStartChanged: Bool) {
|
||||
if !checkStartTimeLessThenEndTime(vm._class.starttime, vm._class.endtime) {
|
||||
if isStartChanged {
|
||||
vm._class.starttime = Date()
|
||||
} else {
|
||||
vm._class.starttime = Date()
|
||||
}
|
||||
print("Invalid time selected. Reverting to old value.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
SheetCreateClassView(isShowingSheet: .constant(true))
|
||||
SheetCreateClassView(isShowingSheet: .constant(true), vm: .init(provider: .shared))
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
// MonthTabView.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by G412 on 10.12.2024.
|
||||
// Created by Mironov Egor on 10.12.2024.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
@ -12,7 +12,7 @@ struct MonthTabView: View {
|
||||
@State private var monthSlider: [[Date.MonthWeek]] = []
|
||||
@State private var createMonth: Bool = false
|
||||
@State private var currentWeekIndex: Int = 0
|
||||
@ObservedObject var vm: ViewModel
|
||||
@ObservedObject var vm: ScheduleViewModel
|
||||
var body: some View {
|
||||
VStack {
|
||||
HStack (spacing: 34) {
|
||||
@ -25,7 +25,6 @@ struct MonthTabView: View {
|
||||
}
|
||||
}
|
||||
.padding(.top, 14)
|
||||
//.background(Color.red)
|
||||
TabView(selection: $currentMonthIndex) {
|
||||
ForEach(monthSlider.indices, id: \.self) { index in
|
||||
let month = monthSlider[index]
|
||||
@ -37,7 +36,6 @@ struct MonthTabView: View {
|
||||
.padding(.bottom, -10)
|
||||
.padding(.horizontal, -15)
|
||||
.tabViewStyle(.page(indexDisplayMode: .never))
|
||||
//.background(Color.green)
|
||||
}
|
||||
.onAppear(perform: {
|
||||
vm.updateSelectedDayIndex()
|
||||
|
@ -11,7 +11,7 @@ struct WeekTabView: View {
|
||||
@State private var currentWeekIndex: Int = 1
|
||||
@State private var weekSlider: [[Date.WeekDay]] = []
|
||||
@State private var createWeek: Bool = false
|
||||
@ObservedObject var vm: ViewModel
|
||||
@ObservedObject var vm: ScheduleViewModel
|
||||
var body: some View {
|
||||
HStack {
|
||||
TabView(selection: $currentWeekIndex) {
|
||||
|
@ -10,5 +10,9 @@ import Foundation
|
||||
|
||||
struct MockData {
|
||||
static let daysOfWeek = ["Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс"]
|
||||
|
||||
// MARK: SheetCreateClassView
|
||||
static let notifications = ["Нет", "За 10 минут", "За 30 миннут", "За 1 час"]
|
||||
|
||||
static let onlineOrOffline = ["Оффлайн", "Онлайн"]
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
final class ClassModel: NSManagedObject {
|
||||
final class ClassModel: NSManagedObject, Identifiable {
|
||||
@NSManaged var auditory: String
|
||||
@NSManaged var professor: String
|
||||
@NSManaged var subject: String
|
||||
@ -18,16 +18,40 @@ final class ClassModel: NSManagedObject {
|
||||
@NSManaged var starttime: Date
|
||||
@NSManaged var endtime: Date
|
||||
@NSManaged var important: Bool
|
||||
@NSManaged var online: String
|
||||
|
||||
// Здесь мы выполняем дополнительную инициализацию, назначая значения по умолчанию
|
||||
override func awakeFromInsert() {
|
||||
super.awakeFromInsert()
|
||||
|
||||
let calendar = Calendar.current
|
||||
let endTime = calendar.date(byAdding: .hour, value: 1, to: Date.init())
|
||||
|
||||
setPrimitiveValue("", forKey: "auditory")
|
||||
setPrimitiveValue("", forKey: "professor")
|
||||
setPrimitiveValue("", forKey: "subject")
|
||||
setPrimitiveValue("", forKey: "comment")
|
||||
setPrimitiveValue("Нет", forKey: "notification")
|
||||
setPrimitiveValue(false, forKey: "important")
|
||||
setPrimitiveValue("Оффлайн", forKey: "online")
|
||||
setPrimitiveValue(Date.init(), forKey: "day")
|
||||
setPrimitiveValue(Date.init(), forKey: "starttime")
|
||||
setPrimitiveValue(endTime, forKey: "endtime")
|
||||
}
|
||||
}
|
||||
|
||||
// Расширение для загрузки данных из памяти
|
||||
extension ClassModel {
|
||||
private static var classesFetchRequest: NSFetchRequest<ClassModel> {
|
||||
NSFetchRequest(entityName: "ClassModel")
|
||||
}
|
||||
|
||||
// Получаем все данные из памяти
|
||||
static func all() -> NSFetchRequest<ClassModel> {
|
||||
let request: NSFetchRequest<ClassModel> = classesFetchRequest
|
||||
request.sortDescriptors = [
|
||||
NSSortDescriptor(keyPath: \ClassModel.day, ascending: true)
|
||||
]
|
||||
return request
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Tab.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by G412 on 13.11.2024.
|
||||
// Created by Mironov Egor on 13.11.2024.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
@ -2,7 +2,43 @@
|
||||
// ClassProvider.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by G412 on 18.12.2024.
|
||||
// Created by Mironov Egor on 18.12.2024.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
// Это класс служит посредником между View и моделью данных
|
||||
// Он позволяет открыть наш файл данных чтобы записывать и извлекать значения
|
||||
// Объект этого класса должен быть единственным за весь жизненный цикл приложения, чтобы не было рассинхронизации
|
||||
// Для этого мы делаем его синглтоном
|
||||
final class ClassProvider {
|
||||
static let shared = ClassProvider()
|
||||
|
||||
// Это свойство для хранения открытого файла модели данных
|
||||
private let persistentContainer: NSPersistentContainer
|
||||
|
||||
var viewContext: NSManagedObjectContext {
|
||||
persistentContainer.viewContext
|
||||
}
|
||||
|
||||
var newContext: NSManagedObjectContext {
|
||||
persistentContainer.newBackgroundContext()
|
||||
}
|
||||
|
||||
private init() {
|
||||
// Открытие файла
|
||||
persistentContainer = NSPersistentContainer(name: "ClassDataModel")
|
||||
|
||||
// Выставляем флаг для автоматического сохранения изменений данных из Veiw в память
|
||||
persistentContainer.viewContext.automaticallyMergesChangesFromParent = true
|
||||
|
||||
// Выполняем открытие файла с данными
|
||||
persistentContainer.loadPersistentStores {_, error in
|
||||
if let error {
|
||||
fatalError("Unable to load store. Error: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ struct Schedule_ICTISApp: App {
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
ContentView()
|
||||
.environment(\.managedObjectContext, ClassProvider.shared.viewContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,90 @@ extension View {
|
||||
}
|
||||
}
|
||||
|
||||
func hideKeyboard() {
|
||||
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
|
||||
// MARK: ScheduleView
|
||||
func datesAreEqual(_ date1: Date, _ date2: Date) -> Bool {
|
||||
let calendar = Calendar.current
|
||||
|
||||
let components1 = calendar.dateComponents([.year, .month, .day], from: date1)
|
||||
let components2 = calendar.dateComponents([.year, .month, .day], from: date2)
|
||||
|
||||
return components1.year == components2.year &&
|
||||
components1.month == components2.month &&
|
||||
components1.day == components2.day
|
||||
}
|
||||
|
||||
func onlineOrNot(_ str: String) -> Color {
|
||||
if (str == "Онлайн") {
|
||||
return Color("blueForOnline")
|
||||
}
|
||||
else {
|
||||
return Color("greenForOffline")
|
||||
}
|
||||
}
|
||||
|
||||
func getSubjectName(_ subject: String, _ professor: String, _ auditory: String) -> String {
|
||||
return "\(subject) \(professor) \(auditory)"
|
||||
}
|
||||
|
||||
func getTimeString(_ date: Date) -> String {
|
||||
let calendar = Calendar.current
|
||||
let components = calendar.dateComponents([.hour, .minute], from: date)
|
||||
|
||||
guard let hour = components.hour, let minute = components.minute else {
|
||||
return "Invalid time"
|
||||
}
|
||||
|
||||
return String(format: "%02d:%02d", hour, minute)
|
||||
}
|
||||
|
||||
var dateFormatter: DateFormatter {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateStyle = .medium
|
||||
formatter.timeStyle = .none
|
||||
return formatter
|
||||
}
|
||||
|
||||
var timeFormatter: DateFormatter {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateFormat = "HH:mm"
|
||||
return formatter
|
||||
}
|
||||
|
||||
func checkStartTimeLessThenEndTime(_ startTime: Date, _ endTime: Date) -> Bool {
|
||||
let calendar = Calendar.current
|
||||
|
||||
let firstComponents = calendar.dateComponents([.hour, .minute], from: startTime)
|
||||
let secondComponents = calendar.dateComponents([.hour, .minute], from: endTime)
|
||||
|
||||
guard let startHours = firstComponents.hour, let startMinutes = firstComponents.minute else {
|
||||
return false
|
||||
}
|
||||
guard let endHours = secondComponents.hour, let endMinutes = secondComponents.minute else {
|
||||
return false
|
||||
}
|
||||
|
||||
print("\(startHours) - \(endHours)")
|
||||
print("\(startMinutes) - \(endMinutes)")
|
||||
if startHours > endHours {
|
||||
return false
|
||||
}
|
||||
else if startHours == endHours {
|
||||
if startMinutes < endMinutes {
|
||||
return true
|
||||
}
|
||||
else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func checkUpFields(_ subject: String, _ auditory: String, _ professor: String, _ time1: Date, _ time3: Date) -> Bool {
|
||||
if (subject != "" || auditory != "" || professor != "") {
|
||||
return true
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +0,0 @@
|
||||
//
|
||||
// Class.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by Mironov Egor on 18.12.2024.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
final class Class: NSManagedObject {
|
||||
@NSManaged var auditory: String
|
||||
@NSManaged var professor: String
|
||||
@NSManaged var subject: String
|
||||
@NSManaged var comment: String
|
||||
@NSManaged var notification: String
|
||||
@NSManaged var day: Date
|
||||
@NSManaged var starttime: Date
|
||||
@NSManaged var endtime: Date
|
||||
@NSManaged var important: Bool
|
||||
|
||||
// Здесь мы выполняем дополнительную инициализацию, назначая значения по умолчанию
|
||||
override func awakeFromInsert() {
|
||||
super.awakeFromInsert()
|
||||
|
||||
setPrimitiveValue("", forKey: "auditory")
|
||||
setPrimitiveValue("", forKey: "professor")
|
||||
setPrimitiveValue("", forKey: "subject")
|
||||
setPrimitiveValue("", forKey: "comment")
|
||||
setPrimitiveValue("Нет", forKey: "notification")
|
||||
setPrimitiveValue(false, forKey: "important")
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
//
|
||||
// Model.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by Mironov Egor on 13.11.2024.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
// MARK: - Welcome
|
||||
struct Schedule: Decodable {
|
||||
let table: Table
|
||||
let weeks: [Int]
|
||||
}
|
||||
|
||||
// MARK: - Table
|
||||
struct Table: Decodable {
|
||||
let type, name: String
|
||||
let week: Int
|
||||
let group: String
|
||||
let table: [[String]]
|
||||
let link: String
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
//
|
||||
// Tab.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by G412 on 13.11.2024.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
enum TabBarModel: String, CaseIterable {
|
||||
case schedule = "house"
|
||||
case tasks = "books.vertical"
|
||||
case settings = "gear"
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
//
|
||||
// ClassProvider.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by G412 on 18.12.2024.
|
||||
//
|
||||
|
||||
import Foundation
|
@ -6,3 +6,21 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
final class EditClassViewModel: ObservableObject {
|
||||
@Published var _class: ClassModel
|
||||
|
||||
private let context: NSManagedObjectContext
|
||||
|
||||
init(provider: ClassProvider, _class: ClassModel? = nil) {
|
||||
self.context = provider.newContext
|
||||
self._class = ClassModel(context: self.context)
|
||||
}
|
||||
|
||||
func save() throws {
|
||||
if context.hasChanges {
|
||||
try context.save()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +0,0 @@
|
||||
//
|
||||
// Class.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by Mironov Egor on 18.12.2024.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
final class Class: NSManagedObject {
|
||||
@NSManaged var auditory: String
|
||||
@NSManaged var professor: String
|
||||
@NSManaged var subject: String
|
||||
@NSManaged var comment: String
|
||||
@NSManaged var notification: String
|
||||
@NSManaged var day: Date
|
||||
@NSManaged var starttime: Date
|
||||
@NSManaged var endtime: Date
|
||||
@NSManaged var important: Bool
|
||||
|
||||
// Здесь мы выполняем дополнительную инициализацию, назначая значения по умолчанию
|
||||
override func awakeFromInsert() {
|
||||
super.awakeFromInsert()
|
||||
|
||||
setPrimitiveValue("", forKey: "auditory")
|
||||
setPrimitiveValue("", forKey: "professor")
|
||||
setPrimitiveValue("", forKey: "subject")
|
||||
setPrimitiveValue("", forKey: "comment")
|
||||
setPrimitiveValue("Нет", forKey: "notification")
|
||||
setPrimitiveValue(false, forKey: "important")
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
//
|
||||
// Model.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by Mironov Egor on 13.11.2024.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
// MARK: - Welcome
|
||||
struct Schedule: Decodable {
|
||||
let table: Table
|
||||
let weeks: [Int]
|
||||
}
|
||||
|
||||
// MARK: - Table
|
||||
struct Table: Decodable {
|
||||
let type, name: String
|
||||
let week: Int
|
||||
let group: String
|
||||
let table: [[String]]
|
||||
let link: String
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
//
|
||||
// Tab.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by G412 on 13.11.2024.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
enum TabBarModel: String, CaseIterable {
|
||||
case schedule = "house"
|
||||
case tasks = "books.vertical"
|
||||
case settings = "gear"
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
//
|
||||
// ClassProvider.swift
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by G412 on 18.12.2024.
|
||||
//
|
||||
|
||||
import Foundation
|
@ -42,13 +42,13 @@ final class ScheduleViewModel: ObservableObject {
|
||||
else {
|
||||
schedule = try await NetworkManager.shared.getSchedule(group)
|
||||
}
|
||||
weekSchedule = schedule.table
|
||||
week = weekSchedule.week
|
||||
numOfGroup = weekSchedule.group
|
||||
classes = weekSchedule.table
|
||||
self.weekSchedule = schedule.table
|
||||
self.week = weekSchedule.week
|
||||
self.numOfGroup = weekSchedule.group
|
||||
self.classes = weekSchedule.table
|
||||
self.isFirstStartOffApp = false
|
||||
self.isShowingAlertForIncorrectGroup = false
|
||||
isLoading = false
|
||||
self.isLoading = false
|
||||
self.errorInNetwork = .noError
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user