From f44e662f08352a38eb542e2c31d92f03696f92ba Mon Sep 17 00:00:00 2001 From: mo khan Date: Sat, 14 Jan 2017 15:37:32 -0700 Subject: change button state when clicked. --- app/presentation/components/set.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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 ( - ); } + + 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"; + } } -- cgit v1.2.3