App.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. import * as React from "react";
  2. import * as eva from "@eva-design/eva";
  3. import {
  4. ApplicationProvider,
  5. Layout,
  6. Button,
  7. IconRegistry,
  8. Text,
  9. Modal,
  10. } from "@ui-kitten/components";
  11. import { EvaIconsPack } from "@ui-kitten/eva-icons";
  12. import { default as theme } from "./theme.json"; // <-- Import app theme
  13. import { default as customMapping } from "./mapping.json"; // <-- Import app theme
  14. import { SplashScreen } from "expo";
  15. import * as Font from "expo-font";
  16. import { Ionicons } from "@expo/vector-icons";
  17. import { NavigationContainer } from "@react-navigation/native";
  18. import {
  19. createStackNavigator,
  20. CardStyleInterpolators,
  21. } from "@react-navigation/stack";
  22. import Dialog from "./components/Dialog";
  23. import Loading from "./components/Loading";
  24. import { useModel } from "flooks";
  25. import * as models from "./models";
  26. import LoadingModel from "./navigation/LoadingModel";
  27. import BottomTabNavigator from "./navigation/BottomTabNavigator";
  28. import LoginStackNavigator from "./navigation/LoginStackNavigator";
  29. import GuideStackNavigator from "./navigation/GuideStackNavigator";
  30. import BasicScreens from "./navigation/BasicNavigator";
  31. import { navigationRef } from "./navigation/RootNavigation";
  32. import * as ApplyStatus from "./config/ApplyStatus";
  33. const Stack = createStackNavigator();
  34. const config = {
  35. animation: "spring",
  36. config: {
  37. stiffness: 1000,
  38. damping: 500,
  39. mass: 3,
  40. overshootClamping: true,
  41. restDisplacementThreshold: 0.01,
  42. restSpeedThreshold: 0.01,
  43. },
  44. };
  45. export default function App(props) {
  46. const [isLoadingComplete, setLoadingComplete] = React.useState(false);
  47. // Load any resources or data that we need prior to rendering the app
  48. React.useEffect(() => {
  49. async function loadResourcesAndDataAsync() {
  50. try {
  51. SplashScreen.preventAutoHide();
  52. // Load fonts
  53. await Font.loadAsync({
  54. ...Ionicons.font,
  55. "space-mono": require("./assets/fonts/SpaceMono-Regular.ttf"),
  56. });
  57. } catch (e) {
  58. // We might want to provide this error information to an error reporting service
  59. console.warn(e);
  60. } finally {
  61. setLoadingComplete(true);
  62. SplashScreen.hide();
  63. }
  64. }
  65. loadResourcesAndDataAsync();
  66. }, []);
  67. if (!isLoadingComplete && !props.skipLoadingScreen) {
  68. return null;
  69. } else {
  70. return (
  71. <>
  72. <IconRegistry icons={EvaIconsPack} />
  73. <ApplicationProvider
  74. {...eva}
  75. theme={{ ...eva.light, ...theme }}
  76. customMapping={customMapping}
  77. >
  78. <Loading />
  79. <Dialog />
  80. <Layout style={{ flex: 1 }}>
  81. <NavigationContainer ref={navigationRef}>
  82. <Stack.Navigator
  83. headerMode='none'
  84. initialRouteName='LoadingModel'
  85. screenOptions={{
  86. gestureEnabled: true,
  87. cardStyleInterpolator:
  88. CardStyleInterpolators.forHorizontalIOS,
  89. }}
  90. >
  91. <Stack.Screen
  92. name='LoadingModel'
  93. component={LoadingModel}
  94. />
  95. {/* 首页tab组件页面 */}
  96. <Stack.Screen
  97. name='Root'
  98. component={BottomTabNavigator}
  99. />
  100. {/* 注册后指南页面 */}
  101. <Stack.Screen
  102. name='Guide'
  103. component={GuideStackNavigator}
  104. />
  105. {/* 登录部分页面 */}
  106. <Stack.Screen
  107. name='Login'
  108. component={LoginStackNavigator}
  109. />
  110. {/* 基础功能页面 */}
  111. {BasicScreens(Stack.Screen)}
  112. </Stack.Navigator>
  113. </NavigationContainer>
  114. </Layout>
  115. </ApplicationProvider>
  116. </>
  117. );
  118. }
  119. }
  120. const container = {
  121. flex: 1,
  122. backgroundColor: "#fff",
  123. };