Banned stack screen

This commit is contained in:
Romain CLEMENT 2023-04-09 22:30:47 +02:00
parent 07e4984fef
commit 18a8fd1e79
4 changed files with 21 additions and 11 deletions

View File

@ -39,7 +39,7 @@ class App extends React.Component<any, any> {
}
store.subscribe(() => {
console.log("see a dispatch");
this.setState({ token: store.getState().userReducer.token})
this.setState({ token: store.getState().userReducer.token });
});
}
@ -69,13 +69,26 @@ class App extends React.Component<any, any> {
console.log("render app", store.getState());
console.log("app state", this.state);
return <NavigationContainer>
<Stack.Navigator>{
<Tab.Navigator>{
this.state.token === ""
?
<Stack.Screen component={this.Auth} name="Authentication" options={{ title: "Authentification" }} />
////////////////////////////////////////////////////////////
<>
<Tab.Screen children={() => <SignIn store={store} />} name="Login" options={{ title: 'Connexion' }} />
<Tab.Screen children={() => <SignUp store={store} />} name="Register" options={{ title: 'Créer un compte' }} />
</>
:
<Stack.Screen component={this.Clip} name="Clipboards" options={{ title: 'Presse papiers' }} />
}</Stack.Navigator>
////////////////////////////////////////////////////////////
<>
<Tab.Screen name="Local" options={{ title: 'local' }}>
{(props) => <ClipViewLocal store={store} navigation={props.navigation} type={"local"} />}
</Tab.Screen>
<Tab.Screen name="Remote" options={{ title: 'distant' }}>
{(props) => <ClipViewRemote store={store} navigation={props.navigation} type={"remote"} />}
</Tab.Screen>
</>
////////////////////////////////////////////////////////////
}</Tab.Navigator>
</NavigationContainer>
};
}

View File

@ -22,7 +22,6 @@ export default class SignIn extends React.Component<any, any> {
);
const signInJson = await signInResponse.json();
if (signInJson.status === "ok") {
console.log(this.props.store);
this.props.store.dispatch(setUser(signInJson.token, this.state.username));
} else console.log(signInJson);
}
@ -38,7 +37,7 @@ export default class SignIn extends React.Component<any, any> {
render(): React.ReactNode {
return (
<View>
<Text>Connexion</Text>
<Text style={{ fontWeight: 'bold', fontSize: 30, margin: 20 }}>Connexion</Text>
<TextInput placeholder="Nom d'utilisateur" value={this.state.username} onChange={this.updateUsername}/>
<TextInput placeholder="Mot de Passe" value={this.state.password} onChange={this.updatePassword}/>
<Button title="Se connecter" onPress={this.signInFunction} />

View File

@ -30,7 +30,6 @@ export default class SignUp extends React.Component<any, any> {
);
const signInJson = await signInResponse.json();
if (signInJson.status === "ok") {
console.log(this.props.store);
this.props.store.dispatch(setUser(signInJson.token, this.state.username));
} else console.log(signInJson);
} else console.log(signUpJson);
@ -47,7 +46,7 @@ export default class SignUp extends React.Component<any, any> {
render(): React.ReactNode {
return (
<View>
<Text>Créer un compte</Text>
<Text style={{ fontWeight: 'bold', fontSize: 30, margin: 20 }}>Créer un compte</Text>
<TextInput placeholder="Nom d'utilisateur" value={this.state.username} onChangeText={this.updateUsername} />
<TextInput placeholder="Mot de Passe" value={this.state.password} onChangeText={this.updatePassword} />
<Button title="S'enregistrer" onPress={this.signUpFunction} />

View File

@ -1,5 +1,5 @@
import React from 'react';
import { Button } from 'react-native';
import { Button, Text } from 'react-native';
import { clearUser } from '../redux/actions';
export default abstract class AClipView extends React.Component<any, any> {
@ -13,7 +13,6 @@ export default abstract class AClipView extends React.Component<any, any> {
getSignOutBtn() {
return <Button title="Sign out" onPress={() => {
console.log("logout");
this.props.store.dispatch(clearUser());
}} />
}