Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package de.westnordost.streetcomplete.ui.util

import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.isImeVisible
import androidx.compose.runtime.Composable

@OptIn(ExperimentalLayoutApi::class)
@Composable
actual fun isImeVisible(): Boolean = WindowInsets.isImeVisible
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package de.westnordost.streetcomplete.quests.address

import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.isImeVisible
import androidx.compose.foundation.text.BasicText
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.text.TextAutoSize
Expand All @@ -21,6 +18,7 @@ import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.TextFieldValue
import de.westnordost.streetcomplete.ui.common.AutoFitTextFieldFontSize
import de.westnordost.streetcomplete.ui.util.isImeVisible
import de.westnordost.streetcomplete.ui.common.SwitchKeyboardPopupButton
import de.westnordost.streetcomplete.ui.common.TextField2

Expand All @@ -30,7 +28,6 @@ import de.westnordost.streetcomplete.ui.common.TextField2
* - one can switch between text and number software keyboard
* - a suggestion can be displayed that is sized the same as the actual input, only with less alpha
* - certain common text styling (monospace, centered) */
@OptIn(ExperimentalLayoutApi::class)
@Composable
fun AnAddressNumberInput(
value: String,
Expand All @@ -49,7 +46,7 @@ fun AnAddressNumberInput(
val keyboardType = if (isAbc) KeyboardType.Text else KeyboardType.Number

var isFocused by remember { mutableStateOf(false) }
val showSwitchKeyboardPopup = isFocused && WindowInsets.isImeVisible
val showSwitchKeyboardPopup = isFocused && isImeVisible()

ProvideTextStyle(LocalTextStyle.current.copy(
// to avoid the size of the text changing when going from e.g. "123j" to "123k"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package de.westnordost.streetcomplete.ui.util

import androidx.compose.runtime.Composable

/** Whether the software keyboard (IME) is currently visible. */
@Composable
// TODO CMP: this is necessary as long as https://youtrack.jetbrains.com/issue/CMP-9906/Commonize-WindowInsets.isVisible-functions is not implemented
expect fun isImeVisible(): Boolean
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package de.westnordost.streetcomplete.ui.util

import androidx.compose.runtime.Composable

@Composable
actual fun isImeVisible(): Boolean = false