From 15fae4815ef7eb8cb40f7e42f4f0c3367de7e7f4 Mon Sep 17 00:00:00 2001 From: G Date: Mon, 9 Sep 2024 09:38:45 +0000 Subject: [PATCH] add a loading props to the button component --- src/components/Button.tsx | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/components/Button.tsx b/src/components/Button.tsx index 47faf3e..f8423d0 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -1,6 +1,6 @@ import type { BoxProps, VariantProps } from "@shopify/restyle"; import type { Theme } from "@themes/Theme"; -import { TouchableOpacity } from "react-native"; +import { ActivityIndicator, TouchableOpacity } from "react-native"; import ButtonBase from "./bases/ButtonBase"; import Text from "./bases/Text"; @@ -9,13 +9,25 @@ type Props = BoxProps & VariantProps & { label: string; onPress: () => void; + isLoading?: boolean; }; -const Button = ({ onPress, label, textVariants, variant, ...rest }: Props) => { +const Button = ({ onPress, label, isLoading, textVariants, variant, ...rest }: Props) => { return ( - - {label} + + {isLoading ? ( + + ) : ( + {label} + )} ); -- libgit2 0.27.1