It's possible to create a Toolbar above keyboard in UIKit using the inputAccessoryView. But how can that be done for SwiftUI? Since, inputAccessoryView isn't supported for SwiftUI (Based on what I looked up online). I have limited knowledge on UIKit and Objective-C so not sure how I can combine SwiftUI and UIKit
import SwiftUI
import Combine
struct TipsView: View {
@State private var amount = ""
var body: some View {
NavigationView {
Form {
Section (header: Text("Amount")) {
HStack (spacing: 1) {
if !amount.isEmpty {
Text("£")
}
TextField("Amount", text: $amount)
.keyboardType(.decimalPad)
.onReceive(Just(amount)) { newValue in
let filtered = newValue.filter { "0123456789.".contains($0)}
if filtered != newValue {
amount = filtered
}
}
}//HStack
}//Section
}//Form
}//NavigationView
}
}
