mirror of
https://github.com/mollyim/monero-wallet-sdk.git
synced 2025-05-20 08:57:51 +01:00
demo: add offline wallet confirmation dialog
This commit is contained in:
parent
45edf35d83
commit
02f8575f82
4 changed files with 61 additions and 46 deletions
|
@ -49,7 +49,7 @@ class AddWalletViewModel(
|
||||||
.stateIn(
|
.stateIn(
|
||||||
scope = viewModelScope,
|
scope = viewModelScope,
|
||||||
started = WhileSubscribed(5000),
|
started = WhileSubscribed(5000),
|
||||||
initialValue = listOf(RemoteNode.EMPTY),
|
initialValue = emptyList(),
|
||||||
)
|
)
|
||||||
|
|
||||||
val selectedRemoteNodes = mutableStateMapOf<Long?, Boolean>()
|
val selectedRemoteNodes = mutableStateMapOf<Long?, Boolean>()
|
||||||
|
|
|
@ -44,21 +44,16 @@ private fun FirstStepScreen(
|
||||||
onRestoreClick: () -> Unit,
|
onRestoreClick: () -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
Scaffold(
|
Scaffold(topBar = {
|
||||||
topBar = {
|
Toolbar(title = "Add wallet", navigationIcon = {
|
||||||
Toolbar(
|
IconButton(onClick = onBackClick) {
|
||||||
title = "Add wallet",
|
Icon(
|
||||||
navigationIcon = {
|
imageVector = AppIcons.ArrowBack,
|
||||||
IconButton(onClick = onBackClick) {
|
contentDescription = "Back",
|
||||||
Icon(
|
)
|
||||||
imageVector = AppIcons.ArrowBack,
|
}
|
||||||
contentDescription = "Back",
|
})
|
||||||
)
|
}) { padding ->
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
) { padding ->
|
|
||||||
Column(
|
Column(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
|
@ -144,21 +139,20 @@ private fun SecondStepScreen(
|
||||||
remoteNodes: List<RemoteNode>,
|
remoteNodes: List<RemoteNode>,
|
||||||
selectedRemoteNodeIds: MutableMap<Long?, Boolean> = mutableMapOf(),
|
selectedRemoteNodeIds: MutableMap<Long?, Boolean> = mutableMapOf(),
|
||||||
) {
|
) {
|
||||||
Scaffold(
|
var showOffLineConfirmationDialog by remember { mutableStateOf(false) }
|
||||||
topBar = {
|
|
||||||
Toolbar(
|
Scaffold(topBar = {
|
||||||
title = if (showRestoreOptions) "Restore wallet" else "New wallet",
|
Toolbar(
|
||||||
navigationIcon = {
|
title = if (showRestoreOptions) "Restore wallet" else "New wallet",
|
||||||
IconButton(onClick = onBackClick) {
|
navigationIcon = {
|
||||||
Icon(
|
IconButton(onClick = onBackClick) {
|
||||||
imageVector = AppIcons.ArrowBack,
|
Icon(
|
||||||
contentDescription = "Back",
|
imageVector = AppIcons.ArrowBack,
|
||||||
)
|
contentDescription = "Back",
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
)
|
})
|
||||||
}
|
}) { padding ->
|
||||||
) { padding ->
|
|
||||||
Column(
|
Column(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.padding(padding)
|
.padding(padding)
|
||||||
|
@ -188,21 +182,18 @@ private fun SecondStepScreen(
|
||||||
Text(
|
Text(
|
||||||
text = "Remote node selection",
|
text = "Remote node selection",
|
||||||
style = MaterialTheme.typography.titleMedium,
|
style = MaterialTheme.typography.titleMedium,
|
||||||
modifier = Modifier
|
modifier = Modifier.padding(16.dp),
|
||||||
.padding(16.dp),
|
|
||||||
)
|
)
|
||||||
MultiSelectRemoteNodeList(
|
MultiSelectRemoteNodeList(
|
||||||
remoteNodes = remoteNodes,
|
remoteNodes = remoteNodes,
|
||||||
selectedIds = selectedRemoteNodeIds,
|
selectedIds = selectedRemoteNodeIds,
|
||||||
modifier = Modifier
|
modifier = Modifier.padding(start = 16.dp),
|
||||||
.padding(start = 16.dp),
|
|
||||||
)
|
)
|
||||||
if (showRestoreOptions) {
|
if (showRestoreOptions) {
|
||||||
Text(
|
Text(
|
||||||
text = "Deterministic wallet recovery",
|
text = "Deterministic wallet recovery",
|
||||||
style = MaterialTheme.typography.titleMedium,
|
style = MaterialTheme.typography.titleMedium,
|
||||||
modifier = Modifier
|
modifier = Modifier.padding(16.dp),
|
||||||
.padding(16.dp),
|
|
||||||
)
|
)
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
value = secretSpendKeyHex,
|
value = secretSpendKeyHex,
|
||||||
|
@ -217,8 +208,7 @@ private fun SecondStepScreen(
|
||||||
Text(
|
Text(
|
||||||
text = "Synchronization",
|
text = "Synchronization",
|
||||||
style = MaterialTheme.typography.titleMedium,
|
style = MaterialTheme.typography.titleMedium,
|
||||||
modifier = Modifier
|
modifier = Modifier.padding(16.dp),
|
||||||
.padding(16.dp),
|
|
||||||
)
|
)
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
value = creationDate,
|
value = creationDate,
|
||||||
|
@ -246,21 +236,47 @@ private fun SecondStepScreen(
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier.fillMaxWidth(),
|
||||||
.fillMaxWidth(),
|
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
) {
|
) {
|
||||||
val validInput = !showRestoreOptions || !(secretSpendKeyHexError || creationDateError || restoreHeightError)
|
val validInput =
|
||||||
|
!showRestoreOptions || !(secretSpendKeyHexError || creationDateError || restoreHeightError)
|
||||||
Button(
|
Button(
|
||||||
onClick = onCreateClick,
|
onClick = {
|
||||||
|
if (selectedRemoteNodeIds.filterValues { checked -> checked }.isEmpty()) {
|
||||||
|
showOffLineConfirmationDialog = true
|
||||||
|
} else {
|
||||||
|
onCreateClick()
|
||||||
|
}
|
||||||
|
},
|
||||||
enabled = validInput,
|
enabled = validInput,
|
||||||
modifier = Modifier
|
modifier = Modifier.padding(16.dp),
|
||||||
.padding(16.dp),
|
|
||||||
) {
|
) {
|
||||||
Text("Finish")
|
Text("Finish")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (showOffLineConfirmationDialog) {
|
||||||
|
AlertDialog(onDismissRequest = { showOffLineConfirmationDialog = false }, title = {
|
||||||
|
Text("No remote nodes selected")
|
||||||
|
}, text = {
|
||||||
|
Text("There are no remote nodes added to your wallet settings. Are you sure you want to start an offline wallet?")
|
||||||
|
}, confirmButton = {
|
||||||
|
TextButton(onClick = {
|
||||||
|
showOffLineConfirmationDialog = false
|
||||||
|
onCreateClick()
|
||||||
|
}) {
|
||||||
|
Text("Continue")
|
||||||
|
}
|
||||||
|
}, dismissButton = {
|
||||||
|
TextButton(onClick = {
|
||||||
|
showOffLineConfirmationDialog = false
|
||||||
|
}) {
|
||||||
|
Text("Cancel")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ fun MultiSelectRemoteNodeList(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Text(
|
Text(
|
||||||
text = "No matching remote nodes",
|
text = "Empty list. Start by adding new remote nodes in the settings.",
|
||||||
style = MaterialTheme.typography.labelMedium,
|
style = MaterialTheme.typography.labelMedium,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
|
||||||
import im.molly.monero.MoneroAmount
|
import im.molly.monero.MoneroAmount
|
||||||
import im.molly.monero.Balance
|
import im.molly.monero.Balance
|
||||||
import im.molly.monero.BlockchainTime
|
import im.molly.monero.BlockchainTime
|
||||||
|
|
Loading…
Reference in a new issue