55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
import React, { useEffect } from 'react';
|
|
import { ApplicationProvider, IconRegistry, Layout } from '@ui-kitten/components';
|
|
import { EvaIconsPack } from '@ui-kitten/eva-icons';
|
|
import * as eva from '@eva-design/eva';
|
|
import AppNavigator from './src/navigation';
|
|
import Toast from 'react-native-toast-message';
|
|
import { Platform } from 'react-native';
|
|
import { AuthProvider, useAuth } from './src/context/AuthContext';
|
|
import { setToastFunction, setLogoutFunction } from './src/utils/api';
|
|
import { AMapSdk } from 'react-native-amap3d';
|
|
|
|
AMapSdk.init(Platform.select({
|
|
android: '812efd3a950ba3675f928630302c6463',
|
|
|
|
}));
|
|
const AppContent = () => {
|
|
const { logout } = useAuth();
|
|
|
|
useEffect(() => {
|
|
// 设置全局 Toast 函数
|
|
setToastFunction((message) => {
|
|
Toast.show({
|
|
type: 'error',
|
|
text1: '提示',
|
|
text2: message,
|
|
position: 'top',
|
|
topOffset: Platform.OS === 'ios' ? 60 : 20,
|
|
visibilityTime: 2000,
|
|
});
|
|
});
|
|
|
|
// 设置全局 logout 函数
|
|
setLogoutFunction(logout);
|
|
}, [logout]);
|
|
|
|
return (
|
|
<Layout style={{ flex: 1 }}>
|
|
<AppNavigator />
|
|
</Layout>
|
|
);
|
|
};
|
|
|
|
export default function App() {
|
|
return (
|
|
<>
|
|
<IconRegistry icons={EvaIconsPack} />
|
|
<ApplicationProvider {...eva} theme={eva.light}>
|
|
<AuthProvider>
|
|
<AppContent />
|
|
</AuthProvider>
|
|
</ApplicationProvider>
|
|
<Toast />
|
|
</>
|
|
);
|
|
} |