mirror of
https://github.com/ivanvorobei/SwiftUI.git
synced 2026-04-26 18:48:43 +02:00
Update
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
See LICENSE folder for this sample’s licensing information.
|
||||
|
||||
Abstract:
|
||||
A view displaying inforamtion about a hike, including an elevation graph.
|
||||
*/
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct HikeView: View {
|
||||
var hike: Hike
|
||||
@State private var showDetail = false
|
||||
|
||||
var transition: AnyTransition {
|
||||
let insertion = AnyTransition.move(edge: .trailing)
|
||||
.combined(with: .opacity)
|
||||
let removal = AnyTransition.scale()
|
||||
.combined(with: .opacity)
|
||||
return .asymmetric(insertion: insertion, removal: removal)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
HStack {
|
||||
HikeGraph(hike: hike, path: \.elevation)
|
||||
.frame(width: 50, height: 30)
|
||||
.animation(nil)
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
Text(verbatim: hike.name)
|
||||
.font(.headline)
|
||||
Text(verbatim: hike.distanceText)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
Button(action: {
|
||||
withAnimation {
|
||||
self.showDetail.toggle()
|
||||
}
|
||||
}) {
|
||||
Image(systemName: "chevron.right.circle")
|
||||
.imageScale(.large)
|
||||
.rotationEffect(.degrees(showDetail ? 90 : 0))
|
||||
.scaleEffect(showDetail ? 1.5 : 1)
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
|
||||
if showDetail {
|
||||
HikeDetail(hike: hike)
|
||||
.transition(transition)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
struct HikeView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
VStack {
|
||||
HikeView(hike: hikeData[0])
|
||||
.padding()
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user