Commit 6c813dcf by Daniel Dahan

development: Updated to Xcode Beta 6

parent d2aa614b
...@@ -56,13 +56,13 @@ public func AnimationFillModeToValue(mode: AnimationFillMode) -> AnimationFillMo ...@@ -56,13 +56,13 @@ public func AnimationFillModeToValue(mode: AnimationFillMode) -> AnimationFillMo
} }
} }
public typealias AnimationDelayCancelBlock = (cancel : Bool) -> Void public typealias AnimationDelayCancelBlock = (Bool) -> Void
public struct Animation { public struct Animation {
/// Delay helper method. /// Delay helper method.
public static func delay(time: TimeInterval, completion: ()-> Void) -> AnimationDelayCancelBlock? { public static func delay(time: TimeInterval, completion: @escaping ()-> Void) -> AnimationDelayCancelBlock? {
func dispatch_later(completion: ()-> Void) { func dispatch_later(completion: @escaping ()-> Void) {
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + time, execute: completion) DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + time, execute: completion)
} }
...@@ -78,7 +78,7 @@ public struct Animation { ...@@ -78,7 +78,7 @@ public struct Animation {
cancelable = delayed cancelable = delayed
dispatch_later { dispatch_later {
cancelable?(cancel: false) cancelable?(false)
} }
return cancelable; return cancelable;
...@@ -88,7 +88,7 @@ public struct Animation { ...@@ -88,7 +88,7 @@ public struct Animation {
:name: delayCancel :name: delayCancel
*/ */
public static func delayCancel(completion: AnimationDelayCancelBlock?) { public static func delayCancel(completion: AnimationDelayCancelBlock?) {
completion?(cancel: true) completion?(true)
} }
......
...@@ -32,8 +32,8 @@ import UIKit ...@@ -32,8 +32,8 @@ import UIKit
public class BottomNavigationFadeAnimatedTransitioning : NSObject, UIViewControllerAnimatedTransitioning { public class BottomNavigationFadeAnimatedTransitioning : NSObject, UIViewControllerAnimatedTransitioning {
public func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { public func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
let fromView : UIView = transitionContext.view(forKey: UITransitionContextFromViewKey)! let fromView : UIView = transitionContext.view(forKey: UITransitionContextViewKey.from)!
let toView : UIView = transitionContext.view(forKey: UITransitionContextToViewKey)! let toView : UIView = transitionContext.view(forKey: UITransitionContextViewKey.to)!
toView.alpha = 0 toView.alpha = 0
transitionContext.containerView.addSubview(fromView) transitionContext.containerView.addSubview(fromView)
......
...@@ -165,7 +165,7 @@ public class Card: PulseView { ...@@ -165,7 +165,7 @@ public class Card: PulseView {
/** /**
:name: leftButtons :name: leftButtons
*/ */
public var leftButtons: Array<UIButton>? { public var leftButtons = [UIButton]() {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -192,7 +192,7 @@ public class Card: PulseView { ...@@ -192,7 +192,7 @@ public class Card: PulseView {
/** /**
:name: rightButtons :name: rightButtons
*/ */
public var rightButtons: Array<UIButton>? { public var rightButtons = [UIButton]() {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -222,7 +222,7 @@ public class Card: PulseView { ...@@ -222,7 +222,7 @@ public class Card: PulseView {
/** /**
:name: init :name: init
*/ */
public convenience init?(image: UIImage? = nil, titleLabel: UILabel? = nil, contentView: UIView? = nil, leftButtons: Array<UIButton>? = nil, rightButtons: Array<UIButton>? = nil) { public convenience init?(image: UIImage? = nil, titleLabel: UILabel? = nil, contentView: UIView? = nil, leftButtons: [UIButton]? = nil, rightButtons: [UIButton]? = nil) {
self.init(frame: CGRect.zero) self.init(frame: CGRect.zero)
prepareProperties(image: image, titleLabel: titleLabel, contentView: contentView, leftButtons: leftButtons, rightButtons: rightButtons) prepareProperties(image: image, titleLabel: titleLabel, contentView: contentView, leftButtons: leftButtons, rightButtons: rightButtons)
} }
...@@ -235,10 +235,10 @@ public class Card: PulseView { ...@@ -235,10 +235,10 @@ public class Card: PulseView {
if self.layer == layer { if self.layer == layer {
if divider { if divider {
var y: CGFloat = contentInset.bottom + dividerInset.bottom var y: CGFloat = contentInset.bottom + dividerInset.bottom
if 0 < leftButtons?.count { if 0 < leftButtons.count {
y += leftButtonsInset.top + leftButtonsInset.bottom + leftButtons![0].frame.height y += leftButtonsInset.top + leftButtonsInset.bottom + leftButtons[0].frame.height
} else if 0 < rightButtons?.count { } else if 0 < rightButtons.count {
y += rightButtonsInset.top + rightButtonsInset.bottom + rightButtons![0].frame.height y += rightButtonsInset.top + rightButtonsInset.bottom + rightButtons[0].frame.height
} }
if 0 < y { if 0 < y {
prepareDivider(y: bounds.height - y - 0.5, width: bounds.width) prepareDivider(y: bounds.height - y - 0.5, width: bounds.width)
...@@ -261,8 +261,8 @@ public class Card: PulseView { ...@@ -261,8 +261,8 @@ public class Card: PulseView {
} }
var verticalFormat: String = "V:|" var verticalFormat: String = "V:|"
var views: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>() var views: Dictionary<String, Any> = Dictionary<String, Any>()
var metrics: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>() var metrics: Dictionary<String, Any> = Dictionary<String, Any>()
if nil != titleLabel { if nil != titleLabel {
verticalFormat += "-(insetTop)" verticalFormat += "-(insetTop)"
...@@ -296,70 +296,66 @@ public class Card: PulseView { ...@@ -296,70 +296,66 @@ public class Card: PulseView {
} }
// leftButtons // leftButtons
if let v: Array<UIButton> = leftButtons { if 0 < leftButtons.count {
if 0 < v.count { var h = "H:|"
var h: String = "H:|" var d = Dictionary<String, Any>()
var d: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>() var i = 0
var i: Int = 0 for b in leftButtons {
for b in v { let k: String = "b\(i)"
let k: String = "b\(i)"
d[k] = b
d[k] = b
if 0 == i {
if 0 == i { h += "-(left)-"
h += "-(left)-" } else {
} else { h += "-(left_right)-"
h += "-(left_right)-" }
}
h += "[\(k)]"
h += "[\(k)]"
_ = layout(b).bottom(contentInset.bottom + leftButtonsInset.bottom)
_ = layout(b).bottom(contentInset.bottom + leftButtonsInset.bottom)
i += 1
i += 1 }
}
addConstraints(Layout.constraint(format: h, options: [], metrics: ["left" : contentInset.left + leftButtonsInset.left, "left_right" : leftButtonsInset.left + leftButtonsInset.right], views: d))
addConstraints(Layout.constraint(format: h, options: [], metrics: ["left" : contentInset.left + leftButtonsInset.left, "left_right" : leftButtonsInset.left + leftButtonsInset.right], views: d)) }
}
}
// rightButtons // rightButtons
if let v: Array<UIButton> = rightButtons { if 0 < rightButtons.count {
if 0 < v.count { var h = "H:"
var h: String = "H:" var d = Dictionary<String, Any>()
var d: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>() var i = rightButtons.count - 1
var i: Int = v.count - 1
for b in rightButtons {
for b in v { let k: String = "b\(i)"
let k: String = "b\(i)"
d[k] = b
d[k] = b
h += "[\(k)]"
h += "[\(k)]"
if 0 == i {
if 0 == i { h += "-(right)-"
h += "-(right)-" } else {
} else { h += "-(right_left)-"
h += "-(right_left)-" }
}
_ = layout(b).bottom(contentInset.bottom + rightButtonsInset.bottom)
_ = layout(b).bottom(contentInset.bottom + rightButtonsInset.bottom)
i -= 1
i -= 1 }
}
addConstraints(Layout.constraint(format: h + "|", options: [], metrics: ["right" : contentInset.right + rightButtonsInset.right, "right_left" : rightButtonsInset.right + rightButtonsInset.left], views: d))
addConstraints(Layout.constraint(format: h + "|", options: [], metrics: ["right" : contentInset.right + rightButtonsInset.right, "right_left" : rightButtonsInset.right + rightButtonsInset.left], views: d)) }
}
}
if 0 < leftButtons?.count { if 0 < leftButtons.count {
verticalFormat += "-(insetC)-[button]" verticalFormat += "-(insetC)-[button]"
views["button"] = leftButtons![0] views["button"] = leftButtons[0]
metrics["insetC"] = leftButtonsInset.top metrics["insetC"] = leftButtonsInset.top
metrics["insetBottom"] = contentInset.bottom + leftButtonsInset.bottom metrics["insetBottom"] = contentInset.bottom + leftButtonsInset.bottom
} else if 0 < rightButtons?.count { } else if 0 < rightButtons.count {
verticalFormat += "-(insetC)-[button]" verticalFormat += "-(insetC)-[button]"
views["button"] = rightButtons![0] views["button"] = rightButtons[0]
metrics["insetC"] = rightButtonsInset.top metrics["insetC"] = rightButtonsInset.top
metrics["insetBottom"] = contentInset.bottom + rightButtonsInset.bottom metrics["insetBottom"] = contentInset.bottom + rightButtonsInset.bottom
} }
...@@ -412,11 +408,11 @@ public class Card: PulseView { ...@@ -412,11 +408,11 @@ public class Card: PulseView {
/** /**
:name: prepareProperties :name: prepareProperties
*/ */
internal func prepareProperties(image: UIImage?, titleLabel: UILabel?, contentView: UIView?, leftButtons: Array<UIButton>?, rightButtons: Array<UIButton>?) { internal func prepareProperties(image: UIImage?, titleLabel: UILabel?, contentView: UIView?, leftButtons: [UIButton]?, rightButtons: [UIButton]?) {
self.image = image self.image = image
self.titleLabel = titleLabel self.titleLabel = titleLabel
self.contentView = contentView self.contentView = contentView
self.leftButtons = leftButtons self.leftButtons = leftButtons ?? []
self.rightButtons = rightButtons self.rightButtons = rightButtons ?? []
} }
} }
...@@ -137,7 +137,7 @@ public class CollectionViewLayout: UICollectionViewLayout { ...@@ -137,7 +137,7 @@ public class CollectionViewLayout: UICollectionViewLayout {
for i in 0..<dataSourceItems.count { for i in 0..<dataSourceItems.count {
let item: DataSourceItem = dataSourceItems[i] let item: DataSourceItem = dataSourceItems[i]
let indexPath = IndexPath(item: i, section: 0) let indexPath = IndexPath(item: i, section: 0)
layoutItems.append((layoutAttributesForItem(at: indexPath)!, indexPath)) layoutItems.append((layoutAttributesForItem(at: indexPath)!, indexPath as NSIndexPath))
offset.x += interimSpace offset.x += interimSpace
offset.x += nil == item.width ? itemSize.width : item.width! offset.x += nil == item.width ? itemSize.width : item.width!
......
...@@ -164,58 +164,57 @@ public class ControlView: View { ...@@ -164,58 +164,57 @@ public class ControlView: View {
if willRenderView { if willRenderView {
layoutIfNeeded() layoutIfNeeded()
if let g: Int = Int(width / gridFactor) { let g = Int(width / gridFactor)
let columns: Int = g + 1 let columns = g + 1
grid.views = [] grid.views = []
grid.axis.columns = columns grid.axis.columns = columns
contentView.grid.columns = columns contentView.grid.columns = columns
// leftControls // leftControls
if let v = leftControls { if let v = leftControls {
for c in v { for c in v {
let w: CGFloat = c.intrinsicContentSize.width let w: CGFloat = c.intrinsicContentSize.width
(c as? UIButton)?.contentEdgeInsets = UIEdgeInsets.zero (c as? UIButton)?.contentEdgeInsets = UIEdgeInsets.zero
c.frame.size.height = frame.size.height - contentInset.top - contentInset.bottom c.frame.size.height = frame.size.height - contentInset.top - contentInset.bottom
let q: Int = Int(w / gridFactor) let q: Int = Int(w / gridFactor)
c.grid.columns = q + 1 c.grid.columns = q + 1
contentView.grid.columns -= c.grid.columns contentView.grid.columns -= c.grid.columns
addSubview(c) addSubview(c)
grid.views.append(c) grid.views.append(c)
} }
} }
addSubview(contentView) addSubview(contentView)
grid.views.append(contentView) grid.views.append(contentView)
// rightControls // rightControls
if let v = rightControls { if let v = rightControls {
for c in v { for c in v {
let w: CGFloat = c.intrinsicContentSize.width let w: CGFloat = c.intrinsicContentSize.width
(c as? UIButton)?.contentEdgeInsets = UIEdgeInsets.zero (c as? UIButton)?.contentEdgeInsets = UIEdgeInsets.zero
c.frame.size.height = frame.size.height - contentInset.top - contentInset.bottom c.frame.size.height = frame.size.height - contentInset.top - contentInset.bottom
let q: Int = Int(w / gridFactor) let q: Int = Int(w / gridFactor)
c.grid.columns = q + 1 c.grid.columns = q + 1
contentView.grid.columns -= c.grid.columns contentView.grid.columns -= c.grid.columns
addSubview(c) addSubview(c)
grid.views.append(c) grid.views.append(c)
} }
} }
grid.contentEdgeInsets = contentInset grid.contentEdgeInsets = contentInset
grid.interimSpace = interimSpace grid.interimSpace = interimSpace
grid.reload() grid.reload()
contentView.grid.reload() contentView.grid.reload()
} }
} }
}
/** /**
Prepares the view instance when intialized. When subclassing, Prepares the view instance when intialized. When subclassing,
......
...@@ -32,7 +32,7 @@ import UIKit ...@@ -32,7 +32,7 @@ import UIKit
public struct DataSourceItem { public struct DataSourceItem {
/// Stores an the data for the item. /// Stores an the data for the item.
public var data: AnyObject? public var data: Any?
/// Width for horizontal scroll direction. /// Width for horizontal scroll direction.
public var width: CGFloat? public var width: CGFloat?
...@@ -42,12 +42,12 @@ public struct DataSourceItem { ...@@ -42,12 +42,12 @@ public struct DataSourceItem {
/** /**
Initializer. Initializer.
- Parameter data: A reference to an AnyObject that is associated - Parameter data: A reference to an Any that is associated
with a width or height. with a width or height.
- Parameter width: The width for the horizontal scroll direction. - Parameter width: The width for the horizontal scroll direction.
- Parameter height: The height for the vertical scroll direction. - Parameter height: The height for the vertical scroll direction.
*/ */
public init(data: AnyObject? = nil, width: CGFloat? = nil, height: CGFloat? = nil) { public init(data: Any? = nil, width: CGFloat? = nil, height: CGFloat? = nil) {
self.data = data self.data = data
self.width = width self.width = width
self.height = height self.height = height
......
...@@ -96,8 +96,8 @@ private class FontLoader { ...@@ -96,8 +96,8 @@ private class FontLoader {
var error: Unmanaged<CFError>? var error: Unmanaged<CFError>?
if !CTFontManagerRegisterGraphicsFont(font, &error) { if !CTFontManagerRegisterGraphicsFont(font, &error) {
let errorDescription = CFErrorCopyDescription(error!.takeUnretainedValue()) let errorDescription = CFErrorCopyDescription(error!.takeUnretainedValue())
let nsError = error!.takeUnretainedValue() as AnyObject as! Error let nsError = error!.takeUnretainedValue() as Any as! Error
NSException(name: .internalInconsistencyException, reason: errorDescription as? String, userInfo: [NSUnderlyingErrorKey: nsError as AnyObject]).raise() NSException(name: .internalInconsistencyException, reason: errorDescription as? String, userInfo: [NSUnderlyingErrorKey: nsError as Any]).raise()
} }
} }
} }
......
...@@ -258,7 +258,7 @@ public class ImageCard: PulseView { ...@@ -258,7 +258,7 @@ public class ImageCard: PulseView {
/** /**
:name: leftButtons :name: leftButtons
*/ */
public var leftButtons: Array<UIButton>? { public var leftButtons = [UIButton]() {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -285,7 +285,7 @@ public class ImageCard: PulseView { ...@@ -285,7 +285,7 @@ public class ImageCard: PulseView {
/** /**
:name: rightButtons :name: rightButtons
*/ */
public var rightButtons: Array<UIButton>? { public var rightButtons = [UIButton]() {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -315,7 +315,7 @@ public class ImageCard: PulseView { ...@@ -315,7 +315,7 @@ public class ImageCard: PulseView {
/** /**
:name: init :name: init
*/ */
public convenience init?(image: UIImage? = nil, titleLabel: UILabel? = nil, contentView: UIView? = nil, leftButtons: Array<UIButton>? = nil, rightButtons: Array<UIButton>? = nil) { public convenience init?(image: UIImage? = nil, titleLabel: UILabel? = nil, contentView: UIView? = nil, leftButtons: [UIButton]? = nil, rightButtons: [UIButton]? = nil) {
self.init(frame: CGRect.zero) self.init(frame: CGRect.zero)
prepareProperties(image: image, titleLabel: titleLabel, contentView: contentView, leftButtons: leftButtons, rightButtons: rightButtons) prepareProperties(image: image, titleLabel: titleLabel, contentView: contentView, leftButtons: leftButtons, rightButtons: rightButtons)
} }
...@@ -332,10 +332,10 @@ public class ImageCard: PulseView { ...@@ -332,10 +332,10 @@ public class ImageCard: PulseView {
// divider // divider
if divider { if divider {
var y: CGFloat = contentInset.bottom + dividerInset.bottom var y: CGFloat = contentInset.bottom + dividerInset.bottom
if 0 < leftButtons?.count { if 0 < leftButtons.count {
y += leftButtonsInset.top + leftButtonsInset.bottom + leftButtons![0].frame.height y += leftButtonsInset.top + leftButtonsInset.bottom + leftButtons[0].frame.height
} else if 0 < rightButtons?.count { } else if 0 < rightButtons.count {
y += rightButtonsInset.top + rightButtonsInset.bottom + rightButtons![0].frame.height y += rightButtonsInset.top + rightButtonsInset.bottom + rightButtons[0].frame.height
} }
if 0 < y { if 0 < y {
prepareDivider(y: bounds.height - y - 0.5, width: bounds.width) prepareDivider(y: bounds.height - y - 0.5, width: bounds.width)
...@@ -358,8 +358,8 @@ public class ImageCard: PulseView { ...@@ -358,8 +358,8 @@ public class ImageCard: PulseView {
} }
var verticalFormat: String = "V:|" var verticalFormat: String = "V:|"
var views: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>() var views: Dictionary<String, Any> = Dictionary<String, Any>()
var metrics: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>() var metrics: Dictionary<String, Any> = Dictionary<String, Any>()
if nil != imageLayer?.contents { if nil != imageLayer?.contents {
verticalFormat += "-(insetTop)" verticalFormat += "-(insetTop)"
...@@ -399,71 +399,67 @@ public class ImageCard: PulseView { ...@@ -399,71 +399,67 @@ public class ImageCard: PulseView {
} }
// leftButtons // leftButtons
if let v: Array<UIButton> = leftButtons { if 0 < leftButtons.count {
if 0 < v.count { var h: String = "H:|"
var h: String = "H:|" var d: Dictionary<String, Any> = Dictionary<String, Any>()
var d: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>() var i: Int = 0
var i: Int = 0 for b in leftButtons {
for b in v { let k: String = "b\(i)"
let k: String = "b\(i)"
d[k] = b
d[k] = b
if 0 == i {
if 0 == i { h += "-(left)-"
h += "-(left)-" } else {
} else { h += "-(left_right)-"
h += "-(left_right)-" }
}
h += "[\(k)]"
h += "[\(k)]"
_ = layout(b).bottom(contentInset.bottom + leftButtonsInset.bottom)
_ = layout(b).bottom(contentInset.bottom + leftButtonsInset.bottom)
i += 1
i += 1 }
}
addConstraints(Layout.constraint(format: h, options: [], metrics: ["left" : contentInset.left + leftButtonsInset.left, "left_right" : leftButtonsInset.left + leftButtonsInset.right], views: d))
addConstraints(Layout.constraint(format: h, options: [], metrics: ["left" : contentInset.left + leftButtonsInset.left, "left_right" : leftButtonsInset.left + leftButtonsInset.right], views: d)) }
}
}
// rightButtons // rightButtons
if let v: Array<UIButton> = rightButtons { if 0 < rightButtons.count {
if 0 < v.count { var h: String = "H:"
var h: String = "H:" var d: Dictionary<String, Any> = Dictionary<String, Any>()
var d: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>() var i: Int = rightButtons.count - 1
var i: Int = v.count - 1
for b in rightButtons {
for b in v { let k: String = "b\(i)"
let k: String = "b\(i)"
d[k] = b
d[k] = b
h += "[\(k)]"
h += "[\(k)]"
if 0 == i {
if 0 == i { h += "-(right)-"
h += "-(right)-" } else {
} else { h += "-(right_left)-"
h += "-(right_left)-" }
}
_ = layout(b).bottom(contentInset.bottom + rightButtonsInset.bottom)
_ = layout(b).bottom(contentInset.bottom + rightButtonsInset.bottom)
i -= 1
i -= 1 }
}
addConstraints(Layout.constraint(format: h + "|", options: [], metrics: ["right" : contentInset.right + rightButtonsInset.right, "right_left" : rightButtonsInset.right + rightButtonsInset.left], views: d))
addConstraints(Layout.constraint(format: h + "|", options: [], metrics: ["right" : contentInset.right + rightButtonsInset.right, "right_left" : rightButtonsInset.right + rightButtonsInset.left], views: d)) }
}
}
if nil == imageLayer?.contents { if nil == imageLayer?.contents {
if 0 < leftButtons?.count { if 0 < leftButtons.count {
verticalFormat += "-(insetC)-[button]" verticalFormat += "-(insetC)-[button]"
views["button"] = leftButtons![0] views["button"] = leftButtons[0]
metrics["insetC"] = leftButtonsInset.top metrics["insetC"] = leftButtonsInset.top
metrics["insetBottom"] = contentInset.bottom + leftButtonsInset.bottom metrics["insetBottom"] = contentInset.bottom + leftButtonsInset.bottom
} else if 0 < rightButtons?.count { } else if 0 < rightButtons.count {
verticalFormat += "-(insetC)-[button]" verticalFormat += "-(insetC)-[button]"
views["button"] = rightButtons![0] views["button"] = rightButtons[0]
metrics["insetC"] = rightButtonsInset.top metrics["insetC"] = rightButtonsInset.top
metrics["insetBottom"] = contentInset.bottom + rightButtonsInset.bottom metrics["insetBottom"] = contentInset.bottom + rightButtonsInset.bottom
} }
...@@ -484,14 +480,14 @@ public class ImageCard: PulseView { ...@@ -484,14 +480,14 @@ public class ImageCard: PulseView {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + contentInset.top + (divider ? dividerInset.top + dividerInset.bottom : 0) metrics["insetC"] = (metrics["insetC"] as! CGFloat) + contentInset.top + (divider ? dividerInset.top + dividerInset.bottom : 0)
} }
} else if nil != contentView { } else if nil != contentView {
if 0 < leftButtons?.count { if 0 < leftButtons.count {
verticalFormat += "-(insetC)-[button]" verticalFormat += "-(insetC)-[button]"
views["button"] = leftButtons![0] views["button"] = leftButtons[0]
metrics["insetC"] = leftButtonsInset.top metrics["insetC"] = leftButtonsInset.top
metrics["insetBottom"] = contentInset.bottom + leftButtonsInset.bottom metrics["insetBottom"] = contentInset.bottom + leftButtonsInset.bottom
} else if 0 < rightButtons?.count { } else if 0 < rightButtons.count {
verticalFormat += "-(insetC)-[button]" verticalFormat += "-(insetC)-[button]"
views["button"] = rightButtons![0] views["button"] = rightButtons[0]
metrics["insetC"] = rightButtonsInset.top metrics["insetC"] = rightButtonsInset.top
metrics["insetBottom"] = contentInset.bottom + rightButtonsInset.bottom metrics["insetBottom"] = contentInset.bottom + rightButtonsInset.bottom
} }
...@@ -502,14 +498,14 @@ public class ImageCard: PulseView { ...@@ -502,14 +498,14 @@ public class ImageCard: PulseView {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + contentViewInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0) metrics["insetC"] = (metrics["insetC"] as! CGFloat) + contentViewInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
} }
} else { } else {
if 0 < leftButtons?.count { if 0 < leftButtons.count {
verticalFormat += "-[button]" verticalFormat += "-[button]"
views["button"] = leftButtons![0] views["button"] = leftButtons[0]
metrics["insetTop"] = (metrics["insetTop"] as! CGFloat) + contentInset.top + leftButtonsInset.top + (divider ? dividerInset.top + dividerInset.bottom : 0) metrics["insetTop"] = (metrics["insetTop"] as! CGFloat) + contentInset.top + leftButtonsInset.top + (divider ? dividerInset.top + dividerInset.bottom : 0)
metrics["insetBottom"] = contentInset.bottom + leftButtonsInset.bottom metrics["insetBottom"] = contentInset.bottom + leftButtonsInset.bottom
} else if 0 < rightButtons?.count { } else if 0 < rightButtons.count {
verticalFormat += "-[button]" verticalFormat += "-[button]"
views["button"] = rightButtons![0] views["button"] = rightButtons[0]
metrics["insetTop"] = (metrics["insetTop"] as! CGFloat) + contentInset.top + rightButtonsInset.top + (divider ? dividerInset.top + dividerInset.bottom : 0) metrics["insetTop"] = (metrics["insetTop"] as! CGFloat) + contentInset.top + rightButtonsInset.top + (divider ? dividerInset.top + dividerInset.bottom : 0)
metrics["insetBottom"] = contentInset.bottom + rightButtonsInset.bottom metrics["insetBottom"] = contentInset.bottom + rightButtonsInset.bottom
} else { } else {
...@@ -565,11 +561,11 @@ public class ImageCard: PulseView { ...@@ -565,11 +561,11 @@ public class ImageCard: PulseView {
/** /**
:name: prepareProperties :name: prepareProperties
*/ */
internal func prepareProperties(image: UIImage?, titleLabel: UILabel?, contentView: UIView?, leftButtons: Array<UIButton>?, rightButtons: Array<UIButton>?) { internal func prepareProperties(image: UIImage?, titleLabel: UILabel?, contentView: UIView?, leftButtons: [UIButton]?, rightButtons: [UIButton]?) {
self.image = image self.image = image
self.titleLabel = titleLabel self.titleLabel = titleLabel
self.contentView = contentView self.contentView = contentView
self.leftButtons = leftButtons self.leftButtons = leftButtons ?? []
self.rightButtons = rightButtons self.rightButtons = rightButtons ?? []
} }
} }
...@@ -41,20 +41,20 @@ public class JSON: Equatable, CustomStringConvertible { ...@@ -41,20 +41,20 @@ public class JSON: Equatable, CustomStringConvertible {
/** /**
:name: object :name: object
*/ */
public private(set) var object: AnyObject public private(set) var object: Any
/** /**
:name: asArray :name: asArray
*/ */
public var asArray: [AnyObject]? { public var asArray: [Any]? {
return object as? [AnyObject] return object as? [Any]
} }
/** /**
:name: asDictionary :name: asDictionary
*/ */
public var asDictionary: [String: AnyObject]? { public var asDictionary: [String: Any]? {
return object as? [String: AnyObject] return object as? [String: Any]
} }
/** /**
...@@ -95,7 +95,7 @@ public class JSON: Equatable, CustomStringConvertible { ...@@ -95,7 +95,7 @@ public class JSON: Equatable, CustomStringConvertible {
/** /**
:name: asNSData :name: asNSData
*/ */
public var asNSData: NSData? { public var asNSData: Data? {
return JSON.serialize(object: object) return JSON.serialize(object: object)
} }
...@@ -122,14 +122,14 @@ public class JSON: Equatable, CustomStringConvertible { ...@@ -122,14 +122,14 @@ public class JSON: Equatable, CustomStringConvertible {
/** /**
:name: serialize :name: serialize
*/ */
public class func serialize(object: AnyObject) -> Data? { public class func serialize(object: Any) -> Data? {
return try? JSONSerialization.data(withJSONObject: object, options: []) return try? JSONSerialization.data(withJSONObject: object, options: [])
} }
/** /**
:name: stringify :name: stringify
*/ */
public class func stringify(_ object: AnyObject) -> String? { public class func stringify(_ object: Any) -> String? {
if let o = object as? JSON { if let o = object as? JSON {
return stringify(o.object) return stringify(o.object)
} else if let data = JSON.serialize(object: object) { } else if let data = JSON.serialize(object: object) {
...@@ -143,7 +143,7 @@ public class JSON: Equatable, CustomStringConvertible { ...@@ -143,7 +143,7 @@ public class JSON: Equatable, CustomStringConvertible {
/** /**
:name: init :name: init
*/ */
public required init(_ object: AnyObject) { public required init(_ object: Any) {
if let o = object as? JSON { if let o = object as? JSON {
self.object = o.object self.object = o.object
} else { } else {
......
...@@ -196,9 +196,7 @@ public class Layer: CAShapeLayer { ...@@ -196,9 +196,7 @@ public class Layer: CAShapeLayer {
*/ */
public var cornerRadiusPreset: CornerRadiusPreset = .none { public var cornerRadiusPreset: CornerRadiusPreset = .none {
didSet { didSet {
if let v: CornerRadiusPreset = cornerRadiusPreset { cornerRadius = CornerRadiusPresetToValue(preset: cornerRadiusPreset)
cornerRadius = CornerRadiusPresetToValue(preset: v)
}
} }
} }
...@@ -254,9 +252,9 @@ public class Layer: CAShapeLayer { ...@@ -254,9 +252,9 @@ public class Layer: CAShapeLayer {
/** /**
An initializer the same as init(). The layer parameter is ignored An initializer the same as init(). The layer parameter is ignored
to avoid crashes on certain architectures. to avoid crashes on certain architectures.
- Parameter layer: AnyObject. - Parameter layer: Any.
*/ */
public override init(layer: AnyObject) { public override init(layer: Any) {
contentsGravityPreset = .ResizeAspectFill contentsGravityPreset = .ResizeAspectFill
super.init() super.init()
prepareVisualLayer() prepareVisualLayer()
......
...@@ -850,11 +850,11 @@ extension Layout { ...@@ -850,11 +850,11 @@ extension Layout {
Creats an Array with a NSLayoutConstraint value. Creats an Array with a NSLayoutConstraint value.
- Parameter format: The VFL format string. - Parameter format: The VFL format string.
- Parameter options: Additional NSLayoutFormatOptions. - Parameter options: Additional NSLayoutFormatOptions.
- Parameter metrics: An optional Dictionary<String, AnyObject> of metric key / value pairs. - Parameter metrics: An optional Dictionary<String, Any> of metric key / value pairs.
- Parameter views: A Dictionary<String, AnyObject> of view key / value pairs. - Parameter views: A Dictionary<String, Any> of view key / value pairs.
- Returns: The Array<NSLayoutConstraint> instance. - Returns: The Array<NSLayoutConstraint> instance.
*/ */
public class func constraint(format: String, options: NSLayoutFormatOptions, metrics: Dictionary<String, AnyObject>?, views: Dictionary<String, AnyObject>) -> Array<NSLayoutConstraint> { public class func constraint(format: String, options: NSLayoutFormatOptions, metrics: Dictionary<String, Any>?, views: Dictionary<String, Any>) -> Array<NSLayoutConstraint> {
for (_, a) in views { for (_, a) in views {
if let v = a as? UIView { if let v = a as? UIView {
v.translatesAutoresizingMaskIntoConstraints = false v.translatesAutoresizingMaskIntoConstraints = false
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
- Parameter initializer: Object initializer. - Parameter initializer: Object initializer.
- Returns: The associated reference for the initializer object. - Returns: The associated reference for the initializer object.
*/ */
internal func AssociatedObject<T: AnyObject>(base: AnyObject, key: UnsafePointer<UInt8>, initializer: () -> T) -> T { internal func AssociatedObject<T: Any>(base: Any, key: UnsafePointer<UInt8>, initializer: () -> T) -> T {
if let v: T = objc_getAssociatedObject(base, key) as? T { if let v: T = objc_getAssociatedObject(base, key) as? T {
return v return v
} }
...@@ -52,6 +52,6 @@ internal func AssociatedObject<T: AnyObject>(base: AnyObject, key: UnsafePointer ...@@ -52,6 +52,6 @@ internal func AssociatedObject<T: AnyObject>(base: AnyObject, key: UnsafePointer
- Parameter value: The object instance to set for the associated object. - Parameter value: The object instance to set for the associated object.
- Returns: The associated reference for the initializer object. - Returns: The associated reference for the initializer object.
*/ */
internal func AssociateObject<T: AnyObject>(base: AnyObject, key: UnsafePointer<UInt8>, value: T) { internal func AssociateObject<T: Any>(base: Any, key: UnsafePointer<UInt8>, value: T) {
objc_setAssociatedObject(base, key, value, .OBJC_ASSOCIATION_RETAIN) objc_setAssociatedObject(base, key, value, .OBJC_ASSOCIATION_RETAIN)
} }
...@@ -63,7 +63,7 @@ extension String { ...@@ -63,7 +63,7 @@ extension String {
:name: replacePunctuationCharacters :name: replacePunctuationCharacters
*/ */
public func replacePunctuationCharacters(separator: String = "") -> String { public func replacePunctuationCharacters(separator: String = "") -> String {
return components(separatedBy: CharacterSet.punctuation).joined(separator: separator).trim() return components(separatedBy: CharacterSet.punctuationCharacters).joined(separator: separator).trim()
} }
/** /**
......
...@@ -185,13 +185,13 @@ extension UIImage { ...@@ -185,13 +185,13 @@ extension UIImage {
- Parameter completion: A completion block that is executed once the image - Parameter completion: A completion block that is executed once the image
has been retrieved. has been retrieved.
*/ */
public class func contentsOfURL(url: URL, completion: ((image: UIImage?, error: Error?) -> Void)) { public class func contentsOfURL(url: URL, completion: ((UIImage?, Error?) -> Void)) {
URLSession.shared.dataTask(with: URLRequest(url: url)) { (data: Data?, response: URLResponse?, error: Error?) in URLSession.shared.dataTask(with: URLRequest(url: url)) { (data: Data?, response: URLResponse?, error: Error?) in
DispatchQueue.main.async { DispatchQueue.main.async {
if let v = error { if let v = error {
completion(image: nil, error: v) completion(nil, v)
} else if let v = data { } else if let v = data {
completion(image: UIImage(data: v), error: nil) completion(UIImage(data: v), nil)
} }
} }
}.resume() }.resume()
...@@ -246,9 +246,9 @@ extension UIImage { ...@@ -246,9 +246,9 @@ extension UIImage {
switch imageOrientation { switch imageOrientation {
case .left, .leftMirrored, .right, .rightMirrored: case .left, .leftMirrored, .right, .rightMirrored:
context.draw(in: CGRect(x: 0, y: 0, width: size.height, height: size.width), image: cgImage!) context.draw(cgImage!, in: CGRect(x: 0, y: 0, width: size.height, height: size.width))
default: default:
context.draw(in: CGRect(origin: .zero, size: size), image: cgImage!) context.draw(cgImage!, in: CGRect(origin: .zero, size: size))
} }
guard let cgImage = context.makeImage() else { guard let cgImage = context.makeImage() else {
......
...@@ -48,10 +48,7 @@ public class Material { ...@@ -48,10 +48,7 @@ public class Material {
guard let v = view else { guard let v = view else {
return return
} }
v.cornerRadius = CornerRadiusPresetToValue(preset: cornerRadiusPreset)
if let preset: CornerRadiusPreset = cornerRadiusPreset {
v.cornerRadius = CornerRadiusPresetToValue(preset: preset)
}
} }
} }
...@@ -61,10 +58,7 @@ public class Material { ...@@ -61,10 +58,7 @@ public class Material {
guard let v = view else { guard let v = view else {
return return
} }
v.borderWidth = BorderWidthPresetToValue(preset: borderWidthPreset)
if let preset: BorderWidthPreset = borderWidthPreset {
v.borderWidth = BorderWidthPresetToValue(preset: preset)
}
} }
} }
......
...@@ -48,7 +48,7 @@ public class MaterialTextLayer : CATextLayer { ...@@ -48,7 +48,7 @@ public class MaterialTextLayer : CATextLayer {
*/ */
@IBInspectable public var text: String? { @IBInspectable public var text: String? {
didSet { didSet {
string = text as? AnyObject string = text as Any
} }
} }
...@@ -171,7 +171,7 @@ public class MaterialTextLayer : CATextLayer { ...@@ -171,7 +171,7 @@ public class MaterialTextLayer : CATextLayer {
/** /**
:name: init :name: init
*/ */
public override init(layer: AnyObject) { public override init(layer: Any) {
super.init() super.init()
prepareLayer() prepareLayer()
} }
...@@ -196,12 +196,10 @@ public class MaterialTextLayer : CATextLayer { ...@@ -196,12 +196,10 @@ public class MaterialTextLayer : CATextLayer {
:name: stringSize :name: stringSize
*/ */
public func stringSize(constrainedToWidth width: Double) -> CGSize { public func stringSize(constrainedToWidth width: Double) -> CGSize {
if let v = fontType { guard let v = fontType, let t = text, 0 < t.utf16.count else {
if 0 < text?.utf16.count { return CGSize.zero
return v.stringSize(string: text!, constrainedToWidth: width) }
} return v.stringSize(string: text!, constrainedToWidth: width)
}
return CGSize.zero
} }
/** /**
......
...@@ -196,93 +196,92 @@ public class NavigationBar: UINavigationBar { ...@@ -196,93 +196,92 @@ public class NavigationBar: UINavigationBar {
let titleView = prepareTitleView(item: item) let titleView = prepareTitleView(item: item)
let contentView = prepareContentView(item: item) let contentView = prepareContentView(item: item)
if let g: Int = Int(width / gridFactor) { let g = Int(width / gridFactor)
let columns: Int = g + 1 let columns = g + 1
titleView.frame.origin = CGPoint.zero titleView.frame.origin = CGPoint.zero
titleView.frame.size = intrinsicContentSize titleView.frame.size = intrinsicContentSize
titleView.grid.views = [] titleView.grid.views = []
titleView.grid.axis.columns = columns titleView.grid.axis.columns = columns
contentView.grid.columns = columns contentView.grid.columns = columns
// leftControls // leftControls
if let v: Array<UIControl> = item.leftControls { if let v: Array<UIControl> = item.leftControls {
for c in v { for c in v {
let w: CGFloat = c.intrinsicContentSize.width let w: CGFloat = c.intrinsicContentSize.width
(c as? UIButton)?.contentEdgeInsets = UIEdgeInsets.zero (c as? UIButton)?.contentEdgeInsets = UIEdgeInsets.zero
c.frame.size.height = titleView.frame.size.height - contentInset.top - contentInset.bottom c.frame.size.height = titleView.frame.size.height - contentInset.top - contentInset.bottom
let q: Int = Int(w / gridFactor) let q: Int = Int(w / gridFactor)
c.grid.columns = q + 1 c.grid.columns = q + 1
contentView.grid.columns -= c.grid.columns contentView.grid.columns -= c.grid.columns
titleView.addSubview(c) titleView.addSubview(c)
titleView.grid.views.append(c) titleView.grid.views.append(c)
}
} }
}
titleView.addSubview(contentView)
titleView.grid.views.append(contentView) titleView.addSubview(contentView)
titleView.grid.views.append(contentView)
// rightControls
if let v: Array<UIControl> = item.rightControls { // rightControls
for c in v { if let v: Array<UIControl> = item.rightControls {
let w: CGFloat = c.intrinsicContentSize.width for c in v {
(c as? UIButton)?.contentEdgeInsets = UIEdgeInsets.zero let w: CGFloat = c.intrinsicContentSize.width
c.frame.size.height = titleView.frame.size.height - contentInset.top - contentInset.bottom (c as? UIButton)?.contentEdgeInsets = UIEdgeInsets.zero
c.frame.size.height = titleView.frame.size.height - contentInset.top - contentInset.bottom
let q: Int = Int(w / gridFactor)
c.grid.columns = q + 1 let q: Int = Int(w / gridFactor)
c.grid.columns = q + 1
contentView.grid.columns -= c.grid.columns
contentView.grid.columns -= c.grid.columns
titleView.addSubview(c)
titleView.grid.views.append(c) titleView.addSubview(c)
} titleView.grid.views.append(c)
} }
}
titleView.grid.contentEdgeInsets = contentInset
titleView.grid.interimSpace = interimSpace titleView.grid.contentEdgeInsets = contentInset
titleView.grid.reload() titleView.grid.interimSpace = interimSpace
titleView.grid.reload()
// contentView alignment.
if nil != item.title && "" != item.title { // contentView alignment.
if nil == item.titleLabel.superview { if nil != item.title && "" != item.title {
contentView.addSubview(item.titleLabel) if nil == item.titleLabel.superview {
} contentView.addSubview(item.titleLabel)
item.titleLabel.frame = contentView.bounds }
} else { item.titleLabel.frame = contentView.bounds
item.titleLabel.removeFromSuperview() } else {
item.titleLabel.removeFromSuperview()
}
if nil != item.detail && "" != item.detail {
if nil == item.detailLabel.superview {
contentView.addSubview(item.detailLabel)
} }
if nil != item.detail && "" != item.detail { if nil == item.titleLabel.superview {
if nil == item.detailLabel.superview { item.detailLabel.frame = contentView.bounds
contentView.addSubview(item.detailLabel)
}
if nil == item.titleLabel.superview {
item.detailLabel.frame = contentView.bounds
} else {
item.titleLabel.sizeToFit()
item.detailLabel.sizeToFit()
let diff: CGFloat = (contentView.frame.height - item.titleLabel.frame.height - item.detailLabel.frame.height) / 2
item.titleLabel.frame.size.height += diff
item.titleLabel.frame.size.width = contentView.frame.width
item.detailLabel.frame.size.height += diff
item.detailLabel.frame.size.width = contentView.frame.width
item.detailLabel.frame.origin.y = item.titleLabel.frame.height
}
} else { } else {
item.detailLabel.removeFromSuperview() item.titleLabel.sizeToFit()
item.detailLabel.sizeToFit()
let diff: CGFloat = (contentView.frame.height - item.titleLabel.frame.height - item.detailLabel.frame.height) / 2
item.titleLabel.frame.size.height += diff
item.titleLabel.frame.size.width = contentView.frame.width
item.detailLabel.frame.size.height += diff
item.detailLabel.frame.size.width = contentView.frame.width
item.detailLabel.frame.origin.y = item.titleLabel.frame.height
} }
} else {
contentView.grid.reload() item.detailLabel.removeFromSuperview()
} }
contentView.grid.reload()
} }
} }
......
...@@ -185,7 +185,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -185,7 +185,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
A CGFloat property that sets the animation duration of the A CGFloat property that sets the animation duration of the
leftView when closing and opening. Defaults to 0.25. leftView when closing and opening. Defaults to 0.25.
*/ */
@IBInspectable public var animationDuration: CGFloat = 0.25 @IBInspectable public var animationDuration: TimeInterval = 0.25
/** /**
A Boolean property that enables and disables the leftView from A Boolean property that enables and disables the leftView from
...@@ -619,7 +619,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -619,7 +619,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
showView(container: v) showView(container: v)
isUserInteractionEnabled = false isUserInteractionEnabled = false
delegate?.navigationDrawerWillOpen?(navigationDrawerController: self, position: .left) delegate?.navigationDrawerWillOpen?(navigationDrawerController: self, position: .left)
UIView.animate(withDuration: Double(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))), UIView.animate(withDuration: TimeInterval(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))),
animations: { animations: {
v.position.x = v.width / 2 v.position.x = v.width / 2
self.rootViewController.view.alpha = 0.5 self.rootViewController.view.alpha = 0.5
...@@ -645,7 +645,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -645,7 +645,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
showView(container: v) showView(container: v)
isUserInteractionEnabled = false isUserInteractionEnabled = false
delegate?.navigationDrawerWillOpen?(navigationDrawerController: self, position: .right) delegate?.navigationDrawerWillOpen?(navigationDrawerController: self, position: .right)
UIView.animate(withDuration: Double(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))), UIView.animate(withDuration: TimeInterval(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))),
animations: { [weak self] in animations: { [weak self] in
if let s = self { if let s = self {
v.position.x = s.view.bounds.width - v.width / 2 v.position.x = s.view.bounds.width - v.width / 2
...@@ -671,7 +671,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -671,7 +671,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
if let v: View = leftView { if let v: View = leftView {
isUserInteractionEnabled = true isUserInteractionEnabled = true
delegate?.navigationDrawerWillClose?(navigationDrawerController: self, position: .left) delegate?.navigationDrawerWillClose?(navigationDrawerController: self, position: .left)
UIView.animate(withDuration: Double(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))), UIView.animate(withDuration: TimeInterval(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))),
animations: { [weak self] in animations: { [weak self] in
if let s = self { if let s = self {
v.position.x = -v.width / 2 v.position.x = -v.width / 2
...@@ -699,7 +699,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele ...@@ -699,7 +699,7 @@ public class NavigationDrawerController: RootController, UIGestureRecognizerDele
if let v: View = rightView { if let v: View = rightView {
isUserInteractionEnabled = true isUserInteractionEnabled = true
delegate?.navigationDrawerWillClose?(navigationDrawerController: self, position: .right) delegate?.navigationDrawerWillClose?(navigationDrawerController: self, position: .right)
UIView.animate(withDuration: Double(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))), UIView.animate(withDuration: TimeInterval(0 == velocity ? animationDuration : fmax(0.1, fmin(1, Double(v.x / velocity)))),
animations: { [weak self] in animations: { [weak self] in
if let s = self { if let s = self {
v.position.x = s.view.bounds.width + v.width / 2 v.position.x = s.view.bounds.width + v.width / 2
......
...@@ -315,7 +315,7 @@ public class Switch: UIControl { ...@@ -315,7 +315,7 @@ public class Switch: UIControl {
Toggle the Switch state, if On will be Off, and if Off will be On. Toggle the Switch state, if On will be Off, and if Off will be On.
- Parameter completion: An Optional completion block. - Parameter completion: An Optional completion block.
*/ */
public func toggle(completion: ((control: Switch) -> Void)? = nil) { public func toggle(completion: ((Switch) -> Void)? = nil) {
setSwitchState(state: .on == internalSwitchState ? .off : .on, animated: true, completion: completion) setSwitchState(state: .on == internalSwitchState ? .off : .on, animated: true, completion: completion)
} }
...@@ -324,7 +324,7 @@ public class Switch: UIControl { ...@@ -324,7 +324,7 @@ public class Switch: UIControl {
- Parameter on: A bool of whether the switch should be in the on state or not. - Parameter on: A bool of whether the switch should be in the on state or not.
- Parameter animated: A Boolean indicating to set the animation or not. - Parameter animated: A Boolean indicating to set the animation or not.
*/ */
public func setOn(on: Bool, animated: Bool, completion: ((control: Switch) -> Void)? = nil) { public func setOn(on: Bool, animated: Bool, completion: ((Switch) -> Void)? = nil) {
setSwitchState(state: on ? .on : .off, animated: animated, completion: completion) setSwitchState(state: on ? .on : .off, animated: animated, completion: completion)
} }
...@@ -334,14 +334,14 @@ public class Switch: UIControl { ...@@ -334,14 +334,14 @@ public class Switch: UIControl {
- Parameter animated: A Boolean indicating to set the animation or not. - Parameter animated: A Boolean indicating to set the animation or not.
- Parameter completion: An Optional completion block. - Parameter completion: An Optional completion block.
*/ */
public func setSwitchState(state: SwitchState, animated: Bool = true, completion: ((control: Switch) -> Void)? = nil) { public func setSwitchState(state: SwitchState, animated: Bool = true, completion: ((Switch) -> Void)? = nil) {
if isEnabled && internalSwitchState != state { if isEnabled && internalSwitchState != state {
internalSwitchState = state internalSwitchState = state
if animated { if animated {
animateToState(state: state) { [weak self] _ in animateToState(state: state) { [weak self] _ in
if let s: Switch = self { if let s: Switch = self {
s.sendActions(for: .valueChanged) s.sendActions(for: .valueChanged)
completion?(control: s) completion?(s)
s.delegate?.switchStateChanged(control: s) s.delegate?.switchStateChanged(control: s)
} }
} }
...@@ -349,7 +349,7 @@ public class Switch: UIControl { ...@@ -349,7 +349,7 @@ public class Switch: UIControl {
button.x = .on == state ? self.onPosition : self.offPosition button.x = .on == state ? self.onPosition : self.offPosition
styleForState(state: state) styleForState(state: state)
sendActions(for: .valueChanged) sendActions(for: .valueChanged)
completion?(control: self) completion?(self)
delegate?.switchStateChanged(control: self) delegate?.switchStateChanged(control: self)
} }
} }
...@@ -508,7 +508,7 @@ public class Switch: UIControl { ...@@ -508,7 +508,7 @@ public class Switch: UIControl {
- Parameter state: The SwitchState to set. - Parameter state: The SwitchState to set.
- Parameter completion: An Optional completion block. - Parameter completion: An Optional completion block.
*/ */
private func animateToState(state: SwitchState, completion: ((control: Switch) -> Void)? = nil) { private func animateToState(state: SwitchState, completion: ((Switch) -> Void)? = nil) {
isUserInteractionEnabled = false isUserInteractionEnabled = false
UIView.animate(withDuration: 0.15, UIView.animate(withDuration: 0.15,
delay: 0.05, delay: 0.05,
...@@ -527,7 +527,7 @@ public class Switch: UIControl { ...@@ -527,7 +527,7 @@ public class Switch: UIControl {
}) { [weak self] _ in }) { [weak self] _ in
if let s: Switch = self { if let s: Switch = self {
s.isUserInteractionEnabled = true s.isUserInteractionEnabled = true
completion?(control: s) completion?(s)
} }
} }
} }
......
...@@ -53,15 +53,15 @@ public class TabBar: View { ...@@ -53,15 +53,15 @@ public class TabBar: View {
} }
/// Buttons. /// Buttons.
public var buttons: Array<UIButton>? { public var buttons: [UIButton]? {
didSet { didSet {
if let v: Array<UIButton> = oldValue { if let v: [UIButton] = oldValue {
for b in v { for b in v {
b.removeFromSuperview() b.removeFromSuperview()
} }
} }
if let v: Array<UIButton> = buttons { if let v: [UIButton] = buttons {
for b in v { for b in v {
addSubview(b) addSubview(b)
} }
...@@ -73,7 +73,7 @@ public class TabBar: View { ...@@ -73,7 +73,7 @@ public class TabBar: View {
public override func layoutSubviews() { public override func layoutSubviews() {
super.layoutSubviews() super.layoutSubviews()
if willRenderView { if willRenderView {
if let v: Array<UIButton> = buttons { if let v: [UIButton] = buttons {
if 0 < v.count { if 0 < v.count {
let columns: Int = grid.axis.columns / v.count let columns: Int = grid.axis.columns / v.count
for b in v { for b in v {
......
...@@ -85,7 +85,7 @@ public class TextStorage: NSTextStorage { ...@@ -85,7 +85,7 @@ public class TextStorage: NSTextStorage {
If you don't need this value, pass NULL. If you don't need this value, pass NULL.
- Returns: The attributes for the character at index. - Returns: The attributes for the character at index.
*/ */
public override func attributes(at location: Int, effectiveRange range: NSRangePointer?) -> [String : AnyObject] { public override func attributes(at location: Int, effectiveRange range: NSRangePointer?) -> [String : Any] {
return store.attributes(at: location, effectiveRange: range) return store.attributes(at: location, effectiveRange: range)
} }
...@@ -106,7 +106,7 @@ public class TextStorage: NSTextStorage { ...@@ -106,7 +106,7 @@ public class TextStorage: NSTextStorage {
- Parameter range: A range of characters that will have their - Parameter range: A range of characters that will have their
attributes updated. attributes updated.
*/ */
public override func setAttributes(_ attrs: [String : AnyObject]?, range: NSRange) { public override func setAttributes(_ attrs: [String : Any]?, range: NSRange) {
store.setAttributes(attrs, range: range) store.setAttributes(attrs, range: range)
edited(NSTextStorageEditActions.editedAttributes, range: range, changeInLength: 0) edited(NSTextStorageEditActions.editedAttributes, range: range, changeInLength: 0)
} }
......
...@@ -181,21 +181,32 @@ public class TextView: UITextView { ...@@ -181,21 +181,32 @@ public class TextView: UITextView {
p.isHidden = !(true == text?.isEmpty) p.isHidden = !(true == text?.isEmpty)
} }
if 0 < text?.utf16.count { guard let t = text else {
showTitleLabel() hideTitleLabel()
} else if 0 == text?.utf16.count { return
hideTitleLabel() }
}
if 0 < t.utf16.count {
showTitleLabel()
} else {
hideTitleLabel()
}
} }
/// Notification handler for when text editing ended. /// Notification handler for when text editing ended.
internal func handleTextViewTextDidEnd() { internal func handleTextViewTextDidEnd() {
if 0 < text?.utf16.count { guard let t = text else {
showTitleLabel() hideTitleLabel()
} else if 0 == text?.utf16.count { return
hideTitleLabel() }
}
titleLabel?.textColor = titleLabelColor if 0 < t.utf16.count {
showTitleLabel()
} else {
hideTitleLabel()
}
titleLabel?.textColor = titleLabelColor
} }
/** /**
...@@ -233,11 +244,13 @@ public class TextView: UITextView { ...@@ -233,11 +244,13 @@ public class TextView: UITextView {
if let v: UILabel = titleLabel { if let v: UILabel = titleLabel {
v.isHidden = true v.isHidden = true
addSubview(v) addSubview(v)
if 0 < text?.utf16.count {
showTitleLabel() guard let t = text, 0 == t.utf16.count else {
} else { v.alpha = 0
v.alpha = 0 return
} }
showTitleLabel()
} }
} }
......
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