diff --git a/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings b/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings index cfdfdc31..ebc90b20 100644 --- a/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings +++ b/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings @@ -91,3 +91,17 @@ "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?"; + + +/* 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"; diff --git a/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings b/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings index 6782f8a0..5e9891f7 100644 --- a/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings +++ b/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings @@ -91,3 +91,17 @@ "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?"; + + +/* 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"; diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankAccountSettingsDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankAccountSettingsDialog.swift new file mode 100644 index 00000000..a6266acb --- /dev/null +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankAccountSettingsDialog.swift @@ -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]) + } + +} diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankSettingsDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankSettingsDialog.swift index 87a0c5f4..998ba826 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankSettingsDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankSettingsDialog.swift @@ -71,8 +71,10 @@ struct BankSettingsDialog: View { } Section(header: Text("Accounts")) { - ForEach(bank.accounts) { account in - Text(account.displayName) + ForEach(bank.accounts.sorted(by: { $0.displayIndex <= $1.displayIndex })) { account in + NavigationLink(destination: LazyView(BankAccountSettingsDialog(account))) { + Text(account.displayName) + } } } } diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/CheckmarkListItem.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/CheckmarkListItem.swift new file mode 100644 index 00000000..a72bd901 --- /dev/null +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/CheckmarkListItem.swift @@ -0,0 +1,61 @@ +import SwiftUI + + +struct CheckmarkListItem: View { + + let title: LocalizedStringKey + + @Binding var isChecked: Bool + + + init(_ title: LocalizedStringKey, _ isChecked: Binding) { + 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) + } + } + +}