sats -> B

This commit is contained in:
callebtc
2025-07-15 18:44:29 +02:00
parent 6dbac1eb4f
commit b20029aedd
10 changed files with 117 additions and 64 deletions
@@ -4,6 +4,8 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Download
import androidx.compose.material3.* import androidx.compose.material3.*
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
@@ -106,71 +108,122 @@ fun CashuPaymentChip(
.clickable { .clickable {
onPaymentClick?.invoke(token) ?: handleCashuPayment(token) onPaymentClick?.invoke(token) ?: handleCashuPayment(token)
}, },
shape = RoundedCornerShape(12.dp), shape = RoundedCornerShape(8.dp),
colors = CardDefaults.cardColors( colors = CardDefaults.cardColors(
containerColor = Color(0xFF00C851) // bitchat green containerColor = Color(0xFF0E0E0E) // Dark background
), ),
elevation = CardDefaults.cardElevation(defaultElevation = 4.dp) elevation = CardDefaults.cardElevation(defaultElevation = 0.dp),
border = androidx.compose.foundation.BorderStroke(
0.25.dp,
Color(0xFF2EC954) // Green outline
)
) { ) {
Row( Row(
modifier = Modifier modifier = Modifier
.padding(horizontal = 12.dp, vertical = 8.dp), .padding(horizontal = 16.dp, vertical = 8.dp),
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp) horizontalArrangement = Arrangement.SpaceBetween
) { ) {
// Payment icon // Left side - Payment info
Text( Column(
text = "", modifier = Modifier.weight(1f),
fontSize = 16.sp, verticalArrangement = Arrangement.spacedBy(4.dp)
color = Color.White ) {
) // Top row: Bitcoin icon and "bitcoin" text
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(2.dp)
) {
// Orange Bitcoin circle with symbol inside
Box(
modifier = Modifier
.size(16.dp)
.background(
Color(0xFFFF9F0A),
shape = androidx.compose.foundation.shape.CircleShape
),
contentAlignment = Alignment.Center
) {
Text(
text = "",
fontSize = 8.sp,
color = Color(0xFF140C01),
fontFamily = FontFamily.Monospace
)
}
// Payment info // "bitcoin" text
Column { Text(
Text( text = "bitcoin",
text = "Cashu Payment", fontSize = 16.sp,
fontSize = 12.sp, color = Color(0xFF2EC954),
color = Color.White.copy(alpha = 0.9f), fontFamily = FontFamily.Monospace
fontWeight = FontWeight.Medium, )
fontFamily = FontFamily.Monospace }
)
Text( // Middle row: Amount and unit
text = "${token.amount} ${token.unit}", Row(
fontSize = 14.sp, verticalAlignment = Alignment.CenterVertically,
color = Color.White, horizontalArrangement = Arrangement.spacedBy(4.dp)
fontWeight = FontWeight.Bold, ) {
fontFamily = FontFamily.Monospace Text(
) text = "${token.amount}",
fontSize = 24.sp,
color = Color(0xFF2EC954),
fontWeight = FontWeight.Medium,
fontFamily = FontFamily.Monospace
)
Text(
text = "",
fontSize = 16.sp,
color = Color(0xFF2EC954),
fontFamily = FontFamily.Monospace
)
}
// Bottom row: Memo (if present)
if (token.memo?.isNotBlank() == true) { if (token.memo?.isNotBlank() == true) {
Text( Text(
text = "\"${token.memo}\"", text = "\"${token.memo}\"",
fontSize = 10.sp, fontSize = 10.sp,
color = Color.White.copy(alpha = 0.8f), color = Color(0xFF26A746),
fontFamily = FontFamily.Monospace fontFamily = FontFamily.Monospace
) )
} }
} }
Spacer(modifier = Modifier.weight(1f)) // Right side - Receive button
// Receive button
Button( Button(
onClick = { onClick = {
onPaymentClick?.invoke(token) ?: handleCashuPayment(token) onPaymentClick?.invoke(token) ?: handleCashuPayment(token)
}, },
modifier = Modifier.height(32.dp), modifier = Modifier.height(40.dp),
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 0.dp), contentPadding = PaddingValues(horizontal = 8.dp, vertical = 8.dp),
colors = ButtonDefaults.buttonColors( colors = ButtonDefaults.buttonColors(
containerColor = Color.White, containerColor = Color(0xFF2EC954),
contentColor = Color(0xFF00C851) contentColor = Color.White
) ),
shape = RoundedCornerShape(8.dp)
) { ) {
Text( Row(
text = "Receive", verticalAlignment = Alignment.CenterVertically,
fontSize = 12.sp, horizontalArrangement = Arrangement.spacedBy(8.dp)
fontWeight = FontWeight.Bold, ) {
fontFamily = FontFamily.Monospace // Download/Receive icon
) Icon(
imageVector = Icons.Filled.Download,
contentDescription = "Receive",
tint = Color.White,
modifier = Modifier.size(16.dp)
)
Text(
text = "Receive",
fontSize = 12.sp,
color = Color.White,
fontFamily = FontFamily.Monospace
)
}
} }
} }
} }
@@ -353,7 +353,7 @@ class CommandProcessor(
if (amount > 1_000_000) { if (amount > 1_000_000) {
val systemMessage = BitchatMessage( val systemMessage = BitchatMessage(
sender = "system", sender = "system",
content = "amount too large: $amount sats. maximum is 1,000,000 sats.", content = "amount too large: $amount . maximum is 1,000,000 .",
timestamp = Date(), timestamp = Date(),
isRelay = false isRelay = false
) )
@@ -291,8 +291,8 @@ private data class PaymentColors(
*/ */
private fun formatSats(sats: Long): String { private fun formatSats(sats: Long): String {
return when { return when {
sats >= 100_000_000 -> String.format("%.2f BTC", sats / 100_000_000.0) sats >= 100_000_000 -> String.format("%.8f BTC", sats / 100_000_000.0)
sats >= 1000 -> String.format("%,d sats", sats) sats >= 1000 -> String.format("%,d ", sats)
else -> "$sats sats" else -> "$sats "
} }
} }
@@ -181,7 +181,7 @@ fun ReceiveLightningDialog(
onValueChange = { amount = it }, onValueChange = { amount = it },
label = { label = {
Text( Text(
text = "Amount (sats)", text = "Amount ()",
fontFamily = FontFamily.Monospace fontFamily = FontFamily.Monospace
) )
}, },
@@ -141,7 +141,7 @@ fun SendEcashDialog(
enabled = !isLoading, enabled = !isLoading,
label = { label = {
Text( Text(
text = "Amount (sats)", text = "Amount ()",
fontFamily = FontFamily.Monospace fontFamily = FontFamily.Monospace
) )
}, },
@@ -380,9 +380,9 @@ private fun formatAmount(amount: Long, unit: String): String {
return when (unit.lowercase()) { return when (unit.lowercase()) {
"sat", "sats" -> { "sat", "sats" -> {
when { when {
amount >= 100_000_000 -> String.format("%.2f BTC", amount / 100_000_000.0) amount >= 100_000_000 -> String.format("%.8f BTC", amount / 100_000_000.0)
amount >= 1000 -> String.format("%,d sats", amount) amount >= 1000 -> String.format("%,d ", amount)
else -> "$amount sats" else -> "$amount "
} }
} }
else -> "$amount $unit" else -> "$amount $unit"
@@ -365,9 +365,9 @@ private fun formatAmount(amount: Long, unit: String): String {
return when (unit.lowercase()) { return when (unit.lowercase()) {
"sat", "sats" -> { "sat", "sats" -> {
when { when {
amount >= 100_000_000 -> String.format("%.2f BTC", amount / 100_000_000.0) amount >= 100_000_000 -> String.format("%.8f BTC", amount / 100_000_000.0)
amount >= 1000 -> String.format("%,d sats", amount) amount >= 1000 -> String.format("%,d ", amount)
else -> "$amount sats" else -> "$amount "
} }
} }
else -> "$amount $unit" else -> "$amount $unit"
@@ -442,9 +442,9 @@ private fun ErrorCard(
private fun formatSats(sats: Long): String { private fun formatSats(sats: Long): String {
return when { return when {
sats >= 100_000_000 -> String.format("%.2f BTC", sats / 100_000_000.0) sats >= 100_000_000 -> String.format("%.8f BTC", sats / 100_000_000.0)
sats >= 1000 -> String.format("%,d sats", sats) sats >= 1000 -> String.format("%,d ", sats)
else -> "$sats sats" else -> "$sats "
} }
} }
@@ -9,9 +9,9 @@ object WalletUtils {
*/ */
fun formatSats(sats: Long): String { fun formatSats(sats: Long): String {
return when { return when {
sats >= 100_000_000 -> String.format("%.2f BTC", sats / 100_000_000.0) sats >= 100_000_000 -> String.format("%.8f BTC", sats / 100_000_000.0)
sats >= 1000 -> String.format("%,d sats", sats) sats >= 1000 -> String.format("%,d ", sats)
else -> "$sats sats" else -> "$sats "
} }
} }
} }
@@ -396,9 +396,9 @@ class WalletViewModel(application: Application) : AndroidViewModel(application)
// Utility function to format sats // Utility function to format sats
private fun formatSats(sats: Long): String { private fun formatSats(sats: Long): String {
return when { return when {
sats >= 100_000_000 -> String.format("%.2f BTC", sats / 100_000_000.0) sats >= 100_000_000 -> String.format("%.8f BTC", sats / 100_000_000.0)
sats >= 1000 -> String.format("%,d sats", sats) sats >= 1000 -> String.format("%,d ", sats)
else -> "$sats sats" else -> "$sats "
} }
} }