[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-ios] 32/36: Shortcuts (50,25,10,5)
From: |
gnunet |
Subject: |
[taler-taler-ios] 32/36: Shortcuts (50,25,10,5) |
Date: |
Mon, 13 Nov 2023 21:27:37 +0100 |
This is an automated email from the git hooks/post-receive script.
marc-stibane pushed a commit to branch master
in repository taler-ios.
commit 5f681aae5e3b2530e66db03f16bef029a4891c9e
Author: Marc Stibane <marc@taler.net>
AuthorDate: Mon Nov 13 21:03:53 2023 +0100
Shortcuts (50,25,10,5)
---
TalerWallet1/Views/Exchange/ManualWithdraw.swift | 3 +-
TalerWallet1/Views/HelperViews/CurrencyField.swift | 18 +++++++-
.../Views/HelperViews/CurrencyInputView.swift | 54 +++++++++++++++-------
TalerWallet1/Views/Peer2peer/RequestPayment.swift | 3 +-
TalerWallet1/Views/Peer2peer/SendAmount.swift | 3 +-
5 files changed, 60 insertions(+), 21 deletions(-)
diff --git a/TalerWallet1/Views/Exchange/ManualWithdraw.swift
b/TalerWallet1/Views/Exchange/ManualWithdraw.swift
index 3e9c3bc..505b55d 100644
--- a/TalerWallet1/Views/Exchange/ManualWithdraw.swift
+++ b/TalerWallet1/Views/Exchange/ManualWithdraw.swift
@@ -34,7 +34,8 @@ struct ManualWithdraw: View {
VStack {
CurrencyInputView(amount: $amountToTransfer,
title: iconOnly ? String(localized: "How
much:")
- : String(localized: "Amount
to withdraw:"))
+ : String(localized: "Amount
to withdraw:"),
+ shortcutLabel: String(localized: "Withdraw",
comment: "VoiceOver: Withdraw $50,$25,$10,$5 shortcut buttons"))
let someCoins = SomeCoins(details: withdrawalAmountDetails)
QuiteSomeCoins(someCoins: someCoins, shouldShowFee: true,
currency: currency, amountEffective:
withdrawalAmountDetails?.amountEffective)
diff --git a/TalerWallet1/Views/HelperViews/CurrencyField.swift
b/TalerWallet1/Views/HelperViews/CurrencyField.swift
index 33c065d..784c9dd 100644
--- a/TalerWallet1/Views/HelperViews/CurrencyField.swift
+++ b/TalerWallet1/Views/HelperViews/CurrencyField.swift
@@ -40,6 +40,10 @@ struct CurrencyField: View {
currencyInputField.resignFirstResponder()
}
+ func updateText(amount: Amount) {
+ currencyInputField.updateText(amount: amount)
+ }
+
public init(amount: Binding<Amount>, currencyInfo: CurrencyInfo) {
self._amount = amount
self.currencyInfo = currencyInfo
@@ -60,6 +64,7 @@ struct CurrencyField: View {
// Input text field to handle UI
currencyInputField
+ .accessibilityHidden(true)
// .textFieldStyle(.roundedBorder)
}
}
@@ -84,6 +89,7 @@ class NoCaretTextField: UITextField {
struct CurrencyInputField: UIViewRepresentable {
@Binding var amount: Amount
let currencyInfo: CurrencyInfo
+
private let textField = NoCaretTextField(frame: .zero)
func makeCoordinator() -> Coordinator {
@@ -98,6 +104,14 @@ struct CurrencyInputField: UIViewRepresentable {
textField.resignFirstResponder()
}
+ func updateText(amount: Amount) {
+ let plain = amount.plainString(currencyInfo)
+ print("Setting textfield to: \(plain)")
+ textField.text = plain
+ let endPosition = textField.endOfDocument
+ textField.selectedTextRange = textField.textRange(from: endPosition,
to: endPosition)
+ }
+
func makeUIView(context: Context) -> NoCaretTextField {
// Assign delegate
textField.delegate = context.coordinator
@@ -147,8 +161,10 @@ struct CurrencyInputField: UIViewRepresentable {
func updateText(_ amount: Amount, textField: UITextField) {
// Update field text and last valid input text
lastValidInput = amount.plainString(input.currencyInfo)
-// print(lastValidInput)
+// print("lastValidInput: `\(lastValidInput)´")
textField.text = lastValidInput
+ let endPosition = textField.endOfDocument
+ textField.selectedTextRange = textField.textRange(from:
endPosition, to: endPosition)
}
func textField(_ textField: UITextField, shouldChangeCharactersIn
range: NSRange, replacementString string: String) -> Bool {
diff --git a/TalerWallet1/Views/HelperViews/CurrencyInputView.swift
b/TalerWallet1/Views/HelperViews/CurrencyInputView.swift
index 841a554..7d6c045 100644
--- a/TalerWallet1/Views/HelperViews/CurrencyInputView.swift
+++ b/TalerWallet1/Views/HelperViews/CurrencyInputView.swift
@@ -8,24 +8,43 @@ import taler_swift
struct CurrencyInputView: View {
@Binding var amount: Amount // the `value´
let title: String
+ let shortcutLabel: String
@EnvironmentObject private var controller: Controller
@State var hasBeenShown = false
var body: some View {
- let currencyInfo = controller.info(for: amount.currencyStr,
controller.currencyTicker)
+ let shortcuts = [50,25,10,5]
+ let currency = amount.currencyStr
+ let currencyInfo = controller.info(for: currency,
controller.currencyTicker)
let currencyField = CurrencyField(amount: $amount, currencyInfo:
currencyInfo)
- VStack (alignment: .leading) {
- Text(title)
-// .padding(.top)
- .accessibilityFont(.title3)
+ VStack (alignment: .center) {
+ HStack {
+ Text(title)
+// .padding(.top)
+ .accessibilityFont(.title3)
+ .accessibilityAddTraits(.isHeader)
+ .accessibilityRemoveTraits(.isStaticText)
+ Spacer()
+ }
currencyField
.frame(maxWidth: .infinity, alignment: .trailing)
.foregroundColor(WalletColors().fieldForeground) // text
color
.background(WalletColors().fieldBackground)
.accessibilityFont(.title2)
.textFieldStyle(.roundedBorder)
+ HStack {
+ ForEach(shortcuts, id: \.self) { shortcut in
+ let shortie = Amount(currency: currency, integer:
UInt64(shortcut), fraction: 0)
+ let title = shortie.string(currencyInfo)
+ Button(title) {
+ currencyField.updateText(amount: shortie)
+ amount = shortie
+ }.buttonStyle(.bordered)
+ .accessibilityLabel("\(shortcutLabel) \(title)")
+ }
+ }
}.onAppear { // make CurrencyField show the keyboard after 0.4
seconds
if hasBeenShown {
// print("❗️Yikes: CurrencyInputView hasBeenShown")
@@ -43,20 +62,21 @@ struct CurrencyInputView: View {
}
// MARK: -
#if DEBUG
-struct CurrencyInputView_Previews: PreviewProvider {
- struct StateContainer : View {
- @State var amountToTransfer = Amount(currency: LONGCURRENCY, cent: 0)
-
- var body: some View {
- CurrencyInputView(amount: $amountToTransfer,
- title: "Amount to withdraw:")
+fileprivate struct Previews: PreviewProvider {
+ @MainActor
+ struct StateContainer: View {
+ @StateObject private var controller = Controller.shared
+ @State var amountToTransfer = Amount(currency: LONGCURRENCY, cent: 0)
+ var body: some View {
+// Preview_Content()
+ CurrencyInputView(amount: $amountToTransfer,
+ title: "Amount to withdraw:",
+ shortcutLabel: "Withdraw")
+ .environmentObject(controller)
+ }
}
- }
-
static var previews: some View {
- List {
- StateContainer()
- }
+ StateContainer()
}
}
#endif
diff --git a/TalerWallet1/Views/Peer2peer/RequestPayment.swift
b/TalerWallet1/Views/Peer2peer/RequestPayment.swift
index ef6a08f..a41b72e 100644
--- a/TalerWallet1/Views/Peer2peer/RequestPayment.swift
+++ b/TalerWallet1/Views/Peer2peer/RequestPayment.swift
@@ -31,7 +31,8 @@ struct RequestPayment: View {
ScrollView { VStack {
CurrencyInputView(amount: $amountToTransfer,
title: iconOnly ? String(localized: "How much:")
- : String(localized: "Amount to
request:"))
+ : String(localized: "Amount to
request:"),
+ shortcutLabel: String(localized: "Request", comment:
"VoiceOver: Request $50,$25,$10,$5 shortcut buttons"))
let someCoins = SomeCoins(details: peerPullCheck)
QuiteSomeCoins(someCoins: someCoins, shouldShowFee: true,
diff --git a/TalerWallet1/Views/Peer2peer/SendAmount.swift
b/TalerWallet1/Views/Peer2peer/SendAmount.swift
index ba9068a..bf1b8c9 100644
--- a/TalerWallet1/Views/Peer2peer/SendAmount.swift
+++ b/TalerWallet1/Views/Peer2peer/SendAmount.swift
@@ -49,7 +49,8 @@ struct SendAmount: View {
.padding(.bottom, 2)
CurrencyInputView(amount: $amountToTransfer,
title: iconOnly ? String(localized: "How
much:")
- : String(localized: "Amount
to send:"))
+ : String(localized: "Amount
to send:"),
+ shortcutLabel: String(localized: "Send", comment:
"VoiceOver: Send $50,$25,$10,$5 shortcut buttons"))
Text("+ \(fee) payment fee")
.accessibilityFont(.body)
.foregroundColor(.red)
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-ios] 18/36: amountToTransfer Transactions, (continued)
- [taler-taler-ios] 18/36: amountToTransfer Transactions, gnunet, 2023/11/13
- [taler-taler-ios] 17/36: amountToTransfer Balances, gnunet, 2023/11/13
- [taler-taler-ios] 09/36: cleanup, zero, gnunet, 2023/11/13
- [taler-taler-ios] 29/36: less logging, gnunet, 2023/11/13
- [taler-taler-ios] 13/36: once at very first startup, gnunet, 2023/11/13
- [taler-taler-ios] 15/36: About with explicit link to taler.net, gnunet, 2023/11/13
- [taler-taler-ios] 28/36: Cleanup property wrappers, gnunet, 2023/11/13
- [taler-taler-ios] 22/36: amountToTransfer ManualWithdraw, gnunet, 2023/11/13
- [taler-taler-ios] 33/36: Announce shouldn't change screen, gnunet, 2023/11/13
- [taler-taler-ios] 34/36: Previews, gnunet, 2023/11/13
- [taler-taler-ios] 32/36: Shortcuts (50,25,10,5),
gnunet <=
- [taler-taler-ios] 11/36: Debugging, gnunet, 2023/11/13
- [taler-taler-ios] 25/36: amountToTransfer Currency, gnunet, 2023/11/13
- [taler-taler-ios] 16/36: TransactionsArraySliceV, gnunet, 2023/11/13
- [taler-taler-ios] 20/36: amountToTransfer Request, gnunet, 2023/11/13
- [taler-taler-ios] 26/36: Minimalistic, gnunet, 2023/11/13
- [taler-taler-ios] 31/36: Use `te´and `ku´ for previews, gnunet, 2023/11/13
- [taler-taler-ios] 10/36: @Published currencyTicker, gnunet, 2023/11/13
- [taler-taler-ios] 35/36: Check Available, accessibility, gnunet, 2023/11/13
- [taler-taler-ios] 36/36: Bump version to 0.9.3 (25), gnunet, 2023/11/13
- [taler-taler-ios] 08/36: Cleanup, gnunet, 2023/11/13