diff options
author | Samuel Newman <mozzius@protonmail.com> | 2024-08-10 00:49:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-10 00:49:11 +0100 |
commit | c2131bb0392487f11b0c31fe68fdd3e847d62142 (patch) | |
tree | 65e926fb03c4921338343e6205a5270c3e674d13 /src/view/com/util/post-embeds/VideoEmbedInner/VideoFallback.tsx | |
parent | ab0da7c892ce7532840417b89a42302ab9db7018 (diff) | |
download | voidsky-c2131bb0392487f11b0c31fe68fdd3e847d62142.tar.zst |
[Videos] Add error boundary to native (#4914)
* move error fallback to own component * use error boundary on native --------- Co-authored-by: Samuel Newman <10959775+mozzius@users.noreply.github.com>
Diffstat (limited to 'src/view/com/util/post-embeds/VideoEmbedInner/VideoFallback.tsx')
-rw-r--r-- | src/view/com/util/post-embeds/VideoEmbedInner/VideoFallback.tsx | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/view/com/util/post-embeds/VideoEmbedInner/VideoFallback.tsx b/src/view/com/util/post-embeds/VideoEmbedInner/VideoFallback.tsx new file mode 100644 index 000000000..1b46163cc --- /dev/null +++ b/src/view/com/util/post-embeds/VideoEmbedInner/VideoFallback.tsx @@ -0,0 +1,61 @@ +import React from 'react' +import {View} from 'react-native' +import {msg, Trans} from '@lingui/macro' +import {useLingui} from '@lingui/react' + +import {atoms as a, useTheme} from '#/alf' +import {Button, ButtonText} from '#/components/Button' +import {Text as TypoText} from '#/components/Typography' + +export function Container({children}: {children: React.ReactNode}) { + const t = useTheme() + return ( + <View + style={[ + a.flex_1, + t.atoms.bg_contrast_25, + a.justify_center, + a.align_center, + a.px_lg, + a.border, + t.atoms.border_contrast_low, + a.rounded_sm, + a.gap_lg, + ]}> + {children} + </View> + ) +} + +export function Text({children}: {children: React.ReactNode}) { + const t = useTheme() + return ( + <TypoText + style={[ + a.text_center, + t.atoms.text_contrast_high, + a.text_md, + a.leading_snug, + {maxWidth: 300}, + ]}> + {children} + </TypoText> + ) +} + +export function RetryButton({onPress}: {onPress: () => void}) { + const {_} = useLingui() + + return ( + <Button + onPress={onPress} + size="small" + color="secondary_inverted" + variant="solid" + label={_(msg`Retry`)}> + <ButtonText> + <Trans>Retry</Trans> + </ButtonText> + </Button> + ) +} |