@@ -42,7 +42,7 @@ import to.bitkit.viewmodels.previewAmountInputViewModel
4242const val KEY_DELETE = " delete"
4343const val KEY_000 = " 000"
4444const val KEY_DECIMAL = " ."
45- private val maxKeyboardHeight = 300 .dp
45+ private val defaultHeight = 300 .dp
4646private val idealButtonHeight = 75 .dp
4747private val minButtonHeight = 50 .dp
4848private const val ROWS = 4
@@ -59,23 +59,13 @@ fun NumberPad(
5959 onPress : (String ) -> Unit ,
6060 modifier : Modifier = Modifier ,
6161 type : NumberPadType = NumberPadType .SIMPLE ,
62- availableHeight : Dp ? = null ,
62+ availableHeight : Dp = defaultHeight ,
6363 errorKey : String? = null,
6464) {
6565 BoxWithConstraints (modifier = modifier) {
66- val constraintsHeight = this .maxHeight
67- val effectiveHeight = availableHeight ? : constraintsHeight
68- val idealTotalHeight = idealButtonHeight * ROWS
69-
70- val maxAllowedHeight = minOf(maxKeyboardHeight, effectiveHeight)
71-
7266 val buttonHeight = when {
73- // If we have plenty of space, use ideal height
74- maxAllowedHeight >= idealTotalHeight -> idealButtonHeight
75- // If space is limited, calculate proportional height but ensure minimum
76- maxAllowedHeight >= (minButtonHeight * ROWS ) -> maxAllowedHeight / ROWS
77- // If extremely limited, use absolute minimum
78- else -> minButtonHeight
67+ constraints.hasFixedHeight -> maxHeight / ROWS
68+ else -> (availableHeight / ROWS ).coerceIn(minButtonHeight, idealButtonHeight)
7969 }
8070
8171 val totalKeyboardHeight = buttonHeight * ROWS
@@ -146,7 +136,7 @@ fun NumberPad(
146136 modifier : Modifier = Modifier ,
147137 currencies : CurrencyState = LocalCurrencies .current,
148138 type : NumberPadType = viewModel.getNumberPadType(currencies),
149- availableHeight : Dp ? = null ,
139+ availableHeight : Dp = defaultHeight ,
150140) {
151141 val uiState by viewModel.uiState.collectAsStateWithLifecycle()
152142 NumberPad (
@@ -253,7 +243,6 @@ private fun Preview() {
253243 FillHeight ()
254244 NumberPad (
255245 viewModel = previewAmountInputViewModel(),
256- modifier = Modifier .fillMaxWidth(),
257246 )
258247 }
259248 }
@@ -303,3 +292,77 @@ private fun PreviewSmall() {
303292 }
304293 }
305294}
295+
296+ @Preview(showSystemUi = true )
297+ @Composable
298+ private fun PreviewSimple () {
299+ AppThemeSurface {
300+ ScreenColumn {
301+ FillHeight ()
302+ NumberPad (
303+ onPress = {},
304+ type = NumberPadType .SIMPLE ,
305+ )
306+ }
307+ }
308+ }
309+
310+ @Preview(showSystemUi = true )
311+ @Composable
312+ private fun PreviewHeight () {
313+ AppThemeSurface {
314+ ScreenColumn {
315+ FillHeight ()
316+ NumberPad (
317+ onPress = {},
318+ type = NumberPadType .SIMPLE ,
319+ modifier = Modifier .height(350 .dp),
320+ )
321+ }
322+ }
323+ }
324+
325+ @Preview(showSystemUi = true )
326+ @Composable
327+ private fun PreviewMaxHeight () {
328+ AppThemeSurface {
329+ ScreenColumn {
330+ FillHeight ()
331+ NumberPad (
332+ onPress = {},
333+ type = NumberPadType .SIMPLE ,
334+ availableHeight = 350 .dp,
335+ )
336+ }
337+ }
338+ }
339+
340+ @Preview(showSystemUi = true )
341+ @Composable
342+ private fun PreviewHeightXs () {
343+ AppThemeSurface {
344+ ScreenColumn {
345+ FillHeight ()
346+ NumberPad (
347+ onPress = {},
348+ type = NumberPadType .SIMPLE ,
349+ modifier = Modifier .height(100 .dp),
350+ )
351+ }
352+ }
353+ }
354+
355+ @Preview(showSystemUi = true )
356+ @Composable
357+ private fun PreviewMaxHeightXs () {
358+ AppThemeSurface {
359+ ScreenColumn {
360+ FillHeight ()
361+ NumberPad (
362+ onPress = {},
363+ type = NumberPadType .SIMPLE ,
364+ availableHeight = 100 .dp,
365+ )
366+ }
367+ }
368+ }
0 commit comments