Skip to content

Commit ed6dec7

Browse files
committed
fix: address hw settings review
1 parent d925ffa commit ed6dec7

2 files changed

Lines changed: 38 additions & 8 deletions

File tree

app/src/main/java/to/bitkit/ui/settings/general/HardwareWalletsSettingsScreen.kt

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import androidx.compose.foundation.layout.fillMaxWidth
1111
import androidx.compose.foundation.layout.height
1212
import androidx.compose.foundation.layout.padding
1313
import androidx.compose.foundation.layout.size
14+
import androidx.compose.foundation.lazy.LazyColumn
15+
import androidx.compose.foundation.lazy.items
1416
import androidx.compose.foundation.shape.CircleShape
1517
import androidx.compose.material3.HorizontalDivider
1618
import androidx.compose.material3.Icon
@@ -36,7 +38,6 @@ import to.bitkit.models.HwWallet
3638
import to.bitkit.models.TransportType
3739
import to.bitkit.ui.components.BodyM
3840
import to.bitkit.ui.components.Display
39-
import to.bitkit.ui.components.FillHeight
4041
import to.bitkit.ui.components.HorizontalSpacer
4142
import to.bitkit.ui.components.HwDeviceIllustrations
4243
import to.bitkit.ui.components.MoneySSB
@@ -111,11 +112,19 @@ private fun Content(
111112
if (wallets.isEmpty()) {
112113
EmptyState(modifier = Modifier.weight(1f))
113114
} else {
114-
wallets.forEach { wallet ->
115-
HwWalletRow(wallet = wallet, onRemoveClick = onRemoveClick)
116-
HorizontalDivider(color = Colors.White10)
115+
LazyColumn(
116+
modifier = Modifier
117+
.weight(1f)
118+
.fillMaxWidth()
119+
) {
120+
items(
121+
items = wallets,
122+
key = { it.id },
123+
) { wallet ->
124+
HwWalletRow(wallet = wallet, onRemoveClick = onRemoveClick)
125+
HorizontalDivider(color = Colors.White10)
126+
}
117127
}
118-
FillHeight()
119128
}
120129

121130
PrimaryButton(
@@ -168,7 +177,7 @@ private fun HwWalletRow(
168177
modifier = modifier
169178
.fillMaxWidth()
170179
.height(52.dp)
171-
.testTag("HardwareWalletRow")
180+
.testTag("HardwareWalletRow_${wallet.id}")
172181
) {
173182
HwConnectionBadge(transportType = wallet.transportType, isConnected = wallet.isConnected)
174183
HorizontalSpacer(12.dp)
@@ -186,7 +195,7 @@ private fun HwWalletRow(
186195
)
187196
IconButton(
188197
onClick = { onRemoveClick(wallet) },
189-
modifier = Modifier.testTag("HardwareWalletRowDelete")
198+
modifier = Modifier.testTag("HardwareWalletRowDelete_${wallet.id}")
190199
) {
191200
Icon(
192201
painter = painterResource(R.drawable.ic_trash),
@@ -204,6 +213,23 @@ private fun HwConnectionBadge(
204213
isConnected: Boolean,
205214
modifier: Modifier = Modifier,
206215
) {
216+
val contentDescription = when (transportType) {
217+
TransportType.BLUETOOTH -> {
218+
if (isConnected) {
219+
stringResource(R.string.hardware__connection_badge_connected_bluetooth)
220+
} else {
221+
stringResource(R.string.hardware__connection_badge_disconnected_bluetooth)
222+
}
223+
}
224+
TransportType.USB -> {
225+
if (isConnected) {
226+
stringResource(R.string.hardware__connection_badge_connected_usb)
227+
} else {
228+
stringResource(R.string.hardware__connection_badge_disconnected_usb)
229+
}
230+
}
231+
}
232+
207233
Box(
208234
contentAlignment = Alignment.Center,
209235
modifier = modifier
@@ -218,7 +244,7 @@ private fun HwConnectionBadge(
218244
TransportType.USB -> R.drawable.ic_usb_connected
219245
}
220246
),
221-
contentDescription = null,
247+
contentDescription = contentDescription,
222248
tint = if (isConnected) Colors.Green else Colors.White64,
223249
modifier = Modifier.size(16.dp)
224250
)

app/src/main/res/values/strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@
164164
<string name="fee__slow__description">±1-2 hours</string>
165165
<string name="fee__slow__shortDescription">±1h</string>
166166
<string name="fee__slow__title">Slow</string>
167+
<string name="hardware__connection_badge_connected_bluetooth">Connected via Bluetooth</string>
168+
<string name="hardware__connection_badge_connected_usb">Connected via USB</string>
169+
<string name="hardware__connection_badge_disconnected_bluetooth">Disconnected via Bluetooth</string>
170+
<string name="hardware__connection_badge_disconnected_usb">Disconnected via USB</string>
167171
<string name="hardware__intro_header">Add your &lt;accent&gt;hardware wallet&lt;/accent&gt;</string>
168172
<string name="hardware__intro_text">Connect your hardware device to watch or manage your long-term funds.</string>
169173
<string name="hardware__intro_title">Hardware Wallet</string>

0 commit comments

Comments
 (0)