title: TextField that accepts only numbers and one decimal point in SwiftUI
body: <p>I searched for a good approach for this problem and none of the questions I'v found answered my needs. I'm struggling with this.</p>
  <p>What I need is a <code>TextField</code> that would accept only <code>0123456789.</code> with format of <code>%.2f</code> and wouldn't require to press Return key to submit. Receiving the value as <code>Double</code> and return as <code>Double</code>.</p>
  <p>The results should be <code>123.45</code> or <code>1.23</code>.</p>
  <p>My attempt:</p>
  <pre><code>    var title: String
      let numberFormatter = NumberFormatter()
  
      @Binding var value: Double
      
      var amountProxy: Binding&lt;String&gt; {
          Binding&lt;String&gt;(
              get: { String(format: &quot;%.2f&quot;, value) },
              set: {
                  if let value = numberFormatter.number(from: $0) {
                      self.value = value.doubleValue
                  }
              }
          )
      }
      
      var body: some View{
          HStack(spacing: 8){
              Text(LocalizedStringKey(title + &quot;:&quot;))
                  .layoutPriority(1)
              TextField(LocalizedStringKey(&quot;&quot;), text: amountProxy)
                  .keyboardType(.decimalPad)
                  .multilineTextAlignment(.trailing)
          }
          .lineLimit(1)
      }
  </code></pre>
  <p>This method results were forcing the user to type one number and move precisely after the decimal point to get the requested value <code>4.20</code>. Something like type, move, repeat. Very poor UX.</p>