11package to.bitkit.ui.sheets.hardware
22
3- import androidx.compose.animation.AnimatedVisibility
3+ import androidx.compose.animation.AnimatedContent
44import androidx.compose.animation.core.InfiniteTransition
55import androidx.compose.animation.core.LinearEasing
66import androidx.compose.animation.core.animateFloat
77import androidx.compose.animation.core.infiniteRepeatable
88import androidx.compose.animation.core.rememberInfiniteTransition
99import androidx.compose.animation.core.tween
10+ import androidx.compose.animation.fadeIn
11+ import androidx.compose.animation.fadeOut
12+ import androidx.compose.animation.togetherWith
1013import androidx.compose.foundation.Image
1114import androidx.compose.foundation.layout.Box
1215import androidx.compose.foundation.layout.Column
@@ -27,7 +30,6 @@ import androidx.compose.ui.tooling.preview.Preview
2730import androidx.compose.ui.unit.dp
2831import to.bitkit.R
2932import to.bitkit.ui.components.BodyM
30- import to.bitkit.ui.components.BodyS
3133import to.bitkit.ui.components.BottomSheetPreview
3234import to.bitkit.ui.components.Display
3335import to.bitkit.ui.components.SecondaryButton
@@ -54,6 +56,9 @@ private const val ARROWS_SPIN_MS = 4000
5456/* * Dashed-ring rotation period: the two rings counter-rotate ~180° per 1s, a turn every ~2s. */
5557private const val RING_SPIN_MS = 2000
5658
59+ /* * Message transition duration. */
60+ private const val MESSAGE_TRANSITION_MS = 200
61+
5762@Composable
5863fun HwSearchingSheet (
5964 modifier : Modifier = Modifier ,
@@ -88,16 +93,22 @@ private fun Content(
8893 ) {
8994 Display (stringResource(R .string.hardware__connect_header).withAccent(accentColor = Colors .Blue ))
9095 VerticalSpacer (8 .dp)
91- BodyM (stringResource(R .string.hardware__connect_text), color = Colors .White64 )
92- AnimatedVisibility (visible = errorMessage != null ) {
93- Column {
94- VerticalSpacer (16 .dp)
95- BodyS (
96- text = errorMessage.orEmpty(),
97- color = Colors .Red ,
98- modifier = Modifier .testTag(" HwSearchingError" )
96+ val defaultMessage = stringResource(R .string.hardware__connect_text)
97+ AnimatedContent (
98+ targetState = (errorMessage != null ) to (errorMessage ? : defaultMessage),
99+ transitionSpec = {
100+ fadeIn(tween(MESSAGE_TRANSITION_MS )).togetherWith(fadeOut(tween(MESSAGE_TRANSITION_MS )))
101+ },
102+ label = " HardwareWalletSearchingMessage" ,
103+ ) { (isError, message) ->
104+ BodyM (
105+ text = message,
106+ color = if (isError) Colors .Red else Colors .White64 ,
107+ minLines = 2 ,
108+ modifier = Modifier .testTag(
109+ if (isError) " HardwareWalletSearchingError" else " HardwareWalletSearchingText"
99110 )
100- }
111+ )
101112 }
102113 }
103114 Box (
0 commit comments