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

Fixing Date Picker Modal Overlapping StatusBar in iOS #352

Closed
wants to merge 2 commits into from
Closed

Fixing Date Picker Modal Overlapping StatusBar in iOS #352

wants to merge 2 commits into from

Conversation

AnassHmida
Copy link

@AnassHmida AnassHmida commented Nov 6, 2023

Hello,

This PR resolves the issue where the content of the date picker modal in iOS is displayed under the StatusBar, preventing users from interacting with the close and save buttons. The problem arose due to the use of an incorrect property for calculating the StatusBar height in the DatePickerModal component for iOS. This fix replaces the incorrect property StatusBar.currentHeight with the appropriate StatusBarManager.HEIGHT for iOS. The changes ensure that the content is properly displayed and the user can interact with the necessary buttons within the date picker modal.

Changes Made:

  • Replaced the usage of StatusBar.currentHeight with StatusBarManager.HEIGHT for calculating the StatusBar's height in the DatePickerModal component for iOS.
  • Tested the changes on iOS to ensure the proper functioning of the date picker modal and the interaction with the buttons.

Fixes: #258 (comment)

Thanks.

@iM-GeeKy iM-GeeKy mentioned this pull request Nov 15, 2023
@joeburghard
Copy link

This approach did not resolve my issue with modal positioning underneath statusbar. I did have a better experience using the getHeight method from nativemodules

 const [iosHeight, setIOSHeight] = React.useState<number>(0)
NativeModules.StatusBarManager.getHeight(({ height }: { height: number }) => {
   setIOSHeight(height)
 })
<View
                  style={[
                    {
                      height: Platform.select({
                        ios: iosHeight,
                        ...

@RichardLindhout
Copy link
Member

I think the best approach is to use react-native-safe-area-context for this (which we already have as a dependency)

@joeburghard
Copy link

@AnassHmida Could you refactor your changes to try the solution @RichardLindhout suggested?

@RichardLindhout
Copy link
Member

I did a fix myself, can you verify this change @AnassHmida

@AnassHmida
Copy link
Author

Hello @joeburghard , the fix you mentioned causes a crash in android , you need to limit it to IOS only :

Platform.OS === "ios" &&  NativeModules.StatusBarManager.getHeight(({ height }: { height: number }) => {
setIOSHeight(height)
})

but other than that , it works great !

@AnassHmida
Copy link
Author

AnassHmida commented Dec 7, 2023

Hey @RichardLindhout , one second , i'm verifying this

@AnassHmida
Copy link
Author

AnassHmida commented Dec 7, 2023

Hey again @RichardLindhout , it seems that the 'react-native-safe-area-context' doesn't seem to work here , i tried the latest version that you released , but now the problem seems to persist , for IOS
IOS and Android Android , i'm going to create a pull request based on @joeburghard 's answer with an android fix.

@RichardLindhout
Copy link
Member

RichardLindhout commented Dec 7, 2023

No it should work I think you did not use the provider

import { SafeAreaProvider } from 'react-native-safe-area-context';
function App() {
  return <SafeAreaProvider>

...other providers
</SafeAreaProvider>;
}

@RichardLindhout
Copy link
Member

react-native-safe-area-context is already a dependency for react-native-paper and this works great! I never saw this problem in my apps so it should be the provider :)

@RichardLindhout
Copy link
Member

Hmm looks like its double applied now :)

I think we may need to improve docs on this

Scherm­afbeelding 2023-12-07 om 17 47 37

@AnassHmida
Copy link
Author

AnassHmida commented Dec 7, 2023

Hmm looks like its double applied now :)

I think we may need to improve docs on this

Scherm­afbeelding 2023-12-07 om 17 47 37

Humm i don't know , i'm wrapping my views in a SafeAreaProvider tag , but that doesn't seem to fix anything , and i don't think it should be conditioned to be like that in the first place , i made a second PR based on @joeburghard 's answer which should be WAI.

Thanks.

@RichardLindhout
Copy link
Member

Please let me know if newest release work for you, on my device it works. We have also support for all the different use cases and the pagesheet presentation style

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

Successfully merging this pull request may close these issues.

Content of date picker modal is in StatusBar on iOS
3 participants