From 6f65765efa7692dd9d546c9ac7279b689f574b2d Mon Sep 17 00:00:00 2001 From: Naman Goel Date: Sun, 3 Jan 2021 02:35:07 -0800 Subject: [PATCH 1/2] Set All textField values again in updateUIView This is to track any changes in modifier values while the UI runs --- Sources/iTextField/iTextField.swift | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Sources/iTextField/iTextField.swift b/Sources/iTextField/iTextField.swift index 3c19e62..ec1bd47 100644 --- a/Sources/iTextField/iTextField.swift +++ b/Sources/iTextField/iTextField.swift @@ -122,6 +122,41 @@ public struct iTextField: UIViewRepresentable { public func updateUIView(_ uiView: UITextField, context: Context) { uiView.text = text + textField.placeholder = placeholder + textField.font = font + textField.textColor = foregroundColor + if let textAlignment = textAlignment { + textField.textAlignment = textAlignment + } + + textField.clearsOnBeginEditing = clearsOnBeginEditing + textField.clearsOnInsertion = clearsOnInsertion + + // Other settings + if let contentType = contentType { + textField.textContentType = contentType + } + if let accentColor = accentColor { + textField.tintColor = accentColor + } + textField.clearButtonMode = clearButtonMode + textField.autocorrectionType = autocorrection + textField.autocapitalizationType = autocapitalization + textField.keyboardType = keyboardType + textField.returnKeyType = returnKeyType + + textField.isSecureTextEntry = isSecure + textField.isUserInteractionEnabled = isUserInteractionEnabled + + textField.setContentHuggingPriority(.defaultHigh, for: .vertical) + textField.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) + + textField.passwordRules = passwordRules + textField.smartDashesType = smartDashesType + textField.smartInsertDeleteType = smartInsertDeleteType + textField.smartQuotesType = smartQuotesType + textField.spellCheckingType = spellCheckingType + if isEditing.wrappedValue { uiView.becomeFirstResponder() } else { From a14ec36fd571c18785403060a3b9d623c7dd15d4 Mon Sep 17 00:00:00 2001 From: Naman Goel Date: Sun, 3 Jan 2021 02:37:43 -0800 Subject: [PATCH 2/2] Fix major mistake Fixed now --- Sources/iTextField/iTextField.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/iTextField/iTextField.swift b/Sources/iTextField/iTextField.swift index ec1bd47..3316c36 100644 --- a/Sources/iTextField/iTextField.swift +++ b/Sources/iTextField/iTextField.swift @@ -120,8 +120,8 @@ public struct iTextField: UIViewRepresentable { return textField } - public func updateUIView(_ uiView: UITextField, context: Context) { - uiView.text = text + public func updateUIView(_ textField: UITextField, context: Context) { + textField.text = text textField.placeholder = placeholder textField.font = font textField.textColor = foregroundColor @@ -158,9 +158,9 @@ public struct iTextField: UIViewRepresentable { textField.spellCheckingType = spellCheckingType if isEditing.wrappedValue { - uiView.becomeFirstResponder() + textField.becomeFirstResponder() } else { - uiView.resignFirstResponder() + textField.resignFirstResponder() } }