|
|
@ -9,14 +9,21 @@ import SwiftUI
|
|
|
|
|
|
|
|
|
|
|
|
struct UnitView: View {
|
|
|
|
struct UnitView: View {
|
|
|
|
@ObservedObject var unitVM: UnitVM
|
|
|
|
@ObservedObject var unitVM: UnitVM
|
|
|
|
|
|
|
|
@ObservedObject var unitsManagerVM: UnitsManagerVM
|
|
|
|
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
var body: some View {
|
|
|
|
VStack(alignment: .leading) {
|
|
|
|
VStack(alignment: .leading) {
|
|
|
|
Text("Unit title")
|
|
|
|
HStack {
|
|
|
|
|
|
|
|
Text("UE " + String(unitVM.model.code))
|
|
|
|
|
|
|
|
Text(unitVM.model.name)
|
|
|
|
|
|
|
|
}
|
|
|
|
.font(.title)
|
|
|
|
.font(.title)
|
|
|
|
.padding()
|
|
|
|
.padding()
|
|
|
|
|
|
|
|
|
|
|
|
UnitViewCell(unitVM: unitVM)
|
|
|
|
UnitViewCell(
|
|
|
|
|
|
|
|
unitVM: unitVM,
|
|
|
|
|
|
|
|
unitsManagerVM: unitsManagerVM
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
Divider()
|
|
|
|
Divider()
|
|
|
|
|
|
|
|
|
|
|
@ -33,14 +40,18 @@ struct UnitView: View {
|
|
|
|
.padding(.horizontal)
|
|
|
|
.padding(.horizontal)
|
|
|
|
|
|
|
|
|
|
|
|
ScrollView {
|
|
|
|
ScrollView {
|
|
|
|
ForEach(unitVM.subjectVMs) { subjectVM in
|
|
|
|
ForEach(unitVM.SubjectsVM) { subjectVM in
|
|
|
|
SubjectViewCell(subjectVM: subjectVM)
|
|
|
|
SubjectViewCell(
|
|
|
|
|
|
|
|
subjectVM: subjectVM,
|
|
|
|
|
|
|
|
unitVM: unitVM,
|
|
|
|
|
|
|
|
unitsManagerVM: unitsManagerVM
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.navigationBarItems(trailing: Button(action: {
|
|
|
|
.navigationBarItems(trailing: Button(action: {
|
|
|
|
// TODO Add action for button. Make editable
|
|
|
|
// TODO Add action for button. Make editable
|
|
|
|
// * (LATER) unit weight
|
|
|
|
// * (LATER, in UnitViewCell) unit weight
|
|
|
|
// * (LATER) unit description
|
|
|
|
// * (LATER, in UnitViewCell) unit description
|
|
|
|
// * subjects
|
|
|
|
// * subjects
|
|
|
|
// * make all fields editable (=> just toggle isEditable is the SubjectCellViews?)
|
|
|
|
// * 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)
|
|
|
|
// * 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 {
|
|
|
|
struct UnitView_Previews: PreviewProvider {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static var ManagerVMStub: UnitsManagerVM = UnitsManagerVM(
|
|
|
|
|
|
|
|
unitsManager: UnitsManager(
|
|
|
|
|
|
|
|
units: Stub.units
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
static var previews: some View {
|
|
|
|
static var previews: some View {
|
|
|
|
UnitView(unitVM: UnitVM(unit: Stub.units[0]))
|
|
|
|
UnitView(
|
|
|
|
|
|
|
|
unitVM: ManagerVMStub.UnitsVM[0],
|
|
|
|
|
|
|
|
unitsManagerVM: ManagerVMStub
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|