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

useSafeArea is not working on Android #3109

Open
2 of 7 tasks
robinclaes opened this issue May 30, 2024 · 1 comment
Open
2 of 7 tasks

useSafeArea is not working on Android #3109

robinclaes opened this issue May 30, 2024 · 1 comment
Assignees
Labels
bug a bug in one of the components question general question on how to do something..

Comments

@robinclaes
Copy link

robinclaes commented May 30, 2024

Description

When using <Incubator.Toast>, it uses <View useSafeArea>, but our toast still appears behind notch/camera on Android

Related to

  • Components
  • Demo
  • Docs
  • Typings

Steps to reproduce

Render a Toast (from Incubator) on the root View on an Android device with a notch
or
Render a <View useSafeArea></View> on the root View of an Android device with a notch

Expected behavior

It renders under the notch

Actual behavior

It renders behind the notch

More Info

What works for us is this, but feels hacky.

import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { Toast as RNUIToast, ToastProps } from 'react-native-ui-lib/src/incubator';
import { isAndroid } from '../util/general';

export function Toast(props: ToastProps) {
  const insets = useSafeAreaInsets();
  // ? We add the style because the useSafeArea is not working on Android
  return <RNUIToast {...props} style={isAndroid && { marginTop: insets.top }} />;
}

Environment

  • React Native version: 0.73.6
  • React Native UI Lib version: 7.23.2

Affected platforms

  • Android
  • iOS
  • Web
@robinclaes robinclaes added the bug a bug in one of the components label May 30, 2024
@adids1221
Copy link
Contributor

adids1221 commented Aug 18, 2024

Hi @robinclaes , useSafeArea is working only in IOS by default.
As you can see in our code - View index file:

const container = useSafeArea && Constants.isIOS ? SafeAreaView : RNView`

So it's not a bug.

About your issue, does it reproduces on a specific device ?
Do you have any screenshot/video?

@adids1221 adids1221 added the question general question on how to do something.. label Aug 18, 2024
@adids1221 adids1221 self-assigned this Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug a bug in one of the components question general question on how to do something..
Projects
None yet
Development

No branches or pull requests

2 participants