|
|
|
@ -9,14 +9,21 @@ import SwiftUI
|
|
|
|
|
|
|
|
|
|
struct UnitView: View {
|
|
|
|
|
@ObservedObject var unitVM: UnitVM
|
|
|
|
|
@ObservedObject var unitsManagerVM: UnitsManagerVM
|
|
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
|
VStack(alignment: .leading) {
|
|
|
|
|
Text("Unit title")
|
|
|
|
|
HStack {
|
|
|
|
|
Text("UE " + String(unitVM.model.code))
|
|
|
|
|
Text(unitVM.model.name)
|
|
|
|
|
}
|
|
|
|
|
.font(.title)
|
|
|
|
|
.padding()
|
|
|
|
|
|
|
|
|
|
UnitViewCell(unitVM: unitVM)
|
|
|
|
|
UnitViewCell(
|
|
|
|
|
unitVM: unitVM,
|
|
|
|
|
unitsManagerVM: unitsManagerVM
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
Divider()
|
|
|
|
|
|
|
|
|
@ -33,14 +40,18 @@ struct UnitView: View {
|
|
|
|
|
.padding(.horizontal)
|
|
|
|
|
|
|
|
|
|
ScrollView {
|
|
|
|
|
ForEach(unitVM.subjectVMs) { subjectVM in
|
|
|
|
|
SubjectViewCell(subjectVM: subjectVM)
|
|
|
|
|
ForEach(unitVM.SubjectsVM) { subjectVM in
|
|
|
|
|
SubjectViewCell(
|
|
|
|
|
subjectVM: subjectVM,
|
|
|
|
|
unitVM: unitVM,
|
|
|
|
|
unitsManagerVM: unitsManagerVM
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.navigationBarItems(trailing: Button(action: {
|
|
|
|
|
// TODO Add action for button. Make editable
|
|
|
|
|
// * (LATER) unit weight
|
|
|
|
|
// * (LATER) unit description
|
|
|
|
|
// * (LATER, in UnitViewCell) unit weight
|
|
|
|
|
// * (LATER, in UnitViewCell) unit description
|
|
|
|
|
// * subjects
|
|
|
|
|
// * make all fields editable (=> just toggle isEditable is the SubjectCellViews?)
|
|
|
|
|
// * create new subject (creation screen with simple form for name, weight, code, isCalled. Of course, will need to deal with adding it to the unitVM, updating the unitVM, and updating the unitsmanagerVM with the new unitVM. Check the result to make sure that the model does get updated by the VM in the end)
|
|
|
|
@ -53,7 +64,17 @@ struct UnitView: View {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct UnitView_Previews: PreviewProvider {
|
|
|
|
|
|
|
|
|
|
static var ManagerVMStub: UnitsManagerVM = UnitsManagerVM(
|
|
|
|
|
unitsManager: UnitsManager(
|
|
|
|
|
units: Stub.units
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
static var previews: some View {
|
|
|
|
|
UnitView(unitVM: UnitVM(unit: Stub.units[0]))
|
|
|
|
|
UnitView(
|
|
|
|
|
unitVM: ManagerVMStub.UnitsVM[0],
|
|
|
|
|
unitsManagerVM: ManagerVMStub
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|