@@ -99,6 +99,7 @@ private const val BUTTON_CONTROL_MARGIN = 48 //dp
99
99
private const val BOTTOM_SHEET_PEEK_HEIGHT = 65 // dp
100
100
private const val BOTTOM_SHEET_NOT_FOUND_HEIGHT = 180 // dp
101
101
private const val DRAG_SENSITIVITY_FACTOR = 300f // dp
102
+ private const val PADDING_FULL_SCREEN_SHEET = 4 // dp
102
103
103
104
private enum class SheetState { PEEK , CONTENT , FULL }
104
105
@@ -668,7 +669,7 @@ private fun ScannerContent(
668
669
sheetState = sheetState,
669
670
dragOffset = dragOffset,
670
671
maxBottomSheetHeight = maxBottomSheetHeight,
671
- fullScreenHeight = with (density) { parentHeight.toDp() } - scannerLayoutConfig.contentPadding.calculateTopPadding() - scannerLayoutConfig.contentPadding.calculateBottomPadding() ,
672
+ fullScreenHeight = with (density) { parentHeight.toDp() } - scannerLayoutConfig.contentPadding.calculateTopPadding(),
672
673
peekHeight = peekHeight + scannerLayoutConfig.contentPadding.calculateBottomPadding(),
673
674
isImageCaptured = ocrScannerState.capturedImage != null
674
675
).value,
@@ -677,8 +678,7 @@ private fun ScannerContent(
677
678
)
678
679
679
680
// Calculate maximum allowed height for bottom sheet
680
- maxBottomSheetHeight =
681
- remember(cropAreaBottom, ocrScannerState.capturedImage) {
681
+ maxBottomSheetHeight = remember(cropAreaBottom, parentHeight, controlButtonBarHeight, ocrScannerState.capturedImage) {
682
682
with (density) {
683
683
val parentHeightDp = parentHeight.toDp()
684
684
val controlBarHeight = controlButtonBarHeight.toDp()
@@ -796,7 +796,12 @@ private fun ScannerContent(
796
796
top.linkTo(topBackground.bottom)
797
797
width = Dimension .fillToConstraints
798
798
height =
799
- Dimension .ratio(if (orientation == ORIENTATION_PORTRAIT ) " 2:1.5" else " 3.1" )
799
+ Dimension .percent(
800
+ when {
801
+ orientation == ORIENTATION_PORTRAIT -> 0.3f // 30% of screen height in portrait
802
+ else -> 0.45f // 45% of screen height in landscape
803
+ }
804
+ )
800
805
}
801
806
.onGloballyPositioned {
802
807
cropAreaBottom = it.boundsInParent().bottom
@@ -1157,7 +1162,7 @@ private fun calculateTargetHeight(
1157
1162
// Calculate the base height (maxBottomSheetHeight) and target height (full screen or adjusted full screen).
1158
1163
val base = maxBottomSheetHeight.value
1159
1164
val target =
1160
- if (! isImageCaptured) fullScreenHeight.value else fullScreenHeight.value - TopAppBarDefaults .TopAppBarExpandedHeight .value
1165
+ if (! isImageCaptured) fullScreenHeight.value else fullScreenHeight.value - TopAppBarDefaults .TopAppBarExpandedHeight .value - PADDING_FULL_SCREEN_SHEET .dp.value
1161
1166
1162
1167
// Calculate the interpolation factor based on the negative drag offset (dragging up).
1163
1168
// Dividing by dragSensitivityFactor scales the drag distance, determining how much drag is needed
@@ -1176,7 +1181,7 @@ private fun calculateTargetHeight(
1176
1181
// When dragging down from FULL state:
1177
1182
// Calculate the base height (full screen or adjusted full screen) and target height (maxBottomSheetHeight).
1178
1183
val base =
1179
- if (! isImageCaptured) fullScreenHeight.value else fullScreenHeight.value - TopAppBarDefaults .TopAppBarExpandedHeight .value
1184
+ if (! isImageCaptured) fullScreenHeight.value else fullScreenHeight.value - TopAppBarDefaults .TopAppBarExpandedHeight .value - PADDING_FULL_SCREEN_SHEET .dp.value
1180
1185
val target = maxBottomSheetHeight.value
1181
1186
1182
1187
// Calculate the interpolation factor based on the positive drag offset (dragging down).
@@ -1198,7 +1203,7 @@ private fun calculateTargetHeight(
1198
1203
// Non-dragging states just return the height defined for that state.
1199
1204
SheetState .PEEK -> peekHeight
1200
1205
SheetState .CONTENT -> maxBottomSheetHeight
1201
- SheetState .FULL -> if (! isImageCaptured) fullScreenHeight else fullScreenHeight - TopAppBarDefaults .TopAppBarExpandedHeight
1206
+ SheetState .FULL -> if (! isImageCaptured) fullScreenHeight else fullScreenHeight - TopAppBarDefaults .TopAppBarExpandedHeight - PADDING_FULL_SCREEN_SHEET .dp
1202
1207
}
1203
1208
}
1204
1209
}
0 commit comments