App.js 5.2 KB

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