Wrap error messages in Layout.Center (#7655)

* Added Portal to ErrorMessage to stack it on top of the view

* Changing Portal solution for Layout.Center according to PR suggestion
This commit is contained in:
André Fernandes
2025-02-05 18:12:50 +00:00
committed by GitHub
parent 9433975984
commit 856c799065
+37 -31
View File
@@ -14,6 +14,7 @@ import {useLingui} from '@lingui/react'
import {usePalette} from '#/lib/hooks/usePalette' import {usePalette} from '#/lib/hooks/usePalette'
import {useTheme} from '#/lib/ThemeContext' import {useTheme} from '#/lib/ThemeContext'
import * as Layout from '#/components/Layout'
import {Text} from '../text/Text' import {Text} from '../text/Text'
export function ErrorMessage({ export function ErrorMessage({
@@ -31,39 +32,44 @@ export function ErrorMessage({
const pal = usePalette('error') const pal = usePalette('error')
const {_} = useLingui() const {_} = useLingui()
return ( return (
<View testID="errorMessageView" style={[styles.outer, pal.view, style]}> <Layout.Center>
<View <View testID="errorMessageView" style={[styles.outer, pal.view, style]}>
style={[styles.errorIcon, {backgroundColor: theme.palette.error.icon}]}> <View
<FontAwesomeIcon style={[
icon="exclamation" styles.errorIcon,
style={pal.text as FontAwesomeIconStyle} {backgroundColor: theme.palette.error.icon},
size={16} ]}>
/>
</View>
<Text
type="sm-medium"
style={[styles.message, pal.text]}
numberOfLines={numberOfLines}>
{message}
</Text>
{onPressTryAgain && (
<TouchableOpacity
testID="errorMessageTryAgainButton"
style={styles.btn}
onPress={onPressTryAgain}
accessibilityRole="button"
accessibilityLabel={_(msg`Retry`)}
accessibilityHint={_(
msg`Retries the last action, which errored out`,
)}>
<FontAwesomeIcon <FontAwesomeIcon
icon="arrows-rotate" icon="exclamation"
style={{color: theme.palette.error.icon}} style={pal.text as FontAwesomeIconStyle}
size={18} size={16}
/> />
</TouchableOpacity> </View>
)} <Text
</View> type="sm-medium"
style={[styles.message, pal.text]}
numberOfLines={numberOfLines}>
{message}
</Text>
{onPressTryAgain && (
<TouchableOpacity
testID="errorMessageTryAgainButton"
style={styles.btn}
onPress={onPressTryAgain}
accessibilityRole="button"
accessibilityLabel={_(msg`Retry`)}
accessibilityHint={_(
msg`Retries the last action, which errored out`,
)}>
<FontAwesomeIcon
icon="arrows-rotate"
style={{color: theme.palette.error.icon}}
size={18}
/>
</TouchableOpacity>
)}
</View>
</Layout.Center>
) )
} }