forked from adrianhajdin/uber
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomButton.tsx
More file actions
60 lines (55 loc) · 1.42 KB
/
CustomButton.tsx
File metadata and controls
60 lines (55 loc) · 1.42 KB
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
import { TouchableOpacity, Text } from "react-native";
import { ButtonProps } from "@/types/type";
const getBgVariantStyle = (variant: ButtonProps["bgVariant"]) => {
switch (variant) {
case "secondary":
return "bg-gray-500";
case "danger":
return "bg-red-500";
case "success":
return "bg-green-500";
case "outline":
return "bg-transparent border-neutral-300 border-[0.5px]";
default:
return "bg-[#0286FF]";
}
};
const getTextVariantStyle = (variant: ButtonProps["textVariant"]) => {
switch (variant) {
case "primary":
return "text-black";
case "secondary":
return "text-gray-100";
case "danger":
return "text-red-100";
case "success":
return "text-green-100";
default:
return "text-white";
}
};
const CustomButton = ({
onPress,
title,
bgVariant = "primary",
textVariant = "default",
IconLeft,
IconRight,
className,
...props
}: ButtonProps) => {
return (
<TouchableOpacity
onPress={onPress}
className={`w-full rounded-full p-3 flex flex-row justify-center items-center shadow-md shadow-neutral-400/70 ${getBgVariantStyle(bgVariant)} ${className}`}
{...props}
>
{IconLeft && <IconLeft />}
<Text className={`text-lg font-bold ${getTextVariantStyle(textVariant)}`}>
{title}
</Text>
{IconRight && <IconRight />}
</TouchableOpacity>
);
};
export default CustomButton;