mirror of
https://github.com/ivabus/GradeMapper
synced 2024-11-10 02:05:17 +03:00
Code refactoring
This commit is contained in:
parent
5e83583583
commit
11dc8c93cf
|
@ -35,23 +35,28 @@ struct ContentView: View {
|
||||||
ForEach([String](coof.keys), id: \.self) {
|
ForEach([String](coof.keys), id: \.self) {
|
||||||
subjectSN in Text("\(subjectSN)")
|
subjectSN in Text("\(subjectSN)")
|
||||||
}
|
}
|
||||||
}.pickerStyle(.wheel)
|
}
|
||||||
|
.pickerStyle(.wheel)
|
||||||
VStack{
|
VStack{
|
||||||
Picker("Оценка", selection: $selectedGrade){
|
Picker("Оценка", selection: $selectedGrade){
|
||||||
ForEach(Grade.allCases, id: \.self) {
|
ForEach(Grade.allCases, id: \.self) {
|
||||||
currGrade in Text("\(currGrade.rawValue)")
|
currGrade in Text("\(currGrade.rawValue)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.pickerStyle(.segmented).padding(.horizontal, 20)
|
}
|
||||||
}.padding(.top, 100)
|
.pickerStyle(.segmented)
|
||||||
|
.padding(.horizontal, 20)
|
||||||
|
}
|
||||||
|
.padding(.top, 100)
|
||||||
Button ("Добавить оценку"){
|
Button ("Добавить оценку"){
|
||||||
counter.multiplier = coof[selectedTypeOfGrade]!
|
counter.multiplier = coof[selectedTypeOfGrade]!
|
||||||
counter.gradesWeighted += Double(selectedGrade.rawValue) * counter.multiplier
|
counter.gradesWeighted += Double(selectedGrade.rawValue) * counter.multiplier
|
||||||
counter.weightsSum += counter.multiplier
|
counter.weightsSum += counter.multiplier
|
||||||
self.sr = (counter.gradesWeighted / counter.weightsSum)
|
self.sr = (counter.gradesWeighted / counter.weightsSum)
|
||||||
}.buttonStyle(.borderedProminent)
|
}
|
||||||
Text(String("Средний балл: \(self.sr)"))
|
.buttonStyle(.borderedProminent)
|
||||||
.fontWeight(.bold)
|
Text(String("Средний балл: \(self.sr)"))
|
||||||
|
.fontWeight(.bold)
|
||||||
Button ("Очистить"){
|
Button ("Очистить"){
|
||||||
counter.multiplier = 1.5
|
counter.multiplier = 1.5
|
||||||
counter.gradesWeighted = 0
|
counter.gradesWeighted = 0
|
||||||
|
@ -59,9 +64,7 @@ struct ContentView: View {
|
||||||
self.sr = 0
|
self.sr = 0
|
||||||
}.buttonStyle(.borderedProminent)
|
}.buttonStyle(.borderedProminent)
|
||||||
}
|
}
|
||||||
.padding(.top, -155.0)
|
.padding(.top, -155.0)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
struct ContentView_Previews: PreviewProvider {
|
struct ContentView_Previews: PreviewProvider {
|
||||||
|
|
Loading…
Reference in a new issue