Closed mykyta-rusyn closed 1 day ago
Hi! 👋
Firstly, thanks for your work on this project! 🙂
In Android below API 30, we can't use setPath() method, so I replaced it with setRoundRect(). I'm not sure how to set just one corner
setPath()
setRoundRect()
Here is the diff that solved my problem:
diff --git a/node_modules/@candlefinance/faster-image/android/src/main/java/com/candlefinance/fasterimage/FasterImageViewManager.kt b/node_modules/@candlefinance/faster-image/android/src/main/java/com/candlefinance/fasterimage/FasterImageViewManager.kt index 5b2fa1a..3dcca1f 100644 --- a/node_modules/@candlefinance/faster-image/android/src/main/java/com/candlefinance/fasterimage/FasterImageViewManager.kt +++ b/node_modules/@candlefinance/faster-image/android/src/main/java/com/candlefinance/fasterimage/FasterImageViewManager.kt @@ -1,6 +1,6 @@ package com.candlefinance.fasterimage - import android.graphics.Bitmap +import android.graphics.Bitmap import android.graphics.BitmapFactory import android.graphics.ColorMatrix import android.graphics.ColorMatrixColorFilter @@ -10,6 +10,7 @@ import android.graphics.RectF import android.graphics.Path import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.Drawable +import android.os.Build import android.util.Base64 import android.view.View import android.view.ViewOutlineProvider @@ -183,6 +184,7 @@ import com.facebook.react.uimanager.events.RCTEventEmitter } private fun setViewBorderRadius(view: AppCompatImageView, borderRadii: BorderRadii) { + view.clipToOutline = true view.outlineProvider = object : ViewOutlineProvider() { override fun getOutline(view: View, outline: Outline) { @@ -212,7 +214,11 @@ import com.facebook.react.uimanager.events.RCTEventEmitter ) } - outline.setPath(path) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + outline.setPath(path) + } else { + outline.setRoundRect(rect, borderRadii.sum().toFloat()) + } } } }
Thanks for the report. Happy to accept a PR else I can add this later in the week.
Hi! 👋
Firstly, thanks for your work on this project! 🙂
In Android below API 30, we can't use
setPath()
method, so I replaced it withsetRoundRect()
. I'm not sure how to set just one cornerHere is the diff that solved my problem: