TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

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

2      

I'm having the same problem. I've looked for solutions but it seems that it's an issue with the library. I'm looking for other solutions where I don't have to use the library for it.

2      

Hacking with Swift is sponsored by String Catalog.

SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!

Localize My App

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

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.