student-legacy/refilc/ios/livecard/lesson_model.swift
Horváth Gergely b7b3a37b52 - data backup
- I can't test it because I'm stuck on the login screen.
2024-05-02 01:41:04 +02:00

41 lines
1.5 KiB
Swift

import Foundation
import ActivityKit
public struct LessonData {
var color: String
var icon: String
var index: String
var title: String
var subtitle: String
var description: String
var startDate: Date
var endDate: Date
var date: ClosedRange<Date>
var nextSubject: String
var nextRoom: String
init(from dictionary: [String: Any]) {
self.color = dictionary["color"] as? String ?? ""
self.icon = dictionary["icon"] as? String ?? ""
self.index = dictionary["index"] as? String ?? ""
self.title = dictionary["title"] as? String ?? ""
self.subtitle = dictionary["subtitle"] as? String ?? ""
self.description = dictionary["description"] as? String ?? ""
self.nextSubject = dictionary["nextSubject"] as? String ?? ""
self.nextRoom = dictionary["nextRoom"] as? String ?? ""
if let startDateStr = dictionary["startDate"] as? String, let startDateInt = Int(startDateStr) {
self.startDate = Date(timeIntervalSince1970: TimeInterval(startDateInt) / 1000)
} else {
self.startDate = Date()
}
if let endDateStr = dictionary["endDate"] as? String, let endDateInt = Int(endDateStr) {
self.endDate = Date(timeIntervalSince1970: TimeInterval(endDateInt) / 1000)
} else {
self.endDate = Date()
}
date = self.startDate...self.endDate
}
}