@@ -36,7 +36,11 @@ import com.synonym.bitkitcore.OnchainActivity
3636import com.synonym.bitkitcore.PaymentState
3737import com.synonym.bitkitcore.PaymentType
3838import to.bitkit.R
39+ import to.bitkit.ext.BoostType
40+ import to.bitkit.ext.boostType
3941import to.bitkit.ext.ellipsisMiddle
42+ import to.bitkit.ext.isBoosted
43+ import to.bitkit.ext.isSent
4044import to.bitkit.ext.rawId
4145import to.bitkit.ext.totalValue
4246import to.bitkit.models.Toast
@@ -70,8 +74,7 @@ fun ActivityExploreScreen(
7074 onCloseClick : () -> Unit ,
7175) {
7276 val activities by listViewModel.filteredActivities.collectAsStateWithLifecycle()
73- val item = activities?.find { it.rawId() == route.id }
74- ? : return
77+ val item = activities?.find { it.rawId() == route.id } ? : return
7578
7679 val app = appViewModel ? : return
7780 val context = LocalContext .current
@@ -113,6 +116,13 @@ fun ActivityExploreScreen(
113116 val intent = Intent (Intent .ACTION_VIEW , url.toUri())
114117 context.startActivity(intent)
115118 },
119+ onClickParent = { id ->
120+ app.toast(
121+ type = Toast .ToastType .WARNING ,
122+ title = " TODO" ,
123+ description = " Navigate to Activity Detail for: $id " ,
124+ )
125+ },
116126 )
117127 }
118128}
@@ -123,28 +133,23 @@ private fun ActivityExploreContent(
123133 txDetails : TxDetails ? = null,
124134 onCopy : (String ) -> Unit = {},
125135 onClickExplore : (String ) -> Unit = {},
136+ onClickParent : (String ) -> Unit = {},
126137) {
127138 Column (
128139 modifier = Modifier
129140 .fillMaxHeight()
130141 .padding(16 .dp)
131142 .verticalScroll(rememberScrollState())
132143 ) {
133- // Header
134144 Row (
135145 verticalAlignment = Alignment .Bottom ,
136146 modifier = Modifier
137147 .fillMaxWidth()
138148 .padding(vertical = 16 .dp)
139149 ) {
140- val isSent = when (item) {
141- is Activity .Lightning -> item.v1.txType == PaymentType .SENT
142- is Activity .Onchain -> item.v1.txType == PaymentType .SENT
143- }
144- val amountPrefix = if (isSent) " -" else " +"
145150 BalanceHeaderView (
146151 sats = item.totalValue().toLong(),
147- prefix = amountPrefix ,
152+ prefix = if (item.isSent()) " - " else " + " ,
148153 showBitcoinSymbol = false ,
149154 modifier = Modifier .weight(1f ),
150155 )
@@ -155,7 +160,12 @@ private fun ActivityExploreContent(
155160
156161 when (item) {
157162 is Activity .Onchain -> {
158- OnchainDetails (onchain = item, onCopy = onCopy, txDetails = txDetails)
163+ OnchainDetails (
164+ onchain = item,
165+ onCopy = onCopy,
166+ txDetails = txDetails,
167+ onClickParent = onClickParent,
168+ )
159169 Spacer (modifier = Modifier .weight(1f ))
160170 PrimaryButton (
161171 text = stringResource(R .string.wallet__activity_explorer),
@@ -187,8 +197,7 @@ private fun LightningDetails(
187197 modifier = Modifier .clickableAlpha(
188198 onClick = copyToClipboard(preimage) {
189199 onCopy(preimage)
190- }
191- ),
200+ }),
192201 )
193202 }
194203 Section (
@@ -197,17 +206,15 @@ private fun LightningDetails(
197206 modifier = Modifier .clickableAlpha(
198207 onClick = copyToClipboard(paymentHash) {
199208 onCopy(paymentHash)
200- }
201- ),
209+ }),
202210 )
203211 Section (
204212 title = stringResource(R .string.wallet__activity_invoice),
205213 value = invoice,
206214 modifier = Modifier .clickableAlpha(
207215 onClick = copyToClipboard(invoice) {
208216 onCopy(invoice)
209- }
210- ),
217+ }),
211218 )
212219}
213220
@@ -216,19 +223,16 @@ private fun ColumnScope.OnchainDetails(
216223 onchain : Activity .Onchain ,
217224 onCopy : (String ) -> Unit ,
218225 txDetails : TxDetails ? ,
226+ onClickParent : (String ) -> Unit ,
219227) {
220228 val txId = onchain.v1.txId
221229 Section (
222- title = stringResource(R .string.wallet__activity_tx_id),
223- value = txId,
224- modifier = Modifier
230+ title = stringResource(R .string.wallet__activity_tx_id), value = txId, modifier = Modifier
225231 .clickableAlpha(
226232 onClick = copyToClipboard(txId) {
227233 onCopy(txId)
228- }
229- )
230- .testTag(" TXID" )
231- )
234+ })
235+ .testTag(" TXID" ))
232236 if (txDetails != null ) {
233237 Section (
234238 title = localizedPlural(R .string.wallet__activity_input, mapOf (" count" to txDetails.vin.size)),
@@ -256,12 +260,31 @@ private fun ColumnScope.OnchainDetails(
256260 CircularProgressIndicator (
257261 strokeWidth = 2 .dp,
258262 modifier = Modifier
259- .size(16 .dp)
260263 .padding(vertical = 16 .dp)
261- .align(Alignment .CenterHorizontally ),
264+ .size(16 .dp)
265+ .align(Alignment .CenterHorizontally )
262266 )
267+ } // TODO use real boosted parents from bitkit-core/ldk-node when available
268+ val boostedParents = listOfNotNull(
269+ " todo_first_parent_txid" .takeIf { onchain.isBoosted() && ! onchain.v1.confirmed },
270+ " todo_second_parent_txid" .takeIf { onchain.isBoosted() && onchain.v1.confirmed },
271+ )
272+
273+ boostedParents.forEachIndexed { index, parent ->
274+ val isRbf = onchain.boostType() == BoostType .RBF
275+ Section (
276+ title = stringResource(
277+ if (isRbf) R .string.wallet__activity_boosted_rbf else R .string.wallet__activity_boosted_cpfp
278+ ).replace(" {num}" , " ${index + 1 } " ), valueContent = {
279+ Column {
280+ BodySSB (text = parent, maxLines = 1 , overflow = TextOverflow .MiddleEllipsis )
281+ }
282+ }, modifier = Modifier
283+ .clickableAlpha {
284+ onClickParent(parent)
285+ }
286+ .testTag(if (isRbf) " RBFBoosted" else " CPFPBoosted" ))
263287 }
264- // TODO add boosted parents info if boosted
265288}
266289
267290@Composable
0 commit comments