Skip to content

Commit 8d41434

Browse files
committed
feat: animation
1 parent 37cc8e0 commit 8d41434

File tree

1 file changed

+50
-13
lines changed

1 file changed

+50
-13
lines changed

app/src/main/java/to/bitkit/ui/screens/wallets/activity/components/ActivityListGrouped.kt

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
package to.bitkit.ui.screens.wallets.activity.components
22

3+
import androidx.compose.animation.AnimatedVisibility
4+
import androidx.compose.animation.core.tween
5+
import androidx.compose.animation.expandVertically
6+
import androidx.compose.animation.fadeIn
7+
import androidx.compose.animation.fadeOut
8+
import androidx.compose.animation.shrinkVertically
39
import androidx.compose.foundation.layout.Column
410
import androidx.compose.foundation.layout.PaddingValues
511
import androidx.compose.foundation.layout.Spacer
@@ -10,6 +16,7 @@ import androidx.compose.foundation.layout.padding
1016
import androidx.compose.foundation.layout.wrapContentWidth
1117
import androidx.compose.foundation.lazy.LazyColumn
1218
import androidx.compose.foundation.lazy.itemsIndexed
19+
import androidx.compose.material3.HorizontalDivider
1320
import androidx.compose.runtime.Composable
1421
import androidx.compose.ui.Alignment
1522
import androidx.compose.ui.Modifier
@@ -18,6 +25,7 @@ import androidx.compose.ui.tooling.preview.Preview
1825
import androidx.compose.ui.unit.dp
1926
import com.synonym.bitkitcore.Activity
2027
import to.bitkit.R
28+
import to.bitkit.ext.rawId
2129
import to.bitkit.ui.components.BodyM
2230
import to.bitkit.ui.components.Caption13Up
2331
import to.bitkit.ui.components.TertiaryButton
@@ -54,21 +62,50 @@ fun ActivityListGrouped(
5462
contentPadding = contentPadding,
5563
modifier = Modifier.fillMaxWidth()
5664
) {
57-
itemsIndexed(groupedItems) { index, item ->
58-
when (item) {
59-
is String -> {
60-
Caption13Up(
61-
text = item,
62-
color = Colors.White64,
63-
modifier = Modifier
64-
.fillMaxWidth()
65-
.padding(vertical = 16.dp)
66-
)
65+
itemsIndexed(
66+
items = groupedItems,
67+
key = { index, item ->
68+
when (item) {
69+
is String -> "header_$item"
70+
is Activity -> when (item) {
71+
is Activity.Lightning -> "lightning_${item.rawId()}"
72+
is Activity.Onchain -> "onchain_${item.rawId()}"
73+
}
74+
75+
else -> "item_$index"
6776
}
77+
}
78+
) { index, item ->
79+
AnimatedVisibility(
80+
visible = true,
81+
enter = fadeIn(animationSpec = tween(durationMillis = 400, delayMillis = 50)) +
82+
expandVertically(
83+
animationSpec = tween(durationMillis = 400, delayMillis = 50),
84+
expandFrom = Alignment.Top
85+
),
86+
exit = fadeOut(animationSpec = tween(durationMillis = 300)) +
87+
shrinkVertically(
88+
animationSpec = tween(durationMillis = 300),
89+
shrinkTowards = Alignment.Top
90+
)
91+
) {
92+
when (item) {
93+
is String -> {
94+
Caption13Up(
95+
text = item,
96+
color = Colors.White64,
97+
modifier = Modifier
98+
.fillMaxWidth()
99+
.padding(vertical = 16.dp)
100+
)
101+
}
68102

69-
is Activity -> {
70-
ActivityRow(item, onActivityItemClick, testTag = "Activity-$index")
71-
VerticalSpacer(16.dp)
103+
is Activity -> {
104+
Column {
105+
ActivityRow(item, onActivityItemClick, testTag = "Activity-$index")
106+
VerticalSpacer(16.dp)
107+
}
108+
}
72109
}
73110
}
74111
}

0 commit comments

Comments
 (0)