init: 初始化模板项目
This commit is contained in:
48
apps/expo/app/_layout.tsx
Normal file
48
apps/expo/app/_layout.tsx
Normal file
@@ -0,0 +1,48 @@
|
||||
import { useEffect } from 'react'
|
||||
import { useColorScheme } from 'react-native'
|
||||
import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native'
|
||||
import { useFonts } from 'expo-font'
|
||||
import { SplashScreen, Stack } from 'expo-router'
|
||||
import { Provider } from 'app/provider'
|
||||
import { NativeToast } from '@my/ui/src/NativeToast'
|
||||
|
||||
export const unstable_settings = {
|
||||
// Ensure that reloading on `/user` keeps a back button present.
|
||||
initialRouteName: 'Home',
|
||||
}
|
||||
|
||||
// Prevent the splash screen from auto-hiding before asset loading is complete.
|
||||
SplashScreen.preventAutoHideAsync()
|
||||
|
||||
export default function App() {
|
||||
const [interLoaded, interError] = useFonts({
|
||||
Inter: require('@tamagui/font-inter/otf/Inter-Medium.otf'),
|
||||
InterBold: require('@tamagui/font-inter/otf/Inter-Bold.otf'),
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (interLoaded || interError) {
|
||||
// Hide the splash screen after the fonts have loaded (or an error was returned) and the UI is ready.
|
||||
SplashScreen.hideAsync()
|
||||
}
|
||||
}, [interLoaded, interError])
|
||||
|
||||
if (!interLoaded && !interError) {
|
||||
return null
|
||||
}
|
||||
|
||||
return <RootLayoutNav />
|
||||
}
|
||||
|
||||
function RootLayoutNav() {
|
||||
const colorScheme = useColorScheme()
|
||||
|
||||
return (
|
||||
<Provider>
|
||||
<ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
|
||||
<Stack />
|
||||
<NativeToast />
|
||||
</ThemeProvider>
|
||||
</Provider>
|
||||
)
|
||||
}
|
||||
15
apps/expo/app/index.tsx
Normal file
15
apps/expo/app/index.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
import { HomeScreen } from 'app/features/home/screen'
|
||||
import { Stack } from 'expo-router'
|
||||
|
||||
export default function Screen() {
|
||||
return (
|
||||
<>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
title: 'Home',
|
||||
}}
|
||||
/>
|
||||
<HomeScreen />
|
||||
</>
|
||||
)
|
||||
}
|
||||
7
apps/expo/app/types.d.ts
vendored
Normal file
7
apps/expo/app/types.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { config } from '@my/config'
|
||||
|
||||
export type Conf = typeof config
|
||||
|
||||
declare module '@my/ui' {
|
||||
interface TamaguiCustomConfig extends Conf {}
|
||||
}
|
||||
21
apps/expo/app/user/[id].tsx
Normal file
21
apps/expo/app/user/[id].tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import { UserDetailScreen } from 'app/features/user/detail-screen'
|
||||
import { Stack } from 'expo-router'
|
||||
import { useParams } from 'solito/navigation'
|
||||
|
||||
export default function Screen() {
|
||||
const { id } = useParams()
|
||||
return (
|
||||
<>
|
||||
<Stack.Screen
|
||||
options={{
|
||||
title: 'User',
|
||||
presentation: 'modal',
|
||||
animation: 'slide_from_right',
|
||||
gestureEnabled: true,
|
||||
gestureDirection: 'horizontal',
|
||||
}}
|
||||
/>
|
||||
<UserDetailScreen id={id as string} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user