index.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 'react-native-modals';
  16. import ModalPortal from './app/components/ModalPortal';
  17. import {RootSiblingParent} from 'react-native-root-siblings';
  18. import { SafeAreaView } from 'react-native-safe-area-context';
  19. import MyStatusBar from './app/components/MyStatusBar';
  20. import { i18nUtil } from './app/i18n';
  21. //let context;
  22. class Index extends Component {
  23. constructor(props) {
  24. super(props);
  25. this.state = {
  26. visible: false,
  27. refreshTime: 0
  28. }
  29. //context = this;
  30. }
  31. componentDidMount() {
  32. i18nUtil.init(() => {
  33. this.setState({
  34. visible: true
  35. })
  36. })
  37. }
  38. /*restartApp() {
  39. console.log("----------------RESTART-----------------");
  40. this.setState({
  41. visible:false
  42. }, () => {
  43. this.setState({
  44. visible: true
  45. })
  46. })
  47. }*/
  48. render() {
  49. return (
  50. <RootSiblingParent>
  51. <MyStatusBar/>
  52. { this.state.visible
  53. ? isIOS
  54. ? <KeyboardAvoidingView style={ui.flex1} behavior="padding">
  55. <Router/>
  56. </KeyboardAvoidingView>
  57. : <Router/>
  58. : <></>
  59. }
  60. <ModalPortal />
  61. { isIOS &&
  62. <SafeAreaView style={{flex: 0, backgroundColor: colorLight}}></SafeAreaView>
  63. }
  64. </RootSiblingParent>
  65. );
  66. }
  67. };
  68. /*if (app.modules.codePush ) {
  69. //热更新配置
  70. let codePushOptions = {
  71. updateDialog: false,
  72. //实时检测更新并下载
  73. checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
  74. //下载完成后立即安装
  75. installMode: codePush.InstallMode.IMMEDIATE
  76. //下次进入安装
  77. //installMode: codePush.InstallMode.ON_NEXT_RESTART
  78. };
  79. AppRegistry.registerComponent(app.name, () => codePush(codePushOptions)(Index));
  80. }*/
  81. AppRegistry.registerComponent(app.name, () => Index);