commit b39155d738505582961cf14b30f0c5f526d413fd
parent 85076129a39de72b2d0a0f163f744283318162a3
Author: Marc Stibane <marc@taler.net>
Date: Tue, 24 Sep 2024 12:15:16 +0200
currencyInput
Diffstat:
2 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/TalerWallet1/Views/HelperViews/CurrencyField.swift b/TalerWallet1/Views/HelperViews/CurrencyField.swift
@@ -63,12 +63,16 @@ struct CurrencyField: View {
ZStack {
// Text view to display the formatted currency
// Set as priority so CurrencyInputField size doesn't affect parent
- Text(amount.formatted(currencyInfo, isNegative: false))
- .layoutPriority(1)
- // make the textfield use the whole width for tapping inside to become active
- .frame(maxWidth: .infinity, alignment: .trailing)
-// .background(.clear) this is not the problem of the white corners
-
+ let text = Text(amount.formatted(currencyInfo, isNegative: false))
+ .layoutPriority(1)
+ // make the textfield use the whole width for tapping inside to become active
+ .frame(maxWidth: .infinity, alignment: .trailing)
+ .padding(4)
+ text
+ .background(WalletColors().fieldBackground)
+ .cornerRadius(10)
+ .overlay(RoundedRectangle(cornerRadius: 10)
+ .stroke(WalletColors().fieldForeground, lineWidth: 1))
// Input text field to handle UI
currencyFieldRepresentable
// .accessibilityHidden(true)
@@ -126,14 +130,14 @@ struct CurrencyTextfieldRepresentable: UIViewRepresentable {
textField.delegate = context.coordinator
// Set keyboard type
- textField.keyboardType = .numberPad
+ textField.keyboardType = .asciiCapableNumberPad // numberPad
// Make visual components invisible...
textField.tintColor = .clear
textField.textColor = .clear
textField.backgroundColor = .clear
// ... except for the bezel around the textfield
- textField.borderStyle = .roundedRect
+ textField.borderStyle = .none // .roundedRect
// textField.textFieldStyle(.roundedBorder)
#if DEBUG
diff --git a/TalerWallet1/Views/HelperViews/CurrencyInputView.swift b/TalerWallet1/Views/HelperViews/CurrencyInputView.swift
@@ -87,11 +87,12 @@ struct CurrencyInputView: View {
.frame(maxWidth: .infinity, alignment: .leading)
.talerFont(.title3)
.accessibilityHidden(true)
+ .padding(.bottom, -6)
currencyField
.accessibilityLabel(title)
.frame(maxWidth: .infinity, alignment: .trailing)
.foregroundColor(WalletColors().fieldForeground) // text color
- .background(WalletColors().fieldBackground)
+// .background(WalletColors().fieldBackground) // problem: white corners
.talerFont(.title2)
.textFieldStyle(.roundedBorder)
.onTapGesture {
@@ -144,6 +145,7 @@ struct CurrencyInputView: View {
}
}
}
+ .padding(.top, 6)
} // iOS 16+ only
}.onAppear { // make CurrencyField show the keyboard after 0.4 seconds
if hasBeenShown {