From a2ca7db052c0ce20b404f6f81b691850b3318b97 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Wed, 13 Mar 2024 14:33:54 +0000 Subject: mobile: Optimistic UI updates on actions --- packages/mobile/components/ui/ActionButton.tsx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 packages/mobile/components/ui/ActionButton.tsx (limited to 'packages/mobile/components/ui/ActionButton.tsx') diff --git a/packages/mobile/components/ui/ActionButton.tsx b/packages/mobile/components/ui/ActionButton.tsx new file mode 100644 index 00000000..c51eb332 --- /dev/null +++ b/packages/mobile/components/ui/ActionButton.tsx @@ -0,0 +1,21 @@ +import { ActivityIndicator, Pressable, PressableProps } from "react-native"; + +export function ActionButton({ + children, + loading, + disabled, + ...props +}: PressableProps & { + loading: boolean; +}) { + if (disabled !== undefined) { + disabled ||= loading; + } else if (loading) { + disabled = true; + } + return ( + + {loading ? : children} + + ); +} -- cgit v1.2.3-70-g09d2