Skip to content

Commit

Permalink
Merge pull request #695 from lukailun/fix/support_rn_0.77
Browse files Browse the repository at this point in the history
feat: Support RN 0.77
  • Loading branch information
scarlac authored Feb 11, 2025
2 parents 1a7fa27 + 7e94541 commit e449cfd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
16 changes: 14 additions & 2 deletions android/src/main/java/com/rncamerakit/RNCameraKitModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class RNCameraKitModule(private val reactContext: ReactApplicationContext) : Nat
* Captures a photo using the camera.
*
* @param options The options for the capture operation.
* @param viewTag The tag of the camera view.
* @param tag The tag of the camera view.
* @param promise The promise to resolve the capture result.
*/
@ReactMethod
Expand All @@ -74,7 +74,19 @@ class RNCameraKitModule(private val reactContext: ReactApplicationContext) : Nat
val uiManager = UIManagerHelper.getUIManagerForReactTag(reactContext, viewTag)
reactContext.runOnUiQueueThread {
val camera = uiManager?.resolveView(viewTag) as CKCamera
camera.capture(options.toHashMap(), promise)
val optionsMap = options.toHashMap()
.mapValues { (_, value) ->
when (value) {
is ReadableMap -> value.toHashMap()
is ReadableArray -> value.toArrayList()
else -> value
}
}
.mapNotNull { (key, value) ->
if (value != null) key to value else null
}
.toMap()
camera.capture(optionsMap, promise)
}
} else {
promise.reject("E_CAPTURE_FAILED", "options or/and tag arguments are null, options: $options, tag: $viewTag")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.ColorPropConverter;
import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.BaseViewManagerInterface;
import com.facebook.react.uimanager.LayoutShadowNode;

public class CKCameraManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & CKCameraManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public class CKCameraManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & CKCameraManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public CKCameraManagerDelegate(U viewManager) {
super(viewManager);
}
Expand Down

0 comments on commit e449cfd

Please sign in to comment.