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
|
import * as React from 'react';
import {StyleSheet, Text} from 'react-native';
import {TouchableOpacity} from 'react-native-gesture-handler';
import {TAGG_LIGHT_BLUE} from '../../constants';
import {getToggleButtonText, normalize, SCREEN_WIDTH} from '../../utils';
type ToggleButtonProps = {
toggleState: boolean;
handleToggle: Function;
buttonType: string;
};
const ToggleButton: React.FC<ToggleButtonProps> = ({
toggleState,
handleToggle,
buttonType,
}) => {
const buttonColor = toggleState
? styles.buttonColorToggled
: styles.buttonColor;
const textColor = toggleState ? styles.textColorToggled : styles.textColor;
return (
<TouchableOpacity
style={[styles.button, buttonColor]}
onPress={() => handleToggle()}>
<Text style={[styles.text, textColor]}>
{getToggleButtonText(buttonType, toggleState)}
</Text>
</TouchableOpacity>
);
};
const styles = StyleSheet.create({
button: {
justifyContent: 'center',
alignItems: 'center',
width: SCREEN_WIDTH * 0.42,
height: SCREEN_WIDTH * 0.08,
borderColor: TAGG_LIGHT_BLUE,
borderWidth: 1,
borderRadius: 2,
marginRight: '2%',
},
text: {
fontWeight: '700',
fontSize: normalize(15),
letterSpacing: 1,
},
buttonColor: {
backgroundColor: TAGG_LIGHT_BLUE,
},
textColor: {color: 'white'},
buttonColorToggled: {backgroundColor: 'white'},
textColorToggled: {color: TAGG_LIGHT_BLUE},
});
export default ToggleButton;
|