Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alert overlay doesn't fit the entire screen when the navigation bar is hidden (Android Only) #69

Open
Moncef-Boukhecheba opened this issue Aug 25, 2020 · 14 comments

Comments

@Moncef-Boukhecheba
Copy link

Hey, I'm new to react native and I'm using this library for all the alerts in my project, and so far it's working great.

However when enabling full screen mode in Android (I just hide the navigation bar using this library https://github.com/thebylito/react-native-navigation-bar-color), the overlay surrounding the alert stops at the non-existant bottom navigation bar.

I couldn't get the expo snack to work since the navigation color library probably uses a lot of native code, but the code works in a normal react-native-app.

Here's the link for the code if you want to reproduce the issue. https://snack.expo.io/@moncefbkb/navigation-bar-awesome-alert

Note (What i tried) :

Referring to this SO question https://stackoverflow.com/questions/46126521/android-navigation-bar-height-react-native, it seems like there's a difference between getting the dimensions from the "screen" and for the "window", as, on Android, the former includes the height of the navigation bar and the status bar.

I thought that this was causing the issue so I changed the library's "styles.js" file to get the height from the "screen" instead of getting it from the "window", but nothing changed.

I even tried to set the height to an absurd amount (1000) and it still stops before the navigation bar. I then tried to do the same thing with a simple view (Giving it a background color, and giving it a height of 1000), and it covered all the screen just fine.

So it seems likely that the problem doesn't come from the other library, and this is why i'm posting the issue here.

@rishabhbhatia
Copy link
Owner

rishabhbhatia commented Aug 27, 2020

@Princeofgame I'll have a look. Downgrading to v1.3.2 should solve it temporarily. Pass alertContainerStyle and overlayStyle props with height & width from Dimensions.get('screen'), give it a try.

Meanwhile, I'll look at it, seems to be a react modal related issue.

@Moncef-Boukhecheba
Copy link
Author

Hey, thank you for the quick reply (and sorry for this late one, I wanted to test your solution before replying).

Thank you for the temporary fix, downgrading the library seems to make things working perfectly now !

I tried the same code on the new version and it didn't work (I switched versions twice), so I guess the new version adds something that creates this problem, which is probably that Modal Component that wraps everything.

So I tried experimenting with the Modal component to help out a bit, but i didn't manage to find anything conclusive (I really don't understand styling).

Nonetheless, here's a basic code snippet for the modal component where i try to create an overlay and it takes the entire space.
Hope it helps : https://snack.expo.io/@moncefbkb/modal-test

@rishabhbhatia
Copy link
Owner

@Princeofgame I looked at the link you shared. Try importing Modal from react-native instead of a third-party library. Remove import { Modal } from 'react-native-paper';. I tried it in my local before, it leaves some space at the bottom. View works just fine.

For some reason the hideNavigationBar from react-native-navigation-bar-color is giving me Device: null is not an object (evaluating 'o.hideNavigationBar') error on snack.

@Moncef-Boukhecheba
Copy link
Author

Moncef-Boukhecheba commented Aug 31, 2020

@rishabhbhatia Oh you're right, sorry i didn't notice the mistake in the import, i used the auto import function from VSCode...
I'll try the new code in a moment.

I have the error too, like i said in the first post, my guess is that the library is probably using some Android native code which snack doesn't support... ? (To be honest, I'm also very confused... xD)

Anyway, it seems that you can make it work by testing on a real Android device.

Edit : You're right ! I tried with the modal from React Native and it's stopping at the navigation bar.

@rishabhbhatia
Copy link
Owner

Yeah I know, it's a little annoying since the Modal doesn't support the styling prop. I'll try to figure out the best solution meanwhile stick with v1.3.2.

@Moncef-Boukhecheba
Copy link
Author

I will, thanks again for the help :D

@ghost
Copy link

ghost commented Sep 10, 2020

Hi, everyone, Thanks for the great plugin first.
I am using this alert thing, it works perfectly on my device.
But it's overlay cuts the navigation bottom and header on other android device,
I attached screenshot for a visual help.
02

Hope you guys fix this error and improve to a better one.
Thanks in advance.

@rishabhbhatia
Copy link
Owner

rishabhbhatia commented Sep 10, 2020

@toplongguodev what is alert and android version you're using? also, specify the navigation library/other device details, will have a look.

@ghost
Copy link

ghost commented Sep 10, 2020

Thanks for your reply.
Xiaomi redmi note 7
android 10

"@react-navigation/bottom-tabs": "^5.7.3",
"@react-navigation/drawer": "^5.5.0",
"@react-navigation/native": "^5.1.6",
"@react-navigation/stack": "^5.2.11",

These are details.
Thanks

@rishabhbhatia
Copy link
Owner

@toplongguodev awesome alert version?

@jahn-brito
Copy link

@toplongguodev I solved this problem using:
overlayStyle={{height: '100%'}}

@AliMohammad93
Copy link

AliMohammad93 commented Dec 15, 2021

I changed StatusBar opacity when alert is open and this solution worked for me

`

    <AwesomeAlert
        show={showAlert}
        customView={customView}
    />

    <StatusBar
        backgroundColor={rgbaColor(0,0,0,showAlert ? 0.4 : 0)}
    />

`

@chuthuong2004
Copy link

Add props

 modalProps={{
        statusBarTranslucent: true,
      }}

@mretiinteractivebrokers

Hi everyone!

I am facing the same issue. When the modal is open, the immersion mode of the android device is broken, and the bottom navbar shows up. After closing the modal, the navbar hides as well.
Do you have any solutions how to solve this issue?

Thank you in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants