carrots and windows.

This commit is contained in:
Kevin G Christiano 2019-11-05 09:25:27 -05:00
parent ae5a1c0c02
commit 88eec2bf9d
2 changed files with 41 additions and 41 deletions

View File

@ -18,8 +18,11 @@ import UIKit
let caret = CaretView()
// caret.size = .medium
caret.direction = .down
caret.isHidden = true
caret.lineWidth = 1.5
// caret.isHidden = true
caret.isUserInteractionEnabled = true
caret.heightAnchor.constraint(equalToConstant: 9).isActive = true
caret.widthAnchor.constraint(equalToConstant: 16).isActive = true
return caret
}()
@ -92,15 +95,14 @@ import UIKit
container.addSubview(dropDownCaretView)
dropDownCaretView.heightAnchor.constraint(equalToConstant: 9).isActive = true
dropDownCaretView.widthAnchor.constraint(equalToConstant: 16).isActive = true
textFieldTrailingConstraint?.isActive = false
dropDownCaretView.topAnchor.constraint(greaterThanOrEqualTo: container.topAnchor, constant: 13).isActive = true
textFieldTrailingConstraint = dropDownCaretView.leadingAnchor.constraint(equalTo: textField.trailingAnchor, constant: 6)
textFieldTrailingConstraint?.isActive = true
container.trailingAnchor.constraint(equalTo: dropDownCaretView.trailingAnchor, constant: 16).isActive = true
container.bottomAnchor.constraint(greaterThanOrEqualTo: dropDownCaretView.bottomAnchor, constant: 13).isActive = true
dropDownCaretView.centerYAnchor.constraint(equalTo: container.centerYAnchor).isActive = true
}
//--------------------------------------------------

View File

@ -12,13 +12,13 @@
// MARK: - Properties
//------------------------------------------------------
private var caretPath: UIBezierPath = UIBezierPath()
public var strokeColor: UIColor = .black
public var lineWidth: CGFloat = 1
public var direction: Direction = .right
// public var size: CaretSize?
private var caretPath: UIBezierPath = UIBezierPath()
public var size: CaretSize?
public var enabledColor: UIColor = .black
public var disabledColor: UIColor = .mfSilver()
@ -33,29 +33,33 @@
// MARK: - Constraints
//------------------------------------------------------
// public enum CaretSize: String {
// case small
// case medium
// case large
//
// // Dimensions of container; provided by InVision.
// func dimensions() -> CGSize {
//
// switch self {
// case .small:
// return CGSize(width: 6, height: 10)
//
// case .medium:
// return CGSize(width: 9, height: 16)
//
// case .large:
// return CGSize(width: 14, height: 24)
// }
// }
// }
// public var heightConstraint: NSLayoutConstraint?
// public var widthConstraint: NSLayoutConstraint?
/// Sizes of CaretView are derived from InVision design specs. They are provided for convenience.
public enum CaretSize {
case small(Orientation)
case medium(Orientation)
case large(Orientation)
/// Orientation based on the longest line of the view
public enum Orientation {
case vertical
case horizontal
}
// Dimensions of container; provided by InVision.
func dimensions() -> CGSize {
switch self {
case .small(let o):
return o == .vertical ? CGSize(width: 6, height: 10) : CGSize(width: 10, height: 6)
case .medium(let o):
return o == .vertical ? CGSize(width: 9, height: 16) : CGSize(width: 16, height: 9)
case .large(let o):
return o == .vertical ? CGSize(width: 14, height: 24) : CGSize(width: 24, height: 14)
}
}
}
//------------------------------------------------------
// MARK: - Initialization
@ -86,10 +90,6 @@
@objc override open func setupView() {
defaultState()
// Establishing references.
// heightConstraint = heightAnchor.constraint(equalToConstant: 0)
// widthConstraint = widthAnchor.constraint(equalToConstant: 0)
}
//------------------------------------------------------
@ -162,12 +162,10 @@
@objc public func setConstraints() {
// guard let dimensions = size?.dimensions() else { return }
//
// heightConstraint?.constant = dimensions.height
// heightConstraint?.isActive = true
// widthConstraint?.constant = dimensions.width
// widthConstraint?.isActive = true
guard let dimensions = size?.dimensions() else { return }
heightAnchor.constraint(equalToConstant: dimensions.height).isActive = true
widthAnchor.constraint(equalToConstant: dimensions.width).isActive = true
}
//------------------------------------------------------