fix: nwc revoke alert
This commit is contained in:
@@ -399,6 +399,10 @@ val EnHomeStrings = AppStrings(
|
||||
permReadTransactionHistory = "Read transaction history",
|
||||
permReadWalletBalance = "Read wallet balance",
|
||||
permReadAccountInfo = "Read account info",
|
||||
revokeDialogTitle = "Revoke connection?",
|
||||
revokeDialogBody = "This will permanently revoke this Nostr Wallet Connect key. Any app using it will lose access.",
|
||||
revokeDialogConfirm = "Revoke",
|
||||
revokeDialogDismiss = "Cancel",
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -401,5 +401,9 @@ val EsHomeStrings = AppStrings(
|
||||
permReadTransactionHistory = "Leer historial de transacciones",
|
||||
permReadWalletBalance = "Leer saldo del monedero",
|
||||
permReadAccountInfo = "Leer información de cuenta",
|
||||
revokeDialogTitle = "¿Revocar conexión?",
|
||||
revokeDialogBody = "Esto revocará permanentemente esta clave Nostr Wallet Connect. Cualquier app que la use perderá el acceso.",
|
||||
revokeDialogConfirm = "Revocar",
|
||||
revokeDialogDismiss = "Cancelar",
|
||||
)
|
||||
)
|
||||
|
||||
@@ -399,5 +399,9 @@ val EuStrings = AppStrings(
|
||||
permReadTransactionHistory = "Transakzio-historia irakurri",
|
||||
permReadWalletBalance = "Zorroko saldoa irakurri",
|
||||
permReadAccountInfo = "Kontuaren informazioa irakurri",
|
||||
revokeDialogTitle = "Konexioa baliogabetu?",
|
||||
revokeDialogBody = "Honek Nostr Wallet Connect gako hau behin betiko baliogabetuko du. Erabiltzen duen edozein aplikaziok sarbidea galduko du.",
|
||||
revokeDialogConfirm = "Baliogabetu",
|
||||
revokeDialogDismiss = "Utzi",
|
||||
)
|
||||
)
|
||||
|
||||
@@ -405,4 +405,8 @@ data class NwcStrings(
|
||||
val permReadTransactionHistory: String,
|
||||
val permReadWalletBalance: String,
|
||||
val permReadAccountInfo: String,
|
||||
val revokeDialogTitle : String,
|
||||
val revokeDialogBody : String,
|
||||
val revokeDialogConfirm : String,
|
||||
val revokeDialogDismiss : String,
|
||||
)
|
||||
@@ -29,6 +29,7 @@ import androidx.compose.material.icons.filled.Key
|
||||
import androidx.compose.material.icons.filled.Link
|
||||
import androidx.compose.material.icons.filled.LinkOff
|
||||
import androidx.compose.material.icons.filled.Search
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
@@ -39,14 +40,16 @@ import androidx.compose.material3.LinearProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.SuggestionChip
|
||||
import androidx.compose.material3.SuggestionChipDefaults
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
@@ -128,10 +131,38 @@ private fun ConnectionDetailContent(
|
||||
val clipboard = LocalClipboard.current
|
||||
val scope = rememberCoroutineScope()
|
||||
|
||||
var showRevokeDialog by remember { mutableStateOf(false) }
|
||||
|
||||
val nowSeconds = remember { System.currentTimeMillis() / 1_000L }
|
||||
val isExpired = connection.expiresAt > 0 && connection.expiresAt < nowSeconds
|
||||
val permissions = connection.permissions
|
||||
|
||||
if (showRevokeDialog) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { showRevokeDialog = false },
|
||||
title = { Text(strings.nwc.revokeDialogTitle) },
|
||||
text = { Text(strings.nwc.revokeDialogBody) },
|
||||
confirmButton = {
|
||||
TextButton(
|
||||
onClick = {
|
||||
showRevokeDialog = false
|
||||
onRevoke?.invoke()
|
||||
}
|
||||
) {
|
||||
Text(
|
||||
text = strings.nwc.revokeDialogConfirm,
|
||||
color = MaterialTheme.colorScheme.error
|
||||
)
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = { showRevokeDialog = false }) {
|
||||
Text(strings.nwc.revokeDialogDismiss)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
LazyColumn(
|
||||
modifier = modifier.fillMaxSize(),
|
||||
contentPadding = PaddingValues(16.dp),
|
||||
@@ -265,7 +296,7 @@ private fun ConnectionDetailContent(
|
||||
item {
|
||||
Spacer(Modifier.height(4.dp))
|
||||
OutlinedButton(
|
||||
onClick = onRevoke,
|
||||
onClick = { showRevokeDialog = true },
|
||||
colors = ButtonDefaults.outlinedButtonColors(
|
||||
contentColor = MaterialTheme.colorScheme.error
|
||||
),
|
||||
@@ -390,27 +421,6 @@ private fun PermissionRow(permission: ConnectionPermission, strings: AppStrings)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun PermissionChip(permission: String) {
|
||||
val strings = LocalAppStrings.current
|
||||
SuggestionChip(
|
||||
onClick = {}, // read-only; no action
|
||||
label = {
|
||||
Text(
|
||||
text = formatPermissionLabel(permission, strings),
|
||||
style = MaterialTheme.typography.labelMedium
|
||||
)
|
||||
},
|
||||
icon = {
|
||||
Icon(
|
||||
imageVector = permissionIcon(permission),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(SuggestionChipDefaults.IconSize)
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// ── Status chip ───────────────────────────────────────────────────────────────
|
||||
|
||||
@Composable
|
||||
|
||||
@@ -373,7 +373,7 @@ fun NwcConnectionRow(
|
||||
connection : NwcGetResponse,
|
||||
isDeleting : Boolean,
|
||||
onDeleteConfirm : () -> Unit,
|
||||
onConnectionClick: () -> Unit, // TODO: open detail screen
|
||||
onConnectionClick: () -> Unit,
|
||||
modifier : Modifier = Modifier
|
||||
) {
|
||||
val key = connection.data
|
||||
|
||||
Reference in New Issue
Block a user