Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 31 additions & 15 deletions src/components/Banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,36 @@ const Banner = ({
Animated.add(position, -1),
layout.height
);

const renderChildrenWithWrapper = () => {
if (typeof children === 'string') {
return (
<Text
style={[
styles.message,
{
color: theme.isV3 ? theme.colors.onSurface : theme.colors.text,
},
]}
accessibilityLiveRegion={visible ? 'polite' : 'none'}
accessibilityRole="alert"
maxFontSizeMultiplier={maxFontSizeMultiplier}
>
{children}
</Text>
);
}
return (
<View
style={styles.content}
accessibilityLiveRegion={visible ? 'polite' : 'none'}
accessibilityRole="alert"
>
{children}
</View>
);
};

return (
<Surface
{...rest}
Expand Down Expand Up @@ -220,21 +250,7 @@ const Banner = ({
<Icon source={icon} size={40} />
</View>
) : null}
<Text
style={[
styles.message,
{
color: theme.isV3
? theme.colors.onSurface
: theme.colors.text,
},
]}
accessibilityLiveRegion={visible ? 'polite' : 'none'}
accessibilityRole="alert"
maxFontSizeMultiplier={maxFontSizeMultiplier}
>
{children}
</Text>
{renderChildrenWithWrapper()}
</View>
<View style={styles.actions}>
{actions.map(({ label, ...others }, i) => (
Expand Down