diff --git a/src/components/Button/Button.tsx b/src/components/Button/Button.tsx index 53c64b7017..d7145b87b3 100644 --- a/src/components/Button/Button.tsx +++ b/src/components/Button/Button.tsx @@ -297,7 +297,6 @@ const Button = ({ > diff --git a/src/components/SegmentedButtons/SegmentedButtonItem.tsx b/src/components/SegmentedButtons/SegmentedButtonItem.tsx index 49bbb7dd0f..dcac15cf06 100644 --- a/src/components/SegmentedButtons/SegmentedButtonItem.tsx +++ b/src/components/SegmentedButtons/SegmentedButtonItem.tsx @@ -161,7 +161,6 @@ const SegmentedButtonItem = ({ & { +type Props = React.ComponentProps & { borderless?: boolean; - background?: BackgroundPropType; + background?: PressableAndroidRippleConfig; disabled?: boolean; onPress?: () => void | null; rippleColor?: string; @@ -41,6 +39,8 @@ const TouchableRipple = ({ theme, ...rest }: Props) => { + const [showUnderlay, setShowUnderlay] = React.useState(false); + const disabled = disabledProp || !rest.onPress; const { calculatedRippleColor, calculatedUnderlayColor } = getTouchableRippleColors({ @@ -56,34 +56,51 @@ const TouchableRipple = ({ Platform.Version >= ANDROID_VERSION_PIE && borderless; + const handlePressIn = (e: GestureResponderEvent) => { + setShowUnderlay(true); + rest.onPressIn?.(e); + }; + + const handlePressOut = (e: GestureResponderEvent) => { + setShowUnderlay(false); + rest.onPressOut?.(e); + }; + if (TouchableRipple.supported) { return ( - - - {React.Children.only(children)} - - + {React.Children.only(children)} + ); } return ( - {React.Children.only(children)} - + ); }; diff --git a/src/components/TouchableRipple/TouchableRipple.tsx b/src/components/TouchableRipple/TouchableRipple.tsx index b7cf4f07a0..52b0eac94f 100644 --- a/src/components/TouchableRipple/TouchableRipple.tsx +++ b/src/components/TouchableRipple/TouchableRipple.tsx @@ -1,28 +1,25 @@ import * as React from 'react'; import { - TouchableWithoutFeedback, - View, ViewStyle, StyleSheet, StyleProp, GestureResponderEvent, Platform, + Pressable, } from 'react-native'; import { withTheme } from '../../core/theming'; import type { Theme } from '../../types'; import { getTouchableRippleColors } from './utils'; -export type Props = React.ComponentPropsWithRef< - typeof TouchableWithoutFeedback -> & { +export type Props = React.ComponentPropsWithRef & { /** * Whether to render the ripple outside the view bounds. */ borderless?: boolean; /** * Type of background drawabale to display the feedback (Android). - * https://reactnative.dev/docs/touchablenativefeedback#background + * https://reactnative.dev/docs/pressable#rippleconfig */ background?: Object; /** @@ -89,7 +86,7 @@ export type Props = React.ComponentPropsWithRef< * export default MyComponent; * ``` * - * @extends TouchableWithoutFeedback props https://reactnative.dev/docs/touchablewithoutfeedback#props + * @extends Pressable props https://reactnative.dev/docs/Pressable#props */ const TouchableRipple = ({ style, @@ -233,16 +230,15 @@ const TouchableRipple = ({ const disabled = disabledProp || !rest.onPress; return ( - - - {React.Children.only(children)} - - + {React.Children.only(children)} + ); }; diff --git a/src/components/__tests__/Appbar/__snapshots__/Appbar.test.js.snap b/src/components/__tests__/Appbar/__snapshots__/Appbar.test.js.snap index ee6deacf47..bb0677717d 100644 --- a/src/components/__tests__/Appbar/__snapshots__/Appbar.test.js.snap +++ b/src/components/__tests__/Appbar/__snapshots__/Appbar.test.js.snap @@ -147,6 +147,7 @@ exports[`Appbar does not pass any additional props to Searchbar 1`] = ` } >