Skip to content

Commit dac2d6c

Browse files
committed
feat: implement tooltip in the CopyAddressCard
1 parent 17b2843 commit dac2d6c

File tree

1 file changed

+32
-17
lines changed

1 file changed

+32
-17
lines changed

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

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ fun ReceiveQrSheet(
104104
val cjitInvoice = remember { mutableStateOf<String?>(null) }
105105
val showCreateCjit = remember { mutableStateOf(false) }
106106
val cjitEntryDetails = remember { mutableStateOf<CjitEntryDetails?>(null) }
107-
val lightningState : LightningState by wallet.lightningState.collectAsStateWithLifecycle()
107+
val lightningState: LightningState by wallet.lightningState.collectAsStateWithLifecycle()
108108

109109
LaunchedEffect(Unit) {
110110
try {
@@ -134,7 +134,7 @@ fun ReceiveQrSheet(
134134

135135
LaunchedEffect(Unit) {
136136
wallet.walletEffect.collect { effect ->
137-
when(effect) {
137+
when (effect) {
138138
WalletViewModelEffects.NavigateGeoBlockScreen -> {
139139
navController.navigate(ReceiveRoutes.LOCATION_BLOCK)
140140
}
@@ -154,6 +154,7 @@ fun ReceiveQrSheet(
154154
showCreateCjit.value = false
155155
cjitInvoice.value = null
156156
}
157+
157158
active && cjitInvoice.value == null -> {
158159
showCreateCjit.value = true
159160
navController.navigate(ReceiveRoutes.AMOUNT)
@@ -549,6 +550,7 @@ private fun CopyValuesSlide(
549550

550551
enum class CopyAddressType { ONCHAIN, LIGHTNING }
551552

553+
@OptIn(ExperimentalMaterial3Api::class)
552554
@Composable
553555
private fun CopyAddressCard(
554556
title: String,
@@ -557,6 +559,10 @@ private fun CopyAddressCard(
557559
) {
558560
val clipboard = LocalClipboardManager.current
559561
val context = LocalContext.current
562+
563+
val tooltipState = rememberTooltipState()
564+
val coroutineScope = rememberCoroutineScope()
565+
560566
Column(
561567
modifier = Modifier
562568
.fillMaxWidth()
@@ -576,21 +582,30 @@ private fun CopyAddressCard(
576582
Row(
577583
horizontalArrangement = Arrangement.spacedBy(16.dp)
578584
) {
579-
PrimaryButton(
580-
text = stringResource(R.string.common__copy),
581-
size = ButtonSize.Small,
582-
onClick = { clipboard.setText(AnnotatedString(address)) },
583-
fullWidth = false,
584-
color = Colors.White10,
585-
icon = {
586-
Icon(
587-
painter = painterResource(R.drawable.ic_copy),
588-
contentDescription = null,
589-
tint = if (type == CopyAddressType.ONCHAIN) Colors.Brand else Colors.Purple,
590-
modifier = Modifier.size(18.dp)
591-
)
592-
}
593-
)
585+
586+
Tooltip(
587+
text = stringResource(R.string.wallet__receive_copied),
588+
tooltipState = tooltipState
589+
) {
590+
PrimaryButton(
591+
text = stringResource(R.string.common__copy),
592+
size = ButtonSize.Small,
593+
onClick = {
594+
clipboard.setText(AnnotatedString(address))
595+
coroutineScope.launch { tooltipState.show() }
596+
},
597+
fullWidth = false,
598+
color = Colors.White10,
599+
icon = {
600+
Icon(
601+
painter = painterResource(R.drawable.ic_copy),
602+
contentDescription = null,
603+
tint = if (type == CopyAddressType.ONCHAIN) Colors.Brand else Colors.Purple,
604+
modifier = Modifier.size(18.dp)
605+
)
606+
}
607+
)
608+
}
594609
PrimaryButton(
595610
text = stringResource(R.string.common__share),
596611
size = ButtonSize.Small,

0 commit comments

Comments
 (0)