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(() => { store.subscribe(() => {
console.log("see a dispatch"); 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("render app", store.getState());
console.log("app state", this.state); console.log("app state", this.state);
return <NavigationContainer> return <NavigationContainer>
<Stack.Navigator>{ <Tab.Navigator>{
this.state.token === "" 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> </NavigationContainer>
}; };
} }

View File

@ -22,7 +22,6 @@ export default class SignIn extends React.Component<any, any> {
); );
const signInJson = await signInResponse.json(); const signInJson = await signInResponse.json();
if (signInJson.status === "ok") { if (signInJson.status === "ok") {
console.log(this.props.store);
this.props.store.dispatch(setUser(signInJson.token, this.state.username)); this.props.store.dispatch(setUser(signInJson.token, this.state.username));
} else console.log(signInJson); } else console.log(signInJson);
} }
@ -38,7 +37,7 @@ export default class SignIn extends React.Component<any, any> {
render(): React.ReactNode { render(): React.ReactNode {
return ( return (
<View> <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="Nom d'utilisateur" value={this.state.username} onChange={this.updateUsername}/>
<TextInput placeholder="Mot de Passe" value={this.state.password} onChange={this.updatePassword}/> <TextInput placeholder="Mot de Passe" value={this.state.password} onChange={this.updatePassword}/>
<Button title="Se connecter" onPress={this.signInFunction} /> <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(); const signInJson = await signInResponse.json();
if (signInJson.status === "ok") { if (signInJson.status === "ok") {
console.log(this.props.store);
this.props.store.dispatch(setUser(signInJson.token, this.state.username)); this.props.store.dispatch(setUser(signInJson.token, this.state.username));
} else console.log(signInJson); } else console.log(signInJson);
} else console.log(signUpJson); } else console.log(signUpJson);
@ -47,7 +46,7 @@ export default class SignUp extends React.Component<any, any> {
render(): React.ReactNode { render(): React.ReactNode {
return ( return (
<View> <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="Nom d'utilisateur" value={this.state.username} onChangeText={this.updateUsername} />
<TextInput placeholder="Mot de Passe" value={this.state.password} onChangeText={this.updatePassword} /> <TextInput placeholder="Mot de Passe" value={this.state.password} onChangeText={this.updatePassword} />
<Button title="S'enregistrer" onPress={this.signUpFunction} /> <Button title="S'enregistrer" onPress={this.signUpFunction} />

View File

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