Skip to content

Commit 706d9a2

Browse files
committed
feat: use x icon for dropped tx activities
1 parent 7dbed41 commit 706d9a2

File tree

4 files changed

+57
-31
lines changed

4 files changed

+57
-31
lines changed

app/src/main/java/to/bitkit/ext/Activities.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ fun Activity.matchesPaymentId(paymentHashOrTxId: String): Boolean = when (this)
6060

6161
fun Activity.isTransfer() = this is Activity.Onchain && this.v1.isTransfer
6262

63+
fun Activity.doesExist() = this is Activity.Onchain && this.v1.doesExist
64+
6365
fun Activity.Onchain.boostType() = when (this.v1.txType) {
6466
PaymentType.SENT -> BoostType.RBF
6567
PaymentType.RECEIVED -> BoostType.CPFP

app/src/main/java/to/bitkit/ui/screens/wallets/activity/components/ActivityIcon.kt

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package to.bitkit.ui.screens.wallets.activity.components
33
import androidx.compose.foundation.background
44
import androidx.compose.foundation.layout.Arrangement
55
import androidx.compose.foundation.layout.Box
6-
import androidx.compose.foundation.layout.Row
6+
import androidx.compose.foundation.layout.Column
77
import androidx.compose.foundation.layout.padding
88
import androidx.compose.foundation.layout.size
99
import androidx.compose.foundation.shape.CircleShape
@@ -24,6 +24,7 @@ import com.synonym.bitkitcore.OnchainActivity
2424
import com.synonym.bitkitcore.PaymentState
2525
import com.synonym.bitkitcore.PaymentType
2626
import to.bitkit.R
27+
import to.bitkit.ext.doesExist
2728
import to.bitkit.ext.isBoosted
2829
import to.bitkit.ext.isFinished
2930
import to.bitkit.ext.isTransfer
@@ -46,7 +47,7 @@ fun ActivityIcon(
4647
val arrowIcon = painterResource(if (txType == PaymentType.SENT) R.drawable.ic_sent else R.drawable.ic_received)
4748

4849
when {
49-
activity.isBoosted() && !activity.isFinished() -> {
50+
activity.isBoosted() && !activity.isFinished() && activity.doesExist() -> {
5051
CircularIcon(
5152
icon = painterResource(R.drawable.ic_timer_alt),
5253
iconColor = Colors.Yellow,
@@ -90,9 +91,14 @@ fun ActivityIcon(
9091
}
9192
}
9293

94+
// onchain
9395
else -> {
9496
CircularIcon(
95-
icon = if (activity.isTransfer()) painterResource(R.drawable.ic_transfer) else arrowIcon,
97+
icon = when {
98+
!activity.doesExist() -> painterResource(R.drawable.ic_x)
99+
activity.isTransfer() -> painterResource(R.drawable.ic_transfer)
100+
else -> arrowIcon
101+
},
96102
iconColor = Colors.Brand,
97103
backgroundColor = Colors.Brand16,
98104
size = size,
@@ -129,8 +135,8 @@ fun CircularIcon(
129135
@Composable
130136
private fun Preview() {
131137
AppThemeSurface {
132-
Row(
133-
horizontalArrangement = Arrangement.spacedBy(16.dp),
138+
Column(
139+
verticalArrangement = Arrangement.spacedBy(16.dp),
134140
modifier = Modifier.padding(16.dp),
135141
) {
136142
// Lightning Sent Succeeded
@@ -293,6 +299,32 @@ private fun Preview() {
293299
)
294300
)
295301
)
302+
303+
// Onchain Removed
304+
ActivityIcon(
305+
activity = Activity.Onchain(
306+
v1 = OnchainActivity(
307+
id = "test-onchain-2",
308+
txType = PaymentType.SENT,
309+
txId = "abc123",
310+
value = 100000uL,
311+
fee = 500uL,
312+
feeRate = 8uL,
313+
address = "bc1...",
314+
confirmed = true,
315+
timestamp = (System.currentTimeMillis() / 1000).toULong(),
316+
isBoosted = true,
317+
boostTxIds = emptyList(),
318+
isTransfer = false,
319+
doesExist = false,
320+
confirmTimestamp = (System.currentTimeMillis() / 1000).toULong(),
321+
channelId = null,
322+
transferTxId = "transferTxId",
323+
createdAt = null,
324+
updatedAt = null,
325+
)
326+
)
327+
)
296328
}
297329
}
298330
}

app/src/main/java/to/bitkit/ui/screens/wallets/activity/components/ActivityRow.kt

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -99,31 +99,23 @@ fun ActivityRow(
9999
is Activity.Lightning -> item.v1.message.ifEmpty { formattedTime(timestamp) }
100100
is Activity.Onchain -> {
101101
when {
102-
!item.v1.doesExist -> {
103-
stringResource(R.string.wallet__activity_removed)
104-
}
102+
!item.v1.doesExist -> stringResource(R.string.wallet__activity_removed)
105103

106-
isTransfer && isSent -> {
107-
if (item.v1.confirmed) {
108-
stringResource(R.string.wallet__activity_transfer_spending_done)
109-
} else {
110-
stringResource(R.string.wallet__activity_transfer_spending_pending)
111-
.replace("{duration}", "1h") // TODO: calculate confirmsIn text
112-
}
104+
isTransfer && isSent -> if (item.v1.confirmed) {
105+
stringResource(R.string.wallet__activity_transfer_spending_done)
106+
} else {
107+
stringResource(R.string.wallet__activity_transfer_spending_pending)
108+
.replace("{duration}", "1h") // TODO: calculate confirmsIn text
113109
}
114110

115-
isTransfer && !isSent -> {
116-
if (item.v1.confirmed) {
117-
stringResource(R.string.wallet__activity_transfer_savings_done)
118-
} else {
119-
stringResource(R.string.wallet__activity_transfer_savings_pending)
120-
.replace("{duration}", "1h") // TODO: calculate confirmsIn text
121-
}
111+
isTransfer && !isSent -> if (item.v1.confirmed) {
112+
stringResource(R.string.wallet__activity_transfer_savings_done)
113+
} else {
114+
stringResource(R.string.wallet__activity_transfer_savings_pending)
115+
.replace("{duration}", "1h") // TODO: calculate confirmsIn text
122116
}
123117

124-
confirmed == true -> {
125-
formattedTime(timestamp)
126-
}
118+
confirmed == true -> formattedTime(timestamp)
127119

128120
else -> {
129121
// TODO: calculate confirmsIn text

app/src/main/java/to/bitkit/ui/screens/wallets/activity/utils/PreviewItems.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ val previewActivityItems = buildList {
2323
id = "1",
2424
txType = PaymentType.RECEIVED,
2525
txId = "01",
26-
value = 42_000_000_u,
26+
value = 42_000_u,
2727
fee = 200_u,
2828
feeRate = 1_u,
2929
address = "bc1",
3030
confirmed = true,
3131
timestamp = today.epochSecond(),
32-
isBoosted = false,
33-
boostTxIds = emptyList(),
34-
isTransfer = true,
35-
doesExist = true,
32+
isBoosted = true,
33+
boostTxIds = listOf("02", "03"),
34+
isTransfer = false,
35+
doesExist = false,
3636
confirmTimestamp = today.epochSecond(),
3737
channelId = "channelId",
3838
transferTxId = "transferTxId",
39-
createdAt = today.epochSecond(),
39+
createdAt = today.epochSecond() - 30_000u,
4040
updatedAt = today.epochSecond(),
4141
)
4242
)

0 commit comments

Comments
 (0)