Skip to content

Instantly share code, notes, and snippets.

View diego3g's full-sized avatar
🚀
Launching a rocket

Diego Fernandes diego3g

🚀
Launching a rocket
View GitHub Profile
@diego3g
diego3g / routes.js
Last active September 11, 2017 17:54
// 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,
// 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>
// 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
// 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 />
// 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);
@diego3g
diego3g / index.js
Last active September 11, 2017 18:15
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,
// 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,
// 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 {
// 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">
@diego3g
diego3g / login.js
Last active September 11, 2017 18:25
// 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>