Commit 305fd69

mo khan <mo@mokhan.ca>
2016-12-25 18:42:24
publish event to fetch next workout.
1 parent 41893fb
Changed files (3)
app/screens/login-screen.js
@@ -33,8 +33,7 @@ export default class LoginScreen extends Screen {
           <Spinner />
         </Content>
       );
-    }
-    else {
+    } else {
       return (
         <Content>
           <List>
app/screens/new-workout-screen.js
@@ -1,17 +1,39 @@
 import React, { Component } from 'react';
-import { View, Image } from 'react-native';
 import { Container, Header, Title, Content, Footer, FooterTab, Button, Icon, Spinner, DeckSwiper, Text } from 'native-base';
 import Screen from './screen';
 import * as events from '../services/events';
 
 export default class NewWorkoutScreen extends Screen {
+  constructor(props) {
+    super(props);
+    this.state = {
+      isLoading: false,
+      eventsOfInterest: [ events.FETCHED_NEW_WORKOUT ]
+    };
+  }
+
+  componentDidMount() {
+    super.componentDidMount();
+    this.publish(events.FETCH_NEW_WORKOUT);
+    this.setState({ isLoading: true });
+  }
+
   render() {
-    return (
-      <Container>
-        <Content>
-          <Text>Yo!</Text>
-        </Content>
-      </Container>
-    );
+    if (this.state.isLoading) {
+      console.log("loading...");
+      return (
+        <Container>
+          <Spinner />
+        </Container>
+      );
+    } else {
+      return (
+        <Container>
+          <Content>
+            <Text>Hello!</Text>
+          </Content>
+        </Container>
+      );
+    }
   }
 }
app/services/events.js
@@ -3,3 +3,5 @@ export const LOGGED_IN = 'LOGGED_IN';
 export const LOGOUT = 'LOGOUT';
 export const FETCH_WORKOUTS = 'FETCH_WORKOUTS';
 export const FETCHED_WORKOUTS = 'FETCHED_WORKOUTS';
+export const FETCH_NEW_WORKOUT = 'FETCH_NEW_WORKOUT';
+export const FETCHED_NEW_WORKOUT = 'FETCHED_NEW_WORKOUT';