On button click i want my MapScreen to "slide" in from the bottom. So i used .annimation(spring()). This used to work, now i get the animation deprecation (needs an value). How can i solve this on the spring() animation.
Is it possible to set a WithAnimation on the if showMapScreen toggle ?
struct ContentView: View {
@State private var showMapScreen = false
var body: some View {
ZStack {
Color.white
.ignoresSafeArea()
VStack {
Button("Show Map") {
showMapScreen.toggle()
}
}
if showMapScreen {
MapScreen()
.padding(.top, 400)
.transition(.move(edge: .bottom))
.animation(spring(), value:???)
}
}
}
}
//second view
struct MapScreen: View {
@State private var mapRegion = MKCoordinateRegion(center:
CLLocationCoordinate2D(latitude: 51.5, longitude: -0.12), span:
MKCoordinateSpan(latitudeDelta: 0.2, longitudeDelta: 0.2))
var body: some View{
ZStack(alignment:.top) {
Color.white
//handle for dragging
Capsule()
.frame(width:40, height:10)
.zIndex(2.0)
Map(coordinateRegion: $mapRegion)
}
.cornerRadius(30)
.edgesIgnoringSafeArea(.bottom)
}
}