Implemented BankAccountSettingsDialog
This commit is contained in:
parent
78af51984d
commit
ec61aec0f7
|
@ -91,3 +91,17 @@
|
||||||
|
|
||||||
"Unsaved changes" = "Unsaved changes";
|
"Unsaved changes" = "Unsaved changes";
|
||||||
"Changed data hasn't been saved. Are you sure you want to discard them?" = "Changed data hasn't been saved. Are you sure you want to discard them?";
|
"Changed data hasn't been saved. Are you sure you want to discard them?" = "Changed data hasn't been saved. Are you sure you want to discard them?";
|
||||||
|
|
||||||
|
|
||||||
|
/* BankAccountSettingsDialog */
|
||||||
|
|
||||||
|
"Account holder name" = "Account holder name";
|
||||||
|
"Bank account identifier" = "Account identifier";
|
||||||
|
"Sub account number" = "Sub account number";
|
||||||
|
"Bank account type" = "Type";
|
||||||
|
|
||||||
|
"Supports" = "Supports";
|
||||||
|
"Supports Retrieving Balance" = "Retrieve balance";
|
||||||
|
"Supports Retrieving Account Transactions" = "Retrieve transactions";
|
||||||
|
"Supports Transferring Money" = "Transfer money";
|
||||||
|
"Supports Instant payment transfer" = "Instant payment transfer";
|
||||||
|
|
|
@ -91,3 +91,17 @@
|
||||||
|
|
||||||
"Unsaved changes" = "Nicht gespeicherte Änderungen";
|
"Unsaved changes" = "Nicht gespeicherte Änderungen";
|
||||||
"Changed data hasn't been saved. Are you sure you want to discard them?" = "Es wurden nicht alle Änderungen gespeichert. Sind Sie sich sicher, dass Sie sie verwerfen möchten?";
|
"Changed data hasn't been saved. Are you sure you want to discard them?" = "Es wurden nicht alle Änderungen gespeichert. Sind Sie sich sicher, dass Sie sie verwerfen möchten?";
|
||||||
|
|
||||||
|
|
||||||
|
/* BankAccountSettingsDialog */
|
||||||
|
|
||||||
|
"Account holder name" = "Kontoinhaber";
|
||||||
|
"Bank account identifier" = "Kontonummer";
|
||||||
|
"Sub account number" = "Unterkontenmerkmal";
|
||||||
|
"Bank account type" = "Typ";
|
||||||
|
|
||||||
|
"Supports" = "Unterstützt";
|
||||||
|
"Supports Retrieving Balance" = "Kontostand abrufen";
|
||||||
|
"Supports Retrieving Account Transactions" = "Kontoumsätze abrufen";
|
||||||
|
"Supports Transferring Money" = "Überweisen";
|
||||||
|
"Supports Instant payment transfer" = "Echtzeitüberweisung";
|
||||||
|
|
|
@ -0,0 +1,103 @@
|
||||||
|
import SwiftUI
|
||||||
|
import BankingUiSwift
|
||||||
|
|
||||||
|
|
||||||
|
struct BankAccountSettingsDialog: View {
|
||||||
|
|
||||||
|
@Environment(\.presentationMode) var presentation
|
||||||
|
|
||||||
|
@Inject private var presenter: BankingPresenterSwift
|
||||||
|
|
||||||
|
|
||||||
|
private let account: BankAccount
|
||||||
|
|
||||||
|
@State private var displayName: String
|
||||||
|
|
||||||
|
@State private var unsavedChangesMessage: Message? = nil
|
||||||
|
|
||||||
|
|
||||||
|
private var hasUnsavedData: Bool {
|
||||||
|
return account.displayName != displayName
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
init(_ account: BankAccount) {
|
||||||
|
self.account = account
|
||||||
|
|
||||||
|
_displayName = State(initialValue: account.displayName)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
Form {
|
||||||
|
Section {
|
||||||
|
LabelledUIKitTextField(label: "Name", text: $displayName)
|
||||||
|
}
|
||||||
|
|
||||||
|
Section {
|
||||||
|
LabelledUIKitTextField(label: "Account holder name", value: account.accountHolderName) // TODO: senseful?
|
||||||
|
|
||||||
|
LabelledUIKitTextField(label: "Bank account identifier", value: account.identifier)
|
||||||
|
|
||||||
|
account.subAccountNumber.map { subAccountNumber in
|
||||||
|
LabelledUIKitTextField(label: "Sub account number", value: subAccountNumber)
|
||||||
|
}
|
||||||
|
|
||||||
|
account.iban.map { iban in
|
||||||
|
LabelledUIKitTextField(label: "IBAN", value: iban)
|
||||||
|
}
|
||||||
|
|
||||||
|
LabelledUIKitTextField(label: "Bank account type", value: account.type.name) // TODO: senseful?
|
||||||
|
}
|
||||||
|
|
||||||
|
Section(header: Text("Supports")) {
|
||||||
|
CheckmarkListItem("Supports Retrieving Balance", account.supportsRetrievingBalance)
|
||||||
|
|
||||||
|
CheckmarkListItem("Supports Retrieving Account Transactions", account.supportsRetrievingAccountTransactions)
|
||||||
|
|
||||||
|
CheckmarkListItem("Supports Transferring Money", account.supportsTransferringMoney)
|
||||||
|
|
||||||
|
CheckmarkListItem("Supports Instant payment transfer", account.supportsInstantPaymentMoneyTransfer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.alert(item: $unsavedChangesMessage) { message in
|
||||||
|
Alert(title: message.title, message: message.message, primaryButton: message.primaryButton, secondaryButton: message.secondaryButton!)
|
||||||
|
}
|
||||||
|
.showNavigationBarTitle(LocalizedStringKey(account.displayName))
|
||||||
|
.setCancelAndDoneNavigationBarButtons(onCancelPressed: cancelPressed, onDonePressed: donePressed)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private func cancelPressed() {
|
||||||
|
if hasUnsavedData {
|
||||||
|
self.unsavedChangesMessage = Message(title: Text("Unsaved changes"), message: Text("Changed data hasn't been saved. Are you sure you want to discard them?"), primaryButton: .ok(closeDialog), secondaryButton: .cancel())
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
closeDialog()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func donePressed() {
|
||||||
|
if hasUnsavedData {
|
||||||
|
account.userSetDisplayName = displayName
|
||||||
|
|
||||||
|
presenter.accountUpdated(account: account.customer)
|
||||||
|
}
|
||||||
|
|
||||||
|
closeDialog()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func closeDialog() {
|
||||||
|
presentation.wrappedValue.dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct BankAccountSettingsDialog_Previews: PreviewProvider {
|
||||||
|
|
||||||
|
static var previews: some View {
|
||||||
|
BankAccountSettingsDialog(previewBanks[0].accounts[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -71,8 +71,10 @@ struct BankSettingsDialog: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
Section(header: Text("Accounts")) {
|
Section(header: Text("Accounts")) {
|
||||||
ForEach(bank.accounts) { account in
|
ForEach(bank.accounts.sorted(by: { $0.displayIndex <= $1.displayIndex })) { account in
|
||||||
Text(account.displayName)
|
NavigationLink(destination: LazyView(BankAccountSettingsDialog(account))) {
|
||||||
|
Text(account.displayName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
|
||||||
|
struct CheckmarkListItem: View {
|
||||||
|
|
||||||
|
let title: LocalizedStringKey
|
||||||
|
|
||||||
|
@Binding var isChecked: Bool
|
||||||
|
|
||||||
|
|
||||||
|
init(_ title: LocalizedStringKey, _ isChecked: Binding<Bool>) {
|
||||||
|
self.title = title
|
||||||
|
|
||||||
|
_isChecked = isChecked
|
||||||
|
}
|
||||||
|
|
||||||
|
init(_ title: LocalizedStringKey, _ isChecked: Bool) {
|
||||||
|
self.init(title, .constant(isChecked))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
HStack {
|
||||||
|
HStack {
|
||||||
|
if isChecked {
|
||||||
|
Image(systemName: "checkmark")
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
.frame(width: 25)
|
||||||
|
|
||||||
|
if isChecked {
|
||||||
|
Text(title)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Text(title)
|
||||||
|
.detailForegroundColor()
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct CheckmarkListItem_Previews: PreviewProvider {
|
||||||
|
|
||||||
|
static var previews: some View {
|
||||||
|
Group {
|
||||||
|
CheckmarkListItem("Title", true)
|
||||||
|
.previewLayout(PreviewLayout.sizeThatFits)
|
||||||
|
|
||||||
|
CheckmarkListItem("Title", false)
|
||||||
|
.previewLayout(PreviewLayout.sizeThatFits)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue