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