master
1import React, { Component } from 'react';
2import { View } from 'react-native';
3import { Button, Icon, Spinner, Text } from 'native-base';
4import Weight from './weight';
5
6export default class Set extends Component {
7 constructor(props) {
8 super(props);
9 this.state = {
10 actual_repetitions: 0
11 };
12 }
13 render() {
14 return (
15 <Button style={{backgroundColor: this.backgroundColor()}} block info onPress={this.onPress.bind(this)}>
16 {this.state.actual_repetitions} / {this.props.target_repetitions} @ <Weight weight={this.props.target_weight} />
17 </Button>
18 );
19 }
20
21 onPress() {
22 let actual_repetitions = this.isCompleted() ? 0 : this.state.actual_repetitions + 1;
23 this.setState({ actual_repetitions });
24 }
25
26 isCompleted() {
27 console.log([this.state.actual_repetitions, this.props.target_repetitions]);
28 return this.state.actual_repetitions === this.props.target_repetitions;
29 }
30
31 backgroundColor() {
32 if (this.isCompleted()) { return "green"; }
33 return this.props.type == "WarmUpSet" ? "pink" : "blue";
34 }
35}