index.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /**
  2. * 入口文件
  3. * @邠心vbe on 2020/05/20
  4. */
  5. import React, { Component } from 'react';
  6. import './app/i18n'
  7. import {AppRegistry, View} from 'react-native';
  8. import 'react-native-gesture-handler';
  9. import './app/utils/themes'
  10. import './app/utils/constant';
  11. import './app/utils/notification';
  12. import './app/utils/vector_icon';
  13. import Router from './app/pages/Router';
  14. import app from './app.json';
  15. import ModalPortal from './app/components/ModalPortal';
  16. import {RootSiblingParent} from 'react-native-root-siblings';
  17. import { SafeAreaInsetsContext, SafeAreaProvider } from 'react-native-safe-area-context';
  18. import MyStatusBar from './app/components/MyStatusBar';
  19. import { i18nUtil } from './app/i18n';
  20. import RouterV2 from './app/pages/RouterV2';
  21. class Index extends Component {
  22. constructor(props) {
  23. super(props);
  24. this.state = {
  25. visible: false,
  26. refreshTime: 0,
  27. navBottom: undefined
  28. }
  29. }
  30. componentDidMount() {
  31. i18nUtil.init(() => {
  32. this.setState({
  33. visible: true
  34. })
  35. })
  36. }
  37. init(insets) {
  38. console.log("insets" + this.state.navBottom, insets)
  39. if (this.state.navBottom == undefined) {
  40. if (insets.top) {
  41. global.statusHeight = insets.top
  42. }
  43. if (insets.bottom != undefined) {
  44. global.navbarHeight = insets.bottom
  45. this.setState({
  46. navBottom: insets.bottom
  47. })
  48. }
  49. }
  50. }
  51. render() {
  52. return (
  53. <SafeAreaProvider>
  54. <RootSiblingParent>
  55. <MyStatusBar/>
  56. { this.state.visible
  57. ? (app.isLumiWhitelabel ? <RouterV2/> : <Router/>)
  58. : <></>
  59. }
  60. <ModalPortal/>
  61. { this.state.navBottom != undefined
  62. ? <View style={{height: isIOS ? 0 : this.state.navBottom, backgroundColor: colorAccent}}></View>
  63. : <SafeAreaInsetsContext.Consumer>
  64. {insets => this.init(insets)}
  65. </SafeAreaInsetsContext.Consumer>
  66. }
  67. </RootSiblingParent>
  68. </SafeAreaProvider>
  69. );
  70. }
  71. };
  72. AppRegistry.registerComponent(app.name, () => Index);