Partially implemented an easier way to input hours
This commit is contained in:
parent
674979ebd3
commit
5578d86ccf
2 changed files with 49 additions and 23 deletions
|
|
@ -7,9 +7,42 @@
|
|||
|
||||
import SwiftUI
|
||||
|
||||
struct June2022: View {
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
//2022-06-01
|
||||
//gay
|
||||
HStack {
|
||||
VStack (alignment: .leading) {
|
||||
Text("2022-06-01")
|
||||
.font(.title2)
|
||||
Text("Version Prerelease Build LVSXT10g.3\n")
|
||||
.font(.footnote)
|
||||
Text("\u{2022} Partially implemented an easier way to input hours. Mostly working on formatting issues, but it shows up somewhat like it's supposed to.")
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
.padding(30)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct May2022: View {
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
//2022-05-25
|
||||
HStack {
|
||||
VStack (alignment: .leading) {
|
||||
Text("2022-05-25")
|
||||
.font(.title2)
|
||||
Text("Version Prerelease Build LVSXT10g.2\n")
|
||||
.font(.footnote)
|
||||
Text("\u{2022} I'm at a stalemate with Swift")
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
.padding(30)
|
||||
|
||||
//2022-05-22
|
||||
HStack {
|
||||
VStack (alignment: .leading) {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ struct ContentView: View {
|
|||
var SISystem = ["km","mi"]
|
||||
var minutes = Array(0...300)
|
||||
var times = Array(0...300).map { String($0) }
|
||||
@State var timeHours: String = ""
|
||||
@State var timeMinutes: String = ""
|
||||
@State var timeSeconds: String = ""
|
||||
@State var selectedSystem: String = "km"
|
||||
|
|
@ -35,6 +36,15 @@ struct ContentView: View {
|
|||
.pickerStyle(.segmented)
|
||||
.frame(minWidth: 60, maxWidth: 300)
|
||||
HStack {
|
||||
VStack {
|
||||
Text("Total hours")
|
||||
TextField("Enter hours here", text: $timeHours)
|
||||
.keyboardType(.numberPad)
|
||||
.textFieldStyle(.roundedBorder)
|
||||
}
|
||||
.frame(minWidth: 100)
|
||||
.padding(.leading, -15)
|
||||
.padding()
|
||||
VStack {
|
||||
Text("Total Minutes")
|
||||
TextField("Enter minutes here", text: $timeMinutes)
|
||||
|
|
@ -54,13 +64,14 @@ struct ContentView: View {
|
|||
.padding(.leading, -15)
|
||||
.padding()
|
||||
}
|
||||
PaceResults(timeMinutes: $timeMinutes, timeSeconds: $timeSeconds, selectedSystem: $selectedSystem, distance: $distance)
|
||||
PaceResults(timeHours: $timeHours, timeMinutes: $timeMinutes, timeSeconds: $timeSeconds, selectedSystem: $selectedSystem, distance: $distance)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct PaceResults: View {
|
||||
@Binding var timeHours: String
|
||||
@Binding var timeMinutes: String
|
||||
@Binding var timeSeconds: String
|
||||
@Binding var selectedSystem: String
|
||||
|
|
@ -69,9 +80,6 @@ struct PaceResults: View {
|
|||
var body: some View {
|
||||
let distanceDub = Double(distance) ?? 1.0
|
||||
|
||||
//var notSelectedSystem = ""
|
||||
//var pacePerUnit = 0.0
|
||||
|
||||
let convertedSeconds:Double = (Double(timeSeconds) ?? 0) * (1.666666666666666666666666)
|
||||
let timeSecondsInt:Int = Int(timeSeconds) ?? 0
|
||||
let timeSecondsUnderSixty:Int = (timeSecondsInt % 60)
|
||||
|
|
@ -84,33 +92,18 @@ struct PaceResults: View {
|
|||
let timeMinutesUnderSixty:Int = timeMinutesInt % 60
|
||||
let timeMinutesToHours:Int = (timeMinutesInt - timeMinutesUnderSixty) / 60
|
||||
|
||||
let totalHours:Double = Double(timeMinutesToHours) + (Double(timeHours) ?? 0)
|
||||
|
||||
let leadingZeros:String = String(format: "%02d:%02d", timeMinutesUnderSixty, timeSecondsUnderSixty)
|
||||
|
||||
let actualTime:Double = timeMinutesDouble + (convertedSeconds / 100)
|
||||
let actualTime:Double = timeMinutesDouble + (convertedSeconds / 100) + (totalHours * 60)
|
||||
let pace:Double = actualTime / distanceDub
|
||||
let paceString:String = String(format: "%.2f", pace)
|
||||
|
||||
/*
|
||||
func pacePerOpString(selectedSystem: String, _ pacePerUnit: inout Double, actualTime: Double, distanceDub: Double, _ notSelectedSystem: inout String) -> String {
|
||||
if selectedSystem == "km" {
|
||||
pacePerUnit = actualTime / (distanceDub * 1.609344)
|
||||
notSelectedSystem = "mi"
|
||||
}
|
||||
else {
|
||||
pacePerUnit = actualTime / (distanceDub * 0.6213711922)
|
||||
notSelectedSystem = "km"
|
||||
}
|
||||
|
||||
let pacePerUnitString:String = String(format: "%.02f", pacePerUnit)
|
||||
return pacePerUnitString
|
||||
}
|
||||
*/
|
||||
|
||||
VStack {
|
||||
Text("Distance: \(distance)\(selectedSystem)")
|
||||
Text("Total time: \(timeMinutesToHours):\(leadingZeros)")
|
||||
Text("Total time: \(totalHours):\(leadingZeros)")
|
||||
Text("\(paceString) minutes per \(selectedSystem)")
|
||||
//Text("\(pacePerOpString(selectedSystem: selectedSystem, &pacePerUnit, actualTime: actualTime, distanceDub: distanceDub, ¬SelectedSystem)) minutes per \(notSelectedSystem)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue