index.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. MyStatusBar.setStatusBarThemes(MyStatusBar.DARK_STYLE, colorLight);//白标签
  39. }
  40. /*restartApp() {
  41. console.log("----------------RESTART-----------------");
  42. this.setState({
  43. visible:false
  44. }, () => {
  45. this.setState({
  46. visible: true
  47. })
  48. })
  49. }*/
  50. render() {
  51. return (
  52. <RootSiblingParent>
  53. <MyStatusBar/>
  54. { this.state.visible
  55. ? isIOS
  56. ? <KeyboardAvoidingView style={ui.flex1} behavior="padding">
  57. <Router/>
  58. </KeyboardAvoidingView>
  59. : <Router/>
  60. : <></>
  61. }
  62. <ModalPortal />
  63. <SafeAreaView style={{flex: 0, backgroundColor: colorLight}}></SafeAreaView>
  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. } else {
  81. AppRegistry.registerComponent(app.name, () => Index);
  82. }