diff options
| author | mo khan <mo@mokhan.ca> | 2017-01-14 15:37:32 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2017-01-14 15:37:32 -0700 |
| commit | f44e662f08352a38eb542e2c31d92f03696f92ba (patch) | |
| tree | a1c4fa7cfc55324375f11ecad376a37662fdc547 | |
| parent | ff3e3acca888554f1aca390485e5859b7c11145c (diff) | |
| -rw-r--r-- | app/presentation/components/set.js | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/app/presentation/components/set.js b/app/presentation/components/set.js index 9e1c4f2..cd668f4 100644 --- a/app/presentation/components/set.js +++ b/app/presentation/components/set.js @@ -12,9 +12,24 @@ export default class Set extends Component { } render() { return ( - <Button block info> + <Button style={{backgroundColor: this.backgroundColor()}} block info onPress={this.onPress.bind(this)}> {this.state.actual_repetitions} / {this.props.target_repetitions} @ <Weight weight={this.props.target_weight} /> </Button> ); } + + onPress() { + let actual_repetitions = this.isCompleted() ? 0 : this.state.actual_repetitions + 1; + this.setState({ actual_repetitions }); + } + + isCompleted() { + console.log([this.state.actual_repetitions, this.props.target_repetitions]); + return this.state.actual_repetitions === this.props.target_repetitions; + } + + backgroundColor() { + if (this.isCompleted()) { return "green"; } + return this.props.type == "WarmUpSet" ? "pink" : "blue"; + } } |
