Remove shared element transitions from favorites section

Close #913
This commit is contained in:
MM20 2024-07-03 21:34:07 +02:00
parent e7e89d884b
commit f96aa0217d
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389
2 changed files with 42 additions and 85 deletions

View File

@ -54,16 +54,15 @@ fun FavoritesTagSelector(
) {
val sheetManager = LocalBottomSheetManager.current
SharedTransitionLayout(
modifier = Modifier
.fillMaxWidth()
.padding(
top = if (reverse) 8.dp else 4.dp,
bottom = if (reverse) 4.dp else 8.dp,
end = if (editButton) 8.dp else 0.dp
),
) {
AnimatedContent(
modifier = Modifier
.fillMaxWidth()
.padding(
top = if (reverse) 8.dp else 4.dp,
bottom = if (reverse) 4.dp else 8.dp,
end = if (editButton) 8.dp else 0.dp
),
targetState = expanded,
) {
if (!it) {
@ -80,11 +79,7 @@ fun FavoritesTagSelector(
) {
FilterChip(
modifier = Modifier
.padding(start = 16.dp)
.sharedBounds(
rememberSharedContentState("favorites"),
this@AnimatedContent
),
.padding(start = 16.dp),
selected = selectedTag == null,
onClick = { onSelectTag(null) },
leadingIcon = {
@ -99,11 +94,7 @@ fun FavoritesTagSelector(
for (tag in tags) {
TagChip(
modifier = Modifier
.padding(start = 8.dp)
.sharedBounds(
rememberSharedContentState("tag-${tag.tag}"),
this@AnimatedContent
),
.padding(start = 8.dp),
tag = tag,
selected = selectedTag == tag.tag,
onClick = {
@ -121,10 +112,6 @@ fun FavoritesTagSelector(
}
IconButton(
modifier = Modifier
.sharedElement(
rememberSharedContentState("expandButton"),
this@AnimatedContent
)
.rotate(rot),
onClick = { onExpand(true) }) {
Icon(Icons.Rounded.ExpandMore, null)
@ -135,10 +122,6 @@ fun FavoritesTagSelector(
if (editButton) {
SmallFloatingActionButton(
modifier = Modifier.sharedBounds(
rememberSharedContentState("editButton"),
this@AnimatedContent
),
elevation = FloatingActionButtonDefaults.bottomAppBarFabElevation(),
onClick = { sheetManager.showEditFavoritesSheet() }
) {
@ -160,11 +143,7 @@ fun FavoritesTagSelector(
) {
FilterChip(
modifier = Modifier
.padding(end = 8.dp)
.sharedBounds(
rememberSharedContentState("favorites"),
this@AnimatedContent
),
.padding(end = 8.dp),
selected = selectedTag == null,
onClick = { onSelectTag(null) },
leadingIcon = {
@ -179,11 +158,7 @@ fun FavoritesTagSelector(
for (tag in tags) {
TagChip(
modifier = Modifier
.padding(end = 8.dp)
.sharedBounds(
rememberSharedContentState("tag-${tag.tag}"),
this@AnimatedContent
),
.padding(end = 8.dp),
tag = tag,
selected = selectedTag == tag.tag,
onClick = {
@ -206,10 +181,6 @@ fun FavoritesTagSelector(
}
IconButton(
modifier = Modifier
.sharedElement(
rememberSharedContentState("expandButton"),
this@AnimatedContent
)
.rotate(rot),
onClick = { onExpand(false) }
) {
@ -218,10 +189,6 @@ fun FavoritesTagSelector(
if (editButton) {
SmallFloatingActionButton(
modifier = Modifier.sharedBounds(
rememberSharedContentState("editButton"),
this@AnimatedContent
),
elevation = FloatingActionButtonDefaults.bottomAppBarFabElevation(),
onClick = { sheetManager.showEditFavoritesSheet() }
) {
@ -236,4 +203,4 @@ fun FavoritesTagSelector(
}
}
}
}

View File

@ -1,8 +1,6 @@
package de.mm20.launcher2.ui.launcher.search.common.grid
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.SharedTransitionLayout
import androidx.compose.animation.SharedTransitionScope
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.togetherWith
@ -31,44 +29,36 @@ fun SearchResultGrid(
highlightedItem: SavableSearchable? = null,
transitionKey: Any? = items
) {
SharedTransitionLayout(
modifier = modifier,
) {
AnimatedContent(
items to transitionKey,
modifier = Modifier
.fillMaxWidth()
.padding(4.dp),
transitionSpec = {
fadeIn() togetherWith fadeOut()
},
contentKey = { it.second }
) { (items, _) ->
Column(
verticalArrangement = if (reverse) Arrangement.BottomReversed else Arrangement.Top
) {
for (i in 0 until ceil(items.size / columns.toFloat()).toInt()) {
Row {
for (j in 0 until columns) {
val item = items.getOrNull(i * columns + j)
if (item != null) {
key(item.key) {
GridItem(
modifier = Modifier
.sharedElement(
rememberSharedContentState(item.key),
this@AnimatedContent,
)
.weight(1f)
.padding(4.dp),
item = item,
showLabels = showLabels,
highlight = item.key == highlightedItem?.key
)
}
} else {
Spacer(modifier = Modifier.weight(1f))
AnimatedContent(
items to transitionKey,
modifier = modifier
.fillMaxWidth()
.padding(4.dp),
transitionSpec = {
fadeIn() togetherWith fadeOut()
},
contentKey = { it.second }
) { (items, _) ->
Column(
verticalArrangement = if (reverse) Arrangement.BottomReversed else Arrangement.Top
) {
for (i in 0 until ceil(items.size / columns.toFloat()).toInt()) {
Row {
for (j in 0 until columns) {
val item = items.getOrNull(i * columns + j)
if (item != null) {
key(item.key) {
GridItem(
modifier = Modifier
.weight(1f)
.padding(4.dp),
item = item,
showLabels = showLabels,
highlight = item.key == highlightedItem?.key
)
}
} else {
Spacer(modifier = Modifier.weight(1f))
}
}
}