From 516e65e7fee852e9ee7b6f6792ffba28c139beda Mon Sep 17 00:00:00 2001 From: Med Dhia <32268384+dhiasaadlaui@users.noreply.github.com> Date: Thu, 24 Aug 2023 17:37:44 +0100 Subject: [PATCH] Update RNCameraKitModule.kt with KDoc --- .../java/com/rncamerakit/RNCameraKitModule.kt | 48 ++++++++++++++++--- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/android/src/main/java/com/rncamerakit/RNCameraKitModule.kt b/android/src/main/java/com/rncamerakit/RNCameraKitModule.kt index be8ad9a6a..2761f2ae2 100644 --- a/android/src/main/java/com/rncamerakit/RNCameraKitModule.kt +++ b/android/src/main/java/com/rncamerakit/RNCameraKitModule.kt @@ -3,14 +3,36 @@ package com.rncamerakit import com.facebook.react.bridge.* import com.facebook.react.uimanager.UIManagerModule +/** + * Native module for interacting with the camera in React Native applications. + * + * This module provides methods to capture photos using the camera and constants + * related to camera orientation. + * + * @param reactContext The application's ReactApplicationContext. + */ class RNCameraKitModule(private val reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) { companion object { - // 0-indexed, rotates counter-clockwise - // Values map to CameraX's Surface.ROTATION_* constants + // Constants for camera orientation + /** + * Represents the portrait orientation with the top of the device up. + */ const val PORTRAIT = 0 // ⬆️ + + /** + * Represents the landscape orientation with the left side of the device up. + */ const val LANDSCAPE_LEFT = 1 // ⬅️ + + /** + * Represents the portrait orientation with the bottom of the device up. + */ const val PORTRAIT_UPSIDE_DOWN = 2 // ⬇️ + + /** + * Represents the landscape orientation with the right side of the device up. + */ const val LANDSCAPE_RIGHT = 3 // ➡️ } @@ -18,15 +40,27 @@ class RNCameraKitModule(private val reactContext: ReactApplicationContext) : Rea return "RNCameraKitModule" } + /** + * Provides constants related to camera orientation. + * + * @return A map containing camera orientation constants. + */ override fun getConstants(): Map { return hashMapOf( - "PORTRAIT" to PORTRAIT, - "PORTRAIT_UPSIDE_DOWN" to PORTRAIT_UPSIDE_DOWN, - "LANDSCAPE_LEFT" to LANDSCAPE_LEFT, - "LANDSCAPE_RIGHT" to LANDSCAPE_RIGHT + "PORTRAIT" to PORTRAIT, + "PORTRAIT_UPSIDE_DOWN" to PORTRAIT_UPSIDE_DOWN, + "LANDSCAPE_LEFT" to LANDSCAPE_LEFT, + "LANDSCAPE_RIGHT" to LANDSCAPE_RIGHT ) } + /** + * Captures a photo using the camera. + * + * @param options The options for the capture operation. + * @param viewTag The tag of the camera view. + * @param promise The promise to resolve the capture result. + */ @ReactMethod fun capture(options: ReadableMap, viewTag: Int, promise: Promise) { // CameraManager does not allow us to return values @@ -37,4 +71,4 @@ class RNCameraKitModule(private val reactContext: ReactApplicationContext) : Rea view.capture(options.toHashMap(), promise) } } -} \ No newline at end of file +}