i am trying to expand and collaps Vstack on the click of button as well as by using Drag.
I am able to to it using button click by below code but not sure hoe to use drag gesture.
import SwiftUI
struct ContentView: View {
@State private var Expand = false
var body: some View {
VStack {
Color
.red
}
.overlay(
GeometryReader { geometry in
VStack() {
VStack {
Text("1")
if Expand {
Text("2")
Text("3")
Text("4")
Text("5")
}
}
Button(Expand ? "Collaps" : "Expand") {
Expand.toggle()
}
}
.background(.yellow)
.frame(maxWidth: .infinity)
}
)
}
}
CodePudding user response: