diff --git a/expo_project/components/SurveyHeader.js b/expo_project/components/SurveyHeader.js new file mode 100644 index 0000000..182b182 --- /dev/null +++ b/expo_project/components/SurveyHeader.js @@ -0,0 +1,50 @@ +import React from "react"; +import { Text, StyleSheet } from "react-native"; +import Theme from "../constants/Theme"; +import moment from "moment"; + +// TODO: verify that all surveys are the same length +const SURVEY_LENGTH_MS = 600000; // 10 minutes + +class SurveyHeader extends React.Component { + constructor(props) { + super(props); + this.state = { + timer: SURVEY_LENGTH_MS + }; + } + + componentDidMount() { + this.interval = setInterval( + () => this.setState({ timer: this.state.timer - 1000 }), + 1000 + ); + } + + componentWillUnmount() { + clearInterval(this.interval); + } + + render() { + const { timer } = this.state; + // for flat numbers (e.g. 60000) seconds = 0, but we want to render "00" + const seconds = moment.duration(timer).seconds() || "00"; + const minutes = moment.duration(timer).minutes() || "00"; + return ( + + {minutes}:{seconds} + + ); + } +} + +const styles = StyleSheet.create({ + text: { + color: "#fff", + fontWeight: "600", + fontSize: 24, + fontFamily: Theme.fonts.medium + } +}); + +export default SurveyHeader; diff --git a/expo_project/navigation/AppNavigator.js b/expo_project/navigation/AppNavigator.js index 2383fd0..4caed4b 100644 --- a/expo_project/navigation/AppNavigator.js +++ b/expo_project/navigation/AppNavigator.js @@ -1,5 +1,4 @@ import { createStackNavigator, createSwitchNavigator } from "react-navigation"; -import colors from "../constants/Colors"; import Theme from "../constants/Theme"; import AuthScreen from "../screens/AuthScreen"; import AuthLoadingScreen from "../screens/AuthLoadingScreen"; @@ -10,7 +9,7 @@ import PrivacyScreen from "../screens/PrivacyScreen"; const navigationOptions = { headerStyle: { - backgroundColor: colors.colorPrimary + backgroundColor: Theme.colors.primary }, headerTintColor: "#fff", headerTitleStyle: { diff --git a/expo_project/screens/SurveyScreen.js b/expo_project/screens/SurveyScreen.js index 7263a00..7d86a26 100644 --- a/expo_project/screens/SurveyScreen.js +++ b/expo_project/screens/SurveyScreen.js @@ -1,3 +1,4 @@ +import { Icon } from "expo"; import React from "react"; import { Animated, @@ -8,7 +9,7 @@ import { View, TouchableOpacity } from "react-native"; -import { Button } from "react-native-paper"; +import { Button, Paragraph } from "react-native-paper"; import { withNavigation } from "react-navigation"; import * as _ from "lodash"; import moment from "moment"; @@ -19,11 +20,13 @@ import { iconColors } from "../constants/Colors"; import Layout from "../constants/Layout"; import firebase from "../lib/firebaseSingleton"; +import SurveyHeader from "../components/SurveyHeader"; + // TODO (Ananta): shouold be dynamically set -const INITIAL_DRAWER_TRANSLATE_Y = Layout.drawer.height; const MIN_DRAWER_TRANSLATE_Y = 0; const MID_DRAWER_TRANSLATE_Y = Layout.drawer.height - 300; -const MAX_DRAWER_TRANSLATE_Y = Layout.drawer.height - 95; // mostly collapsed, with just the header peaking out +const MAX_DRAWER_TRANSLATE_Y = Layout.drawer.height - 100; // mostly collapsed, with just the header peaking out +const INITIAL_DRAWER_TRANSLATE_Y = MAX_DRAWER_TRANSLATE_Y; function _markerToDataPoint(marker) { const dataPoint = {}; @@ -55,9 +58,26 @@ class Indicator extends React.Component { } } +class Instructions extends React.Component { + render() { + return ( + + + + + + + Hold down your finger on the map to create a new marker + + + + ); + } +} + class SurveyScreen extends React.Component { static navigationOptions = { - title: "Long press map to add a pin" + headerTitle: }; constructor(props) { @@ -347,11 +367,15 @@ class SurveyScreen extends React.Component { > - + {activeMarkerId ? ( + + ) : ( + + )} {activeMarker && (