Files
SwiftUI/Examples/InterfacingWithUIKit/StartingPoint/Landmarks/Landmarks/HikeDetail.swift
2019-06-06 11:16:28 +03:00

50 lines
1.3 KiB
Swift
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
See LICENSE folder for this samples 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