Skip to content

Commit 316bf77

Browse files
committed
fix: stabilize search error copy
1 parent 440ab51 commit 316bf77

2 files changed

Lines changed: 23 additions & 12 deletions

File tree

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

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

3-
import androidx.compose.animation.AnimatedVisibility
3+
import androidx.compose.animation.AnimatedContent
44
import androidx.compose.animation.core.InfiniteTransition
55
import androidx.compose.animation.core.LinearEasing
66
import androidx.compose.animation.core.animateFloat
77
import androidx.compose.animation.core.infiniteRepeatable
88
import androidx.compose.animation.core.rememberInfiniteTransition
99
import androidx.compose.animation.core.tween
10+
import androidx.compose.animation.fadeIn
11+
import androidx.compose.animation.fadeOut
12+
import androidx.compose.animation.togetherWith
1013
import androidx.compose.foundation.Image
1114
import androidx.compose.foundation.layout.Box
1215
import androidx.compose.foundation.layout.Column
@@ -27,7 +30,6 @@ import androidx.compose.ui.tooling.preview.Preview
2730
import androidx.compose.ui.unit.dp
2831
import to.bitkit.R
2932
import to.bitkit.ui.components.BodyM
30-
import to.bitkit.ui.components.BodyS
3133
import to.bitkit.ui.components.BottomSheetPreview
3234
import to.bitkit.ui.components.Display
3335
import 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. */
5557
private const val RING_SPIN_MS = 2000
5658

59+
/** Message transition duration. */
60+
private const val MESSAGE_TRANSITION_MS = 200
61+
5762
@Composable
5863
fun 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(

journeys/hardware-wallet/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Connect-flow testTags: `HardwareWalletSheet`, `HardwareWalletIntroScreen`,
7474
`HardwareWalletFoundConnect`, `HardwareWalletPairedScreen`,
7575
`HardwareWalletLabelInput`, `HardwareWalletPairedFinish`,
7676
`HardwareWalletPairCodeScreen` (inline pair code, physical device only),
77-
`HwSearchingError`, and `HwFoundError`.
77+
`HardwareWalletSearchingError`, and `HwFoundError`.
7878

7979
The current Connect Hardware sheet starts USB discovery immediately after Continue. BLE is
8080
included only once Android nearby-devices permission is granted and Bluetooth is enabled.

0 commit comments

Comments
 (0)