Started BankSettingsScreen, but it's not possible to save changes yet or to delete account

This commit is contained in:
dankito 2024-09-18 01:42:31 +02:00
parent d98a77bc1d
commit 2813224eff
6 changed files with 166 additions and 4 deletions

View File

@ -2,13 +2,13 @@ package net.codinux.banking.ui.composables
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.ContentAlpha
import androidx.compose.material.Icon
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
@ -105,5 +105,16 @@ fun NavigationMenuItem(
modifier = Modifier.padding(start = 4.dp)
)
}
if (bank != null) {
if (bankAccount == null) {
Column(Modifier.clickable { DI.uiState.showBankSettingsScreenForBank.value = bank }.padding(start = 8.dp).size(24.dp)) {
Icon(Icons.Outlined.Settings, "Zu Kontoeinstellungen wechseln", tint = textColor, modifier = Modifier.size(24.dp))
}
}
}
if (bankAccount != null) { // show a place holder to match Settings icon's width
Spacer(Modifier.padding(start = 8.dp).size(24.dp))
}
}
}

View File

@ -7,6 +7,7 @@ import kotlinx.coroutines.launch
import net.codinux.banking.ui.config.DI
import net.codinux.banking.ui.dialogs.*
import net.codinux.banking.ui.screens.AccountTransactionDetailsScreen
import net.codinux.banking.ui.screens.BankSettingsScreen
import net.codinux.banking.ui.screens.ExportScreen
import net.codinux.banking.ui.state.UiState
@ -17,6 +18,7 @@ fun StateHandler(uiState: UiState, snackbarHostState: SnackbarHostState) {
val showAddAccountDialog by uiState.showAddAccountDialog.collectAsState()
val showTransferMoneyDialogData by uiState.showTransferMoneyDialogData.collectAsState()
val showAccountTransactionDetailsScreenForId by uiState.showAccountTransactionDetailsScreenForId.collectAsState()
val showBankSettingsScreenForBank by uiState.showBankSettingsScreenForBank.collectAsState()
val showExportScreen by uiState.showExportScreen.collectAsState()
val tanChallengeReceived by uiState.tanChallengeReceived.collectAsState()
@ -40,6 +42,10 @@ fun StateHandler(uiState: UiState, snackbarHostState: SnackbarHostState) {
}
}
showBankSettingsScreenForBank?.let { bank ->
BankSettingsScreen(bank) { uiState.showBankSettingsScreenForBank.value = null }
}
if (showExportScreen) {
ExportScreen { uiState.showExportScreen.value = false }
}

View File

@ -38,6 +38,11 @@ object Colors {
val FormValueTextColor = Color(0xFF999999)
val FormListItemTextColor = FormLabelTextColor
val DestructiveColor = Color(0xFFff3b30)
val Zinc100 = Color(244, 244, 245)
val Zinc100_50 = Zinc100.copy(alpha = 0.5f)

View File

@ -0,0 +1,31 @@
package net.codinux.banking.ui.forms
import androidx.compose.foundation.layout.*
import androidx.compose.material.Icon
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Check
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import net.codinux.banking.ui.config.Colors
@Composable
fun FormListItem(label: String, isSelectable: Boolean = false, isSelected: Boolean = false, selectedIconContentDescription: String? = null) {
Row(Modifier.fillMaxWidth().height(32.dp).padding(4.dp), verticalAlignment = Alignment.CenterVertically) {
if (isSelectable) {
Column(Modifier.size(24.dp).padding(end = 8.dp)) {
if (isSelected) {
Icon(Icons.Outlined.Check, selectedIconContentDescription ?: "Item ist ausgewählt")
}
}
}
Text(label, color = Colors.FormListItemTextColor, fontSize = 16.sp, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.fillMaxHeight())
}
}

View File

@ -0,0 +1,107 @@
package net.codinux.banking.ui.screens
import androidx.compose.foundation.layout.*
import androidx.compose.material.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import net.codinux.banking.dataaccess.entities.BankAccessEntity
import net.codinux.banking.ui.extensions.verticalScroll
import net.codinux.banking.ui.forms.*
@Composable
fun BankSettingsScreen(bank: BankAccessEntity, onClosed: () -> Unit) {
var enteredBankName by remember { mutableStateOf(bank.displayName) }
var enteredLoginName by remember { mutableStateOf(bank.loginName) }
var enteredPassword by remember { mutableStateOf(bank.password ?: "") }
val hasDataChanged by remember(enteredBankName) {
mutableStateOf(
(enteredBankName != bank.bankName && (bank.userSetDisplayName == null || enteredBankName != bank.userSetDisplayName))
|| enteredLoginName != bank.loginName || enteredPassword != bank.password
)
}
FullscreenViewBase(bank.displayName, onClosed = onClosed) {
Column(Modifier.fillMaxSize().verticalScroll().padding(8.dp)) {
Column {
OutlinedTextField(
label = { Text("Name") },
value = enteredBankName,
onValueChange = { enteredBankName = it },
modifier = Modifier.fillMaxWidth()
)
SectionHeader("Online-Banking Zugangsdaten")
OutlinedTextField(
label = { Text("Login Name") },
value = enteredLoginName,
onValueChange = { enteredLoginName = it },
modifier = Modifier.fillMaxWidth().padding(vertical = 8.dp)
)
PasswordTextField(
password = enteredPassword,
onChange = { enteredPassword = it }
)
}
Column {
SectionHeader("Konten")
Column(Modifier.padding(top = 8.dp)) {
bank.accounts.sortedBy { it.displayIndex }.forEach { account ->
FormListItem(account.displayName)
}
}
}
Column {
SectionHeader("Bankdaten")
LabelledValue("Bankleitzahl", bank.domesticBankCode)
LabelledValue("BIC", bank.bic ?: "")
LabelledValue("Kontoinhaber", bank.customerName)
LabelledValue("FinTS Server", bank.serverAddress)
}
Column {
SectionHeader("TAN Verfahren")
Column(Modifier.padding(top = 8.dp)) {
bank.tanMethods.sortedBy { it.identifier }.forEach { tanMethod ->
FormListItem(tanMethod.displayName, true, tanMethod == bank.selectedTanMethod, "TAN Verfahren ist ausgewähltes TAN Verfahren")
}
}
}
if (bank.tanMedia.isNotEmpty()) {
Column {
SectionHeader("TAN Medien")
Column(Modifier.padding(top = 8.dp)) {
bank.tanMedia.sortedBy { it.status }.forEach { tanMedium ->
FormListItem(tanMedium.displayName, true, tanMedium == bank.selectedTanMedium, "TAN Medium ist ausgewähltes TAN Medium")
}
}
}
}
// Spacer(Modifier.weight(1f))
//
// Column(Modifier.padding(top = 18.dp, bottom = 18.dp)) {
// TextButton(modifier = Modifier.fillMaxWidth().height(50.dp), onClick = { }, enabled = false) {
// Text("Konto löschen", color = Colors.DestructiveColor, textAlign = TextAlign.Center)
// }
// }
}
}
}

View File

@ -56,6 +56,8 @@ class UiState : ViewModel() {
val showAccountTransactionDetailsScreenForId = MutableStateFlow<Long?>(null)
val showBankSettingsScreenForBank = MutableStateFlow<BankAccessEntity?>(null)
val showExportScreen = MutableStateFlow(false)