Mijick / PopupView

Popups presentation made simple (SwiftUI)
MIT License
1.19k stars 50 forks source link

Bug with custom center two popups #62

Closed KavinduDissanayake closed 6 months ago

KavinduDissanayake commented 10 months ago

Issue Description

When attempting to .showAndStack() two separate center popups with custom views at the same time, the background view always adopts a gray color. This behavior occurs despite different configurations intended for the popups. Additionally, an issue with tap gestures is present when a bottom sheet with a TabView is used; the button tap does not work upon the first appearance.

Steps to Reproduce

  1. Implement .showAndStack() with two separate center popups with custom views.
  2. Observe that the background view is gray for both popups.
  3. Implement a bottom sheet with a TabView.
  4. Notice that the button within the TabView does not work on the first appearance.

Expected Behavior

The background view should not default to gray when stacking popups, and all user interactions, such as tap gestures on buttons within a TabView, should be responsive upon the first appearance.

Screenshots

Code Snippet


struct BreakDownBottomSheetView: BottomPopup {

    func configurePopup(popup: BottomPopupConfig) -> BottomPopupConfig {
        popup
            .tapOutsideToDismiss(true)
            .dragGestureEnabled(true)
            .contentIgnoresSafeArea(true)
    }

    func createContent() -> some View {
        VStack(spacing: 15){
            TabView(selection: $index) {
                ForEach(yourDataArray, id: \.self) { item in
                    Button(action: {
                        // Button action here
                        // Doesn't work on first appearance
                    }) {
                        Text("Button for \(item)")
                    }
                    .tabItem {
                        Image(systemName: "some-system-image")
                        Text("Tab \(item)")
                    }
                    .tag(item)
                }
            }
            .tabViewStyle(.page(indexDisplayMode: .never))
            .indexViewStyle(PageIndexViewStyle(backgroundDisplayMode: .never))
        }
    }
}

BreakDownBottomSheetView()
    .showAndStack()
KavinduDissanayake commented 10 months ago

@FulcrumOne any update on this issue? cc @alina-petrovska

KavinduDissanayake commented 10 months ago

@FulcrumOne Currently, i'm using your library for my project so waiting for your response. Thanks

FulcrumOne commented 10 months ago

@KavinduDissanayake, sorry but we have a lot of things to do at work. I'll back to you this weekend

KavinduDissanayake commented 10 months ago

No worries, Thanks for your response cc @FulcrumOne

FulcrumOne commented 10 months ago

Hey, @KavinduDissanayake

I'm not sure if I understood you correctly, but the first issue (with TabView button not responding) should be fixed with version 2.2.1.

As for the next ones - could you share some screenshots of the app so I can understand what the problems are? Thanks and have a great weekend!

KavinduDissanayake commented 10 months ago

@FulcrumOne Hi ,Just call your example project with below code , after that you can able see to with alert view bottom not will not dark .Currently Im using your library for my live project , that why it really hurry,Sorry for disturbing.

282708966-1634ae0c-683a-4bf6-ae1b-13da8d7e3670
KavinduDissanayake commented 10 months ago

**@FulcrumOne
More info : `import SwiftUI import MijickPopupView

struct ContentView: View { var body: some View { Button(action: { BottomPopup_Default().showAndStack() CentrePopup_UnlockNewFeatures().showAndStack()

    }, label: {

        /*@START_MENU_TOKEN@*/Text("Button")/*@END_MENU_TOKEN@*/
            .alignHorizontally(.center)
    })
}

}

Preview{

ContentView()

}` 282695723-2e37d6c2-cf70-46a4-9d06-af622372c29e**

FulcrumOne commented 10 months ago

@KavinduDissanayake, thanks, now I understand your point.

Unfortunately, when I designed the PopupView, the behaviour you described was not the expected one (I wanted to achieve that the popups of different types can be visible and clickable at the same time). Nevertheless, I think that the change you requested is possible to achieve by modifying the PopupView class from the library. I'll think how I can add this change to the whole system and get back to you.

KavinduDissanayake commented 10 months ago

@FulcrumOne Thank you so much

KavinduDissanayake commented 10 months ago

TAP ISSUE NUMBER 01

I double check every things , may be problem with area that allows for tap. without any modifier button tap work . But When I add any custom view. tap gesture again not work.

struct BreakDownBottomSheetView: BottomPopup {
    // Adding a sample array of strings

    func configurePopup(popup: BottomPopupConfig) -> BottomPopupConfig {
        popup
            .tapOutsideToDismiss(true)
            .dragGestureEnabled(true)
            .contentIgnoresSafeArea(true)
    }

    func createContent() -> some View {
        VStack(spacing: 15){
            TabView {
                Button(action: {
                    print("Text Print")
                    /*Tap not working with appearance*/
                }, label: {
                    /*@START_MENU_TOKEN@*/Text("Button")/*@END_MENU_TOKEN@*/
                        .alignHorizontally(.center)
                        .background(Color.green)
                })
                Text("First")
                Text("Second")
                Text("Third")
                Text("Fourth")
            }
            .tabViewStyle(.page(indexDisplayMode: .never))
            .indexViewStyle(PageIndexViewStyle(backgroundDisplayMode: .never))
            .frame(height: 400)
            .background(Color.red)
        }
    }
}
KavinduDissanayake commented 10 months ago

@FulcrumOne
// MARK: - Tapable Area

extension PopupStack {
    @ViewBuilder func createTapArea() -> some View { if tapOutsideClosesPopup {
        Color.black.opacity(0.44).ignoresSafeArea().onTapGesture(perform: items.last?.dismiss ?? {})
    }}
}

When I adding this for your library Issue Number 02 resolved(Stack Popup outside not dark color issue), can you check the tap issues and update your pod with I given code is it possible ? cc @FulcrumOne

KavinduDissanayake commented 10 months ago

@FulcrumOne any update , sorry for disturbing

FulcrumOne commented 10 months ago

@KavinduDissanayake, sorry but I'm stuck at work. I'll try to update it this weekend

KavinduDissanayake commented 9 months ago

@FulcrumOne Any Update ?

KavinduDissanayake commented 8 months ago

@FulcrumOne any update on this issue?

FulcrumOne commented 6 months ago

@KavinduDissanayake requested feature was implemented in version 2.3.0