Skip to content

Commit 4fe3125

Browse files
authored
Merge pull request #886 from synonymdev/feat/truncate-middle-address
feat: truncate address in the middle on receive screen
2 parents d460517 + 340a9fe commit 4fe3125

3 files changed

Lines changed: 26 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424
- Mnemonic warning text transitions on reveal #857
2525

2626
### Changed
27+
- Show end of address on Receive Bitcoin screen using middle ellipsis truncation #886
2728
- Update funding screen: replace Advanced with Manual Setup, fix Use Other Wallet navigation to open amount entry, and add Fund Wallet button to no-funds dialog #885
2829
- Updated design of the success screen in the manual channel setup flow #883
2930
- Unified send flow with payment method switcher, details toggle, Lightning support for BIP21 payments, and improved fee rate defaults #863

app/src/main/java/to/bitkit/ui/components/Text.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,16 @@ fun BodyS(
254254
modifier: Modifier = Modifier,
255255
color: Color = MaterialTheme.colorScheme.primary,
256256
textAlign: TextAlign = TextAlign.Start,
257+
maxLines: Int = Int.MAX_VALUE,
258+
overflow: TextOverflow = TextOverflow.Clip,
257259
) {
258260
BodyS(
259261
text = AnnotatedString(text),
260-
modifier = modifier,
261262
color = color,
262263
textAlign = textAlign,
264+
maxLines = maxLines,
265+
overflow = overflow,
266+
modifier = modifier
263267
)
264268
}
265269

@@ -269,14 +273,18 @@ fun BodyS(
269273
modifier: Modifier = Modifier,
270274
color: Color = MaterialTheme.colorScheme.primary,
271275
textAlign: TextAlign = TextAlign.Start,
276+
maxLines: Int = Int.MAX_VALUE,
277+
overflow: TextOverflow = TextOverflow.Clip,
272278
) {
273279
Text(
274280
text = text,
275281
style = AppTextStyles.BodyS.merge(
276282
color = color,
277283
textAlign = textAlign,
278284
),
279-
modifier = modifier,
285+
maxLines = maxLines,
286+
overflow = overflow,
287+
modifier = modifier
280288
)
281289
}
282290

app/src/main/java/to/bitkit/ui/screens/wallets/receive/ReceiveQrScreen.kt

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ import androidx.compose.foundation.layout.Box
1010
import androidx.compose.foundation.layout.Column
1111
import androidx.compose.foundation.layout.PaddingValues
1212
import androidx.compose.foundation.layout.Row
13-
import androidx.compose.foundation.layout.Spacer
1413
import androidx.compose.foundation.layout.fillMaxHeight
1514
import androidx.compose.foundation.layout.fillMaxSize
1615
import androidx.compose.foundation.layout.fillMaxWidth
17-
import androidx.compose.foundation.layout.height
1816
import androidx.compose.foundation.layout.navigationBarsPadding
1917
import androidx.compose.foundation.layout.padding
2018
import androidx.compose.foundation.layout.size
@@ -45,6 +43,7 @@ import androidx.compose.ui.platform.LocalHapticFeedback
4543
import androidx.compose.ui.platform.testTag
4644
import androidx.compose.ui.res.painterResource
4745
import androidx.compose.ui.res.stringResource
46+
import androidx.compose.ui.text.style.TextOverflow
4847
import androidx.compose.ui.tooling.preview.Devices.NEXUS_5
4948
import androidx.compose.ui.tooling.preview.Preview
5049
import androidx.compose.ui.unit.dp
@@ -56,7 +55,6 @@ import kotlinx.coroutines.launch
5655
import org.lightningdevkit.ldknode.ChannelDetails
5756
import to.bitkit.R
5857
import to.bitkit.ext.setClipboardText
59-
import to.bitkit.ext.truncate
6058
import to.bitkit.models.NodeLifecycleState
6159
import to.bitkit.repositories.LightningState
6260
import to.bitkit.repositories.WalletState
@@ -199,7 +197,7 @@ fun ReceiveQrScreen(
199197
) {
200198
SheetTopBar(stringResource(R.string.wallet__receive_bitcoin))
201199
Column {
202-
Spacer(Modifier.height(16.dp))
200+
VerticalSpacer(16.dp)
203201

204202
// Tab row
205203
CustomTabRowWithSpacing(
@@ -221,7 +219,7 @@ fun ReceiveQrScreen(
221219
modifier = Modifier.padding(horizontal = 16.dp)
222220
)
223221

224-
Spacer(Modifier.height(24.dp))
222+
VerticalSpacer(24.dp)
225223

226224
// Content area (QR or Details) with LazyRow
227225
LazyRow(
@@ -268,6 +266,7 @@ fun ReceiveQrScreen(
268266
walletState.bip21,
269267
walletState.onchainAddress,
270268
)
269+
271270
else -> invoice
272271
}
273272

@@ -289,7 +288,7 @@ fun ReceiveQrScreen(
289288
}
290289
}
291290

292-
Spacer(Modifier.height(24.dp))
291+
VerticalSpacer(24.dp)
293292

294293
AnimatedVisibility(visible = lightningState.nodeLifecycleState.isRunning()) {
295294
val showCjitButton = showingCjitOnboarding && selectedTab == ReceiveTab.SPENDING
@@ -332,7 +331,7 @@ fun ReceiveQrScreen(
332331
)
333332
}
334333

335-
Spacer(Modifier.height(16.dp))
334+
VerticalSpacer(16.dp)
336335
}
337336
}
338337
}
@@ -366,7 +365,7 @@ private fun ReceiveQrView(
366365
modifier = Modifier.weight(1f, fill = false)
367366
)
368367

