I have created a bottom card with a drag gesture that is not yet finished. But I ran into an issue when I set the default translation height from zero and it just jumps to what I think is translation 0.
import SwiftUI
struct TimetableBottomCardView: View {
@State var translation: CGSize = CGSize(width: .zero, height: 785)
var body: some View {
VStack {
TimetableBottomCardUI()
Spacer()
}.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Material.ultraThick)
.mask(RoundedRectangle(cornerRadius: 35).ignoresSafeArea(.all, edges: .bottom))
.offset(y: translation.height)
.gesture(
DragGesture()
.onChanged { value in
translation = value.translation
}
.onEnded { value in
withAnimation {
let DefaultTranslation: CGSize = CGSize(width: .zero, height: 785)
translation = DefaultTranslation
}
}
)
}
}
struct TimetableBottomCardView_Previews: PreviewProvider {
static var previews: some View {
TimetableBottomCardView()
.background(.blue)
}
}