Commit 3130a55c by Daniel Dahan

issue-856: fixed issue where TextField.placeholderAnimation = .hidden was not…

issue-856: fixed issue where TextField.placeholderAnimation = .hidden was not correct being displayed when text was set to nil. Closes #856
parent 7d45b943
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'Material' s.name = 'Material'
s.version = '2.10.1' s.version = '2.10.2'
s.license = 'BSD-3-Clause' s.license = 'BSD-3-Clause'
s.summary = 'A Material Design library for creating beautiful applications.' s.summary = 'A Material Design library for creating beautiful applications.'
s.homepage = 'http://materialswift.com' s.homepage = 'http://materialswift.com'
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>2.10.1</string> <string>2.10.2</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
......
...@@ -216,11 +216,11 @@ fileprivate extension SearchBar { ...@@ -216,11 +216,11 @@ fileprivate extension SearchBar {
textField.font = RobotoFont.regular(with: 17) textField.font = RobotoFont.regular(with: 17)
textField.backgroundColor = Color.clear textField.backgroundColor = Color.clear
textField.clearButtonMode = .whileEditing textField.clearButtonMode = .whileEditing
textField.addTarget(self, action: #selector(handleEditingChanged(textField:)), for: .editingChanged)
tintColor = placeholderColor tintColor = placeholderColor
textColor = Color.darkText.primary textColor = Color.darkText.primary
placeholder = "Search" placeholder = "Search"
contentView.addSubview(textField) contentView.addSubview(textField)
textField.addTarget(self, action: #selector(handleEditingChanged(textField:)), for: .editingChanged)
} }
/// Prepares the clearButton. /// Prepares the clearButton.
......
...@@ -76,7 +76,12 @@ open class TextField: UITextField { ...@@ -76,7 +76,12 @@ open class TextField: UITextField {
/// Set the placeholder animation value. /// Set the placeholder animation value.
open var placeholderAnimation = TextFieldPlaceholderAnimation.default { open var placeholderAnimation = TextFieldPlaceholderAnimation.default {
didSet { didSet {
placeholderLabel.isHidden = .hidden == placeholderAnimation && !isEmpty guard isEditing else {
placeholderLabel.isHidden = !isEmpty && .hidden == placeholderAnimation
return
}
placeholderLabel.isHidden = .hidden == placeholderAnimation
} }
} }
...@@ -85,6 +90,12 @@ open class TextField: UITextField { ...@@ -85,6 +90,12 @@ open class TextField: UITextField {
return 0 == text?.utf16.count return 0 == text?.utf16.count
} }
open override var text: String? {
didSet {
placeholderAnimation = { placeholderAnimation }()
}
}
open override var leftView: UIView? { open override var leftView: UIView? {
didSet { didSet {
prepareLeftView() prepareLeftView()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment