From 806d07fb8ae5b3ed715a2a6f331da8b2c4f9a2e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Fri, 14 Feb 2025 14:01:25 +0100 Subject: [PATCH 1/9] add codegen interface for missing props --- .../RNGestureHandlerButtonViewManager.kt | 63 +++++++++++++++++++ .../RNGestureHandlerButtonNativeComponent.ts | 15 +++++ 2 files changed, 78 insertions(+) diff --git a/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt b/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt index 053c0464f8..7740054ae9 100644 --- a/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +++ b/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt @@ -97,16 +97,79 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager(), R @ReactProp(name = "borderWidth") override fun setBorderWidth(view: ButtonViewGroup, borderWidth: Float) { + // view.setBorderWidth(Spacing.ALL, borderWidth) view.borderWidth = borderWidth } + @ReactProp(name = "borderStartWidth") + override fun setBorderLeftWidth(view: ButtonViewGroup, borderStartWidth: Float) { + // view.setBorderWidth(Spacing.LEFT, borderStartWidth) + } + + @ReactProp(name = "borderRightWidth") + override fun setBorderRightWidth(view: ButtonViewGroup, borderRightWidth: Float) { + // view.setBorderWidth(Spacing.RIGHT, borderRightWidth) + } + + @ReactProp(name = "borderTopWidth") + override fun setBorderTopWidth(view: ButtonViewGroup, borderTopWidth: Float) { + // view.setBorderWidth(Spacing.TOP, borderTopWidth) + } + + @ReactProp(name = "borderBottomWidth") + override fun setBorderBottomWidth(view: ButtonViewGroup, borderBottomWidth: Float) { + // view.setBorderWidth(Spacing.BOTTOM, borderBottomWidth) + } + + @ReactProp(name = "borderStartWidth") + override fun setBorderStartWidth(view: ButtonViewGroup, borderStartWidth: Float) { + // view.setBorderWidth(Spacing.START, borderStartWidth) + } + + @ReactProp(name = "borderEndWidth") + override fun setBorderEndWidth(view: ButtonViewGroup, borderEndWidth: Float) { + // view.setBorderWidth(Spacing.END, borderEndWidth) + } + @ReactProp(name = "borderColor") override fun setBorderColor(view: ButtonViewGroup, borderColor: Int?) { + // view.setBorderColor(Spacing.ALL, borderColor) view.borderColor = borderColor } + @ReactProp(name = "borderLeftColor") + override fun setBorderLeftColor(view: ButtonViewGroup, borderLeftColor: Int?) { + // view.setBorderColor(Spacing.LEFT, borderLeftColor) + } + + @ReactProp(name = "borderRightColor") + override fun setBorderRightColor(view: ButtonViewGroup, borderRightColor: Int?) { + // view.setBorderColor(Spacing.RIGHT, borderRightColor) + } + + @ReactProp(name = "borderTopColor") + override fun setBorderTopColor(view: ButtonViewGroup, borderTopColor: Int?) { + // view.setBorderColor(Spacing.TOP, borderTopColor) + } + + @ReactProp(name = "borderBottomColor") + override fun setBorderBottomColor(view: ButtonViewGroup, borderBottomColor: Int?) { + // view.setBorderColor(Spacing.BOTTOM, borderBottomColor) + } + + @ReactProp(name = "borderStartColor") + override fun setBorderStartColor(view: ButtonViewGroup, borderStartColor: Int?) { + // view.setBorderColor(Spacing.START, borderStartColor) + } + + @ReactProp(name = "borderEndColor") + override fun setBorderEndColor(view: ButtonViewGroup, borderEndColor: Int?) { + // view.setBorderColor(Spacing.END, borderEndColor) + } + @ReactProp(name = "borderStyle") override fun setBorderStyle(view: ButtonViewGroup, borderStyle: String?) { + // view.setBorderStyle(value) view.borderStyle = borderStyle } diff --git a/src/specs/RNGestureHandlerButtonNativeComponent.ts b/src/specs/RNGestureHandlerButtonNativeComponent.ts index 8d4c3da4b9..6035fc375b 100644 --- a/src/specs/RNGestureHandlerButtonNativeComponent.ts +++ b/src/specs/RNGestureHandlerButtonNativeComponent.ts @@ -14,8 +14,23 @@ interface NativeProps extends ViewProps { rippleColor?: ColorValue; rippleRadius?: Int32; touchSoundDisabled?: WithDefault; + borderWidth?: Float; + borderLeftWidth?: Float; + borderRightWidth?: Float; + borderTopWidth?: Float; + borderBottomWidth?: Float; + borderStartWidth?: Float; + borderEndWidth?: Float; + borderColor?: ColorValue; + borderLeftColor?: ColorValue; + borderRightColor?: ColorValue; + borderTopColor?: ColorValue; + borderBottomColor?: ColorValue; + borderStartColor?: ColorValue; + borderEndColor?: ColorValue; + borderStyle?: WithDefault; } From 1739938f691e30ff4d0b48698b284058739c69b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Fri, 14 Feb 2025 14:02:25 +0100 Subject: [PATCH 2/9] update paper codegen --- ...RNGestureHandlerButtonManagerDelegate.java | 36 +++++++++++++++++++ ...NGestureHandlerButtonManagerInterface.java | 12 +++++++ 2 files changed, 48 insertions(+) diff --git a/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java b/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java index 755f026e14..0a48c5d4d6 100644 --- a/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java +++ b/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java @@ -47,9 +47,45 @@ public void setProperty(T view, String propName, @Nullable Object value) { case "borderWidth": mViewManager.setBorderWidth(view, value == null ? 0f : ((Double) value).floatValue()); break; + case "borderLeftWidth": + mViewManager.setBorderLeftWidth(view, value == null ? 0f : ((Double) value).floatValue()); + break; + case "borderRightWidth": + mViewManager.setBorderRightWidth(view, value == null ? 0f : ((Double) value).floatValue()); + break; + case "borderTopWidth": + mViewManager.setBorderTopWidth(view, value == null ? 0f : ((Double) value).floatValue()); + break; + case "borderBottomWidth": + mViewManager.setBorderBottomWidth(view, value == null ? 0f : ((Double) value).floatValue()); + break; + case "borderStartWidth": + mViewManager.setBorderStartWidth(view, value == null ? 0f : ((Double) value).floatValue()); + break; + case "borderEndWidth": + mViewManager.setBorderEndWidth(view, value == null ? 0f : ((Double) value).floatValue()); + break; case "borderColor": mViewManager.setBorderColor(view, ColorPropConverter.getColor(value, view.getContext())); break; + case "borderLeftColor": + mViewManager.setBorderLeftColor(view, ColorPropConverter.getColor(value, view.getContext())); + break; + case "borderRightColor": + mViewManager.setBorderRightColor(view, ColorPropConverter.getColor(value, view.getContext())); + break; + case "borderTopColor": + mViewManager.setBorderTopColor(view, ColorPropConverter.getColor(value, view.getContext())); + break; + case "borderBottomColor": + mViewManager.setBorderBottomColor(view, ColorPropConverter.getColor(value, view.getContext())); + break; + case "borderStartColor": + mViewManager.setBorderStartColor(view, ColorPropConverter.getColor(value, view.getContext())); + break; + case "borderEndColor": + mViewManager.setBorderEndColor(view, ColorPropConverter.getColor(value, view.getContext())); + break; case "borderStyle": mViewManager.setBorderStyle(view, value == null ? "solid" : (String) value); break; diff --git a/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerInterface.java b/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerInterface.java index 8798d2c721..0764cfa965 100644 --- a/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerInterface.java +++ b/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerInterface.java @@ -21,6 +21,18 @@ public interface RNGestureHandlerButtonManagerInterface { void setRippleRadius(T view, int value); void setTouchSoundDisabled(T view, boolean value); void setBorderWidth(T view, float value); + void setBorderLeftWidth(T view, float value); + void setBorderRightWidth(T view, float value); + void setBorderTopWidth(T view, float value); + void setBorderBottomWidth(T view, float value); + void setBorderStartWidth(T view, float value); + void setBorderEndWidth(T view, float value); void setBorderColor(T view, @Nullable Integer value); + void setBorderLeftColor(T view, @Nullable Integer value); + void setBorderRightColor(T view, @Nullable Integer value); + void setBorderTopColor(T view, @Nullable Integer value); + void setBorderBottomColor(T view, @Nullable Integer value); + void setBorderStartColor(T view, @Nullable Integer value); + void setBorderEndColor(T view, @Nullable Integer value); void setBorderStyle(T view, @Nullable String value); } From f5318b59f5940fd85341e172daa29863db4bacce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Fri, 14 Feb 2025 15:48:18 +0100 Subject: [PATCH 3/9] move from `ViewGroup` to `ReactViewGroup` --- .../RNGestureHandlerButtonViewManager.kt | 261 ++++-------------- 1 file changed, 59 insertions(+), 202 deletions(-) diff --git a/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt b/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt index 7740054ae9..4d064ffa34 100644 --- a/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +++ b/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt @@ -3,17 +3,7 @@ package com.swmansion.gesturehandler.react import android.annotation.SuppressLint import android.annotation.TargetApi import android.content.Context -import android.content.res.ColorStateList import android.graphics.Color -import android.graphics.DashPathEffect -import android.graphics.Paint -import android.graphics.PathEffect -import android.graphics.drawable.Drawable -import android.graphics.drawable.LayerDrawable -import android.graphics.drawable.PaintDrawable -import android.graphics.drawable.RippleDrawable -import android.graphics.drawable.ShapeDrawable -import android.graphics.drawable.shapes.RectShape import android.os.Build import android.util.TypedValue import android.view.KeyEvent @@ -25,15 +15,21 @@ import android.view.ViewParent import android.view.accessibility.AccessibilityNodeInfo import androidx.core.view.children import com.facebook.react.R +import com.facebook.react.bridge.DynamicFromObject import com.facebook.react.module.annotations.ReactModule -import com.facebook.react.uimanager.PixelUtil +import com.facebook.react.uimanager.LengthPercentage +import com.facebook.react.uimanager.LengthPercentageType +import com.facebook.react.uimanager.Spacing import com.facebook.react.uimanager.ThemedReactContext import com.facebook.react.uimanager.ViewGroupManager import com.facebook.react.uimanager.ViewManagerDelegate -import com.facebook.react.uimanager.ViewProps import com.facebook.react.uimanager.annotations.ReactProp +import com.facebook.react.uimanager.common.UIManagerType +import com.facebook.react.uimanager.common.ViewUtil +import com.facebook.react.uimanager.style.BorderRadiusProp import com.facebook.react.viewmanagers.RNGestureHandlerButtonManagerDelegate import com.facebook.react.viewmanagers.RNGestureHandlerButtonManagerInterface +import com.facebook.react.views.view.ReactViewGroup import com.swmansion.gesturehandler.core.NativeViewGestureHandler import com.swmansion.gesturehandler.react.RNGestureHandlerButtonViewManager.ButtonViewGroup @@ -45,6 +41,19 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager(), R mDelegate = RNGestureHandlerButtonManagerDelegate(this) } + private fun borderRadiusFromDynamic(view: ButtonViewGroup, value: Float): LengthPercentage? { + var borderRadius = LengthPercentage.setFromDynamic(DynamicFromObject(value.toDouble())) + + if (ViewUtil.getUIManagerType(view) != UIManagerType.FABRIC && + borderRadius != null && + borderRadius.type == LengthPercentageType.PERCENT + ) { + borderRadius = null + } + + return borderRadius + } + override fun getName() = REACT_CLASS public override fun createViewInstance(context: ThemedReactContext) = ButtonViewGroup(context) @@ -70,107 +79,104 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager(), R view.isEnabled = enabled } - @ReactProp(name = ViewProps.BORDER_RADIUS) + @ReactProp(name = "borderRadius") override fun setBorderRadius(view: ButtonViewGroup, borderRadius: Float) { - view.borderRadius = borderRadius + view.setBorderRadius(BorderRadiusProp.BORDER_RADIUS, borderRadiusFromDynamic(view, borderRadius)) } @ReactProp(name = "borderTopLeftRadius") override fun setBorderTopLeftRadius(view: ButtonViewGroup, borderTopLeftRadius: Float) { - view.borderTopLeftRadius = borderTopLeftRadius + view.setBorderRadius(BorderRadiusProp.BORDER_TOP_LEFT_RADIUS, borderRadiusFromDynamic(view, borderTopLeftRadius)) } @ReactProp(name = "borderTopRightRadius") override fun setBorderTopRightRadius(view: ButtonViewGroup, borderTopRightRadius: Float) { - view.borderTopRightRadius = borderTopRightRadius + view.setBorderRadius(BorderRadiusProp.BORDER_TOP_RIGHT_RADIUS, borderRadiusFromDynamic(view, borderTopRightRadius)) } @ReactProp(name = "borderBottomLeftRadius") override fun setBorderBottomLeftRadius(view: ButtonViewGroup, borderBottomLeftRadius: Float) { - view.borderBottomLeftRadius = borderBottomLeftRadius + view.setBorderRadius(BorderRadiusProp.BORDER_BOTTOM_LEFT_RADIUS, borderRadiusFromDynamic(view, borderBottomLeftRadius)) } @ReactProp(name = "borderBottomRightRadius") override fun setBorderBottomRightRadius(view: ButtonViewGroup, borderBottomRightRadius: Float) { - view.borderBottomRightRadius = borderBottomRightRadius + view.setBorderRadius(BorderRadiusProp.BORDER_BOTTOM_RIGHT_RADIUS, borderRadiusFromDynamic(view, borderBottomRightRadius)) } @ReactProp(name = "borderWidth") override fun setBorderWidth(view: ButtonViewGroup, borderWidth: Float) { - // view.setBorderWidth(Spacing.ALL, borderWidth) - view.borderWidth = borderWidth + view.setBorderWidth(Spacing.ALL, borderWidth) } @ReactProp(name = "borderStartWidth") override fun setBorderLeftWidth(view: ButtonViewGroup, borderStartWidth: Float) { - // view.setBorderWidth(Spacing.LEFT, borderStartWidth) + view.setBorderWidth(Spacing.LEFT, borderStartWidth) } @ReactProp(name = "borderRightWidth") override fun setBorderRightWidth(view: ButtonViewGroup, borderRightWidth: Float) { - // view.setBorderWidth(Spacing.RIGHT, borderRightWidth) + view.setBorderWidth(Spacing.RIGHT, borderRightWidth) } @ReactProp(name = "borderTopWidth") override fun setBorderTopWidth(view: ButtonViewGroup, borderTopWidth: Float) { - // view.setBorderWidth(Spacing.TOP, borderTopWidth) + view.setBorderWidth(Spacing.TOP, borderTopWidth) } @ReactProp(name = "borderBottomWidth") override fun setBorderBottomWidth(view: ButtonViewGroup, borderBottomWidth: Float) { - // view.setBorderWidth(Spacing.BOTTOM, borderBottomWidth) + view.setBorderWidth(Spacing.BOTTOM, borderBottomWidth) } @ReactProp(name = "borderStartWidth") override fun setBorderStartWidth(view: ButtonViewGroup, borderStartWidth: Float) { - // view.setBorderWidth(Spacing.START, borderStartWidth) + view.setBorderWidth(Spacing.START, borderStartWidth) } @ReactProp(name = "borderEndWidth") override fun setBorderEndWidth(view: ButtonViewGroup, borderEndWidth: Float) { - // view.setBorderWidth(Spacing.END, borderEndWidth) + view.setBorderWidth(Spacing.END, borderEndWidth) } @ReactProp(name = "borderColor") override fun setBorderColor(view: ButtonViewGroup, borderColor: Int?) { - // view.setBorderColor(Spacing.ALL, borderColor) - view.borderColor = borderColor + view.setBorderColor(Spacing.ALL, borderColor) } @ReactProp(name = "borderLeftColor") override fun setBorderLeftColor(view: ButtonViewGroup, borderLeftColor: Int?) { - // view.setBorderColor(Spacing.LEFT, borderLeftColor) + view.setBorderColor(Spacing.LEFT, borderLeftColor) } @ReactProp(name = "borderRightColor") override fun setBorderRightColor(view: ButtonViewGroup, borderRightColor: Int?) { - // view.setBorderColor(Spacing.RIGHT, borderRightColor) + view.setBorderColor(Spacing.RIGHT, borderRightColor) } @ReactProp(name = "borderTopColor") override fun setBorderTopColor(view: ButtonViewGroup, borderTopColor: Int?) { - // view.setBorderColor(Spacing.TOP, borderTopColor) + view.setBorderColor(Spacing.TOP, borderTopColor) } @ReactProp(name = "borderBottomColor") override fun setBorderBottomColor(view: ButtonViewGroup, borderBottomColor: Int?) { - // view.setBorderColor(Spacing.BOTTOM, borderBottomColor) + view.setBorderColor(Spacing.BOTTOM, borderBottomColor) } @ReactProp(name = "borderStartColor") override fun setBorderStartColor(view: ButtonViewGroup, borderStartColor: Int?) { - // view.setBorderColor(Spacing.START, borderStartColor) + view.setBorderColor(Spacing.START, borderStartColor) } @ReactProp(name = "borderEndColor") override fun setBorderEndColor(view: ButtonViewGroup, borderEndColor: Int?) { - // view.setBorderColor(Spacing.END, borderEndColor) + view.setBorderColor(Spacing.END, borderEndColor) } @ReactProp(name = "borderStyle") override fun setBorderStyle(view: ButtonViewGroup, borderStyle: String?) { - // view.setBorderStyle(value) - view.borderStyle = borderStyle + view.setBorderStyle(borderStyle) } @ReactProp(name = "rippleColor") @@ -193,18 +199,12 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager(), R view.isSoundEffectsEnabled = !touchSoundDisabled } - override fun onAfterUpdateTransaction(view: ButtonViewGroup) { - super.onAfterUpdateTransaction(view) - - view.updateBackground() - } - override fun getDelegate(): ViewManagerDelegate? { return mDelegate } class ButtonViewGroup(context: Context?) : - ViewGroup(context), + ReactViewGroup(context), NativeViewGestureHandler.NativeViewGestureHandlerHook { // Using object because of handling null representing no value set. var rippleColor: Int? = null @@ -216,50 +216,13 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager(), R set(radius) = withBackgroundUpdate { field = radius } + var useDrawableOnForeground = false set(useForeground) = withBackgroundUpdate { field = useForeground } - var useBorderlessDrawable = false - var borderRadius = 0f - set(radius) = withBackgroundUpdate { - field = radius * resources.displayMetrics.density - } - var borderTopLeftRadius = 0f - set(radius) = withBackgroundUpdate { - field = radius * resources.displayMetrics.density - } - var borderTopRightRadius = 0f - set(radius) = withBackgroundUpdate { - field = radius * resources.displayMetrics.density - } - var borderBottomLeftRadius = 0f - set(radius) = withBackgroundUpdate { - field = radius * resources.displayMetrics.density - } - var borderBottomRightRadius = 0f - set(radius) = withBackgroundUpdate { - field = radius * resources.displayMetrics.density - } - var borderWidth = 0f - set(width) = withBackgroundUpdate { - field = width * resources.displayMetrics.density - } - var borderColor: Int? = null - set(color) = withBackgroundUpdate { - field = color - } - var borderStyle: String? = "solid" - set(style) = withBackgroundUpdate { - field = style - } - private val hasBorderRadii: Boolean - get() = borderRadius != 0f || - borderTopLeftRadius != 0f || - borderTopRightRadius != 0f || - borderBottomLeftRadius != 0f || - borderBottomRightRadius != 0f + var useBorderlessDrawable = false var exclusive = true @@ -285,30 +248,6 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager(), R needBackgroundUpdate = true } - private fun buildBorderRadii(): FloatArray { - // duplicate radius for each corner, as setCornerRadii expects X radius and Y radius for each - return floatArrayOf( - borderTopLeftRadius, - borderTopLeftRadius, - borderTopRightRadius, - borderTopRightRadius, - borderBottomRightRadius, - borderBottomRightRadius, - borderBottomLeftRadius, - borderBottomLeftRadius, - ) - .map { if (it != 0f) it else borderRadius } - .toFloatArray() - } - - private fun buildBorderStyle(): PathEffect? { - return when (borderStyle) { - "dotted" -> DashPathEffect(floatArrayOf(borderWidth, borderWidth, borderWidth, borderWidth), 0f) - "dashed" -> DashPathEffect(floatArrayOf(borderWidth * 3, borderWidth * 3, borderWidth * 3, borderWidth * 3), 0f) - else -> null - } - } - override fun setBackgroundColor(color: Int) = withBackgroundUpdate { _backgroundColor = color } @@ -381,102 +320,20 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager(), R return false } - private fun updateBackgroundColor(backgroundColor: Int, borderDrawable: Drawable, selectable: Drawable?) { - val colorDrawable = PaintDrawable(backgroundColor) - - if (hasBorderRadii) { - colorDrawable.setCornerRadii(buildBorderRadii()) - } - - val layerDrawable = LayerDrawable(if (selectable != null) arrayOf(colorDrawable, selectable, borderDrawable) else arrayOf(colorDrawable, borderDrawable)) - background = layerDrawable - } - - fun updateBackground() { - if (!needBackgroundUpdate) { - return - } - needBackgroundUpdate = false - - if (_backgroundColor == Color.TRANSPARENT) { - // reset background - background = null - } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - // reset foreground - foreground = null - } - - val selectable = createSelectableDrawable() - val borderDrawable = createBorderDrawable() - - if (hasBorderRadii && selectable is RippleDrawable) { - val mask = PaintDrawable(Color.WHITE) - mask.setCornerRadii(buildBorderRadii()) - selectable.setDrawableByLayerId(android.R.id.mask, mask) - } - - if (useDrawableOnForeground && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - foreground = selectable - if (_backgroundColor != Color.TRANSPARENT) { - updateBackgroundColor(_backgroundColor, borderDrawable, null) - } - } else if (_backgroundColor == Color.TRANSPARENT && rippleColor == null) { - background = LayerDrawable(arrayOf(selectable, borderDrawable)) - } else { - updateBackgroundColor(_backgroundColor, borderDrawable, selectable) - } - } - - private fun createBorderDrawable(): Drawable { - val borderDrawable = PaintDrawable(Color.TRANSPARENT) - - if (hasBorderRadii) { - borderDrawable.setCornerRadii(buildBorderRadii()) - } - - if (borderWidth > 0f) { - borderDrawable.paint.apply { - style = Paint.Style.STROKE - strokeWidth = borderWidth - color = borderColor ?: Color.BLACK - pathEffect = buildBorderStyle() - } - } - - return borderDrawable - } - - private fun createSelectableDrawable(): Drawable? { - // don't create ripple drawable at all when it's not supposed to be visible - if (rippleColor == Color.TRANSPARENT) { - return null - } - - val states = arrayOf(intArrayOf(android.R.attr.state_enabled)) - val rippleRadius = rippleRadius - val colorStateList = if (rippleColor != null) { - val colors = intArrayOf(rippleColor!!) - ColorStateList(states, colors) - } else { - // if rippleColor is null, reapply the default color - context.theme.resolveAttribute(android.R.attr.colorControlHighlight, resolveOutValue, true) - val colors = intArrayOf(resolveOutValue.data) - ColorStateList(states, colors) - } - - val drawable = RippleDrawable( - colorStateList, - null, - if (useBorderlessDrawable) null else ShapeDrawable(RectShape()) - ) - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && rippleRadius != null) { - drawable.radius = PixelUtil.toPixelFromDIP(rippleRadius.toFloat()).toInt() - } - - return drawable - } +// fun updateBackground() { +// if (!needBackgroundUpdate) { +// return +// } +// needBackgroundUpdate = false +// +// val selectable = createSelectableDrawable() +// +// if (selectable is RippleDrawable) { +// val mask = PaintDrawable(Color.WHITE) +// mask.setCornerRadii(buildBorderRadii()) +// selectable.setDrawableByLayerId(android.R.id.mask, mask) +// } +// } override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) { // No-op From 9a5cb68403a4860a54b1112c70d85b1a25b81d8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Fri, 14 Feb 2025 15:52:44 +0100 Subject: [PATCH 4/9] fix background color being intercepted --- .../react/RNGestureHandlerButtonViewManager.kt | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt b/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt index 4d064ffa34..8d77473804 100644 --- a/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +++ b/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt @@ -3,7 +3,6 @@ package com.swmansion.gesturehandler.react import android.annotation.SuppressLint import android.annotation.TargetApi import android.content.Context -import android.graphics.Color import android.os.Build import android.util.TypedValue import android.view.KeyEvent @@ -66,7 +65,7 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager(), R @ReactProp(name = "backgroundColor") override fun setBackgroundColor(view: ButtonViewGroup, backgroundColor: Int) { - view.setBackgroundColor(backgroundColor) + view.backgroundColor = backgroundColor } @ReactProp(name = "borderless") @@ -226,7 +225,6 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager(), R var exclusive = true - private var _backgroundColor = Color.TRANSPARENT private var needBackgroundUpdate = false private var lastEventTime = -1L private var lastAction = -1 @@ -248,10 +246,6 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager(), R needBackgroundUpdate = true } - override fun setBackgroundColor(color: Int) = withBackgroundUpdate { - _backgroundColor = color - } - override fun onInitializeAccessibilityNodeInfo(info: AccessibilityNodeInfo) { super.onInitializeAccessibilityNodeInfo(info) From 98a95ffd83898851bf7d3b1c9f9b6fa22f9f2334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Fri, 14 Feb 2025 17:12:34 +0100 Subject: [PATCH 5/9] use dynamic types for radius --- .../react/RNGestureHandlerButtonViewManager.kt | 15 ++++++++------- .../RNGestureHandlerButtonNativeComponent.ts | 9 +++++++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt b/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt index 8d77473804..4ab7337f2d 100644 --- a/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +++ b/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt @@ -14,6 +14,7 @@ import android.view.ViewParent import android.view.accessibility.AccessibilityNodeInfo import androidx.core.view.children import com.facebook.react.R +import com.facebook.react.bridge.Dynamic import com.facebook.react.bridge.DynamicFromObject import com.facebook.react.module.annotations.ReactModule import com.facebook.react.uimanager.LengthPercentage @@ -40,8 +41,8 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager(), R mDelegate = RNGestureHandlerButtonManagerDelegate(this) } - private fun borderRadiusFromDynamic(view: ButtonViewGroup, value: Float): LengthPercentage? { - var borderRadius = LengthPercentage.setFromDynamic(DynamicFromObject(value.toDouble())) + private fun borderRadiusFromDynamic(view: ButtonViewGroup, value: Dynamic): LengthPercentage? { + var borderRadius = LengthPercentage.setFromDynamic(DynamicFromObject(value)) if (ViewUtil.getUIManagerType(view) != UIManagerType.FABRIC && borderRadius != null && @@ -79,27 +80,27 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager(), R } @ReactProp(name = "borderRadius") - override fun setBorderRadius(view: ButtonViewGroup, borderRadius: Float) { + override fun setBorderRadius(view: ButtonViewGroup, borderRadius: Dynamic) { view.setBorderRadius(BorderRadiusProp.BORDER_RADIUS, borderRadiusFromDynamic(view, borderRadius)) } @ReactProp(name = "borderTopLeftRadius") - override fun setBorderTopLeftRadius(view: ButtonViewGroup, borderTopLeftRadius: Float) { + override fun setBorderTopLeftRadius(view: ButtonViewGroup, borderTopLeftRadius: Dynamic) { view.setBorderRadius(BorderRadiusProp.BORDER_TOP_LEFT_RADIUS, borderRadiusFromDynamic(view, borderTopLeftRadius)) } @ReactProp(name = "borderTopRightRadius") - override fun setBorderTopRightRadius(view: ButtonViewGroup, borderTopRightRadius: Float) { + override fun setBorderTopRightRadius(view: ButtonViewGroup, borderTopRightRadius: Dynamic) { view.setBorderRadius(BorderRadiusProp.BORDER_TOP_RIGHT_RADIUS, borderRadiusFromDynamic(view, borderTopRightRadius)) } @ReactProp(name = "borderBottomLeftRadius") - override fun setBorderBottomLeftRadius(view: ButtonViewGroup, borderBottomLeftRadius: Float) { + override fun setBorderBottomLeftRadius(view: ButtonViewGroup, borderBottomLeftRadius: Dynamic) { view.setBorderRadius(BorderRadiusProp.BORDER_BOTTOM_LEFT_RADIUS, borderRadiusFromDynamic(view, borderBottomLeftRadius)) } @ReactProp(name = "borderBottomRightRadius") - override fun setBorderBottomRightRadius(view: ButtonViewGroup, borderBottomRightRadius: Float) { + override fun setBorderBottomRightRadius(view: ButtonViewGroup, borderBottomRightRadius: Dynamic) { view.setBorderRadius(BorderRadiusProp.BORDER_BOTTOM_RIGHT_RADIUS, borderRadiusFromDynamic(view, borderBottomRightRadius)) } diff --git a/src/specs/RNGestureHandlerButtonNativeComponent.ts b/src/specs/RNGestureHandlerButtonNativeComponent.ts index 6035fc375b..5966cf47e6 100644 --- a/src/specs/RNGestureHandlerButtonNativeComponent.ts +++ b/src/specs/RNGestureHandlerButtonNativeComponent.ts @@ -3,6 +3,7 @@ import type { Int32, WithDefault, Float, + UnsafeMixed, } from 'react-native/Libraries/Types/CodegenTypes'; import type { ViewProps, ColorValue } from 'react-native'; @@ -15,6 +16,14 @@ interface NativeProps extends ViewProps { rippleRadius?: Int32; touchSoundDisabled?: WithDefault; + // explicitly redefine `borderFooRadius`, as `ViewProps` defines it as `Float`, + // but as of RN 0.75.0 it should be defined as `Dynamic` (`Double | string` or `UnsafeMixed`). + borderRadius?: UnsafeMixed; + borderTopLeftRadius?: UnsafeMixed; + borderTopRightRadius?: UnsafeMixed; + borderBottomLeftRadius?: UnsafeMixed; + borderBottomRightRadius?: UnsafeMixed; + borderWidth?: Float; borderLeftWidth?: Float; borderRightWidth?: Float; From d69f5206c79e3d2da5e455dc1fa9c0e1e959ef52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Fri, 14 Feb 2025 17:13:01 +0100 Subject: [PATCH 6/9] update paper codegen --- .../RNGestureHandlerButtonManagerDelegate.java | 16 ++++++++++++++++ .../RNGestureHandlerButtonManagerInterface.java | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java b/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java index 0a48c5d4d6..4f5efa64fc 100644 --- a/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java +++ b/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java @@ -12,6 +12,7 @@ import android.view.View; import androidx.annotation.Nullable; import com.facebook.react.bridge.ColorPropConverter; +import com.facebook.react.bridge.DynamicFromObject; import com.facebook.react.uimanager.BaseViewManager; import com.facebook.react.uimanager.BaseViewManagerDelegate; import com.facebook.react.uimanager.LayoutShadowNode; @@ -44,6 +45,21 @@ public void setProperty(T view, String propName, @Nullable Object value) { case "touchSoundDisabled": mViewManager.setTouchSoundDisabled(view, value == null ? false : (boolean) value); break; + case "borderRadius": + mViewManager.setBorderRadius(view, new DynamicFromObject(value)); + break; + case "borderTopLeftRadius": + mViewManager.setBorderTopLeftRadius(view, new DynamicFromObject(value)); + break; + case "borderTopRightRadius": + mViewManager.setBorderTopRightRadius(view, new DynamicFromObject(value)); + break; + case "borderBottomLeftRadius": + mViewManager.setBorderBottomLeftRadius(view, new DynamicFromObject(value)); + break; + case "borderBottomRightRadius": + mViewManager.setBorderBottomRightRadius(view, new DynamicFromObject(value)); + break; case "borderWidth": mViewManager.setBorderWidth(view, value == null ? 0f : ((Double) value).floatValue()); break; diff --git a/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerInterface.java b/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerInterface.java index 0764cfa965..45e2921fc7 100644 --- a/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerInterface.java +++ b/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerInterface.java @@ -11,6 +11,7 @@ import android.view.View; import androidx.annotation.Nullable; +import com.facebook.react.bridge.Dynamic; public interface RNGestureHandlerButtonManagerInterface { void setExclusive(T view, boolean value); @@ -20,6 +21,11 @@ public interface RNGestureHandlerButtonManagerInterface { void setRippleColor(T view, @Nullable Integer value); void setRippleRadius(T view, int value); void setTouchSoundDisabled(T view, boolean value); + void setBorderRadius(T view, Dynamic value); + void setBorderTopLeftRadius(T view, Dynamic value); + void setBorderTopRightRadius(T view, Dynamic value); + void setBorderBottomLeftRadius(T view, Dynamic value); + void setBorderBottomRightRadius(T view, Dynamic value); void setBorderWidth(T view, float value); void setBorderLeftWidth(T view, float value); void setBorderRightWidth(T view, float value); From 990f32702a2c1eaf35e311c42fc76a7cd5d148c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Fri, 14 Feb 2025 17:26:09 +0100 Subject: [PATCH 7/9] simplify initialization, simplify one return type --- .../react/RNGestureHandlerButtonViewManager.kt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt b/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt index 4ab7337f2d..a7beaec0c7 100644 --- a/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +++ b/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt @@ -35,11 +35,8 @@ import com.swmansion.gesturehandler.react.RNGestureHandlerButtonViewManager.Butt @ReactModule(name = RNGestureHandlerButtonViewManager.REACT_CLASS) class RNGestureHandlerButtonViewManager : ViewGroupManager(), RNGestureHandlerButtonManagerInterface { - private val mDelegate: ViewManagerDelegate - - init { - mDelegate = RNGestureHandlerButtonManagerDelegate(this) - } + private val mDelegate: ViewManagerDelegate = + RNGestureHandlerButtonManagerDelegate(this) private fun borderRadiusFromDynamic(view: ButtonViewGroup, value: Dynamic): LengthPercentage? { var borderRadius = LengthPercentage.setFromDynamic(DynamicFromObject(value)) @@ -199,7 +196,7 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager(), R view.isSoundEffectsEnabled = !touchSoundDisabled } - override fun getDelegate(): ViewManagerDelegate? { + override fun getDelegate(): ViewManagerDelegate { return mDelegate } From 89db763ba6040ff5d6cb830475567b282ea7164d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Fri, 14 Feb 2025 17:37:56 +0100 Subject: [PATCH 8/9] fix border invalid width --- .../RNGestureHandlerButtonViewManager.kt | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt b/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt index a7beaec0c7..51f7f9d483 100644 --- a/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +++ b/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt @@ -19,6 +19,7 @@ import com.facebook.react.bridge.DynamicFromObject import com.facebook.react.module.annotations.ReactModule import com.facebook.react.uimanager.LengthPercentage import com.facebook.react.uimanager.LengthPercentageType +import com.facebook.react.uimanager.PixelUtil import com.facebook.react.uimanager.Spacing import com.facebook.react.uimanager.ThemedReactContext import com.facebook.react.uimanager.ViewGroupManager @@ -103,37 +104,37 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager(), R @ReactProp(name = "borderWidth") override fun setBorderWidth(view: ButtonViewGroup, borderWidth: Float) { - view.setBorderWidth(Spacing.ALL, borderWidth) + view.setBorderWidth(Spacing.ALL, PixelUtil.toPixelFromDIP(borderWidth)) } - @ReactProp(name = "borderStartWidth") - override fun setBorderLeftWidth(view: ButtonViewGroup, borderStartWidth: Float) { - view.setBorderWidth(Spacing.LEFT, borderStartWidth) + @ReactProp(name = "borderLeftWidth") + override fun setBorderLeftWidth(view: ButtonViewGroup, borderLeftWidth: Float) { + view.setBorderWidth(Spacing.LEFT, PixelUtil.toPixelFromDIP(borderLeftWidth)) } @ReactProp(name = "borderRightWidth") override fun setBorderRightWidth(view: ButtonViewGroup, borderRightWidth: Float) { - view.setBorderWidth(Spacing.RIGHT, borderRightWidth) + view.setBorderWidth(Spacing.RIGHT, PixelUtil.toPixelFromDIP(borderRightWidth)) } @ReactProp(name = "borderTopWidth") override fun setBorderTopWidth(view: ButtonViewGroup, borderTopWidth: Float) { - view.setBorderWidth(Spacing.TOP, borderTopWidth) + view.setBorderWidth(Spacing.TOP, PixelUtil.toPixelFromDIP(borderTopWidth)) } @ReactProp(name = "borderBottomWidth") override fun setBorderBottomWidth(view: ButtonViewGroup, borderBottomWidth: Float) { - view.setBorderWidth(Spacing.BOTTOM, borderBottomWidth) + view.setBorderWidth(Spacing.BOTTOM, PixelUtil.toPixelFromDIP(borderBottomWidth)) } @ReactProp(name = "borderStartWidth") override fun setBorderStartWidth(view: ButtonViewGroup, borderStartWidth: Float) { - view.setBorderWidth(Spacing.START, borderStartWidth) + view.setBorderWidth(Spacing.START, PixelUtil.toPixelFromDIP(borderStartWidth)) } @ReactProp(name = "borderEndWidth") override fun setBorderEndWidth(view: ButtonViewGroup, borderEndWidth: Float) { - view.setBorderWidth(Spacing.END, borderEndWidth) + view.setBorderWidth(Spacing.END, PixelUtil.toPixelFromDIP(borderEndWidth)) } @ReactProp(name = "borderColor") From 9782d389ea967e2bde02cab39278b36527058091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20=C5=81=C4=85tka?= Date: Fri, 14 Feb 2025 17:56:15 +0100 Subject: [PATCH 9/9] fix border side positioning --- .../RNGestureHandlerButtonViewManager.kt | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt b/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt index 51f7f9d483..bd3056c891 100644 --- a/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +++ b/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt @@ -20,7 +20,6 @@ import com.facebook.react.module.annotations.ReactModule import com.facebook.react.uimanager.LengthPercentage import com.facebook.react.uimanager.LengthPercentageType import com.facebook.react.uimanager.PixelUtil -import com.facebook.react.uimanager.Spacing import com.facebook.react.uimanager.ThemedReactContext import com.facebook.react.uimanager.ViewGroupManager import com.facebook.react.uimanager.ViewManagerDelegate @@ -104,72 +103,74 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager(), R @ReactProp(name = "borderWidth") override fun setBorderWidth(view: ButtonViewGroup, borderWidth: Float) { - view.setBorderWidth(Spacing.ALL, PixelUtil.toPixelFromDIP(borderWidth)) + view.setBorderWidth(SIDE_ALL, PixelUtil.toPixelFromDIP(borderWidth)) } @ReactProp(name = "borderLeftWidth") override fun setBorderLeftWidth(view: ButtonViewGroup, borderLeftWidth: Float) { - view.setBorderWidth(Spacing.LEFT, PixelUtil.toPixelFromDIP(borderLeftWidth)) + view.setBorderWidth(SIDE_LEFT, PixelUtil.toPixelFromDIP(borderLeftWidth)) } @ReactProp(name = "borderRightWidth") override fun setBorderRightWidth(view: ButtonViewGroup, borderRightWidth: Float) { - view.setBorderWidth(Spacing.RIGHT, PixelUtil.toPixelFromDIP(borderRightWidth)) + view.setBorderWidth(SIDE_RIGHT, PixelUtil.toPixelFromDIP(borderRightWidth)) } @ReactProp(name = "borderTopWidth") override fun setBorderTopWidth(view: ButtonViewGroup, borderTopWidth: Float) { - view.setBorderWidth(Spacing.TOP, PixelUtil.toPixelFromDIP(borderTopWidth)) + view.setBorderWidth(SIDE_TOP, PixelUtil.toPixelFromDIP(borderTopWidth)) } @ReactProp(name = "borderBottomWidth") override fun setBorderBottomWidth(view: ButtonViewGroup, borderBottomWidth: Float) { - view.setBorderWidth(Spacing.BOTTOM, PixelUtil.toPixelFromDIP(borderBottomWidth)) + view.setBorderWidth(SIDE_BOTTOM, PixelUtil.toPixelFromDIP(borderBottomWidth)) } @ReactProp(name = "borderStartWidth") override fun setBorderStartWidth(view: ButtonViewGroup, borderStartWidth: Float) { - view.setBorderWidth(Spacing.START, PixelUtil.toPixelFromDIP(borderStartWidth)) + // todo: make this dependant on the RTL setting + view.setBorderWidth(SIDE_LEFT, PixelUtil.toPixelFromDIP(borderStartWidth)) } @ReactProp(name = "borderEndWidth") override fun setBorderEndWidth(view: ButtonViewGroup, borderEndWidth: Float) { - view.setBorderWidth(Spacing.END, PixelUtil.toPixelFromDIP(borderEndWidth)) + view.setBorderWidth(SIDE_RIGHT, PixelUtil.toPixelFromDIP(borderEndWidth)) } @ReactProp(name = "borderColor") override fun setBorderColor(view: ButtonViewGroup, borderColor: Int?) { - view.setBorderColor(Spacing.ALL, borderColor) + view.setBorderColor(SIDE_ALL, borderColor) } @ReactProp(name = "borderLeftColor") override fun setBorderLeftColor(view: ButtonViewGroup, borderLeftColor: Int?) { - view.setBorderColor(Spacing.LEFT, borderLeftColor) + view.setBorderColor(SIDE_LEFT, borderLeftColor) } @ReactProp(name = "borderRightColor") override fun setBorderRightColor(view: ButtonViewGroup, borderRightColor: Int?) { - view.setBorderColor(Spacing.RIGHT, borderRightColor) + view.setBorderColor(SIDE_RIGHT, borderRightColor) } @ReactProp(name = "borderTopColor") override fun setBorderTopColor(view: ButtonViewGroup, borderTopColor: Int?) { - view.setBorderColor(Spacing.TOP, borderTopColor) + view.setBorderColor(SIDE_TOP, borderTopColor) } @ReactProp(name = "borderBottomColor") override fun setBorderBottomColor(view: ButtonViewGroup, borderBottomColor: Int?) { - view.setBorderColor(Spacing.BOTTOM, borderBottomColor) + view.setBorderColor(SIDE_BOTTOM, borderBottomColor) } @ReactProp(name = "borderStartColor") override fun setBorderStartColor(view: ButtonViewGroup, borderStartColor: Int?) { - view.setBorderColor(Spacing.START, borderStartColor) + // todo: make this dependant on the RTL setting + view.setBorderColor(SIDE_LEFT, borderStartColor) } @ReactProp(name = "borderEndColor") override fun setBorderEndColor(view: ButtonViewGroup, borderEndColor: Int?) { - view.setBorderColor(Spacing.END, borderEndColor) + view.setBorderColor(SIDE_RIGHT, borderEndColor) } @ReactProp(name = "borderStyle") @@ -477,5 +478,10 @@ class RNGestureHandlerButtonViewManager : ViewGroupManager(), R companion object { const val REACT_CLASS = "RNGestureHandlerButton" + const val SIDE_ALL = 0 + const val SIDE_LEFT = 1 + const val SIDE_RIGHT = 2 + const val SIDE_TOP = 3 + const val SIDE_BOTTOM = 4 } }