gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taler-ios] 108/204: inputAccessory 'return'


From: gnunet
Subject: [taler-taler-ios] 108/204: inputAccessory 'return'
Date: Thu, 05 Dec 2024 23:51:16 +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 d81aa50d4ec0f944c977512c2e50b56df10e19ab
Author: Marc Stibane <marc@taler.net>
AuthorDate: Fri Nov 8 14:09:36 2024 +0100

    inputAccessory 'return'
---
 TalerWallet1/Views/HelperViews/CurrencyField.swift | 28 ++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/TalerWallet1/Views/HelperViews/CurrencyField.swift 
b/TalerWallet1/Views/HelperViews/CurrencyField.swift
index 8507515..04de5bd 100644
--- a/TalerWallet1/Views/HelperViews/CurrencyField.swift
+++ b/TalerWallet1/Views/HelperViews/CurrencyField.swift
@@ -110,7 +110,7 @@ struct CurrencyTextfieldRepresentable: UIViewRepresentable {
         textField.becomeFirstResponder()
     }
 
-    @MainActor public func resignFirstResponder() -> Void {
+    @MainActor public func resignFirstResponder() {
         textField.resignFirstResponder()
         Self.endEditing()
     }
@@ -123,6 +123,27 @@ struct CurrencyTextfieldRepresentable: UIViewRepresentable 
{
         textField.selectedTextRange = textField.textRange(from: endPosition, 
to: endPosition)
     }
 
+    func toolBar() -> UIToolbar {
+        let image = UIImage(systemName: "return")
+        let button = UIBarButtonItem(image: image, style: .done, target: 
textField,
+                                    action: 
#selector(UITextField.resignFirstResponder))
+        let flexSpace = UIBarButtonItem(barButtonSystemItem: 
UIBarButtonItem.SystemItem.flexibleSpace,
+                                                     target: self, action: nil)
+        let toolBar: UIToolbar = UIToolbar()
+        toolBar.items = [flexSpace, button]
+
+        // Unable to simultaneously satisfy constraints
+        // Will attempt to recover by breaking constraint
+        // <NSLayoutConstraint: UIImageView: .centerY == _UIModernBarButton: 
.centerY   (active)>
+
+        // this all doesn't help
+//        toolBar.frame.size.height = 100
+//        toolBar.autoresizingMask = .flexibleWidth
+//        toolBar.translatesAutoresizingMaskIntoConstraints = false
+        toolBar.sizeToFit()
+        return toolBar
+    }
+
     func makeUIView(context: Context) -> NoCaretTextField {
         textField.setContentCompressionResistancePriority(.defaultLow, for: 
.horizontal)
 
@@ -130,7 +151,7 @@ struct CurrencyTextfieldRepresentable: UIViewRepresentable {
         textField.delegate = context.coordinator
 
         // Set keyboard type
-        textField.keyboardType = .asciiCapableNumberPad //  numberPad
+        textField.keyboardType = .asciiCapableNumberPad //  numberPad 
decimalPad phonePad numbersAndPunctuation
 
         // Make visual components invisible...
         textField.tintColor = .clear
@@ -154,6 +175,9 @@ struct CurrencyTextfieldRepresentable: UIViewRepresentable {
             for: .editingChanged
         )
 
+        // Add a toolbar with a done button above the keyboard
+        textField.inputAccessoryView = toolBar()
+
         // Set initial textfield text
         context.coordinator.updateText(amount, textField: textField)
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]