Skip to content

Commit

Permalink
adding ImageBackground Example
Browse files Browse the repository at this point in the history
  • Loading branch information
fabOnReact committed Jul 22, 2022
1 parent e643576 commit 365b3d3
Showing 1 changed file with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type {PressEvent} from 'react-native/Libraries/Types/CoreEventTypes';

const React = require('react');
const {
ImageBackground,
AccessibilityInfo,
TextInput,
Button,
Expand Down Expand Up @@ -67,6 +68,21 @@ const styles = StyleSheet.create({
flexDirection: 'column',
justifyContent: 'space-between',
},
container: {
flex: 1,
},
ImageBackground: {
flex: 1,
justifyContent: 'center',
},
text: {
color: 'white',
fontSize: 20,
lineHeight: 84,
fontWeight: 'bold',
textAlign: 'center',
backgroundColor: '#000000c0',
},
});

class AccessibilityExample extends React.Component<{}> {
Expand Down Expand Up @@ -1035,6 +1051,37 @@ class EnabledExamples extends React.Component<{}> {
}
}

class ImportantForAccessibility extends React.Component<{}> {
render(): React.Node {
return (
<View>
<RNTesterBlock title="no-hide-descendants with ImageBackground">
<View style={styles.container}>
<ImageBackground
importantForAccessibility="no-hide-descendants"
source={require('../../assets/trees.jpg')}
resizeMode="cover"
style={styles.ImageBackground}>
<Text style={styles.text}>not accessible</Text>
</ImageBackground>
</View>
</RNTesterBlock>
<RNTesterBlock title="no with ImageBackground">
<View style={styles.container}>
<ImageBackground
importantForAccessibility="no"
source={require('../../assets/trees.jpg')}
resizeMode="cover"
style={styles.ImageBackground}>
<Text style={styles.text}>accessible</Text>
</ImageBackground>
</View>
</RNTesterBlock>
</View>
);
}
}

class EnabledExample extends React.Component<
{
eventListener:
Expand Down Expand Up @@ -1240,6 +1287,12 @@ exports.examples = [
return <EnabledExamples />;
},
},
{
title: 'Testing importantForAccessibility',
render(): React.Element<typeof EnabledExamples> {
return <ImportantForAccessibility />;
},
},
{
title:
'Check if accessibilityState disabled is announced when the screenreader focus moves on the image',
Expand Down

0 comments on commit 365b3d3

Please sign in to comment.