react-native-rectangle-doc-scanner 3.203.0 → 3.204.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -401,7 +401,7 @@ class CameraController(
401
401
 
402
402
  private fun updatePreviewTransform() {
403
403
  val previewSize = previewSize ?: return
404
- adjustPreviewLayout(previewSize)
404
+ ensureMatchParent()
405
405
 
406
406
  val viewWidth = previewView.width
407
407
  val viewHeight = previewView.height
@@ -423,7 +423,8 @@ class CameraController(
423
423
  bufferHeight
424
424
  }
425
425
 
426
- val scale = kotlin.math.min(
426
+ // Fill the view like the default camera preview (center-crop).
427
+ val scale = kotlin.math.max(
427
428
  viewWidth.toFloat() / rotatedBufferWidth,
428
429
  viewHeight.toFloat() / rotatedBufferHeight
429
430
  )
@@ -440,7 +441,7 @@ class CameraController(
440
441
  previewView.setTransform(matrix)
441
442
  }
442
443
 
443
- private fun adjustPreviewLayout(previewSize: Size) {
444
+ private fun ensureMatchParent() {
444
445
  val parentView = previewView.parent as? android.view.View ?: return
445
446
  val parentWidth = parentView.width
446
447
  val parentHeight = parentView.height
@@ -448,32 +449,16 @@ class CameraController(
448
449
  return
449
450
  }
450
451
 
451
- val rotationDegrees = getRotationDegrees()
452
- val bufferWidth = previewSize.width.toFloat()
453
- val bufferHeight = previewSize.height.toFloat()
454
- val bufferAspect = if (rotationDegrees == 90 || rotationDegrees == 270) {
455
- bufferHeight / bufferWidth
456
- } else {
457
- bufferWidth / bufferHeight
458
- }
459
-
460
- val parentAspect = parentWidth.toFloat() / parentHeight.toFloat()
461
- val targetWidth: Int
462
- val targetHeight: Int
463
-
464
- if (parentAspect > bufferAspect) {
465
- targetHeight = parentHeight
466
- targetWidth = (parentHeight * bufferAspect).toInt()
467
- } else {
468
- targetWidth = parentWidth
469
- targetHeight = (parentWidth / bufferAspect).toInt()
470
- }
471
-
472
452
  val layoutParams = (previewView.layoutParams as? android.widget.FrameLayout.LayoutParams)
473
- ?: android.widget.FrameLayout.LayoutParams(targetWidth, targetHeight)
474
- if (layoutParams.width != targetWidth || layoutParams.height != targetHeight) {
475
- layoutParams.width = targetWidth
476
- layoutParams.height = targetHeight
453
+ ?: android.widget.FrameLayout.LayoutParams(
454
+ android.widget.FrameLayout.LayoutParams.MATCH_PARENT,
455
+ android.widget.FrameLayout.LayoutParams.MATCH_PARENT
456
+ )
457
+ if (layoutParams.width != android.widget.FrameLayout.LayoutParams.MATCH_PARENT ||
458
+ layoutParams.height != android.widget.FrameLayout.LayoutParams.MATCH_PARENT
459
+ ) {
460
+ layoutParams.width = android.widget.FrameLayout.LayoutParams.MATCH_PARENT
461
+ layoutParams.height = android.widget.FrameLayout.LayoutParams.MATCH_PARENT
477
462
  layoutParams.gravity = Gravity.CENTER
478
463
  previewView.layoutParams = layoutParams
479
464
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "3.203.0",
3
+ "version": "3.204.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",