Implemented that on tap on label also password visibility gets toggled

This commit is contained in:
dankito 2020-11-05 00:53:43 +01:00
parent c037308751
commit c5cf11e8fc
1 changed files with 4 additions and 0 deletions

View File

@ -101,6 +101,10 @@ struct UIKitTextField: UIViewRepresentable {
if focusTextField { if focusTextField {
DispatchQueue.main.async { // in very few cases focusTextField gets called during view update resulting in 'undefined behavior' -> async() fixes this DispatchQueue.main.async { // in very few cases focusTextField gets called during view update resulting in 'undefined behavior' -> async() fixes this
uiView.focus() uiView.focus()
if isPasswordField { // TODO: currently it works but focusTextField can in general also be set in other ways then by tapping on label
context.coordinator.togglePasswordVisibility()
}
DispatchQueue.main.async { DispatchQueue.main.async {
self.focusTextField = false // reset value so that it can be set again (otherwise it may never gets resetted and then updateUIView() requests focus even though already another view got the focus in the meantime) self.focusTextField = false // reset value so that it can be set again (otherwise it may never gets resetted and then updateUIView() requests focus even though already another view got the focus in the meantime)