diff --git a/app/src/main/java/helium314/keyboard/settings/SearchScreen.kt b/app/src/main/java/helium314/keyboard/settings/SearchScreen.kt index 7448d01ab..66ba49f64 100644 --- a/app/src/main/java/helium314/keyboard/settings/SearchScreen.kt +++ b/app/src/main/java/helium314/keyboard/settings/SearchScreen.kt @@ -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,97 +122,89 @@ fun 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 - if (!value) searchText = TextFieldValue() - } - BackHandler { - if (showSearch || searchText.text.isNotEmpty()) setShowSearch(false) - else onClickBack() - } - Surface( - color = MaterialTheme.colorScheme.surfaceContainer, - ) { - Column { - TopAppBar( - title = title, - windowInsets = TopAppBarDefaults.windowInsets, - navigationIcon = { - IconButton(onClick = { - if (showSearch) setShowSearch(false) - else onClickBack() - }) { - Icon( - painterResource(R.drawable.ic_arrow_back), - stringResource(R.string.spoken_description_action_previous) - ) - } - }, - actions = { - if (icon == null) - IconButton(onClick = { setShowSearch(!showSearch) }) { SearchIcon() } - else - icon() - if (menu != null) - Box { - var showMenu by remember { mutableStateOf(false) } - IconButton( - onClick = { showMenu = true } - ) { Icon(painterResource(R.drawable.ic_arrow_left), "menu", Modifier.rotate(-90f)) } - DropdownMenu( - expanded = showMenu, - onDismissRequest = { showMenu = false } - ) { - menu.forEach { - DropdownMenuItem( - text = { Text(it.first) }, - onClick = { showMenu = false; it.second() } - ) + fun setShowSearch(value: Boolean) { + showSearch = value + if (!value) searchText = TextFieldValue() + } + BackHandler { + if (showSearch || searchText.text.isNotEmpty()) setShowSearch(false) + else onClickBack() + } + Surface( + color = MaterialTheme.colorScheme.surfaceContainer, + ) { + Column { + TopAppBar( + title = title, + windowInsets = WindowInsets(0), + navigationIcon = { + IconButton(onClick = { + if (showSearch) setShowSearch(false) + else onClickBack() + }) { + Icon( + painterResource(R.drawable.ic_arrow_back), + stringResource(R.string.spoken_description_action_previous) + ) + } + }, + actions = { + if (icon == null) + IconButton(onClick = { setShowSearch(!showSearch) }) { SearchIcon() } + else + icon() + if (menu != null) + Box { + var showMenu by remember { mutableStateOf(false) } + IconButton( + onClick = { showMenu = true } + ) { Icon(painterResource(R.drawable.ic_arrow_left), "menu", Modifier.rotate(-90f)) } + DropdownMenu( + expanded = showMenu, + onDismissRequest = { showMenu = false } + ) { + menu.forEach { + DropdownMenuItem( + text = { Text(it.first) }, + onClick = { showMenu = false; it.second() } + ) + } } } - } - }, - ) - ExpandableSearchField( - expanded = showSearch, - onDismiss = { setShowSearch(false) }, - search = searchText, - onSearchChange = { searchText = it }, - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 8.dp), - colors = TextFieldDefaults.colors( - focusedContainerColor = MaterialTheme.colorScheme.surface + }, + ) + ExpandableSearchField( + expanded = showSearch, + onDismiss = { setShowSearch(false) }, + search = searchText, + onSearchChange = { searchText = it }, + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 16.dp, vertical = 8.dp), + colors = TextFieldDefaults.colors( + focusedContainerColor = MaterialTheme.colorScheme.surface + ) ) - ) - } - } - 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 -// ) -// ) - ) { - content() } - } else { - val items = filteredItems(searchText.text) - Scaffold( - contentWindowInsets = WindowInsets.safeDrawing - .only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom) - ) { innerPadding -> - LazyColumn(contentPadding = innerPadding) { - items(items) { - itemContent(it) + } + CompositionLocalProvider(LocalTextStyle provides MaterialTheme.typography.bodyLarge) { + if (searchText.text.isBlank() && content != null) { + Column { + content() + } + } else { + val items = filteredItems(searchText.text) + Scaffold( + contentWindowInsets = WindowInsets.safeDrawing.only(WindowInsetsSides.Bottom) + ) { innerPadding -> + LazyColumn(contentPadding = innerPadding) { + items(items) { + itemContent(it) + } } } } diff --git a/app/src/main/java/helium314/keyboard/settings/screens/MainSettingsScreen.kt b/app/src/main/java/helium314/keyboard/settings/screens/MainSettingsScreen.kt index 7efe23773..67d3a977c 100644 --- a/app/src/main/java/helium314/keyboard/settings/screens/MainSettingsScreen.kt +++ b/app/src/main/java/helium314/keyboard/settings/screens/MainSettingsScreen.kt @@ -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)) ) { diff --git a/app/src/main/java/helium314/keyboard/settings/screens/SubtypeScreen.kt b/app/src/main/java/helium314/keyboard/settings/screens/SubtypeScreen.kt index df1161cbe..d1de9c8be 100644 --- a/app/src/main/java/helium314/keyboard/settings/screens/SubtypeScreen.kt +++ b/app/src/main/java/helium314/keyboard/settings/screens/SubtypeScreen.kt @@ -146,7 +146,7 @@ fun SubtypeScreen( filteredItems = { emptyList() } ) { 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)