Fix settings search insets by moving top & horizontal insets to the top of the setting screen. (#1510)

This commit is contained in:
Eran Leshem 2025-04-27 17:03:18 +03:00 committed by GitHub
parent 54c2c364a0
commit bedb9d1517
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 81 additions and 92 deletions

View file

@ -64,8 +64,7 @@ fun SearchSettingsScreen(
if (content != null) content()
else {
Scaffold(
contentWindowInsets = WindowInsets.safeDrawing
.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom)
contentWindowInsets = WindowInsets.safeDrawing.only(WindowInsetsSides.Bottom)
) { innerPadding ->
Column(
Modifier.verticalScroll(rememberScrollState()).then(Modifier.padding(innerPadding))
@ -123,7 +122,9 @@ fun <T: Any?> SearchScreen(
// keyboard in unexpected situations such as going back from another screen, which is rather annoying
var searchText by remember { mutableStateOf(TextFieldValue()) }
var showSearch by remember { mutableStateOf(false) }
Column(Modifier.fillMaxSize()) {
Scaffold(contentWindowInsets = WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Top))
{ innerPadding ->
Column(Modifier.fillMaxSize().padding(innerPadding)) {
fun setShowSearch(value: Boolean) {
showSearch = value
@ -139,7 +140,7 @@ fun <T: Any?> SearchScreen(
Column {
TopAppBar(
title = title,
windowInsets = TopAppBarDefaults.windowInsets,
windowInsets = WindowInsets(0),
navigationIcon = {
IconButton(onClick = {
if (showSearch) setShowSearch(false)
@ -192,24 +193,13 @@ fun <T: Any?> SearchScreen(
}
CompositionLocalProvider(LocalTextStyle provides MaterialTheme.typography.bodyLarge) {
if (searchText.text.isBlank() && content != null) {
Column(
// todo: how and where to best deal with insets?
// here? manifest android:windowSoftInputMode="adjustResize"?
// other?
// Modifier
// .windowInsetsPadding(
// WindowInsets.safeDrawing.only(
// WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom
// )
// )
) {
Column {
content()
}
} else {
val items = filteredItems(searchText.text)
Scaffold(
contentWindowInsets = WindowInsets.safeDrawing
.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom)
contentWindowInsets = WindowInsets.safeDrawing.only(WindowInsetsSides.Bottom)
) { innerPadding ->
LazyColumn(contentPadding = innerPadding) {
items(items) {
@ -221,6 +211,7 @@ fun <T: Any?> SearchScreen(
}
}
}
}
// from StreetComplete
/** Expandable text field that can be dismissed and requests focus when it is expanded */

View file

@ -48,9 +48,7 @@ fun MainSettingsScreen(
settings = emptyList(),
) {
val enabledSubtypes = SubtypeSettings.getEnabledSubtypes(true)
Scaffold(
contentWindowInsets = WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom)
) { innerPadding ->
Scaffold(contentWindowInsets = WindowInsets.safeDrawing.only(WindowInsetsSides.Bottom)) { innerPadding ->
Column(
Modifier.verticalScroll(rememberScrollState()).then(Modifier.padding(innerPadding))
) {

View file

@ -146,7 +146,7 @@ fun SubtypeScreen(
filteredItems = { emptyList<String>() }
) {
Scaffold(
contentWindowInsets = WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom)
contentWindowInsets = WindowInsets.safeDrawing.only(WindowInsetsSides.Bottom)
) { innerPadding ->
Column(
modifier = Modifier.verticalScroll(scrollState).padding(horizontal = 12.dp)