Add favorites transition
This commit is contained in:
parent
f7f0e54f2e
commit
eae816c3d7
@ -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,28 +28,40 @@ fun SearchResultGrid(
|
||||
reverse: Boolean = false,
|
||||
highlightedItem: SavableSearchable? = null
|
||||
) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
.animateContentSize()
|
||||
.fillMaxWidth()
|
||||
.padding(4.dp),
|
||||
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) {
|
||||
GridItem(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(4.dp),
|
||||
item = item,
|
||||
showLabels = showLabels,
|
||||
highlight = item.key == highlightedItem?.key
|
||||
)
|
||||
} else {
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
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()) {
|
||||
Row {
|
||||
for (j in 0 until columns) {
|
||||
val item = items.getOrNull(i * columns + j)
|
||||
if (item != null) {
|
||||
GridItem(
|
||||
modifier = Modifier
|
||||
.sharedBounds(
|
||||
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))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user