@@ -5,8 +5,9 @@ import {StyleSheet, Text, ViewPropTypes} from 'react-native';
5
5
import { View as AnimatableView } from 'react-native-animatable' ;
6
6
import { PureBaseComponent } from '../../commons' ;
7
7
import { BorderRadiuses , Colors , ThemeManager , Typography } from '../../style' ;
8
- import View from '../view' ;
9
8
import Image from '../image' ;
9
+ import TouchableOpacity from '../touchableOpacity' ;
10
+ import View from '../view' ;
10
11
11
12
const LABEL_FORMATTER_VALUES = [ 1 , 2 , 3 , 4 ] ;
12
13
@@ -192,13 +193,24 @@ export default class Badge extends PureBaseComponent {
192
193
193
194
render ( ) {
194
195
// TODO: remove testId after deprecation
195
- const { borderWidth, backgroundColor, borderColor, containerStyle, icon, testId, testID, ...others } = this . props ;
196
+ const {
197
+ activeOpacity,
198
+ borderWidth,
199
+ backgroundColor,
200
+ borderColor,
201
+ containerStyle,
202
+ icon,
203
+ onPress,
204
+ testId,
205
+ testID,
206
+ ...others
207
+ } = this . props ;
196
208
const backgroundStyle = backgroundColor && { backgroundColor} ;
197
209
const sizeStyle = this . getBadgeSizeStyle ( ) ;
198
210
const borderStyle = borderWidth ? this . getBorderStyling ( ) : undefined ;
199
211
200
212
const animationProps = this . extractAnimationProps ( ) ;
201
- const Container = ! _ . isEmpty ( animationProps ) ? AnimatableView : View ;
213
+ const Container = ! _ . isEmpty ( animationProps ) ? AnimatableView : onPress ? TouchableOpacity : View ;
202
214
if ( ! _ . isEmpty ( animationProps ) ) {
203
215
console . warn (
204
216
'Badge component will soon stop supporting animationProps.' +
@@ -213,6 +225,8 @@ export default class Badge extends PureBaseComponent {
213
225
testID = { testID || testId }
214
226
pointerEvents = { 'none' }
215
227
style = { [ sizeStyle , this . styles . badge , borderStyle , backgroundStyle ] }
228
+ onPress = { onPress }
229
+ activeOpacity = { activeOpacity }
216
230
{ ...animationProps }
217
231
>
218
232
{ icon ? this . renderIcon ( ) : this . renderLabel ( ) }
0 commit comments