import React from 'react'; import { View } from 'react-native'; import { conditionChaining } from '@sendbird/uikit-utils'; import Icon from '../../components/Icon'; import Text from '../../components/Text'; import createStyleSheet from '../../styles/createStyleSheet'; import useUIKitTheme from '../../theme/useUIKitTheme'; import Button from '../Button'; import LoadingSpinner from '../LoadingSpinner'; type Props = { loading?: boolean; icon: keyof typeof Icon.Assets; message?: string; errorRetryLabel?: string; onPressRetry?: () => void; }; const Placeholder = ({ icon, loading = false, message = '', errorRetryLabel, onPressRetry }: Props) => { const { colors } = useUIKitTheme(); // loading ? styles.containerLoading : errorRetryLabel ? styles.containerError : styles.container return ( {conditionChaining( [loading], [ , , ], )} {Boolean(message) && !loading && ( {message} )} {Boolean(errorRetryLabel) && !loading && ( )} ); }; const styles = createStyleSheet({ container: { width: 200, height: 100, alignItems: 'center', justifyContent: 'space-between', }, containerError: { width: 200, height: 148, alignItems: 'center', justifyContent: 'space-between', }, containerLoading: { width: 200, height: 100, alignItems: 'center', justifyContent: 'center', }, }); export default Placeholder;