Skip to content

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

@khan33

Description

@khan33

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()
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions