Repository navigation
Expand file tree
/
Copy pathApp.js
More file actions
110 lines (103 loc) · 2.98 KB
/
Copy pathApp.js
File metadata and controls
110 lines (103 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/**
* react-native-aad-b2c-sample
* https://github.com/michaelburch/react-native-aad-b2c-sample
*
* This is a sample implementation of ad-b2c-react-native that connects
* a React Native app to Azure AD B2C for social login
* https://github.com/GSingh01/ad-b2c-react-native
*/
import React from 'react';
import {SafeAreaView, StyleSheet, Text} from 'react-native';
import Login from './Login';
import Logout from './Logout';
import Home from './Home';
import {NavigationContainer, DarkTheme} from '@react-navigation/native';
import {createStackNavigator} from '@react-navigation/stack';
const Stack = createStackNavigator();
class App extends React.Component {
constructor() {
super();
this.state = {
authenticated: false,
};
}
setAuthenticated = (authenticated) => {
this.setState({
authenticated: authenticated,
});
};
render() {
return (
<SafeAreaView style={styles.scrollView}>
<Text style={styles.bodyText}>react-native-aad-b2c-sample</Text>
<NavigationContainer theme={DarkTheme}>
<Stack.Navigator>
{
// Render different stacks based on authentication status
!this.state.authenticated ? (
<>
<Stack.Screen
name="Login"
options={{
headerShown: true,
animationEnabled: false,
}}
children={(props) => (
<Login
setAuthenticated={this.setAuthenticated}
{...props}
/>
)}
/>
</>
) : (
<>
<Stack.Screen
name="Home"
component={Home}
options={{
headerShown: true,
animationEnabled: false,
cardStyle: {
backgroundColor: 'black',
},
}}
/>
<Stack.Screen
name="Logout"
options={{
headerShown: true,
animationEnabled: false,
cardStyle: {
backgroundColor: 'black',
},
}}
children={(props) => (
<Logout
setAuthenticated={this.setAuthenticated}
{...props}
/>
)}
/>
</>
)
}
</Stack.Navigator>
</NavigationContainer>
</SafeAreaView>
);
}
}
const styles = StyleSheet.create({
scrollView: {
flex: 1,
backgroundColor: 'black',
},
bodyText: {
color: 'white',
alignSelf: 'center',
padding: 5,
fontSize: 18,
},
});
export default App;