Add favorites transition

This commit is contained in:
MM20 2024-05-17 00:03:15 +02:00
parent f7f0e54f2e
commit eae816c3d7
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389
3 changed files with 54 additions and 25 deletions

View File

@ -1,8 +1,16 @@
package de.mm20.launcher2.ui.launcher.search.common.grid
import androidx.compose.animation.animateContentSize
import androidx.compose.foundation.layout.*
import androidx.compose.material.Surface
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.SharedTransitionScope
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.togetherWith
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
@ -20,11 +28,17 @@ fun SearchResultGrid(
reverse: Boolean = false,
highlightedItem: SavableSearchable? = null
) {
Column(
modifier = modifier
.animateContentSize()
SharedTransitionScope {
AnimatedContent(
items,
modifier = it then modifier
.fillMaxWidth()
.padding(4.dp),
transitionSpec = {
fadeIn() togetherWith fadeOut()
}
) { items ->
Column(
verticalArrangement = if (reverse) Arrangement.BottomReversed else Arrangement.Top
) {
for (i in 0 until ceil(items.size / columns.toFloat()).toInt()) {
@ -34,6 +48,10 @@ fun SearchResultGrid(
if (item != null) {
GridItem(
modifier = Modifier
.sharedBounds(
rememberSharedContentState(item.key),
this@AnimatedContent,
)
.weight(1f)
.padding(4.dp),
item = item,
@ -48,3 +66,5 @@ fun SearchResultGrid(
}
}
}
}
}

View File

@ -1,5 +1,9 @@
package de.mm20.launcher2.ui.launcher.search.favorites
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.togetherWith
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding

View File

@ -1,5 +1,10 @@
package de.mm20.launcher2.ui.launcher.widgets.favorites
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.Crossfade
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.togetherWith
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState