Merge pull request #710 from believethehype/main

add a button to cashu preview to redeem on external wallet
This commit is contained in:
Vitor Pamplona
2023-12-04 10:51:41 -05:00
committed by GitHub
2 changed files with 37 additions and 26 deletions

View File

@ -175,27 +175,24 @@ fun CashuPreview(token: CashuToken, accountViewModel: AccountViewModel) {
LoadingAnimation() LoadingAnimation()
} }
Spacer(modifier = StdHorzSpacer)
Text( Text(
stringResource(R.string.cashu_redeem), "⚡ Send to Zap Wallet",
color = Color.White, color = Color.White,
fontSize = 18.sp fontSize = 16.sp
) )
} }
}
Spacer(modifier = StdHorzSpacer) Spacer(modifier = StdHorzSpacer)
Button( Button(
onClick = { onClick = {
if (useWebService) { try {
// In case we want to use the cashu.me webservice val intent = Intent(Intent.ACTION_VIEW, Uri.parse("cashu://$token"))
val url = "https://redeem.cashu.me?token=$token&lightning=$lud16&autopay=false" intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
startActivity(context, intent, null) startActivity(context, intent, null)
} else { } catch (e: Exception) {
// Copying the token to clipboard for now accountViewModel.toast("Cashu", context.getString(R.string.cashu_no_wallet_found))
clipboardManager.setText(AnnotatedString(token.token))
} }
}, },
shape = QuoteBorder, shape = QuoteBorder,
@ -203,9 +200,22 @@ fun CashuPreview(token: CashuToken, accountViewModel: AccountViewModel) {
containerColor = MaterialTheme.colorScheme.primary containerColor = MaterialTheme.colorScheme.primary
) )
) { ) {
Text("", color = Color.White, fontSize = 18.sp) Text("\uD83E\uDD5C Open in Cashu Wallet", color = Color.White, fontSize = 16.sp)
} }
} Spacer(modifier = StdHorzSpacer)
Button(
onClick = {
// Copying the token to clipboard
clipboardManager.setText(AnnotatedString(token.token))
},
shape = QuoteBorder,
colors = ButtonDefaults.buttonColors(
containerColor = MaterialTheme.colorScheme.primary
)
) {
Text("⎘ Copy ", color = Color.White, fontSize = 16.sp)
}
Spacer(modifier = StdHorzSpacer)
} }
} }
} }

View File

@ -629,6 +629,7 @@
<string name="cashu_sucessful_redemption">Cashu Received</string> <string name="cashu_sucessful_redemption">Cashu Received</string>
<string name="cashu_sucessful_redemption_explainer">%1$s sats were sent to your wallet. (Fees: %2$s sats)</string> <string name="cashu_sucessful_redemption_explainer">%1$s sats were sent to your wallet. (Fees: %2$s sats)</string>
<string name="cashu_no_wallet_found">No compatible Cashu wallet found on system</string>
<string name="error_unable_to_fetch_invoice">Unable to fetch invoice from receiver\'s servers</string> <string name="error_unable_to_fetch_invoice">Unable to fetch invoice from receiver\'s servers</string>