MCPcopy Create free account
hub / github.com/callstack/react-native-paper / CheckboxAndroid

Function CheckboxAndroid

src/components/Checkbox/CheckboxAndroid.tsx:56–156  ·  view source on GitHub ↗
({
  status,
  theme: themeOverrides,
  disabled,
  onPress,
  testID,
  ...rest
}: Props)

Source from the content-addressed store, hash-verified

54 * @extends TouchableRipple props https://callstack.github.io/react-native-paper/docs/components/TouchableRipple
55 */
56const CheckboxAndroid = ({
57 status,
58 theme: themeOverrides,
59 disabled,
60 onPress,
61 testID,
62 ...rest
63}: Props) => {
64 const theme = useInternalTheme(themeOverrides);
65 const { current: scaleAnim } = React.useRef<Animated.Value>(
66 new Animated.Value(1)
67 );
68 const isFirstRendering = React.useRef<boolean>(true);
69
70 const {
71 animation: { scale },
72 } = theme;
73
74 React.useEffect(() => {
75 // Do not run animation on very first rendering
76 if (isFirstRendering.current) {
77 isFirstRendering.current = false;
78 return;
79 }
80
81 const checked = status === 'checked';
82
83 Animated.sequence([
84 Animated.timing(scaleAnim, {
85 toValue: 0.85,
86 duration: checked ? ANIMATION_DURATION * scale : 0,
87 useNativeDriver: false,
88 }),
89 Animated.timing(scaleAnim, {
90 toValue: 1,
91 duration: checked
92 ? ANIMATION_DURATION * scale
93 : ANIMATION_DURATION * scale * 1.75,
94 useNativeDriver: false,
95 }),
96 ]).start();
97 }, [status, scaleAnim, scale]);
98
99 const checked = status === 'checked';
100 const indeterminate = status === 'indeterminate';
101
102 const { rippleColor, selectionControlColor } =
103 getAndroidSelectionControlColor({
104 theme,
105 disabled,
106 checked,
107 customColor: rest.color,
108 customUncheckedColor: rest.uncheckedColor,
109 });
110
111 const borderWidth = scaleAnim.interpolate({
112 inputRange: [0.8, 1],
113 outputRange: [7, 0],

Callers

nothing calls this directly

Calls 2

useInternalThemeFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…