From 9de40b4cc80af7f4e68611f31bf27d83dc7fed90 Mon Sep 17 00:00:00 2001 From: dankito Date: Fri, 4 Sep 2020 17:46:14 +0200 Subject: [PATCH] Added hint that for instant payment transfers may fees are charged --- .../main/res/layout/dialog_transfer_money.xml | 5 +- .../src/main/res/values-de/strings.xml | 2 +- .../src/main/res/values/dimens.xml | 1 + .../src/main/res/values/strings.xml | 2 +- .../Base.lproj/Localizable.strings | 7 +++ .../de.lproj/Localizable.strings | 7 +++ .../BankingiOSApp/ui/SelectorWrapper.swift | 19 ++++++ .../BankingiOSApp/ui/UIKitExtensions.swift | 31 ++++++++++ .../ui/views/InstantPaymentInfoView.swift | 62 +++++++++++++++++++ .../ui/views/TransferMoneyDialog.swift | 14 ++++- .../BankingiOSApp/ui/views/UIKitButton.swift | 47 ++++++++++++++ 11 files changed, 192 insertions(+), 5 deletions(-) create mode 100644 ui/BankingiOSApp/BankingiOSApp/ui/SelectorWrapper.swift create mode 100644 ui/BankingiOSApp/BankingiOSApp/ui/views/InstantPaymentInfoView.swift create mode 100644 ui/BankingiOSApp/BankingiOSApp/ui/views/UIKitButton.swift diff --git a/ui/BankingAndroidApp/src/main/res/layout/dialog_transfer_money.xml b/ui/BankingAndroidApp/src/main/res/layout/dialog_transfer_money.xml index 1d693e55..46bf786d 100644 --- a/ui/BankingAndroidApp/src/main/res/layout/dialog_transfer_money.xml +++ b/ui/BankingAndroidApp/src/main/res/layout/dialog_transfer_money.xml @@ -126,10 +126,11 @@ android:id="@+id/chkbxInstantPayment" android:layout_width="match_parent" android:layout_height="30dp" - android:text="@string/dialog_transfer_money_instant_payment" - style="@style/TextAppearance.AppCompat.Medium" android:layout_marginTop="@dimen/dialog_transfer_money_instant_payment_margin_top" android:layout_marginBottom="@dimen/dialog_transfer_money_instant_payment_margin_bottom" + style="@style/TextAppearance.AppCompat.Medium" + android:textSize="@dimen/dialog_transfer_money_instant_payment_text_size" + android:text="@string/dialog_transfer_money_instant_payment" android:visibility="gone" /> diff --git a/ui/BankingAndroidApp/src/main/res/values-de/strings.xml b/ui/BankingAndroidApp/src/main/res/values-de/strings.xml index 938577be..c4b1ebe4 100644 --- a/ui/BankingAndroidApp/src/main/res/values-de/strings.xml +++ b/ui/BankingAndroidApp/src/main/res/values-de/strings.xml @@ -57,7 +57,7 @@ Keine BIC gefunden für BLZ %1$s Betrag: Verwendungszweck: - Echtzeitüberweisung + Echtzeitüberweisung (evtl. kostenpflichtig) Überweisen %1$s %2$s wurden erfolgreich an %3$s überwiesen. Konnte nicht %1$s %2$s an %3$s überweisen.\n\nFehlermeldung Ihrer Bank:\n\n%4$s diff --git a/ui/BankingAndroidApp/src/main/res/values/dimens.xml b/ui/BankingAndroidApp/src/main/res/values/dimens.xml index ea10826e..3c351a87 100644 --- a/ui/BankingAndroidApp/src/main/res/values/dimens.xml +++ b/ui/BankingAndroidApp/src/main/res/values/dimens.xml @@ -54,6 +54,7 @@ 4dp 12dp 50dp + 14sp 6dp 6dp 120dp diff --git a/ui/BankingAndroidApp/src/main/res/values/strings.xml b/ui/BankingAndroidApp/src/main/res/values/strings.xml index a43128a2..33c2089e 100644 --- a/ui/BankingAndroidApp/src/main/res/values/strings.xml +++ b/ui/BankingAndroidApp/src/main/res/values/strings.xml @@ -57,7 +57,7 @@ No BIC found for bank code %1$s Amount: Usage: - Instant payment + Instant payment (may with costs) Transfer Successfully transferred %1$s %2$s to %3$s. Could not transfer %1$s %2$s to %3$s.\n\nError message from your bank:\n\n%4$s diff --git a/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings b/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings index 030f6157..948fb9df 100644 --- a/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings +++ b/ui/BankingiOSApp/BankingiOSApp/Base.lproj/Localizable.strings @@ -80,7 +80,14 @@ "No BIC found for bank code %@" = "No BIC found for bank code %@"; "Amount" = "Amount"; "Usage" = "Usage"; + "Instant Payment" = "Instant Payment"; +"may with costs" = "may with costs"; +"Instant payment information" = "Bank transfers are usually credited within one business day. However, this only applies during bank business hours, and therefore not at weekends and on public holidays. In addition, business hours vary from bank to bank. Mostly they are from 10 - 18 o'clock, sometimes also until 22 o'clock, but sometimes (e. g. Fridays) only until 14 o'clock.\n +Instant payment transfers on the other hand are transferred within a maximum of 10 seconds, regardless of the day and time of day.\n +However, real-time transfers are often subject to a fee.\n +Unfortunately, Bankmeister cannot know whether a bank charges for instant payment transfers. Please refer to the list of prices and services of your bank."; + "Transfer Money" = "Transfer"; "Successfully transferred %@ %@ to %@." = "Successfully transferred %@ %@ to %@."; diff --git a/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings b/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings index 09924e1d..58f5de6f 100644 --- a/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings +++ b/ui/BankingiOSApp/BankingiOSApp/de.lproj/Localizable.strings @@ -80,7 +80,14 @@ "No BIC found for bank code %@" = "Keine BIC gefunden für BLZ %@"; "Amount" = "Betrag"; "Usage" = "Verwendungszweck"; + "Instant Payment" = "Echtzeitüberweisung"; +"may with costs" = "evtl. kostenpflichtig"; +"Instant payment information" = "Normale Überweisungen werden in der Regel innerhalb eines Werktages gutgeschrieben. Dies gilt jedoch nur zu Geschäftszeiten der Banken, also schon mal nicht am Wochenende und an Feiertagen. Zudem unterscheiden sich die Geschäftszeiten von Bank zu Bank. Meistens gehen diese von 10 - 18 Uhr, manchmal auch bis 22 Uhr, manchmal (Freitags) aber auch nur bis 14 Uhr.\n +Echtzeitüberweisungen werden hingegen innerhalb von maximal 10 Sekunden überwiesen, egal an welchem Tag und zu welcher Uhrzeit.\n +Häufig sind Echtzeitüberweisungen jedoch kostenpflichtig.\n +Ob eine Bank Gebühren für Echtzeitüberweisungen erhebt, kann Bankmeister leider nicht wissen. Dies entnehmen Sie bitte dem Preis- / Leistungsverzeichnis Ihrer Bank."; + "Transfer Money" = "Überweisen"; "Successfully transferred %@ %@ to %@." = "%@ %@ wurden erfolgreich an %@ überwiesen."; diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/SelectorWrapper.swift b/ui/BankingiOSApp/BankingiOSApp/ui/SelectorWrapper.swift new file mode 100644 index 00000000..22d9a065 --- /dev/null +++ b/ui/BankingiOSApp/BankingiOSApp/ui/SelectorWrapper.swift @@ -0,0 +1,19 @@ +import SwiftUI + + +class SelectorWrapper : NSObject { + + private let _action: () -> () + + + init(_ action: @escaping () -> ()) { + _action = action + super.init() + } + + + @objc func action() { + _action() + } + +} diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/UIKitExtensions.swift b/ui/BankingiOSApp/BankingiOSApp/ui/UIKitExtensions.swift index c8b38a04..f5520009 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/UIKitExtensions.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/UIKitExtensions.swift @@ -26,6 +26,37 @@ extension UIResponder { } + +extension UIDevice { + + static var deviceType: UIUserInterfaceIdiom { + get { + return UIDevice.current.deviceType + } + } + + var deviceType: UIUserInterfaceIdiom { + get { + return self.userInterfaceIdiom + } + } + + + static var isRunningOniPad: Bool { + get { + return UIDevice.current.userInterfaceIdiom == .pad + } + } + + var isRunningOniPad: Bool { + get { + return self.userInterfaceIdiom == .pad + } + } + +} + + extension UserDefaults { func string(forKey key: String, defaultValue: String) -> String { diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/InstantPaymentInfoView.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/InstantPaymentInfoView.swift new file mode 100644 index 00000000..19ae57c3 --- /dev/null +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/InstantPaymentInfoView.swift @@ -0,0 +1,62 @@ +import SwiftUI + + +struct InstantPaymentInfoView: View { + + @State private var showInstantPaymentInfoPopover = false + + + var body: some View { + HStack { + Text("may with costs") + .font(.caption) + .styleAsDetail() + .lineLimit(1) + .minimumScaleFactor(0.5) + .padding(.horizontal, 0) + + UIKitButton(.infoLight) { self.showInstantPaymentInfoPopover = true } + .popover(isPresented: $showInstantPaymentInfoPopover, arrowEdge: .leading ) { + if UIDevice.isRunningOniPad { + ScrollView { + Text("Instant payment information") + .padding() + .detailForegroundColor() + } + } + else { + VStack { + Text("Instant payment information") + .padding() + .detailForegroundColor() + + HStack { + Spacer() + + Button("OK") { self.showInstantPaymentInfoPopover = false } + + Spacer() + } + } + } + } + } + } + +} + + +struct InstantPaymentInfoView_Previews: PreviewProvider { + + static var previews: some View { + Form { + Section { + Toggle(isOn: .constant(true)) { + InstantPaymentInfoView() + } + } + } + .environment(\.locale, .init(identifier: "de")) + } + +} diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/TransferMoneyDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/TransferMoneyDialog.swift index ece8825f..91dfe965 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/TransferMoneyDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/TransferMoneyDialog.swift @@ -161,7 +161,18 @@ struct TransferMoneyDialog: View { if supportsInstantPayment { Section { - Toggle("Instant Payment", isOn: $instantPayment) + VStack { + Toggle(isOn: $instantPayment) { + HStack { + Text("Instant Payment") + .lineLimit(1) + + if instantPayment { + InstantPaymentInfoView() + } + } + } + } } } @@ -404,5 +415,6 @@ struct TransferMoneyDialog: View { struct TransferMoneyDialog_Previews: PreviewProvider { static var previews: some View { TransferMoneyDialog() + .environment(\.locale, .init(identifier: "de")) } } diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/UIKitButton.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/UIKitButton.swift new file mode 100644 index 00000000..093ec110 --- /dev/null +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/UIKitButton.swift @@ -0,0 +1,47 @@ +import SwiftUI + + +struct UIKitButton: UIViewRepresentable { + + private let type: UIButton.ButtonType + + private let text: String? + + private let selectorWrapper: SelectorWrapper + + + init(_ type: UIButton.ButtonType = .system, text: String? = nil, _ action: @escaping () -> Void) { + self.type = type + + self.text = text + + self.selectorWrapper = SelectorWrapper(action) + } + + + func makeUIView(context: UIViewRepresentableContext) -> UIButton { + let button = UIButton(type: type) + + if let text = text { + button.setTitle(text, for: .normal) + } + + button.addTarget(selectorWrapper, action: #selector(selectorWrapper.action), for: .touchUpInside) + + return button + } + + func updateUIView(_ uiView: UIButton, context: UIViewRepresentableContext) { + uiView.addTarget(selectorWrapper, action: #selector(selectorWrapper.action), for: .touchUpInside) // why gets the target removed at some point and needs to be refreshed? + } + +} + + +struct UIKitButton_Previews: PreviewProvider { + + static var previews: some View { + UIKitButton(.infoLight) { } + } + +}