facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.33k stars 24.36k forks source link

Modal showing activity bar when it should not (using SystemNavigationBar - edit: using java code produces the same bug) #37801

Open Descatres opened 1 year ago

Descatres commented 1 year ago

Description

I'm using SystemNavigationBar to hide my status and activity bars, in order to be able to use the full screen for the app I'm currently developing.

Is there any fix?

Thanks in advance for any support and help.

React Native Version

0.71.4

Output of npx react-native info

System:
    OS: Windows 10 10.0.22621
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 3.01 GB / 15.91 GB
  Binaries:
    Node: 18.12.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 9.6.4 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK: Not Found
    Windows SDK:
      AllowAllTrustedApps: Enabled
      Versions: 10.0.19041.0
  IDEs:
    Android Studio: AI-213.7172.25.2113.9123335
    Visual Studio: 16.11.32126.315 (Visual Studio Enterprise 2019)
  Languages:
    Java: 11.0.17
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0
    react-native: 0.71.4 => 0.71.4
    react-native-windows: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

Snack, code example, screenshot, or link to a repository

App.tsx

import React, {useState} from 'react';
import {Modal, StyleSheet, View} from 'react-native';
import Buttons from './Buttons';
import SystemNavigationBar from 'react-native-system-navigation-bar';

function App(): JSX.Element {
  SystemNavigationBar.fullScreen(true);
  const [visible, setVisible] = useState(false);
  const onclick = () => {
    setVisible(!visible);
  };
  return (
    <View style={styles.content}>
      <Buttons
        press={onclick}
        text={'Open Modal'}
        backgroundColor={'#FFFEFC'}
        borderColor={'#EEEEEE'}
        textColor={'#223631'}
      />
      {visible === true && (
        <Modal transparent={false} visible={visible}>
          <View style={styles.content}>
            <Buttons
              press={onclick}
              text={'Close Modal'}
              backgroundColor={'#FFFEFC'}
              borderColor={'#EEEEEE'}
              textColor={'#223631'}
            />
          </View>
        </Modal>
      )}
    </View>
  );
}

const styles = StyleSheet.create({
  content: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
});

export default App;

Buttons.tsx

import React from 'react';
import {Pressable, Text, View, StyleSheet} from 'react-native';

function Buttons({press, text, backgroundColor, borderColor, textColor}: any) {
  return (
    <Pressable
      style={styles.button}
      onPress={press}
      backgroundColor={backgroundColor}
      borderColor={borderColor}>
      <View style={styles.textFrame}>
        <Text style={styles.textStyle}>
          <Text style={{color: textColor}}>{text}</Text>
        </Text>
      </View>
    </Pressable>
  );
}

const styles = StyleSheet.create({
  button: {
    display: 'flex',
    flexDirection: 'row',
    justifyContent: 'center',
    alignItems: 'center',
    // paddingVertical: 24,
    // paddingHorizontal: 24,
    // alignSelf: 'stretch',
    // flexGrow: 0,
    borderWidth: 4,
    borderRadius: 16,
    height: 88,
    width: 500,
  },
  textFrame: {
    display: 'flex',
    order: 0,
    flexDirection: 'row',
  },
  textStyle: {
    display: 'flex',
    fontFamily: 'OpenSans-SemiBold',
    fontStyle: 'normal',
    fontWeight: '600',
    fontSize: 32,
  },
});

export default Buttons;

Example:

Here, we can see that, at the bottom, after clicking on the open modal button, the bar appears, where it should not.

github-actions[bot] commented 1 year ago
:warning: Newer Version of React Native is Available!
:information_source: You are on a supported minor version, but it looks like there's a newer patch available - 0.71.10. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.
Descatres commented 1 year ago

⚠️ Newer Version of React Native is Available! ℹ️ You are on a supported minor version, but it looks like there's a newer patch available - 0.71.10. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

Note: I'm using specific packages wich require specific versions of others in my project and I can't change versions that easily.

Descatres commented 1 year ago

Update

I tried with java (I made a bridge between java and react native) to test:

TIGER272 commented 1 year ago

Problem persist in 0.71.10.

TheTushar2696 commented 1 year ago

@cortinico Is this a known issue , A PR has also been raised with the fix,Is this in the pipeline,

Thanks in advance

cortinico commented 1 year ago

@cortinico Is this a known issue , A PR has also been raised with the fix,Is this in the pipeline,

Don't you mind following up on the PRs comments that @lunaleaps left then?

AdamGerthel commented 1 year ago

This issue is currently making it impossible to use Modal in a fullscreen app (such as a game, for instance) because it breaks the UI. I tried applying the code from https://github.com/facebook/react-native/pull/36854 but I realized that I'd have to build RN from source which I don't know how to do and seems it would really complicate our workflow with the app in question.

Looking forward to any updates here.

AdamGerthel commented 1 year ago

For anyone looking for a workaround, I've opted to stop using Modal until this has been resolved, and I'm instead using react-native-portal to "teleport" my modals to the root of my view hierarchy so that I can show the content on top of everything else.

qusaieilouti99 commented 11 months ago

Facing a similar issue by adding in my MainAcitivity.java this code into my onCreate function :

Window w = getWindow();
      // these styles should be under super.onCreate to take effect
      w.setStatusBarColor(Color.TRANSPARENT);
      w.setNavigationBarColor(Color.TRANSPARENT);
      w.setNavigationBarContrastEnforced(false);
      w.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE );

I'm trying to achieve edge-to-edge experience in my app and it's working fine by using statusBarTranslucent but there is no way to do so for the nav bar. I guess you can provide something like the statusBarTranslucentthat you already supporting, or just fetch whatever settings or flags applied to the root window and reapply it on updateProperties . @cortinico

github-actions[bot] commented 5 months ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

Descatres commented 5 months ago

this is still open