MCPcopy Create free account
hub / github.com/chart-kit/react-native-chart-kit-example / DrawerSwitchRow

Function DrawerSwitchRow

src/showcase/ShowcaseMenu.tsx:436–508  ·  view source on GitHub ↗
({
  appTheme,
  iconName,
  label,
  onValueChange,
  value,
}: {
  appTheme: ShowcaseMenuTheme;
  iconName: IoniconName;
  label: string;
  onValueChange: (value: boolean) => void;
  value: boolean;
})

Source from the content-addressed store, hash-verified

434};
435
436const DrawerSwitchRow = ({
437 appTheme,
438 iconName,
439 label,
440 onValueChange,
441 value,
442}: {
443 appTheme: ShowcaseMenuTheme;
444 iconName: IoniconName;
445 label: string;
446 onValueChange: (value: boolean) => void;
447 value: boolean;
448}) => {
449 const accentColor = appTheme.series[0] ?? appTheme.text;
450
451 return (
452 <Pressable
453 accessibilityLabel={label}
454 accessibilityRole="switch"
455 accessibilityState={{ checked: value }}
456 onPress={() => onValueChange(!value)}
457 style={({ pressed }) => [
458 styles.row,
459 {
460 backgroundColor: value ? appTheme.background : "transparent",
461 },
462 pressed && styles.pressed,
463 ]}
464 >
465 <View
466 style={[
467 styles.rowIcon,
468 {
469 backgroundColor: value ? accentColor : appTheme.background,
470 borderColor: appTheme.axis,
471 },
472 ]}
473 >
474 <Ionicons
475 name={iconName}
476 size={18}
477 color={value ? appTheme.background : appTheme.text}
478 />
479 </View>
480 <View style={styles.rowTextBlock}>
481 <Text
482 numberOfLines={1}
483 style={[styles.rowLabel, { color: appTheme.text }]}
484 >
485 {label}
486 </Text>
487 </View>
488 <View
489 style={[
490 styles.compactSwitchTrack,
491 {
492 backgroundColor: value ? accentColor : appTheme.axis,
493 },

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected