Another thing.
If you don't want to select from List but just display the current lesson, build other computed varsity, such as these:
/* @State private */var currentLesson: String { // = "Przerwa"
for lesson in testData {
if lesson.startTime <= liveHourString && lesson.endTime >= liveHourString && lesson.dayOfWeek == liveWeekdayString {
var components = Calendar.current.dateComponents([.year, .month, .day, .hour, .minute], from: todaysDate)
let hhmm = lesson.startTime.split(separator: ":")
components.hour = Int(hhmm[0])
components.minute = Int(hhmm[1])
return lesson.name
}
}
return ""
}
/* @State private */var currentLessonStart : Date { // = Date()
for lesson in testData {
if lesson.startTime <= liveHourString && lesson.endTime >= liveHourString && lesson.dayOfWeek == liveWeekdayString {
var components = Calendar.current.dateComponents([.year, .month, .day, .hour, .minute], from: todaysDate)
let hhmm = lesson.startTime.split(separator: ":")
components.hour = Int(hhmm[0])
components.minute = Int(hhmm[1])
return Calendar.current.date(from: components)!
}
}
return Date() // If not found
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: