-
Notifications
You must be signed in to change notification settings - Fork 317
/
Copy pathHikeDetail.swift
47 lines (40 loc) · 1.28 KB
/
HikeDetail.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
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, id: \.0) { value in
Button(action: {
self.dataToShow = value.1
}) {
Text(verbatim: value.0)
.font(.system(size: 15))
.foregroundColor(value.1 == self.dataToShow
? Color.gray
: Color.accentColor)
.animation(nil)
}
}
}
}
}
}
struct HikeDetail_Previews: PreviewProvider {
static var previews: some View {
HikeDetail(hike: hikeData[0])
}
}