Skip to content

Commit e614fa7

Browse files
authored
Support passing custom loaderElement to Toast component (#1971)
1 parent 1d36e27 commit e614fa7

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

src/incubator/toast/index.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const Toast = (props: PropsWithChildren<ToastProps>) => {
3232
renderAttachment,
3333
centerMessage,
3434
showLoader,
35+
loaderElement,
3536
action,
3637
swipeable,
3738
backgroundColor,
@@ -123,13 +124,14 @@ const Toast = (props: PropsWithChildren<ToastProps>) => {
123124
// NOTE: order does matter
124125
if (showLoader) {
125126
return (
126-
<ActivityIndicator
127-
size={'small'}
128-
testID={`${testID}-loader`}
129-
color={Colors.rgba(Colors.$backgroundNeutralHeavy, 0.6)}
130-
style={styles.loader}
131-
/>
132-
// <Loader size={Loader.sizes.SMALL} color={loaderColors} style={styles.loader} testID={`${testID}-loader`}/>
127+
loaderElement ?? (
128+
<ActivityIndicator
129+
size={'small'}
130+
testID={`${testID}-loader`}
131+
color={Colors.rgba(Colors.$backgroundNeutralHeavy, 0.6)}
132+
style={styles.loader}
133+
/>
134+
)
133135
);
134136
}
135137

@@ -167,7 +169,9 @@ const Toast = (props: PropsWithChildren<ToastProps>) => {
167169
};
168170

169171
const renderIcon = () => {
170-
return <Icon source={toastPreset.icon} resizeMode={'contain'} style={styles.icon} tintColor={toastPreset.iconColor}/>;
172+
return (
173+
<Icon source={toastPreset.icon} resizeMode={'contain'} style={styles.icon} tintColor={toastPreset.iconColor}/>
174+
);
171175
};
172176

173177
const renderToastContent = () => {

src/incubator/toast/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {ReactElement} from 'react';
12
import {ImageSourcePropType, StyleProp, TextStyle, ViewStyle} from 'react-native';
23
import {ButtonProps} from '../../components/button';
34

@@ -46,6 +47,10 @@ export interface ToastProps {
4647
* should show a loader
4748
*/
4849
showLoader?: boolean;
50+
/**
51+
* should show a loader
52+
*/
53+
loaderElement?: ReactElement;
4954
/**
5055
* callback for dismiss action
5156
*/

0 commit comments

Comments
 (0)