aboutsummaryrefslogtreecommitdiff
path: root/src/components/common/TaggRadioButton.tsx
blob: 3cc2780c6ca1d4c1cbd4aa47b3eebc5ac3acc843 (plain)
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
import React from 'react';
import {
  GestureResponderEvent,
  StyleSheet,
  TouchableOpacity,
  View,
} from 'react-native';
import {RADIO_BUTTON_GREY, TAGG_LIGHT_BLUE_2} from '../../constants/constants';

interface TaggRadioButtonProps {
  pressed: boolean;
  onPress: (event: GestureResponderEvent) => void;
}
const TaggRadioButton: React.FC<TaggRadioButtonProps> = ({
  pressed,
  onPress,
}) => {
  const activeOuterStyle = {
    borderColor: pressed ? TAGG_LIGHT_BLUE_2 : RADIO_BUTTON_GREY,
  };

  const activeInnerStyle = {
    backgroundColor: pressed ? TAGG_LIGHT_BLUE_2 : 'white',
  };
  return (
    <TouchableOpacity
      style={[styles.outer, activeOuterStyle]}
      onPress={onPress}>
      {pressed && <View style={[styles.inner, activeInnerStyle]} />}
    </TouchableOpacity>
  );
};

const styles = StyleSheet.create({
  outer: {
    width: 20,
    height: 20,
    borderWidth: 1.5,
    borderRadius: 20,

    backgroundColor: 'white',
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'center',
  },
  inner: {
    width: 14,
    height: 14,
    borderRadius: 8,
  },
});

export default TaggRadioButton;