feat: Respect format's aspect ratio in Preview and add resizeMode
prop (#1817)
* feat(preview): respect format's aspect ratio * fix: code guidelines and previewSize in PreviewView * feat: add resizeMode 'cover' and 'contain' on Android
This commit is contained in:
@@ -7,6 +7,7 @@ import com.facebook.react.uimanager.ViewGroupManager
|
||||
import com.facebook.react.uimanager.annotations.ReactProp
|
||||
import com.mrousavy.camera.parsers.Orientation
|
||||
import com.mrousavy.camera.parsers.PixelFormat
|
||||
import com.mrousavy.camera.parsers.ResizeMode
|
||||
import com.mrousavy.camera.parsers.Torch
|
||||
import com.mrousavy.camera.parsers.VideoStabilizationMode
|
||||
|
||||
@@ -128,6 +129,14 @@ class CameraViewManager : ViewGroupManager<CameraView>() {
|
||||
view.format = format
|
||||
}
|
||||
|
||||
@ReactProp(name = "resizeMode")
|
||||
fun setResizeMode(view: CameraView, resizeMode: String) {
|
||||
val newMode = ResizeMode.fromUnionValue(resizeMode)
|
||||
if (view.resizeMode != newMode)
|
||||
addChangedPropToTransaction(view, "resizeMode")
|
||||
view.resizeMode = newMode
|
||||
}
|
||||
|
||||
// TODO: Change when TurboModules release.
|
||||
// We're treating -1 as "null" here, because when I make the fps parameter
|
||||
// of type "Int?" the react bridge throws an error.
|
||||
|
Reference in New Issue
Block a user