@@ -286,22 +286,11 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager<ButtonViewGroup>(), R
286
286
return false
287
287
}
288
288
289
- private fun updateBackgroundColor (backgroundColor : Int , selectable : Drawable ? ) {
289
+ private fun updateBackgroundColor (backgroundColor : Int , borderDrawable : Drawable , selectable : Drawable ? ) {
290
290
val colorDrawable = PaintDrawable (backgroundColor)
291
- val borderDrawable = PaintDrawable (Color .TRANSPARENT )
292
291
293
292
if (hasBorderRadii) {
294
293
colorDrawable.setCornerRadii(buildBorderRadii())
295
- borderDrawable.setCornerRadii(buildBorderRadii())
296
- }
297
-
298
- if (borderWidth > 0f ) {
299
- borderDrawable.paint.apply {
300
- style = Paint .Style .STROKE
301
- strokeWidth = borderWidth
302
- color = borderColor ? : Color .BLACK
303
- pathEffect = buildBorderStyle()
304
- }
305
294
}
306
295
307
296
val layerDrawable = LayerDrawable (if (selectable != null ) arrayOf(colorDrawable, selectable, borderDrawable) else arrayOf(colorDrawable, borderDrawable))
@@ -324,6 +313,7 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager<ButtonViewGroup>(), R
324
313
}
325
314
326
315
val selectable = createSelectableDrawable()
316
+ val borderDrawable = createBorderDrawable()
327
317
328
318
if (hasBorderRadii && selectable is RippleDrawable ) {
329
319
val mask = PaintDrawable (Color .WHITE )
@@ -334,13 +324,32 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager<ButtonViewGroup>(), R
334
324
if (useDrawableOnForeground && Build .VERSION .SDK_INT >= Build .VERSION_CODES .M ) {
335
325
foreground = selectable
336
326
if (_backgroundColor != Color .TRANSPARENT ) {
337
- updateBackgroundColor(_backgroundColor , null )
327
+ updateBackgroundColor(_backgroundColor , borderDrawable, null )
338
328
}
339
329
} else if (_backgroundColor == Color .TRANSPARENT && rippleColor == null ) {
340
- background = selectable
330
+ background = LayerDrawable (arrayOf( selectable, borderDrawable))
341
331
} else {
342
- updateBackgroundColor(_backgroundColor , selectable)
332
+ updateBackgroundColor(_backgroundColor , borderDrawable, selectable)
333
+ }
334
+ }
335
+
336
+ private fun createBorderDrawable (): Drawable {
337
+ val borderDrawable = PaintDrawable (Color .TRANSPARENT )
338
+
339
+ if (hasBorderRadii) {
340
+ borderDrawable.setCornerRadii(buildBorderRadii())
341
+ }
342
+
343
+ if (borderWidth > 0f ) {
344
+ borderDrawable.paint.apply {
345
+ style = Paint .Style .STROKE
346
+ strokeWidth = borderWidth
347
+ color = borderColor ? : Color .BLACK
348
+ pathEffect = buildBorderStyle()
349
+ }
343
350
}
351
+
352
+ return borderDrawable
344
353
}
345
354
346
355
private fun createSelectableDrawable (): Drawable ? {
0 commit comments