This repository has been archived by the owner on Apr 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make survey more user-friendly (#45)
* add instruction to drawer component when not showing form * add a timer to the header
- Loading branch information
1 parent
95e9fd4
commit 79304d7
Showing
3 changed files
with
108 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<Text style={styles.text}> | ||
{minutes}:{seconds} | ||
</Text> | ||
); | ||
} | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
text: { | ||
color: "#fff", | ||
fontWeight: "600", | ||
fontSize: 24, | ||
fontFamily: Theme.fonts.medium | ||
} | ||
}); | ||
|
||
export default SurveyHeader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters