AndreaMiotto / PartialSheet

A SwiftUI Partial Sheet fully customizable with dynamic height
https://github.com/AndreaMiotto/PartialSheet/wiki
MIT License
1.7k stars 190 forks source link

Issue in updating the state variable's value within the partial sheet's content #181

Open khan33 opened 10 months ago

khan33 commented 10 months ago

I'm having trouble updating the state variable's value within the partial sheet's content. The code below works well with SwiftUI's sheet view.

struct DemoView: View {

@State var buttonTxt: String = "Start"
@State var issheet: Bool = false
var body: some View {

    VStack {
        Button {
            issheet.toggle()
        } label: {
            Text("Button")
                .foregroundColor(Color.white)
                .padding()
                .background(Color.red)
        }
    }
    .partialSheet(isPresented: $issheet, content: {
        Button {
            buttonTxt = "Stop"
        } label: {
            Text(buttonTxt)
                .foregroundColor(Color.white)
                .frame(width: 180, height: 55)
                .padding()
                .background(Color.red)

        }
    })
    .padding()
}

}