NavigationView icon indicating copy to clipboard operation
NavigationView copied to clipboard

NavigationView creates a black view to appear when using a textfield

Open Nathan1258 opened this issue 1 year ago • 46 comments

As shown:

https://github.com/Mijick/NavigationView/assets/53881694/43c848f8-d72e-4104-9ba2-9a455266c3a4

Clicking on a textfield will cause a black (or the colour you set config.backgroundColour as within the NavigationGlobalConfig) to appear and fill the entire view.

Nathan1258 avatar Jul 01 '24 21:07 Nathan1258

Hey @Nathan1258,

The problem should be solved in the "patch-1.1.1" branch. Could you please check it and let me know? Thanks!

FulcrumOne avatar Jul 02 '24 17:07 FulcrumOne

Hi @FulcrumOne,

I can confirm the problem has been solved - thank you for being so speedy! Nice to see my UI when entering text 🤣

Will return to stable branch now and wait for patch-1.1.1 to be merged!

Nathan1258 avatar Jul 02 '24 17:07 Nathan1258

Hello @FulcrumOne , I have same problem, and up to date. config.backgroundColour = .red

image

clbemre avatar Jul 09 '24 21:07 clbemre

@clbemre, Hey, I'll look at this at the weekend

PS. Could you paste here the code I can use to reproduce it? Thanks a million!

FulcrumOne avatar Jul 10 '24 12:07 FulcrumOne

@FulcrumOne Hey thank you, I noticed that also, drag gesture conflicts with scrollview and causes an wrong behavior.

Additionally maybe you can add view.navigationBackGesture(.dragEdges) 😀

clbemre avatar Jul 10 '24 20:07 clbemre

@FulcrumOne Hey thank you, I noticed that also, drag gesture conflicts with scrollview and causes an wrong behavior.

Additionally maybe you can add view.navigationBackGesture(.dragEdges) 😀

There is such an option, I don't remember how it's called exactly but one of NavigationGlobalConfig 😉

FulcrumOne avatar Jul 10 '24 21:07 FulcrumOne

@FulcrumOne
I just saw view.navigationBackGesture(.drag). No (.dragEdges), i don't know :)

clbemre avatar Jul 11 '24 12:07 clbemre

In a file "Public+NavigationGlobalConfig", there should be three attributes - backGesturePosition (the one that you're looking for), backGestureThreshold and backgroundColour. Could you confirm that in the version you use, all three attributes exist?

FulcrumOne avatar Jul 11 '24 12:07 FulcrumOne

@FulcrumOne aa okey, i see. We have to configure global config. I thought we could adjust this on a per page basis sorry :)

clbemre avatar Jul 11 '24 12:07 clbemre

@clbemre,

Do you think it would be better to add this option to every screen?

FulcrumOne avatar Jul 11 '24 19:07 FulcrumOne

No but I just want to override . And my main problem is not this. My problem in video :)

clbemre avatar Jul 11 '24 19:07 clbemre

yeah, tomorrow or Saturday I'm returning to this library 😅

FulcrumOne avatar Jul 11 '24 19:07 FulcrumOne

Hello, @clbemre Could you share a code that contains an issue with background color? It will help me to speed up the problem-solving process.

Also the issue with the offset for horizontal drag-gesture action has been resolved in the branch Patch-1.1.2. Feel free to give it a try and let us know if it doesn't work as expected.

alina-p-k avatar Jul 11 '24 20:07 alina-p-k

@jay-jay-lama Hello, my code like this in short.

 var body: some View {
        DefaultContainerView {
            VStack(spacing: 0) {
                navigationBarView
                    .padding(.horizontal, 20)
                ScrollView {
                    VStack(spacing: 20) {
                        Group {
                            nameTextField
                            surnameTextField
                            emailTextField
                        }
                    }
                        .padding(.top, 30)
                        .padding(.horizontal, 20)
                }.scrollDisabled(!isShownKeyboard)
            }.overlay(alignment: .bottom, content: { saveButtonView })
        }
            .keyboardToolbar(focusedField: $focusedField, currentVisibilityID: .toolbarVisibilityID)
            .onKeyboardAppear { self.isShownKeyboard = $0 > 0 }
            .animation(.smooth, value: isShownKeyboard)
            .onTap { focusedField = nil }
    }

