Commit 8caf7fb1 by Daniel Dahan

updated TextField accessibility settings and Material version to 2.9.4 for next release

parent 862927ac
...@@ -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.9.3</string> <string>2.9.4</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
......
...@@ -30,6 +30,12 @@ ...@@ -30,6 +30,12 @@
import UIKit import UIKit
@objc(SearchBarAlignment)
public enum SearchBarAlignment: Int {
case top
case bottom
}
public extension UIViewController { public extension UIViewController {
/** /**
A convenience property that provides access to the SearchBarController. A convenience property that provides access to the SearchBarController.
...@@ -46,6 +52,13 @@ open class SearchBarController: StatusBarController { ...@@ -46,6 +52,13 @@ open class SearchBarController: StatusBarController {
@IBInspectable @IBInspectable
open let searchBar = SearchBar() open let searchBar = SearchBar()
/// The searchBar alignment.
open var searchBarAlignment = SearchBarAlignment.top {
didSet {
layoutSubviews()
}
}
open override func layoutSubviews() { open override func layoutSubviews() {
super.layoutSubviews() super.layoutSubviews()
...@@ -56,6 +69,8 @@ open class SearchBarController: StatusBarController { ...@@ -56,6 +69,8 @@ open class SearchBarController: StatusBarController {
switch displayStyle { switch displayStyle {
case .partial: case .partial:
let h = y + searchBar.height let h = y + searchBar.height
container.y = h container.y = h
container.height = view.height - h container.height = view.height - h
...@@ -75,14 +90,14 @@ open class SearchBarController: StatusBarController { ...@@ -75,14 +90,14 @@ open class SearchBarController: StatusBarController {
} }
} }
extension SearchBarController { fileprivate extension SearchBarController {
/// Prepares the statusBar. /// Prepares the statusBar.
fileprivate func prepareStatusBar() { func prepareStatusBar() {
shouldHideStatusBarOnRotation = false shouldHideStatusBarOnRotation = false
} }
/// Prepares the searchBar. /// Prepares the searchBar.
fileprivate func prepareSearchBar() { func prepareSearchBar() {
searchBar.depthPreset = .depth1 searchBar.depthPreset = .depth1
searchBar.zPosition = 1000 searchBar.zPosition = 1000
view.addSubview(searchBar) view.addSubview(searchBar)
......
...@@ -283,7 +283,7 @@ open class TextField: UITextField { ...@@ -283,7 +283,7 @@ open class TextField: UITextField {
clearButtonMode = .never clearButtonMode = .never
rightViewMode = .whileEditing rightViewMode = .whileEditing
rightView = clearIconButton rightView = clearIconButton
isClearIconButtonAutoHandled = isClearIconButtonAutoHandled ? true : false isClearIconButtonAutoHandled = { isClearIconButtonAutoHandled }()
layoutSubviews() layoutSubviews()
} }
...@@ -330,7 +330,7 @@ open class TextField: UITextField { ...@@ -330,7 +330,7 @@ open class TextField: UITextField {
clearButtonMode = .never clearButtonMode = .never
rightViewMode = .whileEditing rightViewMode = .whileEditing
rightView = visibilityIconButton rightView = visibilityIconButton
isVisibilityIconButtonAutoHandled = isVisibilityIconButtonAutoHandled ? true : false isVisibilityIconButtonAutoHandled = { isVisibilityIconButtonAutoHandled }()
layoutSubviews() layoutSubviews()
} }
...@@ -338,7 +338,7 @@ open class TextField: UITextField { ...@@ -338,7 +338,7 @@ open class TextField: UITextField {
/// Enables the automatic handling of the visibilityIconButton. /// Enables the automatic handling of the visibilityIconButton.
@IBInspectable @IBInspectable
open var isVisibilityIconButtonAutoHandled: Bool = true { open var isVisibilityIconButtonAutoHandled = true {
didSet { didSet {
visibilityIconButton?.removeTarget(self, action: #selector(handleVisibilityIconButton), for: .touchUpInside) visibilityIconButton?.removeTarget(self, action: #selector(handleVisibilityIconButton), for: .touchUpInside)
...@@ -428,21 +428,21 @@ open class TextField: UITextField { ...@@ -428,21 +428,21 @@ open class TextField: UITextField {
} }
} }
extension TextField { fileprivate extension TextField {
/// Prepares the divider. /// Prepares the divider.
fileprivate func prepareDivider() { func prepareDivider() {
dividerColor = dividerNormalColor dividerColor = dividerNormalColor
} }
/// Prepares the placeholderLabel. /// Prepares the placeholderLabel.
fileprivate func preparePlaceholderLabel() { func preparePlaceholderLabel() {
placeholderNormalColor = Color.darkText.others placeholderNormalColor = Color.darkText.others
placeholderLabel.backgroundColor = .clear placeholderLabel.backgroundColor = .clear
addSubview(placeholderLabel) addSubview(placeholderLabel)
} }
/// Prepares the detailLabel. /// Prepares the detailLabel.
fileprivate func prepareDetailLabel() { func prepareDetailLabel() {
detailLabel.font = RobotoFont.regular(with: 12) detailLabel.font = RobotoFont.regular(with: 12)
detailLabel.numberOfLines = 0 detailLabel.numberOfLines = 0
detailColor = Color.darkText.others detailColor = Color.darkText.others
...@@ -450,46 +450,46 @@ extension TextField { ...@@ -450,46 +450,46 @@ extension TextField {
} }
/// Prepares the leftView. /// Prepares the leftView.
fileprivate func prepareLeftView() { func prepareLeftView() {
leftView?.contentMode = .left leftView?.contentMode = .left
leftViewMode = .always leftViewMode = .always
updateLeftViewColor() updateLeftViewColor()
} }
/// Prepares the target handlers. /// Prepares the target handlers.
fileprivate func prepareTargetHandlers() { func prepareTargetHandlers() {
addTarget(self, action: #selector(handleEditingDidBegin), for: .editingDidBegin) addTarget(self, action: #selector(handleEditingDidBegin), for: .editingDidBegin)
addTarget(self, action: #selector(handleEditingChanged), for: .editingChanged) addTarget(self, action: #selector(handleEditingChanged), for: .editingChanged)
addTarget(self, action: #selector(handleEditingDidEnd), for: .editingDidEnd) addTarget(self, action: #selector(handleEditingDidEnd), for: .editingDidEnd)
} }
/// Prepares the textAlignment. /// Prepares the textAlignment.
fileprivate func prepareTextAlignment() { func prepareTextAlignment() {
textAlignment = .rightToLeft == Application.userInterfaceLayoutDirection ? .right : .left textAlignment = .rightToLeft == Application.userInterfaceLayoutDirection ? .right : .left
} }
} }
extension TextField { fileprivate extension TextField {
/// Updates the leftView tint color. /// Updates the leftView tint color.
fileprivate func updateLeftViewColor() { func updateLeftViewColor() {
leftView?.tintColor = isEditing ? leftViewActiveColor : leftViewNormalColor leftView?.tintColor = isEditing ? leftViewActiveColor : leftViewNormalColor
} }
/// Updates the placeholderLabel text color. /// Updates the placeholderLabel text color.
fileprivate func updatePlaceholderLabelColor() { func updatePlaceholderLabelColor() {
tintColor = placeholderActiveColor tintColor = placeholderActiveColor
placeholderLabel.textColor = isEditing ? placeholderActiveColor : placeholderNormalColor placeholderLabel.textColor = isEditing ? placeholderActiveColor : placeholderNormalColor
} }
/// Updates the detailLabel text color. /// Updates the detailLabel text color.
fileprivate func updateDetailLabelColor() { func updateDetailLabelColor() {
detailLabel.textColor = detailColor detailLabel.textColor = detailColor
} }
} }
extension TextField { fileprivate extension TextField {
/// Layout the placeholderLabel. /// Layout the placeholderLabel.
fileprivate func layoutPlaceholderLabel() { func layoutPlaceholderLabel() {
let w = leftViewWidth + textInset let w = leftViewWidth + textInset
let h = 0 == height ? intrinsicContentSize.height : height let h = 0 == height ? intrinsicContentSize.height : height
...@@ -515,7 +515,7 @@ extension TextField { ...@@ -515,7 +515,7 @@ extension TextField {
} }
/// Layout the detailLabel. /// Layout the detailLabel.
fileprivate func layoutDetailLabel() { func layoutDetailLabel() {
let c = dividerContentEdgeInsets let c = dividerContentEdgeInsets
detailLabel.height = detailLabel.sizeThatFits(CGSize(width: width, height: .greatestFiniteMagnitude)).height detailLabel.height = detailLabel.sizeThatFits(CGSize(width: width, height: .greatestFiniteMagnitude)).height
detailLabel.x = c.left detailLabel.x = c.left
...@@ -524,12 +524,12 @@ extension TextField { ...@@ -524,12 +524,12 @@ extension TextField {
} }
/// Layout the a button. /// Layout the a button.
fileprivate func layoutButton(button: UIButton?) { func layoutButton(button: UIButton?) {
button?.frame = CGRect(x: width - height, y: 0, width: height, height: height) button?.frame = CGRect(x: width - height, y: 0, width: height, height: height)
} }
/// Layout the leftView. /// Layout the leftView.
fileprivate func layoutLeftView() { func layoutLeftView() {
guard let v = leftView else { guard let v = leftView else {
return return
} }
...@@ -540,10 +540,10 @@ extension TextField { ...@@ -540,10 +540,10 @@ extension TextField {
} }
} }
extension TextField { fileprivate extension TextField {
/// Handles the text editing did begin state. /// Handles the text editing did begin state.
@objc @objc
fileprivate func handleEditingDidBegin() { func handleEditingDidBegin() {
leftViewEditingBeginAnimation() leftViewEditingBeginAnimation()
placeholderEditingDidBeginAnimation() placeholderEditingDidBeginAnimation()
dividerEditingDidBeginAnimation() dividerEditingDidBeginAnimation()
...@@ -551,13 +551,13 @@ extension TextField { ...@@ -551,13 +551,13 @@ extension TextField {
// Live updates the textField text. // Live updates the textField text.
@objc @objc
fileprivate func handleEditingChanged(textField: UITextField) { func handleEditingChanged(textField: UITextField) {
(delegate as? TextFieldDelegate)?.textField?(textField: self, didChange: textField.text) (delegate as? TextFieldDelegate)?.textField?(textField: self, didChange: textField.text)
} }
/// Handles the text editing did end state. /// Handles the text editing did end state.
@objc @objc
fileprivate func handleEditingDidEnd() { func handleEditingDidEnd() {
leftViewEditingEndAnimation() leftViewEditingEndAnimation()
placeholderEditingDidEndAnimation() placeholderEditingDidEndAnimation()
dividerEditingDidEndAnimation() dividerEditingDidEndAnimation()
...@@ -565,7 +565,7 @@ extension TextField { ...@@ -565,7 +565,7 @@ extension TextField {
/// Handles the clearIconButton TouchUpInside event. /// Handles the clearIconButton TouchUpInside event.
@objc @objc
fileprivate func handleClearIconButton() { func handleClearIconButton() {
guard nil == delegate?.textFieldShouldClear || true == delegate?.textFieldShouldClear?(self) else { guard nil == delegate?.textFieldShouldClear || true == delegate?.textFieldShouldClear?(self) else {
return return
} }
...@@ -581,7 +581,7 @@ extension TextField { ...@@ -581,7 +581,7 @@ extension TextField {
/// Handles the visibilityIconButton TouchUpInside event. /// Handles the visibilityIconButton TouchUpInside event.
@objc @objc
fileprivate func handleVisibilityIconButton() { func handleVisibilityIconButton() {
isSecureTextEntry = !isSecureTextEntry isSecureTextEntry = !isSecureTextEntry
if !isSecureTextEntry { if !isSecureTextEntry {
......
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