Files
circle-collect/src/components/CustomButton.tsx
T
2025-10-01 15:43:42 +05:30

53 lines
1.1 KiB
TypeScript

import React from "react";
import { TouchableOpacity, Text, StyleSheet, ActivityIndicator, ViewStyle } from "react-native";
import colors from "./colors";
type CustomButtonProps = {
title: string;
onPress: () => void;
backgroundColor?: string;
textColor?: string;
loading?: boolean;
style?: ViewStyle;
};
export default function CustomButton({
title,
onPress,
backgroundColor = colors.pastelGreen,
textColor = colors.textDark,
loading = false,
style,
}: CustomButtonProps) {
return (
<TouchableOpacity
style={[styles.button, { backgroundColor }, style]}
onPress={onPress}
disabled={loading}
activeOpacity={0.8}
>
{loading ? (
<ActivityIndicator color={textColor} />
) : (
<Text style={[styles.text, { color: textColor }]}>{title}</Text>
)}
</TouchableOpacity>
);
}
const styles = StyleSheet.create({
button: {
elevation:5,
paddingVertical: 16,
paddingHorizontal: 20,
borderRadius: 12,
alignItems: "center",
justifyContent: "center",
marginVertical: 5,
},
text: {
fontSize: 16,
fontWeight: "bold",
},
});