Front: Router: Use basic constants to use either public or protected routes
This commit is contained in:
+9
-24
@@ -1,33 +1,18 @@
|
||||
import { StatusBar } from 'expo-status-bar';
|
||||
import { Text, View, ColorValue } from 'react-native';
|
||||
import { Provider as PaperProvider, useTheme } from 'react-native-paper';
|
||||
import { NavigationContainer } from '@react-navigation/native';
|
||||
import { Provider as PaperProvider } from 'react-native-paper';
|
||||
import Theme from './Theme';
|
||||
import { Stack, protectedRoutes, publicRoutes } from './Navigation';
|
||||
|
||||
const ExampleBox = (props: { textColor: ColorValue, backgroundColor: ColorValue }) => (
|
||||
<View style={{ backgroundColor: props.backgroundColor }}>
|
||||
<Text style={{ fontSize: 20, textAlign: 'center', color: props.textColor }} >Hello</Text>
|
||||
</View>
|
||||
)
|
||||
|
||||
export function AppContent() {
|
||||
const { colors } = useTheme();
|
||||
return (
|
||||
<View style={{flex: 1, justifyContent: 'center' }}>
|
||||
<ExampleBox backgroundColor={colors.primary} textColor={colors.text}/>
|
||||
<ExampleBox backgroundColor={colors.accent} textColor={colors.text}/>
|
||||
<ExampleBox backgroundColor={colors.error} textColor={colors.text}/>
|
||||
<ExampleBox backgroundColor={colors.surface} textColor={colors.onSurface}/>
|
||||
<ExampleBox backgroundColor={colors.surface} textColor={colors.placeholder}/>
|
||||
<ExampleBox backgroundColor={colors.notification} textColor={colors.text}/>
|
||||
<StatusBar style="auto" />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
const isAuthentified = true;
|
||||
|
||||
export default function App() {
|
||||
return (
|
||||
<PaperProvider theme={Theme}>
|
||||
<AppContent/>
|
||||
<NavigationContainer>
|
||||
<Stack.Navigator>
|
||||
{ isAuthentified ? protectedRoutes : publicRoutes }
|
||||
</Stack.Navigator>
|
||||
</NavigationContainer>
|
||||
</PaperProvider>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user