Skip to content

Commit 337600b

Browse files
committed
fix: match figma searching animation
1 parent 2d53d9f commit 337600b

3 files changed

Lines changed: 43 additions & 5 deletions

File tree

app/src/main/java/to/bitkit/ui/sheets/hardware/HwSearchingSheet.kt

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
package to.bitkit.ui.sheets.hardware
22

3+
import androidx.compose.animation.core.LinearEasing
4+
import androidx.compose.animation.core.animateFloat
5+
import androidx.compose.animation.core.infiniteRepeatable
6+
import androidx.compose.animation.core.rememberInfiniteTransition
7+
import androidx.compose.animation.core.tween
8+
import androidx.compose.foundation.Image
39
import androidx.compose.foundation.layout.Box
410
import androidx.compose.foundation.layout.Column
511
import androidx.compose.foundation.layout.fillMaxSize
612
import androidx.compose.foundation.layout.fillMaxWidth
713
import androidx.compose.foundation.layout.navigationBarsPadding
814
import androidx.compose.foundation.layout.padding
15+
import androidx.compose.foundation.layout.size
916
import androidx.compose.runtime.Composable
17+
import androidx.compose.runtime.getValue
1018
import androidx.compose.ui.Alignment
1119
import androidx.compose.ui.Modifier
20+
import androidx.compose.ui.draw.rotate
1221
import androidx.compose.ui.platform.testTag
22+
import androidx.compose.ui.res.painterResource
1323
import androidx.compose.ui.res.stringResource
1424
import androidx.compose.ui.tooling.preview.Preview
1525
import androidx.compose.ui.unit.dp
@@ -20,12 +30,14 @@ import to.bitkit.ui.components.Display
2030
import to.bitkit.ui.components.SecondaryButton
2131
import to.bitkit.ui.components.VerticalSpacer
2232
import to.bitkit.ui.scaffold.SheetTopBar
23-
import to.bitkit.ui.screens.transfer.components.TransferAnimationView
2433
import to.bitkit.ui.shared.util.gradientBackground
2534
import to.bitkit.ui.theme.AppThemeSurface
2635
import to.bitkit.ui.theme.Colors
2736
import to.bitkit.ui.utils.withAccent
2837

38+
private val ANIMATION_SIZE = 280.dp
39+
private const val ARROWS_SIZE_RATIO = 0.82f
40+
2941
@Composable
3042
fun HwSearchingSheet(
3143
modifier: Modifier = Modifier,
@@ -65,10 +77,7 @@ private fun Content(
6577
.fillMaxWidth()
6678
.weight(1f)
6779
) {
68-
TransferAnimationView(
69-
largeCircleRes = R.drawable.ln_sync_large,
70-
smallCircleRes = R.drawable.ln_sync_small,
71-
)
80+
SearchingAnimation()
7281
}
7382
Column(
7483
modifier = Modifier
@@ -84,6 +93,35 @@ private fun Content(
8493
}
8594
}
8695

96+
@Composable
97+
private fun SearchingAnimation(modifier: Modifier = Modifier) {
98+
val transition = rememberInfiniteTransition(label = "hw_searching")
99+
val rotation by transition.animateFloat(
100+
initialValue = 0f,
101+
targetValue = 360f,
102+
animationSpec = infiniteRepeatable(tween(durationMillis = 2500, easing = LinearEasing)),
103+
label = "arrows_rotation",
104+
)
105+
106+
Box(
107+
contentAlignment = Alignment.Center,
108+
modifier = modifier.size(ANIMATION_SIZE)
109+
) {
110+
Image(
111+
painter = painterResource(R.drawable.hw_searching_ring),
112+
contentDescription = null,
113+
modifier = Modifier.fillMaxSize()
114+
)
115+
Image(
116+
painter = painterResource(R.drawable.hw_searching_arrows),
117+
contentDescription = null,
118+
modifier = Modifier
119+
.fillMaxSize(ARROWS_SIZE_RATIO)
120+
.rotate(rotation)
121+
)
122+
}
123+
}
124+
87125
@Preview(showSystemUi = true)
88126
@Composable
89127
private fun Preview() {
273 KB
Loading
13 KB
Loading

0 commit comments

Comments
 (0)