Commit ef355c28 by Daniel Dahan

fixing conflicted files

parent 6b0bd134
......@@ -45,7 +45,7 @@ extension UIViewController {
This is the recommended method of accessing the ChipBarController
through child UIViewControllers.
*/
public var chipsController: ChipBarController? {
public var chipBarController: ChipBarController? {
return traverseViewControllerHierarchyForClassType()
}
}
......@@ -61,25 +61,25 @@ open class ChipBarController: TransitionController {
layoutSubviews()
}
}
/// The ChipBar used to switch between view controllers.
@IBInspectable
open let chipBar = ChipBar()
/// The chipBar alignment.
open var chipBarAlignment = ChipBarAlignment.bottom {
didSet {
layoutSubviews()
}
}
open override func layoutSubviews() {
super.layoutSubviews()
layoutChipBar()
layoutContainer()
layoutRootViewController()
}
open override func prepare() {
super.prepare()
prepareChipBar()
......@@ -98,12 +98,12 @@ fileprivate extension ChipBarController {
/// Layout the container.
func layoutContainer() {
chipBar.frame.size.width = view.bounds.width
switch displayStyle {
case .partial:
let p = chipBar.bounds.height
let y = view.bounds.height - p
switch chipBarAlignment {
case .top:
container.frame.origin.y = p
......@@ -115,18 +115,18 @@ fileprivate extension ChipBarController {
container.frame.origin.y = 0
container.frame.size.height = view.bounds.height
}
container.frame.size.width = view.bounds.width
case .full:
container.frame = view.bounds
}
}
/// Layout the chipBar.
func layoutChipBar() {
chipBar.frame.size.width = view.bounds.width
switch chipBarAlignment {
case .top:
chipBar.isHidden = false
......@@ -138,7 +138,7 @@ fileprivate extension ChipBarController {
chipBar.isHidden = true
}
}
/// Layout the rootViewController.
func layoutRootViewController() {
rootViewController.view.frame = container.bounds
......
......@@ -114,13 +114,17 @@ open class CollectionView: UICollectionView {
- Parameter frame: A CGRect defining the view's frame.
*/
public init(frame: CGRect) {
super.init(frame: frame, collectionViewLayout: CollectionViewLayout())
let layout = UICollectionViewFlowLayout()
layout.itemSize = CGSize(width: 100, height: 100)
super.init(frame: frame, collectionViewLayout: layout)
prepare()
}
/// A convenience initializer that initializes the object.
public init() {
super.init(frame: .zero, collectionViewLayout: CollectionViewLayout())
let layout = UICollectionViewFlowLayout()
layout.itemSize = CGSize(width: 100, height: 100)
super.init(frame: .zero, collectionViewLayout: layout)
prepare()
}
......
......@@ -39,7 +39,7 @@ open class Layer: CAShapeLayer {
the image to a desired shape within the visualLayer.
*/
open let visualLayer = CAShapeLayer()
/**
A property that manages an image for the visualLayer's contents
property. Images should not be set to the backing layer's contents
......@@ -51,7 +51,7 @@ open class Layer: CAShapeLayer {
visualLayer.contents = image?.cgImage
}
}
/**
Allows a relative subrectangle within the range of 0 to 1 to be
specified for the visualLayer's contents property. This allows
......@@ -63,7 +63,7 @@ open class Layer: CAShapeLayer {
visualLayer.contentsRect = contentsRect
}
}
/**
A CGRect that defines a stretchable region inside the visualLayer
with a fixed border around the edge.
......@@ -73,7 +73,7 @@ open class Layer: CAShapeLayer {
visualLayer.contentsCenter = contentsCenter
}
}
/**
A floating point value that defines a ratio between the pixel
dimensions of the visualLayer's contents property and the size
......@@ -85,14 +85,14 @@ open class Layer: CAShapeLayer {
visualLayer.contentsScale = contentsScale
}
}
/// A Preset for the contentsGravity property.
open var contentsGravityPreset: Gravity {
didSet {
contentsGravity = GravityToValue(gravity: contentsGravityPreset)
}
}
/// Determines how content should be aligned within the visualLayer's bounds.
@IBInspectable
open override var contentsGravity: String {
......@@ -103,7 +103,7 @@ open class Layer: CAShapeLayer {
visualLayer.contentsGravity = value
}
}
/**
A property that sets the cornerRadius of the backing layer. If the shape
property has a value of .circle when the cornerRadius is set, it will
......@@ -116,7 +116,7 @@ open class Layer: CAShapeLayer {
shapePreset = .none
}
}
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
......@@ -126,7 +126,7 @@ open class Layer: CAShapeLayer {
super.init(coder: aDecoder)
prepareVisualLayer()
}
/**
An initializer the same as init(). The layer parameter is ignored
to avoid crashes on certain architectures.
......@@ -137,14 +137,14 @@ open class Layer: CAShapeLayer {
super.init(layer: layer)
prepareVisualLayer()
}
/// A convenience initializer.
public override init() {
contentsGravityPreset = .resizeAspectFill
super.init()
prepareVisualLayer()
}
/**
An initializer that initializes the object with a CGRect object.
- Parameter frame: A CGRect instance.
......@@ -153,23 +153,25 @@ open class Layer: CAShapeLayer {
self.init()
self.frame = frame
}
open override func layoutSublayers() {
super.layoutSublayers()
layoutShape()
layoutVisualLayer()
layoutShadowPath()
}
}
fileprivate extension Layer {
/// Prepares the visualLayer property.
open func prepareVisualLayer() {
func prepareVisualLayer() {
visualLayer.zPosition = 0
visualLayer.masksToBounds = true
addSublayer(visualLayer)
}
/// Manages the layout for the visualLayer property.
internal func layoutVisualLayer() {
func layoutVisualLayer() {
visualLayer.frame = bounds
visualLayer.cornerRadius = cornerRadius
}
......
......@@ -53,7 +53,7 @@ public protocol TextFieldDelegate: UITextFieldDelegate {
*/
@objc
optional func textField(textField: TextField, willClear text: String?)
/**
A delegation method that is executed when the textField is cleared.
- Parameter textField: A TextField.
......@@ -68,11 +68,11 @@ open class TextField: UITextField {
open override var intrinsicContentSize: CGSize {
return CGSize(width: bounds.width, height: 32)
}
/// A Boolean that indicates if the placeholder label is animated.
@IBInspectable
open var isPlaceholderAnimated = true
/// Set the placeholder animation value.
open var placeholderAnimation = TextFieldPlaceholderAnimation.default {
didSet {
......@@ -80,41 +80,41 @@ open class TextField: UITextField {
placeholderLabel.isHidden = !isEmpty && .hidden == placeholderAnimation
return
}
placeholderLabel.isHidden = .hidden == placeholderAnimation
}
}
/// A boolean indicating whether the text is empty.
open var isEmpty: Bool {
return 0 == text?.utf16.count
}
open override var text: String? {
didSet {
placeholderAnimation = { placeholderAnimation }()
}
}
open override var leftView: UIView? {
didSet {
prepareLeftView()
layoutSubviews()
}
}
/// The leftView width value.
open var leftViewWidth: CGFloat {
guard nil != leftView else {
return 0
}
return leftViewOffset + bounds.height
}
/// The leftView offset value.
open var leftViewOffset: CGFloat = 16
/// Placeholder normal text
@IBInspectable
open var leftViewNormalColor = Color.darkText.others {
......@@ -122,7 +122,7 @@ open class TextField: UITextField {
updateLeftViewColor()
}
}
/// Placeholder active text
@IBInspectable
open var leftViewActiveColor = Color.blue.base {
......@@ -130,7 +130,7 @@ open class TextField: UITextField {
updateLeftViewColor()
}
}
/// Divider normal height.
@IBInspectable
open var dividerNormalHeight: CGFloat = 1 {
......@@ -138,12 +138,12 @@ open class TextField: UITextField {
guard !isEditing else {
return
}
dividerThickness = dividerNormalHeight
}
}
/// Divider active height.
@IBInspectable
open var dividerActiveHeight: CGFloat = 2 {
......@@ -151,11 +151,11 @@ open class TextField: UITextField {
guard isEditing else {
return
}
dividerThickness = dividerActiveHeight
}
}
/// Divider normal color.
@IBInspectable
open var dividerNormalColor = Color.grey.lighten2 {
......@@ -163,11 +163,11 @@ open class TextField: UITextField {
guard !isEditing else {
return
}
dividerColor = dividerNormalColor
}
}
/// Divider active color.
@IBInspectable
open var dividerActiveColor = Color.blue.base {
......@@ -175,11 +175,11 @@ open class TextField: UITextField {
guard isEditing else {
return
}
dividerColor = dividerActiveColor
}
}
/// The placeholderLabel font value.
@IBInspectable
open override var font: UIFont? {
......@@ -187,7 +187,7 @@ open class TextField: UITextField {
placeholderLabel.font = font
}
}
/// The placeholderLabel text value.
@IBInspectable
open override var placeholder: String? {
......@@ -203,11 +203,11 @@ open class TextField: UITextField {
layoutSubviews()
}
}
/// The placeholder UILabel.
@IBInspectable
open let placeholderLabel = UILabel()
/// Placeholder normal text
@IBInspectable
open var placeholderNormalColor = Color.darkText.others {
......@@ -215,7 +215,7 @@ open class TextField: UITextField {
updatePlaceholderLabelColor()
}
}
/// Placeholder active text
@IBInspectable
open var placeholderActiveColor = Color.blue.base {
......@@ -223,15 +223,15 @@ open class TextField: UITextField {
updatePlaceholderLabelColor()
}
}
/// This property adds a padding to placeholder y position animation
@IBInspectable
open var placeholderVerticalOffset: CGFloat = 0
/// This property adds a padding to placeholder y position animation
@IBInspectable
open var placeholderHorizontalOffset: CGFloat = 0
/// The scale of the active placeholder in relation to the inactive
@IBInspectable
open var placeholderActiveScale: CGFloat = 0.75 {
......@@ -239,11 +239,11 @@ open class TextField: UITextField {
layoutPlaceholderLabel()
}
}
/// The detailLabel UILabel that is displayed.
@IBInspectable
open let detailLabel = UILabel()
/// The detailLabel text value.
@IBInspectable
open var detail: String? {
......@@ -255,7 +255,7 @@ open class TextField: UITextField {
layoutSubviews()
}
}
/// Detail text
@IBInspectable
open var detailColor = Color.darkText.others {
......@@ -263,7 +263,7 @@ open class TextField: UITextField {
updateDetailLabelColor()
}
}
/// Vertical distance for the detailLabel from the divider.
@IBInspectable
open var detailVerticalOffset: CGFloat = 8 {
......@@ -271,7 +271,7 @@ open class TextField: UITextField {
layoutDetailLabel()
}
}
/// Handles the textAlignment of the placeholderLabel.
open override var textAlignment: NSTextAlignment {
get {
......@@ -283,10 +283,10 @@ open class TextField: UITextField {
detailLabel.textAlignment = value
}
}
/// A reference to the clearIconButton.
open fileprivate(set) var clearIconButton: IconButton?
/// Enables the clearIconButton.
@IBInspectable
open var isClearIconButtonEnabled: Bool {
......@@ -299,11 +299,11 @@ open class TextField: UITextField {
clearIconButton = nil
return
}
guard nil == clearIconButton else {
return
}
clearIconButton = IconButton(image: Icon.cm.clear, tintColor: placeholderNormalColor)
clearIconButton!.contentEdgeInsetsPreset = .none
clearIconButton!.pulseAnimation = .none
......@@ -311,28 +311,28 @@ open class TextField: UITextField {
rightViewMode = .whileEditing
rightView = clearIconButton
isClearIconButtonAutoHandled = { isClearIconButtonAutoHandled }()
layoutSubviews()
}
}
/// Enables the automatic handling of the clearIconButton.
@IBInspectable
open var isClearIconButtonAutoHandled = true {
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
open var isVisibilityIconButtonEnabled: Bool {
......@@ -345,11 +345,11 @@ open class TextField: UITextField {
visibilityIconButton = nil
return
}
guard nil == visibilityIconButton else {
return
}
visibilityIconButton = IconButton(image: Icon.visibility, tintColor: placeholderNormalColor.withAlphaComponent(isSecureTextEntry ? 0.38 : 0.54))
visibilityIconButton!.contentEdgeInsetsPreset = .none
visibilityIconButton!.pulseAnimation = .none
......@@ -358,11 +358,11 @@ open class TextField: UITextField {
rightViewMode = .whileEditing
rightView = visibilityIconButton
isVisibilityIconButtonAutoHandled = { isVisibilityIconButtonAutoHandled }()
layoutSubviews()
}
}
/// Enables the automatic handling of the visibilityIconButton.
@IBInspectable
open var isVisibilityIconButtonAutoHandled = true {
......@@ -371,18 +371,18 @@ open class TextField: UITextField {
guard isVisibilityIconButtonAutoHandled else {
return
}
visibilityIconButton?.addTarget(self, action: #selector(handleVisibilityIconButton), for: .touchUpInside)
}
}
@IBInspectable
open var isPlaceholderUppercasedWhenEditing = false {
didSet {
updatePlaceholderTextToActiveState()
}
}
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
......@@ -391,7 +391,7 @@ open class TextField: UITextField {
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
......@@ -402,12 +402,12 @@ open class TextField: UITextField {
super.init(frame: frame)
prepare()
}
/// A convenience initializer.
public convenience init() {
self.init(frame: .zero)
}
open override func layoutSubviews() {
super.layoutSubviews()
layoutShape()
......@@ -418,26 +418,26 @@ open class TextField: UITextField {
layoutDivider()
layoutLeftView()
}
open override func becomeFirstResponder() -> Bool {
layoutSubviews()
return super.becomeFirstResponder()
}
/// EdgeInsets for text.
open var textInset: CGFloat = 0
open override func textRect(forBounds bounds: CGRect) -> CGRect {
var b = super.textRect(forBounds: bounds)
b.origin.x += textInset
b.size.width -= textInset
return b
}
open override func editingRect(forBounds bounds: CGRect) -> CGRect {
return textRect(forBounds: bounds)
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
......@@ -452,7 +452,7 @@ open class TextField: UITextField {
contentScaleFactor = Screen.scale
font = RobotoFont.regular(with: 16)
textColor = Color.darkText.primary
prepareDivider()
preparePlaceholderLabel()
prepareDetailLabel()
......@@ -466,14 +466,14 @@ fileprivate extension TextField {
func prepareDivider() {
dividerColor = dividerNormalColor
}
/// Prepares the placeholderLabel.
func preparePlaceholderLabel() {
placeholderNormalColor = Color.darkText.others
placeholderLabel.backgroundColor = .clear
addSubview(placeholderLabel)
}
/// Prepares the detailLabel.
func prepareDetailLabel() {
detailLabel.font = RobotoFont.regular(with: 12)
......@@ -481,21 +481,21 @@ fileprivate extension TextField {
detailColor = Color.darkText.others
addSubview(detailLabel)
}
/// Prepares the leftView.
func prepareLeftView() {
leftView?.contentMode = .left
leftViewMode = .always
updateLeftViewColor()
}
/// Prepares the target handlers.
func prepareTargetHandlers() {
addTarget(self, action: #selector(handleEditingDidBegin), for: .editingDidBegin)
addTarget(self, action: #selector(handleEditingChanged), for: .editingChanged)
addTarget(self, action: #selector(handleEditingDidEnd), for: .editingDidEnd)
}
/// Prepares the textAlignment.
func prepareTextAlignment() {
textAlignment = .rightToLeft == Application.userInterfaceLayoutDirection ? .right : .left
......@@ -507,39 +507,39 @@ fileprivate extension TextField {
func updateLeftViewColor() {
leftView?.tintColor = isEditing ? leftViewActiveColor : leftViewNormalColor
}
/// Updates the placeholderLabel text color.
func updatePlaceholderLabelColor() {
tintColor = placeholderActiveColor
placeholderLabel.textColor = isEditing ? placeholderActiveColor : placeholderNormalColor
}
/// Update the placeholder text to the active state.
func updatePlaceholderTextToActiveState() {
guard isPlaceholderUppercasedWhenEditing else {
return
}
guard isEditing || !isEmpty else {
return
}
placeholderLabel.text = placeholderLabel.text?.uppercased()
}
/// Update the placeholder text to the normal state.
func updatePlaceholderTextToNormalState() {
guard isPlaceholderUppercasedWhenEditing else {
return
}
guard isEmpty else {
return
}
placeholderLabel.text = placeholderLabel.text?.capitalized
}
/// Updates the detailLabel text color.
func updateDetailLabelColor() {
detailLabel.textColor = detailColor
......@@ -551,28 +551,28 @@ fileprivate extension TextField {
func layoutPlaceholderLabel() {
let w = leftViewWidth + textInset
let h = 0 == bounds.height ? intrinsicContentSize.height : bounds.height
placeholderLabel.transform = CGAffineTransform.identity
guard isEditing || !isEmpty || !isPlaceholderAnimated else {
placeholderLabel.frame = CGRect(x: w, y: 0, width: bounds.width - leftViewWidth - 2 * textInset, height: h)
return
}
placeholderLabel.frame = CGRect(x: w, y: 0, width: bounds.width - leftViewWidth - 2 * textInset, height: h)
placeholderLabel.transform = CGAffineTransform(scaleX: placeholderActiveScale, y: placeholderActiveScale)
switch textAlignment {
case .left, .natural:
placeholderLabel.frame.origin.x = w + placeholderHorizontalOffset
case .right:
placeholderLabel.frame.origin.x = bounds.width - placeholderLabel.bounds.width - textInset + placeholderHorizontalOffset
placeholderLabel.frame.origin.x = (bounds.width * (1.0 - placeholderActiveScale)) - textInset + placeholderHorizontalOffset
default:break
}
placeholderLabel.frame.origin.y = -placeholderLabel.bounds.height + placeholderVerticalOffset
}
/// Layout the detailLabel.
func layoutDetailLabel() {
let c = dividerContentEdgeInsets
......@@ -581,18 +581,18 @@ fileprivate extension TextField {
detailLabel.frame.origin.y = bounds.height + detailVerticalOffset
detailLabel.frame.size.width = bounds.width - c.left - c.right
}
/// Layout the a button.
func layoutButton(button: UIButton?) {
button?.frame = CGRect(x: bounds.width - bounds.height, y: 0, width: bounds.height, height: bounds.height)
}
/// Layout the leftView.
func layoutLeftView() {
guard let v = leftView else {
return
}
let w = leftViewWidth
v.frame = CGRect(x: 0, y: 0, width: w, height: bounds.height)
dividerContentEdgeInsets.left = w
......@@ -607,13 +607,13 @@ fileprivate extension TextField {
placeholderEditingDidBeginAnimation()
dividerEditingDidBeginAnimation()
}
// Live updates the textField text.
@objc
func handleEditingChanged(textField: UITextField) {
(delegate as? TextFieldDelegate)?.textField?(textField: self, didChange: textField.text)
}
/// Handles the text editing did end state.
@objc
func handleEditingDidEnd() {
......@@ -621,33 +621,33 @@ fileprivate extension TextField {
placeholderEditingDidEndAnimation()
dividerEditingDidEndAnimation()
}
/// Handles the clearIconButton TouchUpInside event.
@objc
func handleClearIconButton() {
guard nil == delegate?.textFieldShouldClear || true == delegate?.textFieldShouldClear?(self) else {
return
}
let t = text
(delegate as? TextFieldDelegate)?.textField?(textField: self, willClear: t)
text = nil
(delegate as? TextFieldDelegate)?.textField?(textField: self, didClear: t)
}
/// Handles the visibilityIconButton TouchUpInside event.
@objc
func handleVisibilityIconButton() {
isSecureTextEntry = !isSecureTextEntry
if !isSecureTextEntry {
super.font = nil
font = placeholderLabel.font
}
visibilityIconButton?.tintColor = visibilityIconButton?.tintColor.withAlphaComponent(isSecureTextEntry ? 0.38 : 0.54)
}
}
......@@ -657,87 +657,87 @@ extension TextField {
fileprivate func leftViewEditingBeginAnimation() {
updateLeftViewColor()
}
/// The animation for leftView when editing ends.
fileprivate func leftViewEditingEndAnimation() {
updateLeftViewColor()
}
/// The animation for the divider when editing begins.
fileprivate func dividerEditingDidBeginAnimation() {
dividerThickness = dividerActiveHeight
dividerColor = dividerActiveColor
}
/// The animation for the divider when editing ends.
fileprivate func dividerEditingDidEndAnimation() {
dividerThickness = dividerNormalHeight
dividerColor = dividerNormalColor
}
/// The animation for the placeholder when editing begins.
fileprivate func placeholderEditingDidBeginAnimation() {
guard .default == placeholderAnimation else {
placeholderLabel.isHidden = true
return
}
updatePlaceholderLabelColor()
guard isPlaceholderAnimated else {
updatePlaceholderTextToActiveState()
return
}
guard isEmpty else {
updatePlaceholderTextToActiveState()
return
}
UIView.animate(withDuration: 0.15, animations: { [weak self] in
guard let s = self else {
return
}
s.placeholderLabel.transform = CGAffineTransform(scaleX: s.placeholderActiveScale, y: s.placeholderActiveScale)
s.updatePlaceholderTextToActiveState()
switch s.textAlignment {
case .left, .natural:
s.placeholderLabel.frame.origin.x = s.leftViewWidth + s.textInset + s.placeholderHorizontalOffset
case .right:
s.placeholderLabel.frame.origin.x = s.bounds.width - s.placeholderLabel.bounds.width - s.textInset + s.placeholderHorizontalOffset
s.placeholderLabel.frame.origin.x = (s.bounds.width * (1.0 - s.placeholderActiveScale)) - s.textInset + s.placeholderHorizontalOffset
default:break
}
s.placeholderLabel.frame.origin.y = -s.placeholderLabel.bounds.height + s.placeholderVerticalOffset
})
}
/// The animation for the placeholder when editing ends.
fileprivate func placeholderEditingDidEndAnimation() {
guard .default == placeholderAnimation else {
placeholderLabel.isHidden = !isEmpty
return
}
updatePlaceholderLabelColor()
updatePlaceholderTextToNormalState()
guard isPlaceholderAnimated else {
return
}
guard isEmpty else {
return
}
UIView.animate(withDuration: 0.15, animations: { [weak self] in
guard let s = self else {
return
}
s.placeholderLabel.transform = CGAffineTransform.identity
s.placeholderLabel.frame.origin.x = s.leftViewWidth + s.textInset
s.placeholderLabel.frame.origin.y = 0
......
......@@ -33,10 +33,34 @@ import UIKit
fileprivate var ToolbarContext: UInt8 = 0
open class Toolbar: Bar {
/// A convenience property to set the titleLabel.text.
@IBInspectable
open var title: String? {
get {
return titleLabel.text
}
set(value) {
titleLabel.text = value
layoutSubviews()
}
}
/// Title label.
@IBInspectable
open let titleLabel = UILabel()
/// A convenience property to set the detailLabel.text.
@IBInspectable
open var detail: String? {
get {
return detailLabel.text
}
set(value) {
detailLabel.text = value
layoutSubviews()
}
}
/// Detail label.
@IBInspectable
open let detailLabel = UILabel()
......
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