Commit 9b743d59 by Michael Gaylord

Make it compile

parent 361b858d
......@@ -45,7 +45,7 @@ public protocol TextFieldDelegate: UITextFieldDelegate {
*/
@objc
optional func textField(textField: UITextField, didChange text: String?)
/**
A delegation method that is executed when the textField will clear.
- Parameter textField: A UITextField.
......@@ -133,8 +133,8 @@ open class TextField: UITextField {
}
/// Divider active height.
@IBInspectable
/// Divider active height.
@IBInspectable
open var dividerActiveHeight: CGFloat = 2 {
didSet {
guard isEditing else {
......@@ -144,9 +144,9 @@ open class TextField: UITextField {
dividerThickness = dividerActiveHeight
}
}
/// Divider normal color.
@IBInspectable
/// Divider normal color.
@IBInspectable
open var dividerNormalColor = Color.darkText.dividers {
didSet {
guard !isEditing else {
......@@ -156,121 +156,121 @@ open class TextField: UITextField {
dividerColor = dividerNormalColor
}
}
/// Divider active color.
@IBInspectable
/// Divider active color.
@IBInspectable
open var dividerActiveColor = Color.blue.base {
didSet {
didSet {
guard isEditing else {
return
}
dividerColor = dividerActiveColor
}
}
/// The placeholderLabel font value.
@IBInspectable
}
}
/// The placeholderLabel font value.
@IBInspectable
open override var font: UIFont? {
didSet {
placeholderLabel.font = font
}
}
/// The placeholderLabel text value.
@IBInspectable
didSet {
placeholderLabel.font = font
}
}
/// The placeholderLabel text value.
@IBInspectable
open override var placeholder: String? {
get {
return placeholderLabel.text
}
set(value) {
get {
return placeholderLabel.text
}
set(value) {
if isEditing && isPlaceholderUppercasedWhenEditing {
placeholderLabel.text = value?.uppercased()
} else {
placeholderLabel.text = value
}
layoutSubviews()
}
}
/// The placeholder UILabel.
@IBInspectable
}
}
/// The placeholder UILabel.
@IBInspectable
open let placeholderLabel = UILabel()
/// Placeholder normal text
@IBInspectable
/// Placeholder normal text
@IBInspectable
open var placeholderNormalColor = Color.darkText.others {
didSet {
didSet {
updatePlaceholderLabelColor()
}
}
/// Placeholder active text
@IBInspectable
}
}
/// Placeholder active text
@IBInspectable
open var placeholderActiveColor = Color.blue.base {
didSet {
didSet {
updatePlaceholderLabelColor()
}
}
/// This property adds a padding to placeholder y position animation
@IBInspectable
}
}
/// This property adds a padding to placeholder y position animation
@IBInspectable
open var placeholderVerticalOffset: CGFloat = 0
/// The detailLabel UILabel that is displayed.
@IBInspectable
/// The detailLabel UILabel that is displayed.
@IBInspectable
open let detailLabel = UILabel()
/// The detailLabel text value.
@IBInspectable
/// The detailLabel text value.
@IBInspectable
open var detail: String? {
get {
return detailLabel.text
}
set(value) {
detailLabel.text = value
get {
return detailLabel.text
}
set(value) {
detailLabel.text = value
layoutSubviews()
}
}
/// Detail text
@IBInspectable
}
}
/// Detail text
@IBInspectable
open var detailColor = Color.darkText.others {
didSet {
didSet {
updateDetailLabelColor()
}
}
}
}
/// Vertical distance for the detailLabel from the divider.
@IBInspectable
/// Vertical distance for the detailLabel from the divider.
@IBInspectable
open var detailVerticalOffset: CGFloat = 8 {
didSet {
layoutDetailLabel()
}
}
/// Handles the textAlignment of the placeholderLabel.
open override var textAlignment: NSTextAlignment {
get {
return super.textAlignment
}
set(value) {
super.textAlignment = value
placeholderLabel.textAlignment = value
detailLabel.textAlignment = value
}
}
didSet {
layoutDetailLabel()
}
}
/// Handles the textAlignment of the placeholderLabel.
open override var textAlignment: NSTextAlignment {
get {
return super.textAlignment
}
set(value) {
super.textAlignment = value
placeholderLabel.textAlignment = value
detailLabel.textAlignment = value
}
}
/// A reference to the clearIconButton.
open fileprivate(set) var clearIconButton: IconButton?
/// Enables the clearIconButton.
@IBInspectable
/// Enables the clearIconButton.
@IBInspectable
open var isClearIconButtonEnabled: Bool {
get {
return nil != clearIconButton
}
set(value) {
get {
return nil != clearIconButton
}
set(value) {
guard value else {
clearIconButton?.removeTarget(self, action: #selector(handleClearIconButton), for: .touchUpInside)
clearIconButton = nil
......@@ -290,33 +290,33 @@ open class TextField: UITextField {
isClearIconButtonAutoHandled = isClearIconButtonAutoHandled ? true : false
layoutSubviews()
}
}
/// Enables the automatic handling of the clearIconButton.
@IBInspectable
}
}
/// Enables the automatic handling of the clearIconButton.
@IBInspectable
open var isClearIconButtonAutoHandled = true {
didSet {
clearIconButton?.removeTarget(self, action: #selector(handleClearIconButton), for: .touchUpInside)
didSet {
clearIconButton?.removeTarget(self, action: #selector(handleClearIconButton), for: .touchUpInside)
guard isClearIconButtonAutoHandled else {
return
}
}
clearIconButton?.addTarget(self, action: #selector(handleClearIconButton), for: .touchUpInside)
}
}
}
}
/// A reference to the visibilityIconButton.
open fileprivate(set) var visibilityIconButton: IconButton?
/// Enables the visibilityIconButton.
@IBInspectable
/// Enables the visibilityIconButton.
@IBInspectable
open var isVisibilityIconButtonEnabled: Bool {
get {
return nil != visibilityIconButton
}
set(value) {
get {
return nil != visibilityIconButton
}
set(value) {
guard value else {
visibilityIconButton?.removeTarget(self, action: #selector(handleVisibilityIconButton), for: .touchUpInside)
visibilityIconButton = nil
......@@ -337,22 +337,22 @@ open class TextField: UITextField {
isVisibilityIconButtonAutoHandled = isVisibilityIconButtonAutoHandled ? true : false
layoutSubviews()
}
}
/// Enables the automatic handling of the visibilityIconButton.
@IBInspectable
}
}
/// Enables the automatic handling of the visibilityIconButton.
@IBInspectable
open var isVisibilityIconButtonAutoHandled: Bool = true {
didSet {
visibilityIconButton?.removeTarget(self, action: #selector(handleVisibilityIconButton), for: .touchUpInside)
didSet {
visibilityIconButton?.removeTarget(self, action: #selector(handleVisibilityIconButton), for: .touchUpInside)
guard isVisibilityIconButtonAutoHandled else {
return
}
}
visibilityIconButton?.addTarget(self, action: #selector(handleVisibilityIconButton), for: .touchUpInside)
}
}
}
}
@IBInspectable
open var isPlaceholderUppercasedWhenEditing: Bool = false {
......@@ -360,38 +360,38 @@ open class TextField: UITextField {
placeholder = placeholder?.uppercased()
}
}
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
*/
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
prepare()
}
/**
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
prepare()
}
/**
An initializer that initializes the object with a CGRect object.
If AutoLayout is used, it is better to initilize the instance
using the init() initializer.
- Parameter frame: A CGRect instance.
*/
public override init(frame: CGRect) {
super.init(frame: frame)
prepare()
}
/// A convenience initializer.
public convenience init() {
self.init(frame: .zero)
}
open override func layoutSubviews() {
super.layoutSubviews()
public override init(frame: CGRect) {
super.init(frame: frame)
prepare()
}
/// A convenience initializer.
public convenience init() {
self.init(frame: .zero)
}
open override func layoutSubviews() {
super.layoutSubviews()
layoutShape()
reload()
}
}
open override func becomeFirstResponder() -> Bool {
setNeedsLayout()
layoutIfNeeded()
......@@ -409,30 +409,30 @@ open class TextField: UITextField {
return textRect(forBounds: bounds)
}
/**
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
to initialize property values and other setup operations.
The super.prepare method should always be called immediately
when subclassing.
*/
open func prepare() {
clipsToBounds = false
borderStyle = .none
backgroundColor = nil
contentScaleFactor = Screen.scale
open func prepare() {
clipsToBounds = false
borderStyle = .none
backgroundColor = nil
contentScaleFactor = Screen.scale
font = RobotoFont.regular(with: 16)
textColor = Color.darkText.primary
prepareDivider()
preparePlaceholderLabel()
prepareDetailLabel()
prepareTargetHandlers()
preparePlaceholderLabel()
prepareDetailLabel()
prepareTargetHandlers()
prepareTextAlignment()
}
}
/// Ensures that the components are sized correctly.
open func reload() {
/// Ensures that the components are sized correctly.
open func reload() {
layoutPlaceholderLabel()
layoutDetailLabel()
layoutButton(button: clearIconButton)
......@@ -688,8 +688,8 @@ extension TextField {
}
updatePlaceholderLabelColor()
if self?.isPlaceholderUppercasedWhenEditing ?? false{
s.placeholderLabel.text = s.placeholderLabel.text?.capitalized
if self.isPlaceholderUppercasedWhenEditing {
placeholderLabel.text = placeholderLabel.text?.capitalized
}
guard isPlaceholderAnimated else {
return
......
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