Skip to content

Instantly share code, notes, and snippets.

@matinzd
Created July 24, 2025 16:33
Show Gist options
  • Select an option

  • Save matinzd/17a81fe4c4284d8dc986d00597e0e709 to your computer and use it in GitHub Desktop.

Select an option

Save matinzd/17a81fe4c4284d8dc986d00597e0e709 to your computer and use it in GitHub Desktop.
import { useAppTheme } from '@kreddy-frontend/shared-ui';
import { Platform } from 'react-native';
import { Switch } from 'react-native-gesture-handler';
interface ToggleProps {
value: boolean;
onValueChange: (value: boolean) => void;
disabled?: boolean;
}
export const Toggle = ({ value, onValueChange, disabled }: ToggleProps) => {
const { colors } = useAppTheme();
return (
<Switch
hitSlop={12}
trackColor={Platform.select({
ios: {
false: colors.white,
true: colors.black_10,
},
android: {
false: colors.black_60,
true: colors.black_40,
},
})}
thumbColor={Platform.select({
ios: value ? colors.white : colors.black_10,
android: value ? colors.black_10 : colors.gray_80,
})}
onValueChange={onValueChange}
value={value}
disabled={disabled}
style={{ backgroundColor: 'red' }}
// style={Platform.select({ ios: { minWidth: 68 } })}
/>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment