()
| 12 | 'Snackbar with longer message which does not fit in one line'; |
| 13 | |
| 14 | const 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, |
nothing calls this directly
no test coverage detected
searching dependent graphs…