From 70db760ae530d055f4b6c0ec585ac24066453c16 Mon Sep 17 00:00:00 2001 From: Suhas Dissanayake Date: Sun, 31 Dec 2023 21:52:27 +0530 Subject: [PATCH] fix: keyboard popping up in calculator --- .../ui/components/CalculatorDisplay.kt | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/net/youapps/calcyou/ui/components/CalculatorDisplay.kt b/app/src/main/java/net/youapps/calcyou/ui/components/CalculatorDisplay.kt index e2ab06c..87488a8 100644 --- a/app/src/main/java/net/youapps/calcyou/ui/components/CalculatorDisplay.kt +++ b/app/src/main/java/net/youapps/calcyou/ui/components/CalculatorDisplay.kt @@ -17,9 +17,11 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.material3.surfaceColorAtElevation import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip +import androidx.compose.ui.platform.LocalTextInputService import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp @@ -62,23 +64,25 @@ fun ColumnScope.CalculatorDisplay(calculatorViewModel: CalculatorViewModel) { .background(MaterialTheme.colorScheme.surfaceColorAtElevation(50.dp)), horizontalArrangement = Arrangement.End ) { - BasicTextField( - value = calculatorViewModel.displayText, - onValueChange = { - calculatorViewModel.displayText = it - }, - singleLine = true, - modifier = Modifier - .fillMaxWidth() - .padding(vertical = 8.dp, horizontal = 16.dp), - maxLines = 1, - textStyle = MaterialTheme.typography.displayMedium.plus( - TextStyle( - textAlign = TextAlign.End, - color = MaterialTheme.colorScheme.onSurface + CompositionLocalProvider(LocalTextInputService provides null) { + BasicTextField( + value = calculatorViewModel.displayText, + onValueChange = { + calculatorViewModel.displayText = it + }, + singleLine = true, + modifier = Modifier + .fillMaxWidth() + .padding(vertical = 8.dp, horizontal = 16.dp), + maxLines = 1, + textStyle = MaterialTheme.typography.displayMedium.plus( + TextStyle( + textAlign = TextAlign.End, + color = MaterialTheme.colorScheme.onSurface + ) ) ) - ) + } } }