Closed satan87 closed 4 years ago
Hey Nicolas, thank you for reporting the issue.
I have looked at it, it is not a bug but intended. The use case should be that you store your own text. The model is only used to update the view, developer should handle the data.
I will update the sample code soon, but here is a quick demo.
@State private var yourText = ""
@State private var textFieldModel = BDModalTextFieldModel()
func presentModalTextField() {
// assign your text to the text field's text before present
textFieldModel.text = yourText
textFieldModel.onCancel = {
// ignore to update yourText and dismiss
self.textFieldModel.isFirstResponder = false
self.presentSheet = false
}
textFieldModel.onCommit = {
// grab the text from the text field and dismiss
self.yourText = self.textFieldModel.text
self.textFieldModel.isFirstResponder = false
self.presentSheet = false
}
textFieldModel.onReturnKey = {
// grab the text from the text field and dismiss
self.yourText = self.textFieldModel.text
self.textFieldModel.isFirstResponder = false
self.presentSheet = false
}
}
Thank you for the quick answer .. it is working well thanks.
Hello,
Great work on the component, they're very nice and easy to use.
I believe there is a bug on the ModelTextField with the cancel option. Here how to reproduce it:
Thanks, Nicolas