aboutsummaryrefslogtreecommitdiffstats
path: root/components/RadioButton.js
blob: 4c178e2f3dd6a39a39debde93ed68fe86a63f538 (plain) (blame)
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, View, TouchableOpacity, Text } from "react-native";

export default class RadioButton extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      value: props.value ?? true,
      contStyle: props.style ?? {},
      onClick: props.onClick,
      label: props.label,
    }
  }

  render() {
    return (
      <View style={[this.state.contStyle, styles.contStyle]}>
        <TouchableOpacity style={styles.outer} onPress={this.state.onClick}>
          <View style={this.state.value ? styles.inner : {}}></View>
        </TouchableOpacity>
        <Text style={styles.label}>{this.state.label}</Text>
      </View >
    )
  }
}

const styles = StyleSheet.create({
  contStyle: {
    flexDirection: "row",
    marginTop: 10,
  },
  label: {
    marginLeft: 15,
    marginTop: 3,
    fontSize: 17,
    fontWeight: "bold",
    color: "white",
  },
  outer: {
    borderColor: "#EB1F63",
    borderWidth: 2,
    borderRadius: 20,
    width: 30,
    height: 30,
  },
  inner: {
    borderColor: "#EB1F63",
    borderWidth: 10,
    borderRadius: 20,
    width: 20,
    height: 20,
    top: 3,
    left: 3,
  },
})