This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/routes.js | |
import { StackNavigator } from 'react-navigation'; | |
import Login from './pages/login'; | |
import Logged from './pages/logged'; | |
export const SignedOutRoutes = StackNavigator({ | |
Login: { | |
screen: Login, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/pages/login.js | |
import React from "react"; | |
import { View } from "react-native"; | |
import { Card, Button, FormLabel, FormInput } from "react-native-elements"; | |
export default ({ navigation }) => ( | |
<View style={{ paddingVertical: 20 }}> | |
<Card> | |
<FormLabel>E-mail</FormLabel> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/pages/logged.js | |
import React from "react"; | |
import { View } from "react-native"; | |
import { Card, Button, Text } from "react-native-elements"; | |
export default ({ navigation }) => ( | |
<View style={{ paddingVertical: 20 }}> | |
<Card title="John Doe"> | |
<View |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/index.js | |
import React from 'react'; | |
import { View } from 'react-native'; | |
import { SignedOutRoutes, SignedInRoutes } from './routes'; | |
export default class App extends React.Component { | |
render() { | |
return <SignedOutRoutes /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/services/auth.js | |
import { AsyncStorage } from 'react-native'; | |
export const TOKEN_KEY = "@RocketSeat:token"; | |
export const onSignIn = () => AsyncStorage.setItem(TOKEN_KEY, "true"); | |
export const onSignOut = () => AsyncStorage.removeItem(TOKEN_KEY); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { View } from 'react-native'; | |
import { isSignedIn } from "./services/auth"; | |
import { createRootNavigator, SignedOutRoutes, SignedInRoutes } from './routes'; | |
export default class App extends React.Component { | |
state = { | |
signed: false, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/routes.js | |
import { StackNavigator } from 'react-navigation'; | |
import Login from './pages/login'; | |
import Logged from './pages/logged'; | |
export const SignedOutRoutes = StackNavigator({ | |
Login: { | |
screen: Login, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/index.js | |
import React from 'react'; | |
import { View } from 'react-native'; | |
import { isSignedIn } from "./services/auth"; | |
import { createRootNavigator, SignedOutRoutes, SignedInRoutes } from './routes'; | |
export default class App extends React.Component { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/pages/logged.js | |
import React from "react"; | |
import { View } from "react-native"; | |
import { Card, Button, Text } from "react-native-elements"; | |
import { onSignOut } from "../services/auth"; | |
export default ({ navigation }) => ( | |
<View style={{ paddingVertical: 20 }}> | |
<Card title="John Doe"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/pages/login.js | |
import React from "react"; | |
import { View } from "react-native"; | |
import { Card, Button, FormLabel, FormInput } from "react-native-elements"; | |
import { onSignIn } from "../services/auth"; | |
export default ({ navigation }) => ( | |
<View style={{ paddingVertical: 20 }}> | |
<Card> |
OlderNewer