UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

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      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

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.