PopupView icon indicating copy to clipboard operation
PopupView copied to clipboard

dismissCallback() not call

Open hoangnam714 opened this issue 2 years ago • 7 comments

I used the library and noticed that the dismiss Callback was not called after the popup was hidden

hoangnam714 avatar Jul 15 '22 07:07 hoangnam714

Hey @hoangnam714, hidden in what way? Could you please provide minimal reproducible example? Have a nice day

f3dm76 avatar Jul 15 '22 07:07 f3dm76

here is the code i used, thank you very much

 .popup(isPresented: $showDetail, type: .`default`, position: .bottom, dragToDismiss: true, closeOnTap: false, backgroundColor: .black.opacity(0.4),dismissCallback: {
            self.tabbarStore.isHident = false
            TabBarModifier.showTabBar()
        }) {
            AchievementDetailView(data: achievementData.achievements[indexAchivement], ontapDissmiss: {
                self.showDetail = false
            })
        }

hoangnam714 avatar Jul 15 '22 07:07 hoangnam714

@hoangnam714 I can not launch your code exactly, here is the closest I could do - dismissCallback is called as expected

.popup(isPresented: $floats.showingTopFirst, type: .`default`, position: .bottom, dragToDismiss: true, closeOnTap: false, backgroundColor: .black.opacity(0.4), dismissCallback: {
                print("Hello")
                   }) {
                       Color.red
                   }

f3dm76 avatar Jul 15 '22 07:07 f3dm76

@f3dm76 I understood why the callback function didn't work, because I didn't use the default diss miss, instead I changed the value of the state outside the code block.

hoangnam714 avatar Jul 15 '22 07:07 hoangnam714

Screen Shot 2022-07-15 at 14 54 30

hoangnam714 avatar Jul 15 '22 07:07 hoangnam714

I am not sure if dismiss block should be called in this case... I'll think about it. Have a nice day!

f3dm76 avatar Jul 15 '22 07:07 f3dm76

Thank you, I will think more about this, because sometimes we don't close the popup as soon as the user touches it, instead it needs a close button for example. :)

hoangnam714 avatar Jul 15 '22 07:07 hoangnam714

Hey @hoangnam714, I gave it more thought and since .sheet does it, I also added this. I also added dismiss source as a parameter in dismiss callback, so you can distinguish if you need this.This feature is implemented in version 1.2.0, please give it a go. Have a marvellous day!

f3dm76 avatar Oct 11 '22 11:10 f3dm76