MCPcopy Index your code
hub / github.com/callstack/react-native-paper / BannerExample

Function BannerExample

example/src/Examples/BannerExample.tsx:20–101  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18);
19
20const BannerExample = () => {
21 const [visible, setVisible] = React.useState<boolean>(true);
22 const [useCustomTheme, setUseCustomTheme] = React.useState<boolean>(false);
23 const defaultTheme = useExampleTheme();
24
25 const [height, setHeight] = React.useState(0);
26
27 const handleLayout = ({ nativeEvent }: LayoutChangeEvent) => {
28 const { height: layoutHeight } = nativeEvent.layout;
29 setHeight(layoutHeight);
30 };
31
32 const customTheme = !defaultTheme.isV3
33 ? {
34 ...defaultTheme,
35 colors: {
36 text: MD2Colors.white,
37 surface: MD2Colors.blue200,
38 primary: MD2Colors.purple900,
39 },
40 }
41 : {
42 ...defaultTheme,
43 colors: {
44 onSurface: MD3Colors.tertiary100,
45 elevation: {
46 level1: MD3Colors.tertiary50,
47 },
48 primary: MD3Colors.tertiary10,
49 },
50 };
51
52 return (
53 <>
54 <ScreenWrapper>
55 <View style={[styles.grid, { paddingTop: height }]}>
56 {PHOTOS.map((uri) => (
57 <View key={uri} style={styles.item}>
58 <Image
59 source={{ uri }}
60 style={styles.photo}
61 accessibilityIgnoresInvertColors
62 />
63 </View>
64 ))}
65 </View>
66 </ScreenWrapper>
67 <FAB
68 icon="eye"
69 label={visible ? 'Hide banner' : 'Show banner'}
70 style={styles.fab}
71 onPress={() => setVisible(!visible)}
72 />
73 <Banner
74 onLayout={handleLayout}
75 actions={[
76 {
77 label: `Set ${useCustomTheme ? 'default' : 'custom'} theme`,

Callers

nothing calls this directly

Calls 1

useExampleThemeFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…