Commit 5604916

mo khan <mo@mokhan.ca>
2016-12-22 16:40:53
display gravatar.
1 parent a20ddae
Changed files (3)
app/components/workout.js
@@ -24,7 +24,6 @@ export default class Workout extends Component {
   rowHeader() {
     const date = moment(this.props.occurred_at).format('MMM Do YY');
     const text = `${this.props.routine_name} ${this.props.body_weight.amount} lbs ${date}`;
-    console.log(text);
     return text;
   }
 }
app/screens/dashboard-screen.js
@@ -1,4 +1,5 @@
 import React, { Component } from 'react';
+import { View, Image } from 'react-native';
 import { Container, Header, Title, Content, Footer, FooterTab, Button, Icon, Spinner } from 'native-base';
 import ApplicationStorage from '../infrastructure/application-storage';
 import ApplicationComponent from '../components/application-component';
@@ -20,10 +21,14 @@ export default class DashboardScreen extends ApplicationComponent {
 
   render() {
     let content = this.state.isLoading ? <Spinner /> : this.state.workouts.map(workout => <Workout key={workout.id} {...workout} />);
+    let gravatarUri = this.gravatarUri();
     return (
       <Container>
         <Header>
           <Title>Stronglifters {this.props.username}</Title>
+          <Button transparent rounded>
+            <Image source={{uri: gravatarUri}} style={{width: 32, height: 32}} />
+          </Button>
         </Header>
         <Content>
           {content}
@@ -65,9 +70,14 @@ export default class DashboardScreen extends ApplicationComponent {
   }
 
   onLogout() {
-    let storage = new ApplicationStorage();
+    const storage = new ApplicationStorage();
     storage.delete('authentication_token');
     storage.delete('username');
     this.props.navigator.pop();
   }
+
+  gravatarUri() {
+    const secureHost = "https://secure.gravatar.com/avatar";
+    return `${secureHost}/${this.props.gravatar_id}?s=32&d=mm`;
+  }
 }
app/screens/login-screen.js
@@ -20,7 +20,7 @@ export default class LoginScreen extends ApplicationComponent {
 
   componentDidMount() {
     super.componentDidMount();
-    //this.notify({username: 'mokha'}); // TODO:: REMOVE
+    this.notify({username: 'mokha', gravatar_id: '96c04b963c1ab66002bf3455900a2680' }); // TODO:: REMOVE
   }
 
   render() {
@@ -76,7 +76,7 @@ export default class LoginScreen extends ApplicationComponent {
   notify(event) {
     this.setState({isLoading: false});
     this.props.navigator.push({
-      component: DashboardScreen, params: { username: event.username }
+      component: DashboardScreen, params: { ...event }
     });
   }
 }