Fix searchables closing on refresh
This commit is contained in:
parent
5a1d2660ca
commit
991f0c88d8
@ -12,6 +12,7 @@ import androidx.compose.foundation.layout.Spacer
|
|||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.key
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import de.mm20.launcher2.search.SavableSearchable
|
import de.mm20.launcher2.search.SavableSearchable
|
||||||
@ -26,18 +27,20 @@ fun SearchResultGrid(
|
|||||||
showLabels: Boolean = LocalGridSettings.current.showLabels,
|
showLabels: Boolean = LocalGridSettings.current.showLabels,
|
||||||
columns: Int = LocalGridSettings.current.columnCount,
|
columns: Int = LocalGridSettings.current.columnCount,
|
||||||
reverse: Boolean = false,
|
reverse: Boolean = false,
|
||||||
highlightedItem: SavableSearchable? = null
|
highlightedItem: SavableSearchable? = null,
|
||||||
|
transitionKey: Any? = items
|
||||||
) {
|
) {
|
||||||
SharedTransitionScope {
|
SharedTransitionScope {
|
||||||
AnimatedContent(
|
AnimatedContent(
|
||||||
items,
|
items to transitionKey,
|
||||||
modifier = it then modifier
|
modifier = it then modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(4.dp),
|
.padding(4.dp),
|
||||||
transitionSpec = {
|
transitionSpec = {
|
||||||
fadeIn() togetherWith fadeOut()
|
fadeIn() togetherWith fadeOut()
|
||||||
}
|
},
|
||||||
) { items ->
|
contentKey = { it.second }
|
||||||
|
) { (items, _) ->
|
||||||
Column(
|
Column(
|
||||||
verticalArrangement = if (reverse) Arrangement.BottomReversed else Arrangement.Top
|
verticalArrangement = if (reverse) Arrangement.BottomReversed else Arrangement.Top
|
||||||
) {
|
) {
|
||||||
@ -46,18 +49,20 @@ fun SearchResultGrid(
|
|||||||
for (j in 0 until columns) {
|
for (j in 0 until columns) {
|
||||||
val item = items.getOrNull(i * columns + j)
|
val item = items.getOrNull(i * columns + j)
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
GridItem(
|
key(item.key) {
|
||||||
modifier = Modifier
|
GridItem(
|
||||||
.sharedElement(
|
modifier = Modifier
|
||||||
rememberSharedContentState(item.key),
|
.sharedElement(
|
||||||
this@AnimatedContent,
|
rememberSharedContentState(item.key),
|
||||||
)
|
this@AnimatedContent,
|
||||||
.weight(1f)
|
)
|
||||||
.padding(4.dp),
|
.weight(1f)
|
||||||
item = item,
|
.padding(4.dp),
|
||||||
showLabels = showLabels,
|
item = item,
|
||||||
highlight = item.key == highlightedItem?.key
|
showLabels = showLabels,
|
||||||
)
|
highlight = item.key == highlightedItem?.key
|
||||||
|
)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,7 +54,7 @@ fun LazyListScope.SearchFavorites(
|
|||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
if (favorites.isNotEmpty()) {
|
if (favorites.isNotEmpty()) {
|
||||||
SearchResultGrid(favorites)
|
SearchResultGrid(favorites, transitionKey = selectedTag)
|
||||||
} else {
|
} else {
|
||||||
Banner(
|
Banner(
|
||||||
modifier = Modifier.padding(16.dp),
|
modifier = Modifier.padding(16.dp),
|
||||||
|
|||||||
@ -42,7 +42,7 @@ fun FavoritesWidget(widget: FavoritesWidget) {
|
|||||||
|
|
||||||
Column {
|
Column {
|
||||||
if (favorites.isNotEmpty()) {
|
if (favorites.isNotEmpty()) {
|
||||||
SearchResultGrid(favorites)
|
SearchResultGrid(favorites, transitionKey = selectedTag)
|
||||||
} else {
|
} else {
|
||||||
Banner(
|
Banner(
|
||||||
modifier = Modifier.padding(16.dp),
|
modifier = Modifier.padding(16.dp),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user