-
-
Notifications
You must be signed in to change notification settings - Fork 106
/
Copy pathCounter.js
56 lines (48 loc) · 1.24 KB
/
Counter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* @providesModule Counter
*/
import React from 'react';
import {
Text,
View
} from 'react-native'
import styles from './components/theme'
import Button from './components/button'
import AnimateNumber from 'react-native-animate-number'
export default class Counter extends React.Component {
state = {
value: 1000
}
render() {
return <View style={styles.container}>
<AnimateNumber
interval='10'
timing='easeIn'
value={this.state.value}
style={[styles.customFont, styles.header]}
formatter={(val) => {
return parseFloat(val).toFixed(2);
}}
/>
<View style={styles.groupButton}>
<Button onPress={() => this.incrementValue()} theme='dark'>
Increment
</Button>
<Button onPress={() => this.decrementValue()} theme='light'>
Decrement
</Button>
</View>
<Text style={[styles.customFont, styles.normal]}>Open up main.js to start working on your app!</Text>
</View>
}
decrementValue() {
this.setState({
value: this.state.value - Math.floor(Math.random() * 200)
})
}
incrementValue() {
this.setState({
value: this.state.value + Math.floor(Math.random() * 200)
})
}
}