index.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * 入口文件
  3. * @邠心vbe on 2020/05/20
  4. */
  5. import React, { Component } from 'react';
  6. import './app/i18n'
  7. import {AppRegistry, KeyboardAvoidingView} 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 { SafeAreaView } from 'react-native-safe-area-context';
  18. import MyStatusBar from './app/components/MyStatusBar';
  19. import { i18nUtil } from './app/i18n';
  20. class Index extends Component {
  21. constructor(props) {
  22. super(props);
  23. this.state = {
  24. visible: false,
  25. refreshTime: 0
  26. }
  27. }
  28. componentDidMount() {
  29. i18nUtil.init(() => {
  30. this.setState({
  31. visible: true
  32. })
  33. })
  34. }
  35. render() {
  36. return (
  37. <RootSiblingParent>
  38. <MyStatusBar/>
  39. { this.state.visible
  40. ? isIOS
  41. ? <KeyboardAvoidingView style={ui.flex1} behavior="padding">
  42. <Router/>
  43. </KeyboardAvoidingView>
  44. : <Router/>
  45. : <></>
  46. }
  47. <ModalPortal />
  48. { isIOS && (
  49. <SafeAreaView style={{flex: 0, backgroundColor: colorLight}}></SafeAreaView>)
  50. }
  51. </RootSiblingParent>
  52. );
  53. }
  54. };
  55. AppRegistry.registerComponent(app.name, () => Index);
  56. /*if (app.modules.codePush ) {
  57. //热更新配置
  58. let codePushOptions = {
  59. updateDialog: false,
  60. //实时检测更新并下载
  61. checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
  62. //下载完成后立即安装
  63. installMode: codePush.InstallMode.IMMEDIATE
  64. //下次进入安装
  65. //installMode: codePush.InstallMode.ON_NEXT_RESTART
  66. };
  67. AppRegistry.registerComponent(app.name, () => codePush(codePushOptions)(Index));
  68. }*/