App.js 4.6 KB

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