also

struct DefaultContainerView<Content: View>: View {

    let content: Content

    init(@ViewBuilder content: () -> Content) {
        self.content = content()
    }

    var body: some View {
        ZStack {
            DefaultBackgroundView()

            content
        }
    }
}

clbemre avatar Jul 12 '24 23:07 clbemre

@clbemre, both problems should be resolved in the newest version

FulcrumOne avatar Jul 13 '24 17:07 FulcrumOne

@FulcrumOne Thank you!

clbemre avatar Jul 14 '24 11:07 clbemre

@FulcrumOne It has solved. But just there is a little problem.

clbemre avatar Jul 14 '24 11:07 clbemre

Oh, could you describe it, because I'm clearly blind and can't notice it 😅

FulcrumOne avatar Jul 14 '24 11:07 FulcrumOne

@FulcrumOne when it first opens on each screen there is a flicker for the first time when trying to scroll and then it works fine without flickering 😀

clbemre avatar Jul 14 '24 11:07 clbemre

Oh, yeah, you're right. I'll check it, thanks

FulcrumOne avatar Jul 14 '24 11:07 FulcrumOne

@FulcrumOne I have tested without NavigationView plugin this page. When I remove the navigationview plugin from the page, I do not encounter this problem.

clbemre avatar Jul 14 '24 11:07 clbemre

@FulcrumOne It seems that I've noticed the same problem if I use native solution without our library. Navigation bar has it's own observer of scrollView callbacks and it can be native problem. And issue appears not only on first screen presenting but also during switching between the textfields and also just during ordinary scrolling. So it's random... Need also your test to confirm the situation.

On the video the same problem with native solution.

https://github.com/user-attachments/assets/96582c54-c53f-4872-947b-802ed0a6b0c7

alina-p-k avatar Jul 14 '24 12:07 alina-p-k

I unserstood. But i told you , When I remove the navigationview plugin from the page, I do not encounter this problem. :)

clbemre avatar Jul 14 '24 12:07 clbemre

removed video. without NavigationView

clbemre avatar Jul 14 '24 12:07 clbemre

@FulcrumOne hey there is also a very little problem :)

removed video

with background

 var navigationConfig: NavigationGlobalConfig {
        var config = NavigationGlobalConfig()
        config.backgroundColour = .red
        config.backGesturePosition = .edge
        config.backGestureThreshold = 0.25
        return config
    }

clbemre avatar Jul 14 '24 13:07 clbemre

removed video. without background

var navigationConfig: NavigationGlobalConfig {
        var config = NavigationGlobalConfig() 
        config.backGesturePosition = .edge
        config.backGestureThreshold = 0.25
        return config
    }

clbemre avatar Jul 14 '24 13:07 clbemre

@clbemre, this is actually tricky one and I doubt I will be able to "fix it" - background color cannot be clear, otherwise you always see the view underneath. It's because the animation of the views involves modifying their offset (or scale / rotation).

If you really need to make the safe areas clear, I strongly recommend using .ignoresSafeArea modifier 😉

FulcrumOne avatar Jul 14 '24 13:07 FulcrumOne

@FulcrumOne I set the background color. Actually, I don't have a problem with this, I just said it so you know :)

I use .ignoresSafeArea when necessary. But I don't understand where you mean I should use it :)

clbemre avatar Jul 14 '24 13:07 clbemre

Oh, I just thought about an use-case like putting a picture that is supposed to be behind a status bar / home indicator and someone may think that it can be resolved with clear background (someone actually asked me exactly this). So if it's not your question just please ignore it 😅

That previous problem I'll try to resolve later today. Thanks for reporting!

FulcrumOne avatar Jul 14 '24 13:07 FulcrumOne

@FulcrumOne Hey, hello again. How are you? I have a little problem again :) I have tested without NavigationView. FYI :)

also it's block my keyboard toolbarview visibility.

https://github.com/user-attachments/assets/dbcbe535-de96-4076-9b01-ea97c761f989

clbemre avatar Jul 22 '24 18:07 clbemre