don't scroll icon selector on each icon selection

This commit is contained in:
Helium314 2025-02-08 20:42:48 +01:00
parent f5c3fca8c6
commit 6e18c9af8c
2 changed files with 5 additions and 5 deletions

View file

@ -14,7 +14,6 @@ import helium314.keyboard.latin.utils.prefs
import kotlinx.coroutines.flow.MutableStateFlow
// todo (roughly in order)
// check dark and light theme (don't have dynamic)
// any way to get rid of the "old" background on starting settings? probably comes from app theme, can we avoid it?
// try making old fragment back stuff work better, and try the different themes (with and without top bar, it should only appear for old fragments)
// calling KeyboardSwitcher.getInstance().forceUpdateKeyboardTheme(requireContext()) while keyboard is showing shows just full screen background

View file

@ -100,12 +100,13 @@ fun CustomizeIconsDialog(
iconsSet.addAll(iconsForName)
KeyboardIconsSet.getAllIcons(ctx).forEach { iconsSet.addAll(it.value) }
val icons = iconsSet.toList()
var selectedIcon by rememberSaveable { mutableStateOf(KeyboardIconsSet.instance.iconIds[iconName]) }
val initialIcon = KeyboardIconsSet.instance.iconIds[iconName]
var selectedIcon by rememberSaveable { mutableStateOf(initialIcon) }
val gridState = rememberLazyGridState()
LaunchedEffect(selectedIcon) {
val index = icons.indexOf(selectedIcon)
if (index != -1) gridState.scrollToItem(index, -state.layoutInfo.viewportSize.height / 3)
LaunchedEffect(initialIcon) {
val index = icons.indexOf(initialIcon)
if (index != -1) gridState.animateScrollToItem(index, -state.layoutInfo.viewportSize.height / 3)
}
ThreeButtonAlertDialog(
onDismissRequest = { showIconDialog = null },