aboutsummaryrefslogtreecommitdiff
path: root/src/components/common/BasicButton.tsx
blob: 1fe29cd9724da5c9d51b85ef4f409b35c51ea043 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import React from 'react';
import {StyleProp, StyleSheet, Text, View, ViewStyle} from 'react-native';
import {TAGG_LIGHT_BLUE} from '../../constants';
import {TouchableOpacity} from 'react-native-gesture-handler';
import {normalize} from '../../utils';

interface BasicButtonProps {
  title: string;
  onPress: () => void;
  solid?: boolean;
  externalStyles?: Record<string, StyleProp<ViewStyle>>;
}
const BasicButton: React.FC<BasicButtonProps> = ({
  title,
  onPress,
  solid,
  externalStyles,
}) => {
  return (
    <View style={[styles.container, externalStyles?.container]}>
      <TouchableOpacity
        style={[
          styles.genericButtonStyle,
          solid ? styles.solidButton : styles.outlineButton,
        ]}
        onPress={onPress}>
        <Text
          style={[
            styles.buttonTitle,
            solid
              ? styles.solidButtonTitleColor
              : styles.outlineButtonTitleColor,
          ]}>
          {title}
        </Text>
      </TouchableOpacity>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    height: '100%',
    flexDirection: 'column',
    justifyContent: 'space-around',
  },
  genericButtonStyle: {
    justifyContent: 'center',
    alignItems: 'center',
    borderRadius: 3,
    padding: 0,
    width: '100%',
    height: '100%',
  },
  solidButton: {
    padding: 0,
    backgroundColor: TAGG_LIGHT_BLUE,
  },
  outlineButton: {
    borderWidth: 2,
    backgroundColor: 'white',
    borderColor: TAGG_LIGHT_BLUE,
  },
  solidButtonTitleColor: {
    color: 'white',
  },
  outlineButtonTitleColor: {
    color: TAGG_LIGHT_BLUE,
  },
  buttonTitle: {
    fontSize: normalize(15),
    fontWeight: '700',
    letterSpacing: 1,
  },
});

export default BasicButton;