@@ -27,7 +27,6 @@ import androidx.compose.runtime.mutableStateOf
2727import androidx.compose.runtime.remember
2828import androidx.compose.runtime.rememberCoroutineScope
2929import androidx.compose.runtime.setValue
30- import androidx.lifecycle.compose.collectAsStateWithLifecycle
3130import androidx.compose.ui.Alignment
3231import androidx.compose.ui.Modifier
3332import androidx.compose.ui.draw.scale
@@ -40,6 +39,7 @@ import androidx.compose.ui.text.style.TextOverflow
4039import androidx.compose.ui.tooling.preview.Preview
4140import androidx.compose.ui.unit.dp
4241import androidx.compose.ui.unit.sp
42+ import androidx.lifecycle.compose.collectAsStateWithLifecycle
4343import com.synonym.bitkitcore.BtBolt11InvoiceState
4444import com.synonym.bitkitcore.BtOrderState
4545import com.synonym.bitkitcore.BtOrderState2
@@ -56,12 +56,13 @@ import com.synonym.bitkitcore.ILspNode
5656import com.synonym.bitkitcore.IcJitEntry
5757import kotlinx.coroutines.delay
5858import kotlinx.coroutines.launch
59- import to.bitkit.ext.formatWithDotSeparator
59+ import to.bitkit.models.formatToModernDisplay
6060import to.bitkit.ui.Routes
6161import to.bitkit.ui.blocktankViewModel
6262import to.bitkit.ui.components.BodyS
6363import to.bitkit.ui.components.PrimaryButton
6464import to.bitkit.ui.scaffold.AppTopBar
65+ import to.bitkit.ui.shared.util.clickableAlpha
6566import to.bitkit.ui.theme.AppThemeSurface
6667import to.bitkit.ui.theme.Colors
6768import to.bitkit.utils.Logger
@@ -215,20 +216,17 @@ private fun OrderDetailView(
215216 .padding(16 .dp)
216217 ) {
217218 Column (modifier = Modifier .padding(16 .dp)) {
218- Text (
219- text = " Order Details" ,
220- style = MaterialTheme .typography.titleMedium
221- )
219+ Text (text = " Order Details" , style = MaterialTheme .typography.titleMedium)
222220 Spacer (modifier = Modifier .height(8 .dp))
223221 DetailRow (" ID" , order.id)
224222 DetailRow (" Onchain txs" , order.payment.onchain.transactions.size.toString())
225223 DetailRow (" State" , order.state.toString())
226224 DetailRow (" State 2" , order.state2.toString())
227- DetailRow (" LSP Balance" , " ${ order.lspBalanceSat} sats " )
228- DetailRow (" Client Balance" , " ${ order.clientBalanceSat} sats " )
229- DetailRow (" Total Fee" , " ${ order.feeSat} sats " )
230- DetailRow (" Network Fee" , " ${ order.networkFeeSat} sats " )
231- DetailRow (" Service Fee" , " ${ order.serviceFeeSat} sats " )
225+ DetailRow (" LSP Balance" , order.lspBalanceSat.formatToModernDisplay() )
226+ DetailRow (" Client Balance" , order.clientBalanceSat.formatToModernDisplay() )
227+ DetailRow (" Total Fee" , order.feeSat.formatToModernDisplay() )
228+ DetailRow (" Network Fee" , order.networkFeeSat.formatToModernDisplay() )
229+ DetailRow (" Service Fee" , order.serviceFeeSat.formatToModernDisplay() )
232230 }
233231 }
234232 }
@@ -242,10 +240,7 @@ private fun OrderDetailView(
242240 .padding(16 .dp)
243241 ) {
244242 Column (modifier = Modifier .padding(16 .dp)) {
245- Text (
246- text = " Channel Settings" ,
247- style = MaterialTheme .typography.titleMedium
248- )
243+ Text (text = " Channel Settings" , style = MaterialTheme .typography.titleMedium)
249244 Spacer (modifier = Modifier .height(8 .dp))
250245 DetailRow (" Zero Conf" , if (order.zeroConf) " Yes" else " No" )
251246 DetailRow (" Zero Reserve" , if (order.zeroReserve) " Yes" else " No" )
@@ -268,10 +263,7 @@ private fun OrderDetailView(
268263 .padding(16 .dp)
269264 ) {
270265 Column (modifier = Modifier .padding(16 .dp)) {
271- Text (
272- text = " LSP Information" ,
273- style = MaterialTheme .typography.titleMedium
274- )
266+ Text (text = " LSP Information" , style = MaterialTheme .typography.titleMedium)
275267 Spacer (modifier = Modifier .height(8 .dp))
276268 DetailRow (" Alias" , order.lspNode.alias)
277269 DetailRow (" Node ID" , order.lspNode.pubkey)
@@ -300,7 +292,7 @@ private fun OrderDetailView(
300292 DetailRow (" Coupon Code" , couponCode)
301293 order.discount?.let { discount ->
302294 DetailRow (" Discount Type" , discount.code)
303- DetailRow (" Value" , " ${ discount.absoluteSat} " )
295+ DetailRow (" Value" , discount.absoluteSat.formatToModernDisplay() )
304296 }
305297 }
306298 }
@@ -316,10 +308,7 @@ private fun OrderDetailView(
316308 .padding(16 .dp)
317309 ) {
318310 Column (modifier = Modifier .padding(16 .dp)) {
319- Text (
320- text = " Timestamps" ,
321- style = MaterialTheme .typography.titleMedium
322- )
311+ Text (text = " Timestamps" , style = MaterialTheme .typography.titleMedium)
323312 Spacer (modifier = Modifier .height(8 .dp))
324313 DetailRow (" Created" , order.createdAt)
325314 DetailRow (" Updated" , order.updatedAt)
@@ -391,14 +380,11 @@ private fun CJitDetailView(
391380 .padding(16 .dp)
392381 ) {
393382 Column (modifier = Modifier .padding(16 .dp)) {
394- Text (
395- text = " Entry Details" ,
396- style = MaterialTheme .typography.titleMedium
397- )
383+ Text (text = " Entry Details" , style = MaterialTheme .typography.titleMedium)
398384 Spacer (modifier = Modifier .height(8 .dp))
399385 DetailRow (label = " ID" , value = entry.id)
400386 DetailRow (label = " State" , value = entry.state.toString())
401- DetailRow (label = " Channel Size" , value = " ${ entry.channelSizeSat} sats " )
387+ DetailRow (label = " Channel Size" , value = entry.channelSizeSat.formatToModernDisplay() )
402388 entry.channelOpenError?.let { error ->
403389 DetailRow (label = " Error" , value = error, isError = true )
404390 }
@@ -415,14 +401,11 @@ private fun CJitDetailView(
415401 .padding(16 .dp)
416402 ) {
417403 Column (modifier = Modifier .padding(16 .dp)) {
418- Text (
419- text = " Fees" ,
420- style = MaterialTheme .typography.titleMedium
421- )
404+ Text (text = " Fees" , style = MaterialTheme .typography.titleMedium)
422405 Spacer (modifier = Modifier .height(8 .dp))
423- DetailRow (label = " Total Fee" , value = " ${ entry.feeSat} sats " )
424- DetailRow (label = " Network Fee" , value = " ${ entry.networkFeeSat} sats " )
425- DetailRow (label = " Service Fee" , value = " ${ entry.serviceFeeSat} sats " )
406+ DetailRow (label = " Total Fee" , value = entry.feeSat.formatToModernDisplay() )
407+ DetailRow (label = " Network Fee" , value = entry.networkFeeSat.formatToModernDisplay() )
408+ DetailRow (label = " Service Fee" , value = entry.serviceFeeSat.formatToModernDisplay() )
426409 }
427410 }
428411 }
@@ -436,10 +419,7 @@ private fun CJitDetailView(
436419 .padding(16 .dp)
437420 ) {
438421 Column (modifier = Modifier .padding(16 .dp)) {
439- Text (
440- text = " Channel Settings" ,
441- style = MaterialTheme .typography.titleMedium
442- )
422+ Text (text = " Channel Settings" , style = MaterialTheme .typography.titleMedium)
443423 Spacer (modifier = Modifier .height(8 .dp))
444424 DetailRow (label = " Node ID" , value = entry.nodeId)
445425 DetailRow (label = " Expiry Weeks" , value = " ${entry.channelExpiryWeeks} " )
@@ -456,10 +436,7 @@ private fun CJitDetailView(
456436 .padding(16 .dp)
457437 ) {
458438 Column (modifier = Modifier .padding(16 .dp)) {
459- Text (
460- text = " LSP Information" ,
461- style = MaterialTheme .typography.titleMedium
462- )
439+ Text (text = " LSP Information" , style = MaterialTheme .typography.titleMedium)
463440 Spacer (modifier = Modifier .height(8 .dp))
464441 DetailRow (label = " Alias" , value = entry.lspNode.alias)
465442 DetailRow (label = " Node ID" , value = entry.lspNode.pubkey)
@@ -477,10 +454,7 @@ private fun CJitDetailView(
477454 .padding(16 .dp)
478455 ) {
479456 Column (modifier = Modifier .padding(16 .dp)) {
480- Text (
481- text = " Discount" ,
482- style = MaterialTheme .typography.titleMedium
483- )
457+ Text (text = " Discount" , style = MaterialTheme .typography.titleMedium)
484458 Spacer (modifier = Modifier .height(8 .dp))
485459 DetailRow (label = " Coupon Code" , value = entry.couponCode)
486460 entry.discount?.let { discount ->
@@ -501,10 +475,7 @@ private fun CJitDetailView(
501475 .padding(16 .dp)
502476 ) {
503477 Column (modifier = Modifier .padding(16 .dp)) {
504- Text (
505- text = " Timestamps" ,
506- style = MaterialTheme .typography.titleMedium
507- )
478+ Text (text = " Timestamps" , style = MaterialTheme .typography.titleMedium)
508479 Spacer (modifier = Modifier .height(8 .dp))
509480 DetailRow (label = " Created" , value = entry.createdAt)
510481 DetailRow (label = " Updated" , value = entry.updatedAt)
@@ -543,7 +514,7 @@ private fun CopyableText(text: String) {
543514 overflow = TextOverflow .Ellipsis ,
544515 modifier = Modifier
545516 .scale(scale)
546- .clickable {
517+ .clickableAlpha {
547518 clipboardManager.setText(AnnotatedString (text))
548519 coroutineScope.launch {
549520 isPressed = true
@@ -557,10 +528,10 @@ private fun CopyableText(text: String) {
557528@Composable
558529private fun OrderRow (order : IBtOrder ) {
559530 Column (
531+ verticalArrangement = Arrangement .spacedBy(8 .dp),
560532 modifier = Modifier
561533 .fillMaxWidth()
562- .padding(8 .dp),
563- verticalArrangement = Arrangement .spacedBy(8 .dp)
534+ .padding(8 .dp)
564535 ) {
565536 Row (
566537 modifier = Modifier .fillMaxWidth(),
@@ -581,23 +552,23 @@ private fun OrderRow(order: IBtOrder) {
581552 }
582553
583554 Row (
555+ horizontalArrangement = Arrangement .SpaceBetween ,
584556 modifier = Modifier .fillMaxWidth(),
585- horizontalArrangement = Arrangement .SpaceBetween
586557 ) {
587- BalanceInfo (label = " LSP Balance" , value = " ${ order.lspBalanceSat.formatWithDotSeparator()} sats " )
588- BalanceInfo (
558+ InfoCell (label = " LSP Balance" , value = order.lspBalanceSat.formatToModernDisplay() )
559+ InfoCell (
589560 label = " Client Balance" ,
590- value = " ${ order.clientBalanceSat.formatWithDotSeparator()} sats " ,
561+ value = order.clientBalanceSat.formatToModernDisplay() ,
591562 alignment = Alignment .End
592563 )
593564 }
594565
595566 Row (
567+ horizontalArrangement = Arrangement .SpaceBetween ,
596568 modifier = Modifier .fillMaxWidth(),
597- horizontalArrangement = Arrangement .SpaceBetween
598569 ) {
599- BalanceInfo (label = " Fees" , value = " ${ order.feeSat.formatWithDotSeparator()} sats " )
600- BalanceInfo (
570+ InfoCell (label = " Fees" , value = order.feeSat.formatToModernDisplay() )
571+ InfoCell (
601572 label = " Expires" ,
602573 value = order.channelExpiresAt.take(10 ),
603574 alignment = Alignment .End
@@ -636,10 +607,10 @@ private fun CJitRow(entry: IcJitEntry) {
636607 modifier = Modifier .fillMaxWidth(),
637608 horizontalArrangement = Arrangement .SpaceBetween
638609 ) {
639- BalanceInfo (label = " Channel Size" , value = " ${entry.channelSizeSat.formatWithDotSeparator ()} sats" )
640- BalanceInfo (
610+ InfoCell (label = " Channel Size" , value = " ${entry.channelSizeSat.formatToModernDisplay ()} sats" )
611+ InfoCell (
641612 label = " Fees" ,
642- value = " ${entry.feeSat.formatWithDotSeparator ()} sats" ,
613+ value = " ${entry.feeSat.formatToModernDisplay ()} sats" ,
643614 alignment = Alignment .End
644615 )
645616 }
@@ -663,7 +634,7 @@ private fun CJitRow(entry: IcJitEntry) {
663634}
664635
665636@Composable
666- private fun BalanceInfo (label : String , value : String , alignment : Alignment .Horizontal = Alignment .Start ) {
637+ private fun InfoCell (label : String , value : String , alignment : Alignment .Horizontal = Alignment .Start ) {
667638 Column (horizontalAlignment = alignment) {
668639 Text (
669640 text = label,
@@ -715,7 +686,7 @@ private fun DetailRow(label: String, value: String, isError: Boolean = false) {
715686 textAlign = TextAlign .End ,
716687 modifier = Modifier
717688 .scale(scale)
718- .clickable {
689+ .clickableAlpha {
719690 clipboardManager.setText(AnnotatedString (value))
720691 coroutineScope.launch {
721692 isPressed = true
0 commit comments