@@ -2,7 +2,6 @@ import * as React from 'react';
22import {
33 AccessibilityRole ,
44 Animated ,
5- ColorValue ,
65 GestureResponderEvent ,
76 Platform ,
87 PressableAndroidRippleConfig ,
@@ -13,8 +12,6 @@ import {
1312 ViewStyle ,
1413} from 'react-native' ;
1514
16- import color from 'color' ;
17-
1815import {
1916 ButtonMode ,
2017 getButtonColors ,
@@ -66,10 +63,6 @@ export type Props = $Omit<React.ComponentProps<typeof Surface>, 'mode'> & {
6663 * Custom button's text color.
6764 */
6865 textColor ?: string ;
69- /**
70- * Color of the ripple effect.
71- */
72- rippleColor ?: ColorValue ;
7366 /**
7467 * Whether to show a loading indicator.
7568 */
@@ -186,7 +179,6 @@ const Button = (
186179 icon,
187180 buttonColor : customButtonColor ,
188181 textColor : customTextColor ,
189- rippleColor : customRippleColor ,
190182 children,
191183 accessibilityLabel,
192184 accessibilityHint,
@@ -282,26 +274,29 @@ const Button = (
282274 const borderRadius = 5 * roundness ;
283275 const iconSize = 18 ;
284276
285- const { backgroundColor, borderColor, textColor, borderWidth } =
286- getButtonColors ( {
287- customButtonColor,
288- customTextColor,
289- theme,
290- mode,
291- disabled,
292- dark,
293- } ) ;
294-
295- const rippleColor =
296- customRippleColor || color ( textColor ) . alpha ( 0.12 ) . rgb ( ) . string ( ) ;
277+ const {
278+ backgroundColor,
279+ borderColor,
280+ textColor,
281+ textOpacity,
282+ borderWidth,
283+ backgroundOpacity,
284+ } = getButtonColors ( {
285+ customButtonColor,
286+ customTextColor,
287+ theme,
288+ mode,
289+ disabled,
290+ dark,
291+ } ) ;
297292
298293 const touchableStyle = {
299294 ...borderRadiusStyles ,
300295 borderRadius : borderRadiusStyles . borderRadius ?? borderRadius ,
301296 } ;
302297
303298 const buttonStyle = {
304- backgroundColor,
299+ backgroundColor : backgroundOpacity < 1 ? 'transparent' : backgroundColor ,
305300 borderColor,
306301 borderWidth,
307302 ...touchableStyle ,
@@ -348,6 +343,19 @@ const Button = (
348343 elevation = { elevation }
349344 container
350345 >
346+ { backgroundOpacity < 1 && (
347+ < View
348+ pointerEvents = "none"
349+ style = { [
350+ StyleSheet . absoluteFill ,
351+ {
352+ backgroundColor,
353+ opacity : backgroundOpacity ,
354+ borderRadius : touchableStyle . borderRadius ,
355+ } ,
356+ ] }
357+ />
358+ ) }
351359 < TouchableRipple
352360 borderless
353361 background = { background }
@@ -363,13 +371,12 @@ const Button = (
363371 accessible = { accessible }
364372 hitSlop = { hitSlop }
365373 disabled = { disabled }
366- rippleColor = { rippleColor }
367374 style = { getButtonTouchableRippleStyle ( touchableStyle , borderWidth ) }
368375 testID = { testID }
369376 theme = { theme }
370377 ref = { touchableRef }
371378 >
372- < View style = { [ styles . content , contentStyle ] } >
379+ < View style = { [ styles . content , { opacity : textOpacity } , contentStyle ] } >
373380 { icon && loading !== true ? (
374381 < View style = { iconStyle } testID = { `${ testID } -icon-container` } >
375382 < Icon
0 commit comments