2024-05-14 23:40:14 +05:30
|
|
|
import { TouchableHighlight, TouchableOpacity, ViewStyle } from "react-native";
|
2024-03-27 20:36:03 +05:30
|
|
|
import { Lottie } from "../../../App/common/constants/StringConstant";
|
|
|
|
|
import { ButtonState } from "../../../App/common/interface/widgets/widgetData/FooterWithCardWidgetData";
|
|
|
|
|
import { LottieFieldData } from "../../../App/common/interface/widgets/widgetData/TitleWidgetData";
|
2024-03-28 12:12:34 +05:30
|
|
|
import { StyledLottie } from "../../widgets/styled-lottie/StyledLottie";
|
2024-03-27 20:36:03 +05:30
|
|
|
import styles from "./CtaButtonStyle";
|
2025-01-13 19:00:56 +05:30
|
|
|
import { Platform } from "react-native";
|
|
|
|
|
import { OsTypeConstants } from "../../../App/common/constants/BuildConfigConstants";
|
2024-03-27 20:36:03 +05:30
|
|
|
|
|
|
|
|
const CtaButton = ({
|
|
|
|
|
onPress,
|
|
|
|
|
style,
|
|
|
|
|
children,
|
|
|
|
|
state,
|
|
|
|
|
}: {
|
|
|
|
|
onPress?: () => void;
|
|
|
|
|
style?: ViewStyle;
|
|
|
|
|
children?: React.ReactNode;
|
|
|
|
|
state?: ButtonState;
|
|
|
|
|
}) => {
|
|
|
|
|
const loaderData: LottieFieldData = {
|
|
|
|
|
url: Lottie.FOOTER_LOADER_URL,
|
|
|
|
|
loop: true,
|
|
|
|
|
lottieStyle: styles.loaderLottieStyle,
|
|
|
|
|
};
|
|
|
|
|
return (
|
2024-05-14 23:40:14 +05:30
|
|
|
<TouchableOpacity
|
2025-01-13 19:00:56 +05:30
|
|
|
activeOpacity={1}
|
2024-03-27 20:36:03 +05:30
|
|
|
onPress={onPress}
|
|
|
|
|
disabled={state === ButtonState.DISABLED || state === ButtonState.LOADING}
|
|
|
|
|
style={[styles.footerButtonContainer, style]}
|
|
|
|
|
>
|
|
|
|
|
{state === ButtonState.LOADING ? (
|
2025-02-12 21:38:48 +05:30
|
|
|
<StyledLottie lottieFieldData={loaderData} />
|
2024-03-27 20:36:03 +05:30
|
|
|
) : (
|
|
|
|
|
children
|
|
|
|
|
)}
|
2024-05-14 23:40:14 +05:30
|
|
|
</TouchableOpacity>
|
2024-03-27 20:36:03 +05:30
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default CtaButton;
|