splits/Splits/HelpView.swift

103 lines
2.7 KiB
Swift

//
// ModalView.swift
// Splits
//
// Created by Isaac Greene on 4/3/22.
//
import SwiftUI
import RichTextView
struct HelpView: View {
@State var mathSheet = false
@State var problemSheet = false
var body: some View {
ScrollView {
VStack {
Text("Help")
.font(.largeTitle)
.bold()
.padding(.top, 40)
Text("Due to limitations in the 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\nI apologize for any inconvenience. In the future, I hope to make our app easier to use.\n\nI'm currently looking to add help articles about running to this page and it'll have loads of stuff about running and pace and all that stuff to actually help you with running. If I do, the purpose of this app might change.")
.padding()
Button("See our math", action: {
self.mathSheet.toggle()
})
.padding(30)
.sheet(isPresented: self.$mathSheet, content: {
algorithmView()
})
}
}
}
}
struct algorithmView: View {
var body: some View {
Text("The Algorithm")
.font(.largeTitle)
.bold()
VStack(alignment: .leading, spacing: 0) {
Text("Calculating pace is fairly straightforward, and does not change with increased complexity. The standard formula is simply this:\n")
mathView()
Text("\nWhere:\n")
HStack {
Text("\"t\"")
.font(.custom("Charter", size: 18))
Text("is total time")
}
HStack{
Text("\"d\"")
.font(.custom("Charter", size: 18))
Text("is distance")
}
HStack {
Text("\"p\"")
.font(.custom("Charter", size: 18))
Text("is the resulting pace")
}
}
.padding()
}
}
struct mathView: View {
@State var mathString:String = "[math] \\frac{t}{d} &= p [/math]"
var body: some View {
mathLaTeX_inator(mathString: $mathString)
.padding(30)
.frame(maxHeight: 300)
}
}
struct mathLaTeX_inator: UIViewRepresentable {
@Environment(\.colorScheme) var colorScheme
@Binding var mathString:String
func makeUIView(context: Context) -> RichTextView {
let richTextView = RichTextView(
input: mathString,
latexParser: LatexParser(),
font: UIFont.systemFont(ofSize: UIFont.systemFontSize),
textColor: (colorScheme == .dark ? UIColor.white : UIColor.black),
frame: CGRect.zero,
completion: nil
)
return richTextView
}
func updateUIView(_ uiView: RichTextView, context: Context) {
uiView.update(
input: mathString,
latexParser: LatexParser(),
font: UIFont.systemFont(ofSize: UIFont.systemFontSize),
textColor: (colorScheme == .dark ? UIColor.white : UIColor.black),
completion: nil
)
}
}