NEW: Start my new Ultimate Portfolio App course with a free Hacking with Swift+ trial! >>

Why is my PartialSheet view not re rendering when state changes?

Forums > SwiftUI

I am using the Partial sheet library

My particular use case is using PartialSheet to display a view where a user is adding something to a list (in the main view underneath the sheet), when they press the add button on the sheet, a new confimation message needs to be rendered in the sheet view, before the user then returns to the main view.

The issue I am facing is when I update my state inside this sheet view, the state is being updated but my PartialSheet does not seem to re render.

My theory is that this is simply an isue with the library as the PartialSheet is attached to the main view so doesnt get this Views state changes. However, I wondered if I am missing something and can solve this issue. I've created a simple View to display this scenario and have attached a gif of the view in action.

Here is the code

import SwiftUI
import PartialSheet

struct AnotherContentView: View {
//    @State var isConfirmSheetShown = false
    @EnvironmentObject var partialSheet : PartialSheetManager
    @State private var isTriggered = false

    var body: some View {
        VStack{
            Text(isTriggered == true ? "Trigerred" : "Not triggered")
        Button(action: {

            self.partialSheet.showPartialSheet({
                print("dismissed")
                                    }) {
                VStack() {
                Text(isTriggered == true ? "Trigerred" : "Not triggered")
                Button(action: {
                    isTriggered.toggle()

                },label:{Text("Trigger state change")})
                .padding(.top, 16.0)

                }}

        }, label: {
            Text("Display the ViewModifier sheet")
        })
        }
            }
}

Here is a video of the view in action

https://i.imgur.com/2JG6scR.mp4

   

Hacking with Swift is sponsored by Instabug

SPONSORED Catch bugs as soon as they happen and know exactly why a crash occurred. Instabug's SDK grabs all the logs they need to fix bugs, crashes and performance issues in minutes instead of days. Get screenshots, device details, network logs, repro steps, and tons of other critical insights needed to resolve issues and prioritize product backlogs straight from your dashboard. It only takes a minute to integrate!

Get started now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.