From ebbe24444c092990d1adcb9bd50a215f197ef53e Mon Sep 17 00:00:00 2001 From: Paul Craciunoiu Date: Mon, 8 Jul 2024 13:10:41 -0600 Subject: [PATCH] Fix bug no 2 - dismiss keyboard when tap outside fields. --- .../tiktokreporter/reportform/ReportFormScreen.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/java/org/mozilla/tiktokreporter/reportform/ReportFormScreen.kt b/app/src/main/java/org/mozilla/tiktokreporter/reportform/ReportFormScreen.kt index 851914e..811c8e0 100644 --- a/app/src/main/java/org/mozilla/tiktokreporter/reportform/ReportFormScreen.kt +++ b/app/src/main/java/org/mozilla/tiktokreporter/reportform/ReportFormScreen.kt @@ -9,6 +9,7 @@ import android.provider.Settings import androidx.activity.ComponentActivity import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts +import androidx.compose.foundation.gestures.detectTapGestures import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -31,8 +32,10 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalLifecycleOwner +import androidx.compose.ui.platform.LocalSoftwareKeyboardController import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel @@ -363,11 +366,17 @@ private fun ReportFormScreenContent( }) { innerPadding -> val scrollState = rememberScrollState() val coroutineScope = rememberCoroutineScope() + val keyboardController = LocalSoftwareKeyboardController.current Column( modifier = Modifier .fillMaxSize() .padding(innerPadding) + .pointerInput(Unit) { + detectTapGestures(onTap = { + keyboardController?.hide() + }) + } ) { MozillaTabRow( modifier = Modifier, tabs = state.tabs.map {