├── .gitignore ├── App-Reference ├── auth-flow │ ├── index.js │ └── screens │ │ ├── Home.js │ │ ├── Profile.js │ │ ├── SignIn.js │ │ └── SignUp.js ├── custom-transition │ └── index.js ├── index.js ├── modal-from-tab-bar │ └── index.js ├── react-native-modal │ └── index.js ├── redux-hardware-back-button │ ├── index.js │ └── router.js ├── redux-integration │ ├── index.js │ └── router.js ├── replace-screen │ └── index.js └── stacknavigator-modal │ └── index.js ├── App ├── auth-flow │ ├── index.js │ └── screens │ │ ├── Home.js │ │ ├── Profile.js │ │ ├── SignIn.js │ │ └── SignUp.js ├── custom-screen-interpolator │ └── index.js ├── custom-transition │ └── index.js ├── index.js ├── modal-from-tab-bar │ └── index.js ├── react-native-modal │ └── index.js ├── redux-hardware-back-button │ ├── index.js │ └── router.js ├── redux-integration │ ├── index.js │ └── router.js ├── replace-screen │ └── index.js └── stacknavigator-modal │ └── index.js ├── README.md ├── app.json ├── package.json └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | .expo -------------------------------------------------------------------------------- /App-Reference/auth-flow/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { AsyncStorage, View, Text } from 'react-native'; 3 | import { StackNavigator, TabNavigator } from 'react-navigation'; 4 | import { FontAwesome } from '@expo/vector-icons'; 5 | 6 | import SignUp from './screens/SignUp'; 7 | import SignIn from './screens/SignIn'; 8 | import Home from './screens/Home'; 9 | import Profile from './screens/Profile'; 10 | 11 | const checkAuth = () => { 12 | return new Promise(async (resolve, reject) => { 13 | const isAuthorized = await AsyncStorage.getItem('authorized'); 14 | if (isAuthorized) { 15 | resolve(true); 16 | } else { 17 | resolve(false); 18 | } 19 | }); 20 | } 21 | 22 | const AuthStack = StackNavigator({ 23 | SignUp: { 24 | screen: SignUp, 25 | navigationOptions: { 26 | title: 'Sign Up', 27 | } 28 | }, 29 | SignIn: { 30 | screen: SignIn, 31 | navigationOptions: { 32 | title: 'Sign In', 33 | } 34 | } 35 | }); 36 | 37 | const PrimaryApp = TabNavigator( 38 | { 39 | Home: { 40 | screen: Home, 41 | navigationOptions: { 42 | tabBarLabel: 'Home', 43 | tabBarIcon: ({ tintColor }) => 44 | } 45 | }, 46 | Profile: { 47 | screen: Profile, 48 | navigationOptions: { 49 | tabBarLabel: 'Profile', 50 | tabBarIcon: ({ tintColor }) => 51 | } 52 | } 53 | } 54 | ); 55 | 56 | // NEW CODE 57 | class App extends React.Component { 58 | state = { 59 | isAuthorized: false, 60 | checkingInitialAuth: true, 61 | } 62 | 63 | async componentWillMount() { 64 | const isAuthorized = await checkAuth(); 65 | this.setState({ 66 | isAuthorized, 67 | checkingInitialAuth: false, 68 | }); 69 | } 70 | 71 | signIn = () => { 72 | this.setState({ isAuthorized: true }); 73 | AsyncStorage.setItem('authorized', 'true'); 74 | } 75 | 76 | signOut = () => { 77 | this.setState({ isAuthorized: false }); 78 | AsyncStorage.removeItem('authorized'); 79 | } 80 | 81 | render() { 82 | const { isAuthorized, checkingInitialAuth } = this.state; 83 | if (checkingInitialAuth) { 84 | return ( 85 | 86 | Loading... 87 | 88 | ); 89 | } else if (isAuthorized) { 90 | return ; 91 | } else { 92 | return ; 93 | } 94 | } 95 | } 96 | 97 | export default App; 98 | -------------------------------------------------------------------------------- /App-Reference/auth-flow/screens/Home.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { ScrollView, Text, Linking, View } from "react-native"; 3 | import { Card, Button } from "react-native-elements"; 4 | 5 | const images = [ 6 | { 7 | key: 1, 8 | name: "Nathan Anderson", 9 | url: "https://unsplash.com/photos/C9t94JC4_L8" 10 | }, 11 | { 12 | key: 2, 13 | name: "Jamison McAndie", 14 | url: "https://unsplash.com/photos/waZEHLRP98s" 15 | }, 16 | { 17 | key: 3, 18 | name: "Alberto Restifo", 19 | url: "https://unsplash.com/photos/cFplR9ZGnAk" 20 | }, 21 | { 22 | key: 4, 23 | name: "John Towner", 24 | url: "https://unsplash.com/photos/89PFnHKg8HE" 25 | } 26 | ]; 27 | 28 | export default () => ( 29 | 30 | 31 | {images.map(({ name, image, url, key }) => ( 32 | 33 | 34 | Photo by {name}. 35 | 36 |