|
@@ -7,9 +7,17 @@ A view displaying information about a hike, including an elevation graph.
|
|
|
|
|
|
import SwiftUI
|
|
|
|
|
|
+extension AnyTransition{
|
|
|
+ static var moveAndFade: AnyTransition{
|
|
|
+ let insertion = AnyTransition.move(edge: .trailing).combined(with: .opacity)
|
|
|
+ let removal = AnyTransition.scale.combined(with: .opacity)
|
|
|
+ return .asymmetric(insertion: insertion, removal: removal)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
struct HikeView: View {
|
|
|
var hike: Hike
|
|
|
- @State private var showDetail = false
|
|
|
+ @State private var showDetail = true
|
|
|
|
|
|
var body: some View {
|
|
|
VStack {
|
|
@@ -27,17 +35,23 @@ struct HikeView: View {
|
|
|
Spacer()
|
|
|
|
|
|
Button(action: {
|
|
|
- self.showDetail.toggle()
|
|
|
+ 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(.moveAndFade)
|
|
|
}
|
|
|
}
|
|
|
}
|