Added km/hr and mi/hr. Did some formatting stuff.

This commit is contained in:
Isaac Greene 2022-06-17 16:38:15 -04:00
parent af513b8c05
commit acc9f86315
5 changed files with 76 additions and 26 deletions

View file

@ -339,6 +339,8 @@
DEVELOPMENT_TEAM = UQJ7U8R2CV;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Splits/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Paces;
INFOPLIST_KEY_NSFaceIDUsageDescription = "We'll need authentication before we can show sensitive data";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
@ -353,7 +355,7 @@
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.0;
PRODUCT_BUNDLE_IDENTIFIER = Brandlar.Splits;
PRODUCT_BUNDLE_IDENTIFIER = Brandlar.Paces;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
RUN_DOCUMENTATION_COMPILER = YES;
@ -375,6 +377,8 @@
DEVELOPMENT_TEAM = UQJ7U8R2CV;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Splits/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Paces;
INFOPLIST_KEY_NSFaceIDUsageDescription = "We'll need authentication before we can show sensitive data";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
@ -389,7 +393,7 @@
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.0;
PRODUCT_BUNDLE_IDENTIFIER = Brandlar.Splits;
PRODUCT_BUNDLE_IDENTIFIER = Brandlar.Paces;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
RUN_DOCUMENTATION_COMPILER = YES;

View file

@ -10,6 +10,19 @@ import SwiftUI
struct June2022: View {
var body: some View {
ScrollView {
//2022-06-16
HStack {
VStack (alignment: .leading) {
Text("2022-06-17")
.font(.title2)
Text("Version Release Candidate 4\n")
.font(.footnote)
Text("\u{2022} Added km/hr and mi/hr\n\u{2022} Did some formatting with the stuff\n\u{2022} Added Back and Next buttons")
}
Spacer()
}
.padding(30)
//2022-06-16
HStack {
VStack (alignment: .leading) {

View file

@ -50,6 +50,17 @@ struct ContentView: View {
timeSeconds = ""
}
Spacer()
Button("Back") {
if focusedField == .distance {
focusedField = nil
} else if focusedField == .hours {
focusedField = .distance
} else if focusedField == .minutes {
focusedField = .hours
} else {
focusedField = .minutes
}
}
Button("Next") {
if focusedField == .distance {
focusedField = .hours
@ -112,6 +123,7 @@ struct ContentView: View {
}
PaceResults(timeHours: $timeHours, timeMinutes: $timeMinutes, timeSeconds: $timeSeconds, selectedSystem: $selectedSystem, distance: $distance)
}
.frame(maxWidth: 700)
}
}
}
@ -181,6 +193,8 @@ struct PaceResults: View {
return actualTime / distanceDub
}()
let paceOpposite = (selectedSystem == "km" ? (pace * 1.609344) : (pace * 0.6213711922))
let paceFormatted:String = {
let paceSeconds = pace.truncatingRemainder(dividingBy: 1.0)
let paceMinutes = (pace.truncatingRemainder(dividingBy: 60.0) - paceSeconds)
@ -191,7 +205,6 @@ struct PaceResults: View {
}()
let paceFormattedOpposite:String = {
let paceOpposite = (selectedSystem == "km" ? (pace * 1.609344) : (pace * 0.6213711922))
let paceSecondsOpposite = paceOpposite.truncatingRemainder(dividingBy: 1.0)
let paceMinutesOpposite = (paceOpposite.truncatingRemainder(dividingBy: 60.0) - paceSecondsOpposite)
let paceHoursOpposite = String(format: "%.0f", ((paceOpposite - paceMinutesOpposite) / 60))
@ -215,21 +228,41 @@ struct PaceResults: View {
// as 05:07 which is a format most people, and certainly
// the people this app is intended for, will understand
let pacePerHour: String = {
let pph = 60 / pace
return (pace != 0 ? String(format: "%.2f", pph) : "0")
}()
let pacePerHourOpposite: String = {
let npph = 60 / paceOpposite
return (pace != 0 ? String(format: "%.2f", npph) : "0")
}()
VStack {
HStack {
Text("\(hoursFormatted):\(leadingZeros)")
.padding()
.frame(minWidth: 100)
VStack (alignment: .leading) {
Text("\(roundString(Double(removeLeadingZeros(distance: &distance)) ?? 0))\(selectedSystem)")
Text("\(convertedDistanceString)\(notSelectedSystem)")
}
.frame(minWidth: 100)
Text("\(hoursFormatted):\(leadingZeros)")
.padding()
.frame(minWidth: 100)
VStack(alignment: .trailing) {
}
HStack {
VStack(alignment: .leading) {
Text("\(paceFormatted)/\(selectedSystem)")
Text("\(paceFormattedOpposite)/\(notSelectedSystem)")
}
.frame(minWidth: 100)
VStack(alignment: .leading) {
Text("\(pacePerHour) \(selectedSystem)/hr")
Text("\(pacePerHourOpposite) \(notSelectedSystem)/hr")
}
.frame(minWidth: 100)
}
}
.padding()
}
func removeLeadingZeros(distance: inout String) -> String {
while distance.starts(with: "0") {

View file

@ -62,8 +62,8 @@ struct DocsView: View {
}
Section(header: Text("App Information")) {
NavigationLink("Software License", destination: LicenseView())
Text("Version: Release Candidate 3")
Text("Release date: 2022-06-16")
Text("Version: Release Candidate 4")
Text("Release date: 2022-06-17")
Text("Start date: 2022-03-25")
Link("Built with SwiftUI \(Image(systemName: "swift"))", destination: URL(string: "https://developer.apple.com/xcode/swiftui")!)
}