import React, { useMemo } from 'react'; import { StyleSheet, Text, TouchableOpacity } from 'react-native'; import { useTheme } from '../../contexts/themeContext/ThemeContext'; import { useTranslationContext } from '../../contexts/translationContext/TranslationContext'; import { primitives } from '../../theme'; type LoadingErrorWrapperProps = { text: string; onPress?: () => void; }; const LoadingErrorWrapper = (props: React.PropsWithChildren) => { const { children, onPress, text } = props; const styles = useStyles(); return ( {text} {children} ); }; export type LoadingErrorProps = { error?: boolean | Error; listType?: 'channel' | 'message' | 'default'; loadNextPage?: () => Promise; retry?: () => void; }; export const LoadingErrorIndicator = (props: LoadingErrorProps) => { const { listType, retry = () => null } = props; const { t } = useTranslationContext(); const styles = useStyles(); switch (listType) { case 'channel': return ( ); case 'message': return ( ); default: return ; } }; LoadingErrorIndicator.displayName = 'LoadingErrorIndicator{loadingErrorIndicator}'; const useStyles = () => { const { theme: { loadingErrorIndicator: { errorText, retryText, container }, semantics, }, } = useTheme(); return useMemo(() => { return StyleSheet.create({ container: { alignItems: 'center', height: '100%', justifyContent: 'center', width: '100%', ...container, }, errorText: { color: semantics.accentError, fontSize: primitives.typographyFontSizeMd, lineHeight: primitives.typographyLineHeightNormal, fontWeight: primitives.typographyFontWeightSemiBold, paddingVertical: primitives.spacingSm, ...errorText, }, retryText: { color: semantics.textPrimary, fontSize: primitives.typographyFontSizeLg, lineHeight: primitives.typographyLineHeightNormal, fontWeight: primitives.typographyFontWeightSemiBold, ...retryText, }, }); }, [container, semantics.accentError, semantics.textPrimary, errorText, retryText]); };