Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more viewmodels #42

Merged
merged 5 commits into from
Jul 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions Calq.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -358,17 +358,16 @@
path = ExamScreen;
sourceTree = "<group>";
};
F1138E5229959627008E7FD8 /* SettingsScreen */ = {
F1138E5229959627008E7FD8 /* SettingsScreens */ = {
isa = PBXGroup;
children = (
F1A59A422A6354890039C95E /* SettingsScreen */,
F1A53D012A196C0E0045C5B0 /* EditWeight */,
F1B0B169299648A200F3D1FD /* EditSubjectScreen.swift */,
F17F4443298C4E7D000A3993 /* SettingsScreen.swift */,
F1138E5029958878008E7FD8 /* DocumentPicker.swift */,
F192DD23299D10CB0077B905 /* NewSubject.swift */,
F1D3433C29C37024002ED7DE /* SettingsVM.swift */,
);
path = SettingsScreen;
path = SettingsScreens;
sourceTree = "<group>";
};
F1138E5329959664008E7FD8 /* SubjectInfoScreens */ = {
Expand All @@ -386,9 +385,9 @@
children = (
F17F4441298C4DDF000A3993 /* TabView.swift */,
F14140452A47639E007E4648 /* TabViewVM.swift */,
F1E8BFE1299004AA00486A6D /* Overview */,
F1E8BFE1299004AA00486A6D /* OverviewScreen */,
F10D66B0298D57AA00993237 /* ExamScreen */,
F1138E5229959627008E7FD8 /* SettingsScreen */,
F1138E5229959627008E7FD8 /* SettingsScreens */,
F1F568C6298D912D00227F88 /* NewGradeScreen */,
F1138E5329959664008E7FD8 /* SubjectInfoScreens */,
F1B0B1672996489900F3D1FD /* EditGradeScreen.swift */,
Expand All @@ -408,6 +407,15 @@
path = EditWeight;
sourceTree = "<group>";
};
F1A59A422A6354890039C95E /* SettingsScreen */ = {
isa = PBXGroup;
children = (
F17F4443298C4E7D000A3993 /* SettingsScreen.swift */,
F1D3433C29C37024002ED7DE /* SettingsVM.swift */,
);
path = SettingsScreen;
sourceTree = "<group>";
};
F1B386452A1CFE6800F0C5AC /* CalqTests */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -439,13 +447,13 @@
path = JSON;
sourceTree = "<group>";
};
F1E8BFE1299004AA00486A6D /* Overview */ = {
F1E8BFE1299004AA00486A6D /* OverviewScreen */ = {
isa = PBXGroup;
children = (
F17F443E298C4DCE000A3993 /* OverviewScreen.swift */,
F19B10A429AF84C000B11C82 /* OverviewVM.swift */,
);
path = Overview;
path = OverviewScreen;
sourceTree = "<group>";
};
F1F568C6298D912D00227F88 /* NewGradeScreen */ = {
Expand Down
24 changes: 12 additions & 12 deletions Calq/Screens/EditGradeScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ struct EditGradeScreen: View {
var body: some View {
ScrollView(showsIndicators: false) {
VStack {
VStack {
CardContainer {
VStack(alignment: .leading) {
Text("gradeName")
TextField("gradeName", text: $testName)
.textFieldStyle(.roundedBorder)
}.padding()
}.background(CardView())
}
}

ZStack {
CardContainer {
VStack(alignment: .leading) {
Text("gradeType")
Picker("gradeType", selection: $testType) {
ForEach(Array(Util.getTypes().enumerated()), id: \.offset) { _, type in
Text(type.name).tag(type.id)
}
}.pickerStyle(.segmented).colorMultiply(color)
}.padding()
}.background(CardView())
}
}

ZStack {
CardContainer {
VStack(alignment: .leading) {
Text("gradeHalfyear")
Picker("gradeYear", selection: $testYear) {
Expand All @@ -55,10 +55,10 @@ struct EditGradeScreen: View {
HStack {
DatePicker("gradeDate", selection: $testDate, displayedComponents: [.date])
}
}.padding()
}.background(CardView())
}
}

ZStack {
CardContainer {
VStack(alignment: .leading) {
Text("gradePoints")
HStack {
Expand All @@ -68,8 +68,8 @@ struct EditGradeScreen: View {
})
.accentColor(Color.accentColor)
}
}.padding()
}.background(CardView())
}
}

Button("gradeSave") {
saveGrade()
Expand Down
39 changes: 19 additions & 20 deletions Calq/Screens/ExamScreen/ExamScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,18 @@ struct ExamScreen: View {
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.top, 10)

VStack {
ForEach(1...5, id: \.self) { i in
ExamView(subject: getExam(i), type: i)
.environmentObject(vm)
CardContainer {
VStack {
ForEach(1...5, id: \.self) { i in
ExamView(subject: getExam(i), type: i)
.environmentObject(vm)
}
}
}.background(CardView())
}

Spacer()

}.onAppear {
vm.updateViews()
// resetExams() //if broken to debug ig
}
}.onAppear(perform: vm.updateViews)
.padding()
.navigationTitle("ExamViewTitle")
}
Expand All @@ -56,7 +55,7 @@ struct ExamView: View {

let thumbImage = UIImage(systemName: "circle.fill")
UISlider.appearance().setThumbImage(thumbImage, for: .normal)
// UISlider.appearance().thumbTintColor = .cyan//subject != nil ? UIColor(getSubjectColor(subject)) : UIColor.gray
// UISlider.appearance().thumbTintColor = .cyan//subject != nil ? UIColor(getSubjectColor(subject)) : UIColor.gray
}

var body: some View {
Expand All @@ -76,16 +75,16 @@ struct ExamView: View {
}

if subject != nil {
Section {
Button {
removeExam(type, subject!)
vm.changeExamSelection()
subject = nil
sliderValue = 0
} label: {
Text("ExamViewSubRemove")
}.buttonStyle(MenuPickerDestructive())
}
Section {
Button {
removeExam(type, subject!)
vm.changeExamSelection()
subject = nil
sliderValue = 0
} label: {
Text("ExamViewSubRemove")
}.buttonStyle(MenuPickerDestructive())
}
}
}
} label: {
Expand Down
2 changes: 1 addition & 1 deletion Calq/Screens/FirstLaunchScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct FirstLaunchScreen: View {
vm.showedFirstlaunch()
}.buttonStyle(SecondaryStyle())

} .padding().background(CardView())
}.padding().background(CardView())

Spacer()

Expand Down
2 changes: 1 addition & 1 deletion Calq/Screens/NewGradeScreen/ImpactSegment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct ImpactSegment: View {
var body: some View {
GeometryReader {geo in
VStack(spacing: 4) {
// Upper sEgemnt
// Upper Segment
HStack(spacing: 0) {
ForEach( 0...15, id: \.self ) {i in
GradeSegment(colors: $colors, values: $values, width: geo.size.width/16, index: i)
Expand Down
25 changes: 12 additions & 13 deletions Calq/Screens/NewGradeScreen/NewGradeScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ struct NewGradeScreen: View {
}
}

@ViewBuilder
func subjectView(_ sub: UserSubject) -> SettingsIcon {
SettingsIcon(color: getSubjectColor(sub), icon: sub.lk ? "bookmark.fill" : "bookmark", text: sub.name, completation: {
vm.selectSub(sub)
Expand All @@ -48,26 +47,26 @@ struct NewGradeView: View {
ScrollView(showsIndicators: false) {
if vm.selectedSubject != nil {
VStack {
ZStack {
CardContainer {
VStack(alignment: .leading) {
Text("gradeName")
TextField("gradeName", text: $vm.gradeName)
.textFieldStyle(.roundedBorder)
}.padding()
}.background(CardView())
}
}

ZStack {
CardContainer {
VStack(alignment: .leading) {
Text("gradeType")
Picker("gradeYear", selection: $vm.gradeType) {
ForEach(Array(Util.getTypes().enumerated()), id: \.offset) { _, type in
Text(type.name).tag(type.id)
}
}.pickerStyle(.segmented)
}.padding()
}.background(CardView())
}
}

ZStack {
CardContainer {
VStack(alignment: .leading) {
Text("gradeHalfyear")
Picker("gradeYear", selection: $vm.year) {
Expand All @@ -80,10 +79,10 @@ struct NewGradeView: View {
HStack {
DatePicker("gradeDate", selection: $vm.date, displayedComponents: [.date])
}
}.padding()
}.background(CardView())
}
}

ZStack {
CardContainer {
VStack(alignment: .leading) {
Text("gradePoints")
HStack {
Expand All @@ -94,8 +93,8 @@ struct NewGradeView: View {
.accentColor(Color.accentColor)
}
ImpactSegment(subject: $vm.selectedSubject, gradeType: $vm.gradeType, year: $vm.year).frame(height: 35)
}.padding()
}.background(CardView())
}
}

Button("gradeNewAdd") {
vm.saveGrade()
Expand Down
95 changes: 0 additions & 95 deletions Calq/Screens/Overview/OverviewScreen.swift

This file was deleted.

Loading