aboutsummaryrefslogtreecommitdiff
path: root/src/components/common/TaggSquareButton.tsx
blob: 1a1c33b33f0ba97b0de183a1b48a7729c3401295 (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import React from 'react';
import {
  GestureResponderEvent,
  StyleSheet,
  Text,
  TextStyle,
  TouchableOpacity,
  ViewProps,
  ViewStyle,
} from 'react-native';
import LinearGradient from 'react-native-linear-gradient';
import {
  BACKGROUND_GRADIENT_MAP,
  TAGG_LIGHT_BLUE,
  TAGG_PURPLE,
} from '../../constants';
import {normalize, SCREEN_WIDTH} from '../../utils';
interface TaggSquareButtonProps extends ViewProps {
  onPress: (event: GestureResponderEvent) => void;
  title: string;
  buttonStyle: 'normal' | 'large' | 'gradient';
  buttonColor: 'purple' | 'white' | 'blue';
  labelColor: 'white' | 'blue';
  style?: ViewStyle;
  labelStyle?: TextStyle;
}

const TaggSquareButton: React.FC<TaggSquareButtonProps> = (props) => {
  const buttonColor = (() => {
    switch (props.buttonColor) {
      case 'purple':
        return {backgroundColor: TAGG_PURPLE};
      case 'blue':
        return {backgroundColor: TAGG_LIGHT_BLUE};
      case 'white':
      default:
        return {backgroundColor: 'white'};
    }
  })();
  const labelColor = (() => {
    switch (props.labelColor) {
      case 'white':
        return {color: 'white'};
      case 'blue':
      default:
        return {color: '#78A0EF'};
    }
  })();
  switch (props.buttonStyle) {
    case 'large':
      return (
        <TouchableOpacity
          onPress={props.onPress}
          style={[styles.largeButton, buttonColor, props.style]}>
          <Text style={[styles.largeLabel, labelColor, props.labelStyle]}>
            {props.title}
          </Text>
        </TouchableOpacity>
      );
    case 'gradient':
      return (
        <TouchableOpacity onPress={props.onPress} style={props.style}>
          <LinearGradient
            style={styles.gradientButton}
            colors={BACKGROUND_GRADIENT_MAP[0]}
            useAngle
            angle={90}>
            <Text style={[styles.gradientLabel, props.labelStyle]}>
              {props.title}
            </Text>
          </LinearGradient>
        </TouchableOpacity>
      );
    case 'normal':
    default:
      return (
        <TouchableOpacity
          onPress={props.onPress}
          style={[styles.normalButton, buttonColor, props.style]}>
          <Text style={[styles.normalLabel, labelColor, props.labelStyle]}>
            {props.title}
          </Text>
        </TouchableOpacity>
      );
  }
};

const styles = StyleSheet.create({
  largeButton: {
    justifyContent: 'center',
    alignItems: 'center',
    width: '70%',
    height: '10%',
    borderRadius: 5,
  },
  largeLabel: {
    fontSize: normalize(26),
    fontWeight: '500',
    color: '#eee',
  },
  normalButton: {
    justifyContent: 'center',
    alignItems: 'center',
    width: SCREEN_WIDTH * 0.45,
    aspectRatio: 3.7,
    borderRadius: 5,
    marginBottom: '5%',
  },
  normalLabel: {
    fontSize: normalize(20),
    fontWeight: '500',
  },
  gradientButton: {
    marginTop: '8%',
    borderRadius: 5,
    paddingVertical: '5%',
    aspectRatio: 3.3,
    elevation: 2,
    backgroundColor: '#2196F3',
  },
  gradientLabel: {
    color: 'white',
    fontWeight: '600',
    textAlign: 'center',
    fontSize: normalize(17),
  },
});

export default TaggSquareButton;