aboutsummaryrefslogtreecommitdiff
path: root/src/components/common/GradientBorderButton.tsx
blob: a5dbde9d2d58164c949f1a417a1c32b6fbfa9c3b (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
import MaskedView from '@react-native-community/masked-view';
import React from 'react';
import {StyleSheet, Text, View} from 'react-native';
import {TouchableOpacity} from 'react-native-gesture-handler';
import LinearGradient from 'react-native-linear-gradient';
import {TAGG_LIGHT_BLUE_2, TAGG_PURPLE} from '../../constants';
import {normalize, SCREEN_WIDTH} from '../../utils';

interface GradientBorderButtonProps {
  text: string;
  darkStyle: boolean;
  onPress: () => void;
}

const GradientBorderButton: React.FC<GradientBorderButtonProps> = ({
  text,
  darkStyle,
  onPress,
}) => {
  const labelColor = darkStyle ? 'white' : '#828282';
  const borderWidth = darkStyle ? 2 : 1;
  return (
    <TouchableOpacity style={styles.container} onPress={onPress}>
      <MaskedView
        maskElement={
          <View
            style={[styles.gradientContainer, styles.maskBorder, {borderWidth}]}
          />
        }>
        <LinearGradient
          colors={[TAGG_PURPLE, TAGG_LIGHT_BLUE_2]}
          start={{x: 0.0, y: 1.0}}
          end={{x: 1.0, y: 1.0}}
          style={styles.gradientContainer}
        />
      </MaskedView>
      <View style={styles.textContainer}>
        <Text style={[styles.label, {color: labelColor}]}>{text}</Text>
      </View>
    </TouchableOpacity>
  );
};
const styles = StyleSheet.create({
  container: {
    marginVertical: 10,
  },
  gradientContainer: {
    width: SCREEN_WIDTH / 2 - 40,
    height: 43,
  },
  label: {
    fontWeight: '500',
    fontSize: normalize(14),
    textAlign: 'center',
  },
  maskBorder: {
    borderRadius: 20,
  },
  textContainer: {
    position: 'absolute',
    width: SCREEN_WIDTH / 2 - 40,
    height: 43,
    justifyContent: 'center',
    alignItems: 'center',
  },
});
export default GradientBorderButton;