Commit
This commit is contained in:
@ -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
|
Reference in New Issue
Block a user