Dear all, please be patient with me as I'm quite new to SwiftUI. I'm designing and setting up my first SwiftUI app. I'd like to release it for Mac and iPad.
I'm leveraging the NavigationSplit View, storing all the data in SwiftData. The whole application and dataset is driven by the selection of a value at the beginning. In fact I have a table like the one below (and all the other tables have a relationship one to many with this one):
import SwiftData
@Model
class Stagione {
var initStagione: Bool
var idStagione: idStagione
init(initStagione: Bool, idStagione: idStagione) {
self.initStagione = initStagione
self.idStagione = idStagione
}
}
enum idStagione: Int, Codable, Identifiable, CaseIterable {
case PrimoAnno, SecondoAnno, TerzoAnno, QuartoAnno, QuintoAnno, SestoAnno, SettimoAnno
var id: Self {
self
}
var descr: String {
switch self {
case .PrimoAnno:
"2023/2024"
case .SecondoAnno:
"2024/2025"
case .TerzoAnno:
"2025/2026"
case .QuartoAnno:
"2026/2027"
case .QuintoAnno:
"2027/2028"
case .SestoAnno:
"2028/2029"
case .SettimoAnno:
"2029/2030"
}
}
}
I'd like to understand, based on your suggestion, how I can place the selection of the idStagione when the app is launched so that all the data displayed in the application are filtered by that parameter. On the other hand, if the parameter is changed I'd like the application to change the data shown.
I was thinking of two possible options:
- Having a form with a picker to select the idStagione
- Place the picker in the sidebar
Do you have any suggestion? Is there any example of something with the same logic that you can share with me?
Thanks in advance for your support, A.