mirror of
https://github.com/ivanvorobei/SwiftUI.git
synced 2026-03-21 17:09:25 +01:00
50 lines
1.3 KiB
Swift
Executable File
50 lines
1.3 KiB
Swift
Executable File
/*
|
||
See LICENSE folder for this sample’s licensing information.
|
||
|
||
Abstract:
|
||
A view showing the details for a hike.
|
||
*/
|
||
|
||
import SwiftUI
|
||
|
||
struct HikeDetail: View {
|
||
let hike: Hike
|
||
@State var dataToShow = \Hike.Observation.elevation
|
||
|
||
var buttons = [
|
||
("Elevation", \Hike.Observation.elevation),
|
||
("Heart Rate", \Hike.Observation.heartRate),
|
||
("Pace", \Hike.Observation.pace),
|
||
]
|
||
|
||
var body: some View {
|
||
return VStack {
|
||
HikeGraph(hike: hike, path: dataToShow)
|
||
.frame(height: 200, alignment: .center)
|
||
|
||
HStack(spacing: 25) {
|
||
ForEach(buttons.identified(by: \.0)) { value in
|
||
Button(action: {
|
||
self.dataToShow = value.1
|
||
}) {
|
||
Text(verbatim: value.0)
|
||
.font(.system(size: 15))
|
||
.color(value.1 == self.dataToShow
|
||
? Color.gray
|
||
: Color.accentColor)
|
||
.animation(nil)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
#if DEBUG
|
||
struct HikeDetail_Previews: PreviewProvider {
|
||
static var previews: some View {
|
||
HikeDetail(hike: hikeData[0])
|
||
}
|
||
}
|
||
#endif
|