Added tab view and restructured code to have just three tabs. Also got minutes to hours overflow working, seconds has currently gotten worse in functionality. See change log in-app for more details

This commit is contained in:
Isaac Greene 2022-04-10 00:16:34 -04:00
parent 15389248af
commit 8cb3960507
5 changed files with 103 additions and 98 deletions

View file

@ -10,13 +10,22 @@ import SwiftUI
struct April2022: View {
var body: some View {
ScrollView {
//2022-04-10
VStack (alignment: .leading) {
Text("2022-04-10")
.font(.title2)
Text("Version Prerelease Build LVSXT10l\n")
.font(.footnote)
Text("\u{2022} Added known issues view.\n\t\u{2022} Might add this to the change log navigation at the bottom in the future")
}
//2022-04-09
VStack (alignment: .leading) {
Text("2022-04-09:")
.font(.title2)
Text("Version Prerelease Build LVSXT10q\n")
Text("Version Prerelease Build LVSXT10n\n")
.font(.footnote)
Text("\u{2022} Fixed the math with seconds so now you can actually use them! YEAH BABY!\n\u{2022} Rounded pace so that you don't get values like 4.999999999999996 minutes per km\n\t\u{2022} Working on getting the seconds to change into minutes like 340 seconds will show as 5 minutes 40 seconds or \"0:05:40\"\n\u{2022} Removed warning about not using seconds (because they work now!)\n\u{2022} Got math color right. Issue was I had my colors switched so it showed black text in dark mode, and white text in light mode.\n\u{2022} Fixed distance between time boxes\n\u{2022} Removed text about not using seconds greater than 59 in text field")
Text("\u{2022} Fixed the math with seconds so now you can actually use them! YEAH BABY!\n\u{2022} Rounded pace so that you don't get values like 4.999999999999996 minutes per km\n\t\u{2022} Working on getting the seconds to change into minutes like 340 seconds will show as 5 minutes 40 seconds or \"0:05:40\"\n\u{2022} Removed warning about not using seconds (because they work now!)\n\u{2022} Got math color right. Issue was I had my colors switched so it showed black text in dark mode, and white text in light mode.\n\u{2022} Fixed distance between time boxes\n\u{2022} Removed text about not using seconds greater than 59 in text field\n\u{2022} Properly implemented tab view so that each view gets ONE (1) tab\n\u{2022} Added Git which I should've done long ago\n\u{2022} Tweaked various visual elements. For some reason, SF Symbols doesn't have a calculator??? So instead I'm using \"candybarphone\" but \"building\" looked good, too\n\u{2022} Got overflow of minutes working so now 100 minutes will show as 1 hour 40 minutes.\n\t\u{2022} Seconds overflow does not work (see known issues)")
}
.padding(30)

View file

@ -6,22 +6,6 @@
//
import SwiftUI
struct ChangeLogView: View {
@State var showSheet = false
var body: some View {
VStack {
Button("Change log", action: {
self.showSheet.toggle()
})
.padding(.bottom, 25)
}
.sheet(isPresented: self.$showSheet, content: {
ChangeLog()
})
}
}
struct ChangeLog: View {
var body: some View {

View file

@ -19,43 +19,44 @@ struct ContentView: View {
var body: some View {
VStack {
TextField("Enter distance here", text: $distance)
.padding()
.keyboardType(.decimalPad)
.textFieldStyle(.roundedBorder)
}
VStack {
Text("Unit of measurement:")
Picker("System of measurement", selection: $selectedSystem, content: {
ForEach(SISystem, id: \.self, content: { unit in
Text(unit)
VStack {
TextField("Enter distance here", text: $distance)
.padding()
.keyboardType(.decimalPad)
.textFieldStyle(.roundedBorder)
}
VStack {
Text("Unit of measurement:")
Picker("System of measurement", selection: $selectedSystem, content: {
ForEach(SISystem, id: \.self, content: { unit in
Text(unit)
})
})
})
.pickerStyle(.segmented)
.frame(minWidth: 60, maxWidth: 300)
HStack {
VStack {
Text("Total Minutes")
TextField("Enter minutes here", text: $timeMinutes)
.pickerStyle(.segmented)
.frame(minWidth: 60, maxWidth: 300)
HStack {
VStack {
Text("Total Minutes")
TextField("Enter minutes here", text: $timeMinutes)
.keyboardType(.numberPad)
.textFieldStyle(.roundedBorder)
}
.frame(minWidth: 100)
.padding(.trailing, -15)
.padding()
VStack {
Text("Total Seconds")
TextField("Enter seconds here", text: $timeSeconds)
.keyboardType(.numberPad)
.textFieldStyle(.roundedBorder)
}
.frame(minWidth: 100)
.padding(.leading, -15)
.padding()
}
.frame(minWidth: 100)
.padding(.trailing, -15)
.padding()
VStack {
Text("Total Seconds")
TextField("Enter seconds here", text: $timeSeconds)
.keyboardType(.numberPad)
.textFieldStyle(.roundedBorder)
}
.frame(minWidth: 100)
.padding(.leading, -15)
.padding()
PaceResults(timeMinutes: $timeMinutes, timeSeconds: $timeSeconds, selectedSystem: $selectedSystem, distance: $distance)
}
PaceResults(timeMinutes: $timeMinutes, timeSeconds: $timeSeconds, selectedSystem: $selectedSystem, distance: $distance)
}
ChangeLogView()
}
}
@ -66,20 +67,23 @@ struct PaceResults: View {
@Binding var distance: String
var body: some View {
let timeMinutesDouble = Double(timeMinutes) ?? 0.0
let timeHours = String(Int(timeMinutesDouble / 60))
let convertedSeconds = (Double(timeSeconds) ?? 0) * (1+(2/3))
let timeSecondsInt = Int(timeSeconds) ?? 0
let timeSecondsUnderSixty = (timeSecondsInt > 60 ? Int(timeSecondsInt / 60) : timeSecondsInt)
let timeMinutesInt = (Int(timeMinutes) ?? 0) + (Int(timeSecondsUnderSixty))
let timeMinutesUnderSixty = timeMinutesInt - ((Int(timeHours) ?? 0) * 60)
let leadingZeros = String(format: "%02d:%02d", timeMinutesUnderSixty, timeSecondsInt)
let actualTime = timeMinutesDouble + (convertedSeconds / 100)
let pace = actualTime / (Double(distance) ?? 1)
let paceString = String(format: "%.2f", pace)
VStack {
let timeMinutesDouble = Double(timeMinutes) ?? 0.0
let timeHours = String(Int(timeMinutesDouble / 60))
let timeMinutesInt = Int(timeMinutes) ?? 0
let timeSecondsInt = Int(timeSeconds) ?? 0
let leadingZeros = String(format: "%02d:%02d", timeMinutesInt, timeSecondsInt)
let convertedSeconds = (Double(timeSeconds) ?? 0) * (1+(2/3))
let actualTime = timeMinutesDouble + (convertedSeconds / 100)
let pace = actualTime / (Double(distance) ?? 1)
let paceString = String(format: "%.2f", pace)
Text("Distance: \(distance)\(selectedSystem)")
Text("Total time: \(timeHours):\(leadingZeros)")
Text("\(paceString) minutes per \(selectedSystem)")

View file

@ -9,44 +9,40 @@ import SwiftUI
import RichTextView
struct ModalView: View {
@State var showSheet2 = false
@State var mathSheet = false
@State var problemSheet = false
var body: some View {
Text("Help")
.font(.largeTitle)
.bold()
.padding(.top, 40)
Text("Due to limitations in our system, you can only use kilometers and miles at this time. \nSmaller units like meters and feet are not supported. \nYou can, however, use decimals, such as .2km or .8mi.\n\nWe apologize for any inconvenience. In the future, we hope to make our app easier to use.")
.padding()
Button("See our math", action: {
self.showSheet2.toggle()
})
.padding(30)
.sheet(isPresented: self.$showSheet2, content: {
SubSubView()
})
VStack {
Text("Help")
.font(.largeTitle)
.bold()
.padding(.top, 40)
Text("Due to limitations in our system, you can only use kilometers and miles at this time. \nSmaller units like meters and feet are not supported. \nYou can, however, use decimals, such as .2km or .8mi.\n\nWe apologize for any inconvenience. In the future, we hope to make our app easier to use.")
.padding()
Button("See our math", action: {
self.mathSheet.toggle()
})
.padding(30)
.sheet(isPresented: self.$mathSheet, content: {
algorithmView()
})
Button("Known issues", action: {
self.problemSheet.toggle()
})
.padding(30)
.padding(.top, -30)
.sheet(isPresented: self.$problemSheet, content: {
problemView()
})
}
}
}
struct SubView: View {
@State var showSheet2 = false
var body: some View {
Text("Help")
.font(.largeTitle)
.bold()
.padding(.top, 40)
Text("Due to limitations in our system, you can only use kilometers and miles at this time. \nSmaller units like meters and feet are not supported. \nYou can, however, use decimals, such as .2km or .8mi.\n\nWe apologize for any inconvenience. In the future, we hope to make our app easier to use.")
.padding()
Button("See our math", action: {
self.showSheet2.toggle()
})
.padding(30)
.sheet(isPresented: self.$showSheet2, content: {
SubSubView()
})
}
}
struct SubSubView: View {
struct algorithmView: View {
var body: some View {
Text("The Algorithm")
@ -113,3 +109,15 @@ struct mathLaTeX_inator: UIViewRepresentable {
)
}
}
struct problemView: View {
var body: some View {
VStack {
Text("Known issues")
.font(.largeTitle)
.bold()
.padding(.top, 40)
Text("\n\u{2022} You can not dismiss the keyboard\n\t\u{2022} This hides the tab bar at the bottom\n\u{2022} Visually displayed seconds and total time are incorrect\n\t\u{2022} This DOES NOT affect pace. That is still correct.")
}
}
}

View file

@ -2,7 +2,7 @@
// TabViewData.swift
// Splits
//
// Created by Eric J. Greene on 4/9/22.
// Created by Isaac Greene on 4/9/22.
//
import SwiftUI
@ -12,7 +12,7 @@ struct TabViewData: View {
TabView {
ContentView()
.tabItem {
Label("Calculator", systemImage: "stopwatch")
Label("Calculator", systemImage: "candybarphone")
}
ModalView()
.tabItem {