369-
Spacer(modifier = Modifier.height(16.dp))
368+
VerticalSpacer(16.dp)
370369
Row(
371370
horizontalArrangement = Arrangement.spacedBy(16.dp),
372371
verticalAlignment = Alignment.Top,
@@ -434,7 +433,7 @@ private fun ReceiveQrView(
434433
modifier = Modifier.weight(1f)
435434
)
436435
}
437-
Spacer(modifier = Modifier.height(16.dp))
436+
VerticalSpacer(16.dp)
438437
}
439438
}
440439

@@ -577,12 +576,14 @@ private fun CopyAddressCard(
577576
.padding(24.dp)
578577
) {
579578
Caption13Up(text = title, color = Colors.White64)
580-
Spacer(modifier = Modifier.height(16.dp))
579+
VerticalSpacer(16.dp)
581580
BodyS(
582-
text = (body ?: address).truncate(32).uppercase(),
581+
text = (body ?: address).uppercase(),
582+
maxLines = 1,
583+
overflow = TextOverflow.MiddleEllipsis,
583584
modifier = testTag?.let { Modifier.testTag(it) } ?: Modifier
584585
)
585-
Spacer(modifier = Modifier.height(16.dp))
586+
VerticalSpacer(16.dp)
586587
Row(
587588
horizontalArrangement = Arrangement.spacedBy(16.dp)
588589
) {
@@ -862,7 +863,8 @@ private fun PreviewDetailsMode() {
862863
tab = ReceiveTab.AUTO,
863864
walletState = WalletState(
864865
onchainAddress = "bcrt1qfserxgtuesul4m9zva56wzk849yf9l8rk4qy0l",
865-
bolt11 = "lnbcrt500u1pn7umn7pp5x0s9lt9fwrff6rp70pz3guwnjgw97sjuv79...",
866+
bolt11 = "lnbcrt500u1pn7umn7pp5x0s9lt9fwrff6rp70pz3guwnjgw97sjuv79vhx9n2ps8q6tcdehhxapqd9h8vmmfv" +
867+
"djjqen0wgsyqvpsxqcrqvpsxqcrqvpsxqcrqvpsxqcrqvpsxqcrqvpsxqcrqvpsxqcrqvpsxq"
866868
),
867869
cjitInvoice = null,
868870
onClickEditInvoice = {},

0 commit comments

Comments
 (0)