-
Notifications
You must be signed in to change notification settings - Fork 0
/
ButtonCounter.js
65 lines (59 loc) · 1.63 KB
/
ButtonCounter.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
57
58
59
60
61
62
63
64
65
import React from "react";
import { Pressable, Text, StyleSheet,View } from "react-native";
const ButtonCounter= (props) => {
return(
<View>
<Pressable
style={(props.text=="+")? additiveButton : (props.count==0)? disableButton : reducerButton}
onPress={() => {
if (props.text=="+"){
props.onCountPress(props.count + 1)
}
else if(props.text=="-" && props.count!=0) {
props.onCountPress(props.count - 1)
}
}}
>
<Text style={styles.textButton}>{props.text}</Text>
</Pressable>
</View>
)
}
const styles=StyleSheet.create({
reducerButton:{
borderRadius:30,
backgroundColor: '#FF5252',
alignItems: 'center',
justifyContent: 'center',
borderWidth:2,
width: 60,
height:60,
borderColor: '#e7e7e7'
},
additiveButton:{
borderRadius:30,
backgroundColor: '#4CAF50',
alignItems: 'center',
justifyContent: 'center',
borderWidth:2,
width: 60,
height:60,
borderColor: '#e7e7e7'
},
textButton:{
fontSize:40,
color: '#fff'
},
disableButton:{
backgroundColor: 'rgba(255, 82, 82, 0.6)',
borderRadius: 30,
borderWidth: 2,
borderColor: '#e7e7e7',
height: 60,
width: 60,
justifyContent: 'center',
alignItems: 'center'
}
})
const {reducerButton, additiveButton, textButton, disableButton}=styles;
export default ButtonCounter;