From 6dd615decb7107560f15f0ab13a43509428b7d45 Mon Sep 17 00:00:00 2001 From: Luke Walczak Date: Wed, 10 Jan 2024 22:04:28 +0100 Subject: [PATCH] feat: pass background prop to nested touchables (#4108) --- src/components/Button/Button.tsx | 8 ++++++++ src/components/Checkbox/CheckboxAndroid.tsx | 2 ++ src/components/Checkbox/CheckboxIOS.tsx | 2 ++ src/components/Checkbox/CheckboxItem.tsx | 8 ++++++++ src/components/Chip/Chip.tsx | 8 ++++++++ src/components/Drawer/DrawerItem.tsx | 8 ++++++++ src/components/FAB/AnimatedFAB.tsx | 8 ++++++++ src/components/FAB/FAB.tsx | 8 ++++++++ src/components/List/ListAccordion.tsx | 8 ++++++++ src/components/Menu/MenuItem.tsx | 8 ++++++++ src/components/RadioButton/RadioButtonAndroid.tsx | 2 ++ src/components/RadioButton/RadioButtonIOS.tsx | 2 ++ src/components/RadioButton/RadioButtonItem.tsx | 8 ++++++++ src/components/SegmentedButtons/SegmentedButtonItem.tsx | 8 ++++++++ 14 files changed, 88 insertions(+) diff --git a/src/components/Button/Button.tsx b/src/components/Button/Button.tsx index cae10b0eb5..a023087730 100644 --- a/src/components/Button/Button.tsx +++ b/src/components/Button/Button.tsx @@ -5,6 +5,7 @@ import { ColorValue, GestureResponderEvent, Platform, + PressableAndroidRippleConfig, StyleProp, StyleSheet, TextStyle, @@ -83,6 +84,11 @@ export type Props = $Omit, 'mode'> & { * Make the label text uppercased. Note that this won't work if you pass React elements as children. */ uppercase?: boolean; + /** + * Type of background drawabale to display the feedback (Android). + * https://reactnative.dev/docs/pressable#rippleconfig + */ + background?: PressableAndroidRippleConfig; /** * Accessibility label for the button. This is read by the screen reader when the user taps the button. */ @@ -183,6 +189,7 @@ const Button = ( labelStyle, testID = 'button', accessible, + background, maxFontSizeMultiplier, ...rest }: Props, @@ -325,6 +332,7 @@ const Button = ( > & { * Checkboxes allow the selection of multiple options from a set. * This component follows platform guidelines for iOS, but can be used * on any platform. + * + * @extends TouchableRipple props https://callstack.github.io/react-native-paper/docs/components/TouchableRipple */ const CheckboxIOS = ({ status, diff --git a/src/components/Checkbox/CheckboxItem.tsx b/src/components/Checkbox/CheckboxItem.tsx index c62c2097fa..dd3b5fea21 100644 --- a/src/components/Checkbox/CheckboxItem.tsx +++ b/src/components/Checkbox/CheckboxItem.tsx @@ -2,6 +2,7 @@ import * as React from 'react'; import { ColorValue, GestureResponderEvent, + PressableAndroidRippleConfig, StyleProp, StyleSheet, TextStyle, @@ -38,6 +39,11 @@ export type Props = { * Function to execute on long press. */ onLongPress?: (e: GestureResponderEvent) => void; + /** + * Type of background drawabale to display the feedback (Android). + * https://reactnative.dev/docs/pressable#rippleconfig + */ + background?: PressableAndroidRippleConfig; /** * Accessibility label for the touchable. This is read by the screen reader when the user taps the touchable. */ @@ -137,6 +143,7 @@ const CheckboxItem = ({ labelVariant = 'bodyLarge', labelMaxFontSizeMultiplier = 1.5, rippleColor, + background, ...props }: Props) => { const theme = useInternalTheme(themeOverrides); @@ -177,6 +184,7 @@ const CheckboxItem = ({ disabled={disabled} rippleColor={rippleColor} theme={theme} + background={background} > , 'mode'> & { * Whether the chip is disabled. A disabled chip is greyed out and `onPress` is not called on touch. */ disabled?: boolean; + /** + * Type of background drawabale to display the feedback (Android). + * https://reactnative.dev/docs/pressable#rippleconfig + */ + background?: PressableAndroidRippleConfig; /** * Accessibility label for the chip. This is read by the screen reader when the user taps the chip. */ @@ -173,6 +179,7 @@ const Chip = ({ avatar, selected = false, disabled = false, + background, accessibilityLabel, closeIconAccessibilityLabel = 'Close', onPress, @@ -306,6 +313,7 @@ const Chip = ({ > & { * Function to execute on press. */ onPress?: (e: GestureResponderEvent) => void; + /** + * Type of background drawabale to display the feedback (Android). + * https://reactnative.dev/docs/pressable#rippleconfig + */ + background?: PressableAndroidRippleConfig; /** * Accessibility label for the button. This is read by the screen reader when the user taps the button. */ @@ -88,6 +94,7 @@ const DrawerItem = ({ rippleColor: customRippleColor, style, onPress, + background, accessibilityLabel, right, labelMaxFontSizeMultiplier, @@ -121,6 +128,7 @@ const DrawerItem = ({ , 'mode'> & { * Make the label text uppercased. */ uppercase?: boolean; + /** + * Type of background drawabale to display the feedback (Android). + * https://reactnative.dev/docs/pressable#rippleconfig + */ + background?: PressableAndroidRippleConfig; /** * Accessibility label for the FAB. This is read by the screen reader when the user taps the FAB. * Uses `label` by default if specified. @@ -197,6 +203,7 @@ const SCALE = 0.9; const AnimatedFAB = ({ icon, label, + background, accessibilityLabel = label, accessibilityState, color: customColor, @@ -427,6 +434,7 @@ const AnimatedFAB = ({ > , 'mode'> & { * Make the label text uppercased. */ uppercase?: boolean; + /** + * Type of background drawabale to display the feedback (Android). + * https://reactnative.dev/docs/pressable#rippleconfig + */ + background?: PressableAndroidRippleConfig; /** * Accessibility label for the FAB. This is read by the screen reader when the user taps the FAB. * Uses `label` by default if specified. @@ -178,6 +184,7 @@ const FAB = forwardRef( { icon, label, + background, accessibilityLabel = label, accessibilityState, animated = true, @@ -285,6 +292,7 @@ const FAB = forwardRef( > & { * Radio buttons allow the selection a single option from a set. * This component follows platform guidelines for iOS, but can be used * on any platform. + * + * @extends TouchableRipple props https://callstack.github.io/react-native-paper/docs/components/TouchableRipple */ const RadioButtonIOS = ({ disabled, diff --git a/src/components/RadioButton/RadioButtonItem.tsx b/src/components/RadioButton/RadioButtonItem.tsx index 741f55f366..adc1f75813 100644 --- a/src/components/RadioButton/RadioButtonItem.tsx +++ b/src/components/RadioButton/RadioButtonItem.tsx @@ -2,6 +2,7 @@ import * as React from 'react'; import { ColorValue, GestureResponderEvent, + PressableAndroidRippleConfig, StyleProp, StyleSheet, TextStyle, @@ -32,6 +33,11 @@ export type Props = { * Whether radio is disabled. */ disabled?: boolean; + /** + * Type of background drawabale to display the feedback (Android). + * https://reactnative.dev/docs/pressable#rippleconfig + */ + background?: PressableAndroidRippleConfig; /** * Function to execute on press. */ @@ -143,6 +149,7 @@ const RadioButtonItem = ({ rippleColor, status, theme: themeOverrides, + background, accessibilityLabel = label, testID, mode, @@ -209,6 +216,7 @@ const RadioButtonItem = ({ }} testID={testID} disabled={disabled} + background={background} theme={theme} rippleColor={rippleColor} > diff --git a/src/components/SegmentedButtons/SegmentedButtonItem.tsx b/src/components/SegmentedButtons/SegmentedButtonItem.tsx index 7ce624e449..d88f2a46f9 100644 --- a/src/components/SegmentedButtons/SegmentedButtonItem.tsx +++ b/src/components/SegmentedButtons/SegmentedButtonItem.tsx @@ -3,6 +3,7 @@ import { Animated, ColorValue, GestureResponderEvent, + PressableAndroidRippleConfig, StyleProp, StyleSheet, TextStyle, @@ -51,6 +52,11 @@ export type Props = { * Whether the button is disabled. */ disabled?: boolean; + /** + * Type of background drawabale to display the feedback (Android). + * https://reactnative.dev/docs/pressable#rippleconfig + */ + background?: PressableAndroidRippleConfig; /** * Accessibility label for the `SegmentedButtonItem`. This is read by the screen reader when the user taps the button. */ @@ -108,6 +114,7 @@ const SegmentedButtonItem = ({ checkedColor, uncheckedColor, rippleColor: customRippleColor, + background, icon, testID, label, @@ -208,6 +215,7 @@ const SegmentedButtonItem = ({ rippleColor={rippleColor} testID={testID} style={rippleStyle} + background={background} theme={theme} >