()
| 14 | import ScreenWrapper from '../ScreenWrapper'; |
| 15 | |
| 16 | const SwitchExample = () => { |
| 17 | const [valueNormal, setNormalValue] = React.useState<boolean>(true); |
| 18 | const [valueCustom, setCustomValue] = React.useState<boolean>(true); |
| 19 | |
| 20 | const { isV3 } = useExampleTheme(); |
| 21 | |
| 22 | const switchValueNormalLabel = `switch ${ |
| 23 | valueNormal === true ? 'on' : 'off' |
| 24 | }`; |
| 25 | const switchValueCustomlLabel = `switch ${ |
| 26 | valueCustom === true ? 'on' : 'off' |
| 27 | }`; |
| 28 | |
| 29 | const TextComponent = isV3 ? Text : Paragraph; |
| 30 | |
| 31 | return Platform.OS === 'android' ? ( |
| 32 | <ScreenWrapper style={styles.container}> |
| 33 | <TouchableRipple onPress={() => setNormalValue(!valueNormal)}> |
| 34 | <View style={styles.row}> |
| 35 | <TextComponent>Normal {switchValueNormalLabel}</TextComponent> |
| 36 | <View pointerEvents="none"> |
| 37 | <Switch value={valueNormal} /> |
| 38 | </View> |
| 39 | </View> |
| 40 | </TouchableRipple> |
| 41 | <TouchableRipple onPress={() => setCustomValue(!valueCustom)}> |
| 42 | <View style={styles.row}> |
| 43 | <TextComponent>Custom {switchValueCustomlLabel}</TextComponent> |
| 44 | <View pointerEvents="none"> |
| 45 | <Switch |
| 46 | value={valueCustom} |
| 47 | color={isV3 ? MD3Colors.tertiary50 : MD2Colors.blue500} |
| 48 | /> |
| 49 | </View> |
| 50 | </View> |
| 51 | </TouchableRipple> |
| 52 | <View style={styles.row}> |
| 53 | <TextComponent>Switch on (disabled)</TextComponent> |
| 54 | <Switch disabled value /> |
| 55 | </View> |
| 56 | <View style={styles.row}> |
| 57 | <TextComponent>Switch off (disabled)</TextComponent> |
| 58 | <Switch disabled /> |
| 59 | </View> |
| 60 | </ScreenWrapper> |
| 61 | ) : ( |
| 62 | <ScreenWrapper style={styles.container}> |
| 63 | <View style={styles.row}> |
| 64 | <TextComponent>Normal {switchValueNormalLabel}</TextComponent> |
| 65 | <Switch |
| 66 | value={valueNormal} |
| 67 | onValueChange={() => setNormalValue(!valueNormal)} |
| 68 | /> |
| 69 | </View> |
| 70 | <View style={styles.row}> |
| 71 | <TextComponent>Custom {switchValueCustomlLabel}</TextComponent> |
| 72 | <Switch |
| 73 | value={valueCustom} |
nothing calls this directly
no test coverage detected
searching dependent graphs…