Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/components/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export type Props = {
* testID to be used on tests.
*/
testID?: string;
/**
* custom icon.
*/
icon?: (props: { size: number; color: string }) => JSX.Element;
};

/**
Expand Down
21 changes: 14 additions & 7 deletions src/components/Checkbox/CheckboxAndroid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export type Props = $RemoveChildren<typeof TouchableRipple> & {
* testID to be used on tests.
*/
testID?: string;
/**
* custom icon.
*/
icon?: (props: { size: number; color: string }) => JSX.Element;
};

// From https://material.io/design/motion/speed.html#duration
Expand All @@ -59,6 +63,7 @@ const CheckboxAndroid = ({
disabled,
onPress,
testID,
icon: customIcon,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
Expand Down Expand Up @@ -134,13 +139,15 @@ const CheckboxAndroid = ({
theme={theme}
>
<Animated.View style={{ transform: [{ scale: scaleAnim }] }}>
<MaterialCommunityIcon
allowFontScaling={false}
name={icon}
size={24}
color={selectionControlColor}
direction="ltr"
/>
{customIcon?.({ size: 24, color: selectionControlColor }) || (
<MaterialCommunityIcon
allowFontScaling={false}
name={icon}
size={24}
color={selectionControlColor}
direction="ltr"
/>
)}
<View style={[StyleSheet.absoluteFill, styles.fillContainer]}>
<Animated.View
style={[
Expand Down
21 changes: 14 additions & 7 deletions src/components/Checkbox/CheckboxIOS.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export type Props = $RemoveChildren<typeof TouchableRipple> & {
* testID to be used on tests.
*/
testID?: string;
/**
* custom icon.
*/
icon?: (props: { size: number; color: string }) => JSX.Element;
};

/**
Expand All @@ -47,6 +51,7 @@ const CheckboxIOS = ({
onPress,
theme: themeOverrides,
testID,
icon: customIcon,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
Expand Down Expand Up @@ -77,13 +82,15 @@ const CheckboxIOS = ({
theme={theme}
>
<View style={{ opacity }}>
<MaterialCommunityIcon
allowFontScaling={false}
name={icon}
size={24}
color={checkedColor}
direction="ltr"
/>
{customIcon?.({ size: 24, color: checkedColor }) || (
<MaterialCommunityIcon
allowFontScaling={false}
name={icon}
size={24}
color={checkedColor}
direction="ltr"
/>
)}
</View>
</TouchableRipple>
);
Expand Down
7 changes: 6 additions & 1 deletion src/components/Checkbox/CheckboxItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export type Props = {
* testID to be used on tests.
*/
testID?: string;
/**
* custom icon.
*/
icon?: (props: { size: number; color: string }) => JSX.Element;
/**
* Checkbox control position.
*/
Expand Down Expand Up @@ -142,6 +146,7 @@ const CheckboxItem = ({
labelStyle,
theme: themeOverrides,
testID,
icon,
mode,
position = 'trailing',
accessibilityLabel = label,
Expand All @@ -154,7 +159,7 @@ const CheckboxItem = ({
...props
}: Props) => {
const theme = useInternalTheme(themeOverrides);
const checkboxProps = { ...props, status, theme, disabled };
const checkboxProps = { ...props, status, theme, disabled, icon };
const isLeading = position === 'leading';
let checkbox;

Expand Down