I added toolbar to 2 text fields, but the toolbar shows up twice:
This is the code for my custom text field:
public struct SUIDecimalField: View {
public var body: some View {
TextField(placeholder, text: $value)
.focused(focused)
.textFieldStyle(.roundedBorder)
.keyboardType(.decimalPad)
.toolbar {
ToolbarItemGroup(placement: .keyboard) {
HStack {
Button(LOC(.clearKeyboardButton)) {
value = ""
}
Spacer()
Button(LOC(.dismissKeyboardButton)) {
focused.wrappedValue = false
}
}
}
}
}
}
As you can see i only added the toolbar to the text field. I have 2 text fields, and it showed up twice.
Looks like the toolbar is somehow shared between all text fields. I am wondering how do I resolve it? I really want to put the toolbar inside the text field implementation so that the logic is encapsulated.