MCPcopy Create free account
hub / github.com/callstack/react-native-paper / SnackbarExample

Function SnackbarExample

example/src/Examples/SnackbarExample.tsx:14–118  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12 'Snackbar with longer message which does not fit in one line';
13
14const SnackbarExample = () => {
15 const preferences = React.useContext(PreferencesContext);
16 const theme = useExampleTheme();
17
18 const [options, setOptions] = React.useState({
19 showSnackbar: false,
20 showAction: true,
21 showCloseIcon: false,
22 showLongerMessage: false,
23 showLongerAction: false,
24 });
25
26 const {
27 showSnackbar,
28 showAction,
29 showCloseIcon,
30 showLongerMessage,
31 showLongerAction,
32 } = options;
33
34 const action = {
35 label: showLongerAction ? 'Toggle Theme' : 'Action',
36 onPress: () => {
37 preferences?.toggleTheme();
38 },
39 };
40
41 return (
42 <>
43 <ScreenWrapper contentContainerStyle={styles.container}>
44 <List.Section title="Snackbar options">
45 <View style={styles.row}>
46 <Text>Action button</Text>
47 <Switch
48 value={showAction}
49 onValueChange={() =>
50 setOptions({ ...options, showAction: !showAction })
51 }
52 />
53 </View>
54 {theme.isV3 && (
55 <View style={styles.row}>
56 <Text>Close icon button</Text>
57 <Switch
58 value={showCloseIcon}
59 onValueChange={() =>
60 setOptions({ ...options, showCloseIcon: !showCloseIcon })
61 }
62 />
63 </View>
64 )}
65 <View style={styles.row}>
66 <Text>Longer message</Text>
67 <Switch
68 value={showLongerMessage}
69 onValueChange={() =>
70 setOptions({
71 ...options,

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…