@@ -4,7 +4,7 @@ import {ImageSourcePropType, ImageStyle, StyleProp, StyleSheet, Text, TextStyle,
4
4
import { View as AnimatableView } from 'react-native-animatable' ;
5
5
import { extractAccessibilityProps , extractAnimationProps } from '../../commons/modifiers' ;
6
6
import { asBaseComponent } from '../../commons/new' ;
7
- import { BorderRadiuses , Colors , Typography } from '../../style' ;
7
+ import { BorderRadiuses , Colors , Spacings , Typography } from '../../style' ;
8
8
import TouchableOpacity from '../touchableOpacity' ;
9
9
import Image from '../image' ;
10
10
import View from '../view' ;
@@ -143,6 +143,15 @@ class Badge extends PureComponent<BadgeProps> {
143
143
height : badgeHeight ,
144
144
minWidth : badgeHeight
145
145
} ;
146
+ if ( icon && label ) {
147
+ style . paddingRight = 6 ;
148
+ style . paddingLeft = 4 ;
149
+ style . height = Spacings . s5 ;
150
+ if ( borderWidth ) {
151
+ style . height += borderWidth * 2 ;
152
+ }
153
+ return style ;
154
+ }
146
155
147
156
const isPimple = label === undefined ;
148
157
if ( isPimple || icon ) {
@@ -213,7 +222,8 @@ class Badge extends PureComponent<BadgeProps> {
213
222
}
214
223
215
224
renderIcon ( ) {
216
- const { icon, iconStyle, iconProps, borderColor} = this . props ;
225
+ const { icon, iconStyle, iconProps, borderColor, label} = this . props ;
226
+ const flex = label ? 0 : 1 ;
217
227
return (
218
228
< Image
219
229
source = { icon ! }
@@ -222,7 +232,7 @@ class Badge extends PureComponent<BadgeProps> {
222
232
borderColor = { borderColor }
223
233
{ ...iconProps }
224
234
style = { {
225
- flex : 1 ,
235
+ flex,
226
236
...iconStyle
227
237
} }
228
238
/>
@@ -237,6 +247,7 @@ class Badge extends PureComponent<BadgeProps> {
237
247
containerStyle,
238
248
hitSlop,
239
249
icon,
250
+ label,
240
251
onPress,
241
252
testId,
242
253
testID,
@@ -265,7 +276,10 @@ class Badge extends PureComponent<BadgeProps> {
265
276
hitSlop = { hitSlop }
266
277
{ ...animationProps }
267
278
>
268
- { icon ? this . renderIcon ( ) : this . renderLabel ( ) }
279
+ < View flex row centerV >
280
+ { icon && this . renderIcon ( ) }
281
+ { label && this . renderLabel ( ) }
282
+ </ View >
269
283
</ Container >
270
284
</ View >
271
285
) ;
0 commit comments