From 80edc1a26ab7703dda58e16181346660e42bba70 Mon Sep 17 00:00:00 2001 From: Kaushik Thallapally Date: Mon, 8 Jan 2024 08:05:49 -0800 Subject: [PATCH] feat: added the loading prop to IconButton and updated react native (#4201) --- example/src/Examples/IconButtonExample.tsx | 27 ++++++++++++++++++++++ src/components/IconButton/IconButton.tsx | 13 ++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/example/src/Examples/IconButtonExample.tsx b/example/src/Examples/IconButtonExample.tsx index d3a9b79143..594ad7a32c 100644 --- a/example/src/Examples/IconButtonExample.tsx +++ b/example/src/Examples/IconButtonExample.tsx @@ -18,6 +18,7 @@ const ButtonExample = () => { iconColor={MD2Colors.green500} onPress={() => {}} /> + {}} loading /> {}} /> { {}} /> {}} /> {}} /> + {}} loading /> @@ -62,6 +64,14 @@ const ButtonExample = () => { size={24} onPress={() => {}} /> + {}} + /> @@ -87,6 +97,14 @@ const ButtonExample = () => { size={24} onPress={() => {}} /> + {}} + loading + /> @@ -112,6 +130,14 @@ const ButtonExample = () => { size={24} onPress={() => {}} /> + {}} + loading + /> @@ -139,6 +165,7 @@ const ButtonExample = () => { containerColor={MD3Colors.tertiary60} /> {}} /> + {}} loading /> diff --git a/src/components/IconButton/IconButton.tsx b/src/components/IconButton/IconButton.tsx index 9aa4f7a929..84db018d38 100644 --- a/src/components/IconButton/IconButton.tsx +++ b/src/components/IconButton/IconButton.tsx @@ -13,6 +13,7 @@ import { getIconButtonColor } from './utils'; import { useInternalTheme } from '../../core/theming'; import type { $RemoveChildren, ThemeProp } from '../../types'; import { forwardRef } from '../../utils/forwardRef'; +import ActivityIndicator from '../ActivityIndicator'; import CrossFadeIcon from '../CrossFadeIcon'; import Icon, { IconSource } from '../Icon'; import Surface from '../Surface'; @@ -80,6 +81,11 @@ export type Props = $RemoveChildren & { * @optional */ theme?: ThemeProp; + /** + * @optional + * If true Activity Indicator will appear instead of icon + */ + loading?: boolean; }; /** @@ -121,6 +127,7 @@ const IconButton = forwardRef( style, theme: themeOverrides, testID = 'icon-button', + loading = false, ...rest }: Props, ref @@ -192,7 +199,11 @@ const IconButton = forwardRef( testID={testID} {...rest} > - + {loading ? ( + + ) : ( + + )} );