demo: replace UI string resources by literal strings

This commit is contained in:
Oscar Mira 2023-04-26 12:36:42 +02:00
parent ea15bf80c6
commit 7d39842402
7 changed files with 28 additions and 71 deletions

View File

@ -8,13 +8,11 @@ import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import im.molly.monero.MoneroNetwork
import im.molly.monero.demo.R
import im.molly.monero.demo.data.model.DefaultMoneroNetwork
import im.molly.monero.demo.data.model.RemoteNode
import im.molly.monero.demo.ui.component.SelectListBox
@ -48,12 +46,12 @@ private fun FirstStepScreen(
Scaffold(
topBar = {
Toolbar(
title = stringResource(R.string.add_wallet),
title = "Add wallet",
navigationIcon = {
IconButton(onClick = onBackClick) {
Icon(
imageVector = AppIcons.ArrowBack,
contentDescription = stringResource(R.string.back),
contentDescription = "Back",
)
}
}
@ -70,13 +68,13 @@ private fun FirstStepScreen(
Button(
onClick = onCreateClick,
) {
Text(stringResource(R.string.create_a_new_wallet))
Text("Create a new wallet")
}
OutlinedButton(
onClick = {}, // TODO: onRestoreClick,
modifier = Modifier.padding(top = 8.dp),
) {
Text(stringResource(R.string.i_already_have_a_wallet))
Text("I already have a wallet")
}
}
}
@ -125,14 +123,13 @@ private fun SecondStepScreen(
) {
Scaffold(
topBar = {
val titleRes = if (showRestoreOptions) R.string.restore_wallet else R.string.new_wallet
Toolbar(
title = stringResource(titleRes),
title = if (showRestoreOptions) "Restore wallet" else "New wallet",
navigationIcon = {
IconButton(onClick = onBackClick) {
Icon(
imageVector = AppIcons.ArrowBack,
contentDescription = stringResource(R.string.back),
contentDescription = "Back",
)
}
}
@ -146,7 +143,7 @@ private fun SecondStepScreen(
) {
OutlinedTextField(
value = walletName,
label = { Text(stringResource(R.string.wallet_name)) },
label = { Text("Wallet name") },
onValueChange = onWalletNameChanged,
singleLine = true,
modifier = Modifier
@ -154,7 +151,7 @@ private fun SecondStepScreen(
.padding(start = 16.dp, end = 16.dp),
)
SelectListBox(
labelRes = R.string.network,
label = "Network",
options = MoneroNetwork.values().map { it.name },
selectedOption = network.name,
onOptionClick = {
@ -165,7 +162,7 @@ private fun SecondStepScreen(
.padding(16.dp),
)
Text(
text = stringResource(R.string.remote_node_selection),
text = "Remote node selection",
style = MaterialTheme.typography.titleMedium,
modifier = Modifier
.padding(16.dp),
@ -186,7 +183,7 @@ private fun SecondStepScreen(
modifier = Modifier
.padding(16.dp),
) {
Text(stringResource(R.string.finish))
Text("Finish")
}
}
}

View File

@ -16,7 +16,6 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import im.molly.monero.MoneroNetwork
import im.molly.monero.demo.R
import im.molly.monero.demo.data.model.RemoteNode
import im.molly.monero.demo.ui.component.SelectListBox
import im.molly.monero.demo.ui.theme.AppTheme
@ -64,11 +63,11 @@ private fun EditRemoteNodeDialog(
Modifier.verticalScroll(rememberScrollState()),
) {
Text(
text = stringResource(R.string.enter_your_monero_node_information_below),
text = "Enter your Monero node information below.",
modifier = Modifier.padding(vertical = 16.dp),
)
SelectListBox(
labelRes = R.string.network,
label = "Network",
options = MoneroNetwork.values().map { it.name },
selectedOption = remoteNode.network.name,
onOptionClick = {
@ -81,15 +80,13 @@ private fun EditRemoteNodeDialog(
onValueChange = { input ->
onRemoteNodeChange(remoteNode.copy(uri = Uri.parse(input)))
},
label = {
Text(stringResource(R.string.url))
},
label = { Text("URL") },
singleLine = true,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri),
isError = showError,
)
Text(
text = stringResource(R.string.protocol_is_required_http_or_https),
text = "Protocol is required (http:// or https://)",
style = MaterialTheme.typography.bodySmall,
modifier = Modifier.padding(start = 16.dp, bottom = 16.dp),
)
@ -99,9 +96,7 @@ private fun EditRemoteNodeDialog(
onValueChange = { input ->
onRemoteNodeChange(remoteNode.copy(username = input))
},
label = {
Text(stringResource(R.string.username))
},
label = { Text("Username") },
singleLine = true,
)
OutlinedTextField(
@ -109,9 +104,7 @@ private fun EditRemoteNodeDialog(
onValueChange = { input ->
onRemoteNodeChange(remoteNode.copy(password = input))
},
label = {
Text(stringResource(R.string.password))
},
label = { Text("Password") },
singleLine = true,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password),
visualTransformation = PasswordVisualTransformation(),
@ -123,7 +116,7 @@ private fun EditRemoteNodeDialog(
onClick = onSaveRequest,
enabled = !showError,
) {
Text(stringResource(R.string.save))
Text("Save")
}
},
dismissButton = {

View File

@ -10,10 +10,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.res.stringResource
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import im.molly.monero.demo.R
import im.molly.monero.demo.ui.component.Toolbar
@Composable
@ -43,13 +41,13 @@ private fun HomeScreen(
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
topBar = {
Toolbar(
title = stringResource(R.string.monero_wallets),
title = "Monero wallets",
scrollBehavior = scrollBehavior,
)
},
floatingActionButton = {
ExtendedFloatingActionButton(onClick = onAddWalletClick) {
Text(stringResource(R.string.add_wallet))
Text("Add wallets")
}
},
) { padding ->

View File

@ -5,9 +5,7 @@ import androidx.compose.foundation.layout.*
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import im.molly.monero.demo.R
import im.molly.monero.demo.data.model.RemoteNode
import im.molly.monero.demo.ui.theme.AppIcons
@ -93,7 +91,7 @@ private fun WalletKebabMenu(
IconButton(onClick = { expanded = true }) {
Icon(
imageVector = AppIcons.MoreVert,
contentDescription = stringResource(R.string.open_menu),
contentDescription = "Open menu",
)
}
DropdownMenu(
@ -101,14 +99,14 @@ private fun WalletKebabMenu(
onDismissRequest = { expanded = false },
) {
DropdownMenuItem(
text = { Text(stringResource(R.string.edit)) },
text = { Text("Edit") },
onClick = {
onEditClick()
expanded = false
},
)
DropdownMenuItem(
text = { Text(stringResource(R.string.delete)) },
text = { Text("Delete") },
onClick = {
onDeleteClick()
expanded = false

View File

@ -5,7 +5,6 @@ import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontWeight
@ -15,7 +14,6 @@ import androidx.lifecycle.viewmodel.compose.viewModel
import im.molly.monero.Balance
import im.molly.monero.Ledger
import im.molly.monero.MoneroCurrency
import im.molly.monero.demo.R
import im.molly.monero.demo.data.model.WalletConfig
import im.molly.monero.demo.ui.component.Toolbar
import im.molly.monero.demo.ui.theme.AppIcons
@ -91,7 +89,7 @@ private fun WalletScreenPopulated(
IconButton(onClick = onBackClick) {
Icon(
imageVector = AppIcons.ArrowBack,
contentDescription = stringResource(R.string.back),
contentDescription = "Back",
)
}
},
@ -157,7 +155,7 @@ private fun WalletKebabMenu(
IconButton(onClick = { expanded = true }) {
Icon(
imageVector = AppIcons.MoreVert,
contentDescription = stringResource(R.string.open_menu),
contentDescription = "Open menu",
)
}
DropdownMenu(
@ -165,14 +163,14 @@ private fun WalletKebabMenu(
onDismissRequest = { expanded = false },
) {
DropdownMenuItem(
text = { Text(stringResource(R.string.rename)) },
text = { Text("Rename") },
onClick = {
onRenameClick()
expanded = false
},
)
DropdownMenuItem(
text = { Text(stringResource(R.string.delete)) },
text = { Text("Delete") },
onClick = {
onDeleteClick()
expanded = false

View File

@ -1,16 +1,14 @@
package im.molly.monero.demo.ui.component
import androidx.annotation.StringRes
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SelectListBox(
@StringRes labelRes: Int,
label: String,
options: List<String>,
selectedOption: String,
onOptionClick: (String) -> Unit,
@ -32,7 +30,7 @@ fun SelectListBox(
modifier = Modifier
.fillMaxWidth()
.menuAnchor(),
label = { Text(stringResource(labelRes)) },
label = { Text(label) },
trailingIcon = {
ExposedDropdownMenuDefaults.TrailingIcon(
expanded = expanded

View File

@ -2,30 +2,5 @@
<string name="app_name">Monero SDK Demo</string>
<string name="home">Home</string>
<string name="history">History</string>
<string name="monero_wallets">Monero wallets</string>
<string name="create_a_new_wallet">Create a new wallet</string>
<string name="i_already_have_a_wallet">I already have a wallet</string>
<string name="back">Back</string>
<string name="finish">Finish</string>
<string name="new_wallet">New wallet</string>
<string name="restore_wallet">Restore wallet</string>
<string name="settings">Settings</string>
<string name="add_remote_node">Add remote node</string>
<string name="edit">Edit</string>
<string name="rename">Rename</string>
<string name="open_menu">Open menu</string>
<string name="delete">Delete</string>
<string name="save">Save</string>
<string name="description">Description</string>
<string name="url">URL</string>
<string name="password">Password</string>
<string name="username">Username</string>
<string name="monero_node">Monero node</string>
<string name="enter_your_monero_node_information_below">Enter your Monero node information below.</string>
<string name="protocol_is_required_http_or_https">Protocol is required (http:// or https://)</string>
<string name="network">Network</string>
<string name="remote_nodes">Remote nodes</string>
<string name="add_wallet">Add wallet</string>
<string name="wallet_name">Wallet name</string>
<string name="remote_node_selection">Remote node selection</string>
</resources>