Fix last item on more settings screens.

This commit is contained in:
eranl 2025-04-15 03:00:28 +03:00
parent 988c99aeae
commit 86d4d0dfaf
2 changed files with 181 additions and 149 deletions

View file

@ -6,6 +6,7 @@ import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
@ -201,7 +202,8 @@ fun <T: Any?> SearchScreen(
} }
} else { } else {
val items = filteredItems(searchText.text) val items = filteredItems(searchText.text)
LazyColumn { Scaffold { innerPadding ->
LazyColumn(contentPadding = PaddingValues.Absolute(bottom = innerPadding.calculateBottomPadding())) {
items(items) { items(items) {
itemContent(it) itemContent(it)
} }
@ -210,6 +212,7 @@ fun <T: Any?> SearchScreen(
} }
} }
} }
}
// from StreetComplete // from StreetComplete
/** Expandable text field that can be dismissed and requests focus when it is expanded */ /** Expandable text field that can be dismissed and requests focus when it is expanded */

View file

@ -13,6 +13,7 @@ import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface import androidx.compose.material3.Surface
import androidx.compose.material3.Switch import androidx.compose.material3.Switch
import androidx.compose.material3.Text import androidx.compose.material3.Text
@ -140,8 +141,10 @@ fun SubtypeScreen(
itemContent = { }, itemContent = { },
filteredItems = { emptyList<String>() } filteredItems = { emptyList<String>() }
) { ) {
Scaffold { innerPadding ->
Column( Column(
modifier = Modifier.verticalScroll(scrollState).padding(horizontal = 12.dp), modifier = Modifier.verticalScroll(scrollState).padding(horizontal = 12.dp)
.then(Modifier.padding(bottom = innerPadding.calculateBottomPadding())),
verticalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(8.dp),
) { ) {
MainLayoutRow(currentSubtype, customMainLayouts) { setCurrentSubtype(it) } MainLayoutRow(currentSubtype, customMainLayouts) { setCurrentSubtype(it) }
@ -172,7 +175,10 @@ fun SubtypeScreen(
if (currentSubtype.locale.script() == ScriptUtils.SCRIPT_LATIN) { if (currentSubtype.locale.script() == ScriptUtils.SCRIPT_LATIN) {
WithSmallTitle(stringResource(R.string.show_popup_keys_title)) { WithSmallTitle(stringResource(R.string.show_popup_keys_title)) {
val explicitValue = currentSubtype.getExtraValueOf(ExtraValue.MORE_POPUPS) val explicitValue = currentSubtype.getExtraValueOf(ExtraValue.MORE_POPUPS)
val value = explicitValue ?: prefs.getString(Settings.PREF_MORE_POPUP_KEYS, Defaults.PREF_MORE_POPUP_KEYS)!! val value = explicitValue ?: prefs.getString(
Settings.PREF_MORE_POPUP_KEYS,
Defaults.PREF_MORE_POPUP_KEYS
)!!
Row { Row {
TextButton(onClick = { showMorePopupsDialog = true }, Modifier.weight(1f)) TextButton(onClick = { showMorePopupsDialog = true }, Modifier.weight(1f))
{ Text(stringResource(morePopupKeysResId(value))) } { Text(stringResource(morePopupKeysResId(value))) }
@ -187,7 +193,10 @@ fun SubtypeScreen(
val checked = currentSubtype.getExtraValueOf(ExtraValue.LOCALIZED_NUMBER_ROW)?.toBoolean() val checked = currentSubtype.getExtraValueOf(ExtraValue.LOCALIZED_NUMBER_ROW)?.toBoolean()
Text(stringResource(R.string.localized_number_row), Modifier.weight(1f)) Text(stringResource(R.string.localized_number_row), Modifier.weight(1f))
Switch( Switch(
checked = checked ?: prefs.getBoolean(Settings.PREF_LOCALIZED_NUMBER_ROW, Defaults.PREF_LOCALIZED_NUMBER_ROW), checked = checked ?: prefs.getBoolean(
Settings.PREF_LOCALIZED_NUMBER_ROW,
Defaults.PREF_LOCALIZED_NUMBER_ROW
),
onCheckedChange = { onCheckedChange = {
setCurrentSubtype(currentSubtype.with(ExtraValue.LOCALIZED_NUMBER_ROW, it.toString())) setCurrentSubtype(currentSubtype.with(ExtraValue.LOCALIZED_NUMBER_ROW, it.toString()))
} }
@ -198,7 +207,10 @@ fun SubtypeScreen(
} }
} }
HorizontalDivider() HorizontalDivider()
Text(stringResource(R.string.settings_screen_secondary_layouts), style = MaterialTheme.typography.titleMedium) Text(
stringResource(R.string.settings_screen_secondary_layouts),
style = MaterialTheme.typography.titleMedium
)
LayoutType.entries.forEach { type -> LayoutType.entries.forEach { type ->
if (type == LayoutType.MAIN) return@forEach if (type == LayoutType.MAIN) return@forEach
WithSmallTitle(stringResource(type.displayNameId)) { WithSmallTitle(stringResource(type.displayNameId)) {
@ -212,11 +224,14 @@ fun SubtypeScreen(
onSelected = { onSelected = {
setCurrentSubtype(currentSubtype.withLayout(type, it)) setCurrentSubtype(currentSubtype.withLayout(type, it))
}, },
extraButton = { DefaultButton(explicitLayout == null) { extraButton = {
DefaultButton(explicitLayout == null) {
setCurrentSubtype(currentSubtype.withoutLayout(type)) setCurrentSubtype(currentSubtype.withoutLayout(type))
} }, }
},
) { ) {
val displayName = if (LayoutUtilsCustom.isCustomLayout(it)) LayoutUtilsCustom.getDisplayName(it) val displayName =
if (LayoutUtilsCustom.isCustomLayout(it)) LayoutUtilsCustom.getDisplayName(it)
else it.getStringResourceOrName("layout_", ctx) else it.getStringResourceOrName("layout_", ctx)
var showLayoutEditDialog by remember { mutableStateOf(false) } var showLayoutEditDialog by remember { mutableStateOf(false) }
Row( Row(
@ -226,7 +241,14 @@ fun SubtypeScreen(
) { ) {
Text(displayName) Text(displayName)
if (LayoutUtilsCustom.isCustomLayout(it)) if (LayoutUtilsCustom.isCustomLayout(it))
IconButton({ showLayoutEditDialog = true }) { Icon(painterResource(R.drawable.ic_edit), stringResource(R.string.edit_layout)) } IconButton({
showLayoutEditDialog = true
}) {
Icon(
painterResource(R.drawable.ic_edit),
stringResource(R.string.edit_layout)
)
}
} }
if (showLayoutEditDialog) if (showLayoutEditDialog)
LayoutEditDialog( LayoutEditDialog(
@ -260,7 +282,10 @@ fun SubtypeScreen(
val setting = currentSubtype.getExtraValueOf(ExtraValue.POPUP_ORDER) val setting = currentSubtype.getExtraValueOf(ExtraValue.POPUP_ORDER)
PopupOrderDialog( PopupOrderDialog(
onDismissRequest = { showKeyOrderDialog = false }, onDismissRequest = { showKeyOrderDialog = false },
initialValue = setting ?: prefs.getString(Settings.PREF_POPUP_KEYS_ORDER, Defaults.PREF_POPUP_KEYS_ORDER)!!, initialValue = setting ?: prefs.getString(
Settings.PREF_POPUP_KEYS_ORDER,
Defaults.PREF_POPUP_KEYS_ORDER
)!!,
title = stringResource(R.string.popup_order), title = stringResource(R.string.popup_order),
showDefault = setting != null, showDefault = setting != null,
onConfirmed = { onConfirmed = {
@ -275,7 +300,10 @@ fun SubtypeScreen(
val setting = currentSubtype.getExtraValueOf(ExtraValue.HINT_ORDER) val setting = currentSubtype.getExtraValueOf(ExtraValue.HINT_ORDER)
PopupOrderDialog( PopupOrderDialog(
onDismissRequest = { showHintOrderDialog = false }, onDismissRequest = { showHintOrderDialog = false },
initialValue = setting ?: prefs.getString(Settings.PREF_POPUP_KEYS_LABELS_ORDER, Defaults.PREF_POPUP_KEYS_LABELS_ORDER)!!, initialValue = setting ?: prefs.getString(
Settings.PREF_POPUP_KEYS_LABELS_ORDER,
Defaults.PREF_POPUP_KEYS_LABELS_ORDER
)!!,
title = stringResource(R.string.hint_source), title = stringResource(R.string.hint_source),
showDefault = setting != null, showDefault = setting != null,
onConfirmed = { onConfirmed = {
@ -299,6 +327,7 @@ fun SubtypeScreen(
) )
} }
} }
}
// from ReorderSwitchPreference // from ReorderSwitchPreference