Front: Add Basic authentication view

This commit is contained in:
Arthi-chaud
2022-08-07 12:42:11 +02:00
parent 77b2c17d83
commit 8f44885fd3
2 changed files with 28 additions and 16 deletions
+21
View File
@@ -0,0 +1,21 @@
import React from "react";
import { Text, View } from 'react-native';
import { Button } from "react-native-paper";
import { useDispatch } from "react-redux";
import { setUserToken } from "../state/UserSlice";
const AuthenticationView = () => {
const dispatch = useDispatch();
return (
<View style={{ flex: 1, justifyContent: 'center' }}>
<Text style={{ textAlign: "center" }}>Welcom to Chromacase</Text>
<Text style={{ textAlign: "center" }}>This is the Authentication Screen</Text>
<Button onPress={() => dispatch(setUserToken('kkkk'))}>
Tap here to login
</Button>
</View>
);
}
export default AuthenticationView;
+7 -16
View File
@@ -1,26 +1,17 @@
import React from "react";
import { Text, View, ColorValue } from 'react-native';
import { useTheme } from "react-native-paper";
const ExampleBox = (props: { textColor: ColorValue, backgroundColor: ColorValue }) => (
<View style={{ backgroundColor: props.backgroundColor }}>
<Text style={{ fontSize: 20, textAlign: 'center', color: props.textColor }} >Hello</Text>
</View>
)
import { Text, View } from 'react-native';
import { Button } from "react-native-paper";
import { useDispatch } from "react-redux";
import { unsetUserToken } from "../state/UserSlice";
const HomeView = () => {
const { colors } = useTheme();
const dispatch = useDispatch();
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} />
<Text style={{ textAlign: "center" }}>This is the Home Screen</Text>
<Button onPress={() => dispatch(unsetUserToken())}>Log out</Button>
</View>
);
}
export default HomeView;