Commit 8ab07c8

mo khan <mo@mokhan.ca>
2016-12-17 19:49:46
add history button and hide warm up sets.
1 parent 97a0203
Changed files (2)
app/components/exercise.js
@@ -6,12 +6,17 @@ export default class Exercise extends Component {
     return (
       <CardItem>
         <Text>{this.props.name}</Text>
-        {this.props.sets.map((set) => <CardItem key={set.id}><Text>{this.summaryFor(set)}</Text></CardItem>)}
+        {this.workSets().map((set) => <CardItem key={set.id}><Text note>{this.summaryFor(set)}</Text></CardItem>)}
       </CardItem>
     );
   }
 
+  workSets() {
+    return this.props.sets.filter((set) => set.type == "WorkSet");
+  }
+
   summaryFor(set) {
-    return `${set.type} ${set.actual_repetitions}/${set.target_repetitions} @ ${set.target_weight}`;
+    let actual_repetitions = set.actual_repetitions || 0;
+    return `${actual_repetitions}/${set.target_repetitions} @ ${set.target_weight}`;
   }
 }
app/screens/dashboard-screen.js
@@ -15,7 +15,7 @@ export default class DashboardScreen extends ApplicationComponent {
 
   componentDidMount() {
     super.componentDidMount();
-    this.publish({event: 'FETCH_WORKOUTS'});
+    this.onLoadHistory();
   }
 
   render() {
@@ -29,11 +29,14 @@ export default class DashboardScreen extends ApplicationComponent {
         </Content>
         <Footer>
           <FooterTab>
+            <Button transparent active onPress={this.onLoadHistory.bind(this)}>
+              <Icon name='ios-apps-outline' />
+            </Button>
             <Button transparent onPress={this.onStartWorkout.bind(this)}>
-              <Icon name='ios-call' />
+              <Icon name='ios-camera-outline' />
             </Button>
             <Button transparent onPress={this.onLogout.bind(this)}>
-              <Icon name='ios-call' />
+              <Icon name='ios-compass' />
             </Button>
           </FooterTab>
         </Footer>
@@ -41,6 +44,10 @@ export default class DashboardScreen extends ApplicationComponent {
     );
   }
 
+  onLoadHistory() {
+    this.publish({event: 'FETCH_WORKOUTS'});
+  }
+
   notify(event) {
     switch(event.event) {
       case "FETCHED_WORKOUTS":