Commit ac53a489 by Daniel Dahan

progression commit

parent e1fdce7a
......@@ -39,7 +39,7 @@ public class Button: UIButton {
allows the dropshadow effect on the backing layer, while clipping
the image to a desired shape within the visualLayer.
*/
public private(set) lazy var visualLayer: CAShapeLayer = CAShapeLayer()
public private(set) var visualLayer: CAShapeLayer!
/**
A base delegate reference used when subclassing View.
......@@ -196,26 +196,23 @@ public class Button: UIButton {
}
}
/**
A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer. This is the preferred method of setting depth
in order to maintain consitency across UI objects.
*/
public var depthPreset = .none {
/// A preset value for Depth.
public var depthPreset: DepthPreset = .none {
didSet {
let v = DepthPresetToValue(preset: depthPreset)
shadowOffset = v.offset
shadowOpacity = v.opacity
shadowRadius = v.radius
layoutShadowPath()
depth = DepthPresetToValue(preset: depthPreset)
}
}
/**
A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer.
*/
public var depth = Depth.zero {
didSet {
shadowOffset = depth.offset
shadowOffset = depth.offsetAsSize
shadowOpacity = depth.opacity
shadowRadius = depth.radius
layoutShadowPath()
}
}
......@@ -312,19 +309,26 @@ public class Button: UIButton {
}
/// A preset property for updated contentEdgeInsets.
public var contentEdgeInsetsPreset: InsetsPreset {
public var contentInsetPreset: InsetPreset = .none {
didSet {
let value: Insets = InsetsPresetToValue(preset: contentEdgeInsetsPreset)
contentEdgeInsets = UIEdgeInsetsMake(value.top, value.left, value.bottom, value.right)
contentInset = InsetPresetToValue(preset: contentInsetPreset)
}
}
/**
:name: contentInset
*/
@IBInspectable public var contentInset = Inset.zero {
didSet {
contentEdgeInsets = contentInset.asEdgeInsets
}
}
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
*/
public required init?(coder aDecoder: NSCoder) {
contentEdgeInsetsPreset = .none
super.init(coder: aDecoder)
prepareView()
}
......@@ -336,7 +340,6 @@ public class Button: UIButton {
- Parameter frame: A CGRect instance.
*/
public override init(frame: CGRect) {
contentEdgeInsetsPreset = .None
super.init(frame: frame)
prepareView()
}
......@@ -360,7 +363,7 @@ public class Button: UIButton {
}
public override func alignmentRectInsets() -> UIEdgeInsets {
return UIEdgeInsetsZero
return UIEdgeInset.zero
}
/**
......@@ -473,13 +476,14 @@ public class Button: UIButton {
when subclassing.
*/
public func prepareView() {
contentScaleFactor = Device.scale
contentScaleFactor = Device.scale
prepareVisualLayer()
}
/// Prepares the visualLayer property.
internal func prepareVisualLayer() {
visualLayer.zPosition = 0
visualLayer = CAShapeLayer()
visualLayer.zPosition = 0
visualLayer.masksToBounds = true
layer.addSublayer(visualLayer)
}
......@@ -503,12 +507,12 @@ public class Button: UIButton {
/// Sets the shadow path.
internal func layoutShadowPath() {
if shadowPathAutoSizeEnabled {
if .None == depth {
if .none == depthPreset {
shadowPath = nil
} else if nil == shadowPath {
shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath
shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).cgPath
} else {
animate(MaterialAnimation.shadowPath(UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath, duration: 0))
animate(animation: MaterialAnimation.shadowPath(path: UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).cgPath, duration: 0))
}
}
}
......
......@@ -274,7 +274,7 @@ public class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
var userInfo: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
userInfo[NSLocalizedDescriptionKey] = "[Material Error: Unsupported focusMode.]"
userInfo[NSLocalizedFailureReasonErrorKey] = "[Material Error: Unsupported focusMode.]"
error = NSError(domain: "io.cosmicmind.Material.CaptureView", code: 0001, userInfo: userInfo)
error = NSError(domain: "io.cosmicmind.Material.Capture", code: 0001, userInfo: userInfo)
userInfo[NSUnderlyingErrorKey] = error
}
if let e: NSError = error {
......@@ -303,7 +303,7 @@ public class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
var userInfo: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
userInfo[NSLocalizedDescriptionKey] = "[Material Error: Unsupported flashMode.]"
userInfo[NSLocalizedFailureReasonErrorKey] = "[Material Error: Unsupported flashMode.]"
error = NSError(domain: "io.cosmicmind.Material.CaptureView", code: 0002, userInfo: userInfo)
error = NSError(domain: "io.cosmicmind.Material.Capture", code: 0002, userInfo: userInfo)
userInfo[NSUnderlyingErrorKey] = error
}
if let e: NSError = error {
......@@ -332,7 +332,7 @@ public class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
var userInfo: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
userInfo[NSLocalizedDescriptionKey] = "[Material Error: Unsupported torchMode.]"
userInfo[NSLocalizedFailureReasonErrorKey] = "[Material Error: Unsupported torchMode.]"
error = NSError(domain: "io.cosmicmind.Material.CaptureView", code: 0003, userInfo: userInfo)
error = NSError(domain: "io.cosmicmind.Material.Capture", code: 0003, userInfo: userInfo)
userInfo[NSUnderlyingErrorKey] = error
}
if let e: NSError = error {
......@@ -477,7 +477,7 @@ public class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
var userInfo: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
userInfo[NSLocalizedDescriptionKey] = "[Material Error: Unsupported focus.]"
userInfo[NSLocalizedFailureReasonErrorKey] = "[Material Error: Unsupported focus.]"
error = NSError(domain: "io.cosmicmind.Material.CaptureView", code: 0004, userInfo: userInfo)
error = NSError(domain: "io.cosmicmind.Material.Capture", code: 0004, userInfo: userInfo)
userInfo[NSUnderlyingErrorKey] = error
}
if let e: NSError = error {
......@@ -508,7 +508,7 @@ public class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
var userInfo: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
userInfo[NSLocalizedDescriptionKey] = "[Material Error: Unsupported expose.]"
userInfo[NSLocalizedFailureReasonErrorKey] = "[Material Error: Unsupported expose.]"
error = NSError(domain: "io.cosmicmind.Material.CaptureView", code: 0005, userInfo: userInfo)
error = NSError(domain: "io.cosmicmind.Material.Capture", code: 0005, userInfo: userInfo)
userInfo[NSUnderlyingErrorKey] = error
}
if let e: NSError = error {
......@@ -580,14 +580,14 @@ public class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
var userInfo: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
userInfo[NSLocalizedDescriptionKey] = "[Material Error: Cannot fix image orientation.]"
userInfo[NSLocalizedFailureReasonErrorKey] = "[Material Error: Cannot fix image orientation.]"
captureError = NSError(domain: "io.cosmicmind.Material.CaptureView", code: 0006, userInfo: userInfo)
captureError = NSError(domain: "io.cosmicmind.Material.Capture", code: 0006, userInfo: userInfo)
userInfo[NSUnderlyingErrorKey] = error
}
} else {
var userInfo: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
userInfo[NSLocalizedDescriptionKey] = "[Material Error: Cannot capture image from data.]"
userInfo[NSLocalizedFailureReasonErrorKey] = "[Material Error: Cannot capture image from data.]"
captureError = NSError(domain: "io.cosmicmind.Material.CaptureView", code: 0007, userInfo: userInfo)
captureError = NSError(domain: "io.cosmicmind.Material.Capture", code: 0007, userInfo: userInfo)
userInfo[NSUnderlyingErrorKey] = error
}
}
......@@ -771,7 +771,7 @@ public class CaptureSession: NSObject, AVCaptureFileOutputRecordingDelegate {
default:break
}
// Draw the underlying CGImage with the calculated transform.
// Draw the underlying cgImage with the calculated transform.
guard let context = CGContext(data: nil, width: Int(image.size.width), height: Int(image.size.height), bitsPerComponent: image.cgImage!.bitsPerComponent, bytesPerRow: 0, space: image.cgImage!.colorSpace!, bitmapInfo: image.cgImage!.bitmapInfo.rawValue) else {
return nil
}
......
......@@ -30,7 +30,7 @@
import UIKit
public class CardView : PulseView {
public class Card: PulseView {
/**
:name: dividerLayer
*/
......@@ -57,16 +57,16 @@ public class CardView : PulseView {
/**
:name: dividerInsets
*/
public var dividerInsetPreset: InsetsPreset = .none {
public var dividerInsetPreset: InsetPreset = .none {
didSet {
dividerInset = InsetsPresetToValue(preset: dividerInsetPreset)
dividerInset = InsetPresetToValue(preset: dividerInsetPreset)
}
}
/**
:name: dividerInset
*/
@IBInspectable public var dividerInset = Insets(top: 8, left: 0, bottom: 8, right: 0) {
@IBInspectable public var dividerInset = Inset(top: 8, left: 0, bottom: 8, right: 0) {
didSet {
reloadView()
}
......@@ -75,16 +75,16 @@ public class CardView : PulseView {
/**
:name: contentInsets
*/
public var contentInsetPreset: InsetsPreset = .square2 {
public var contentInsetPreset: InsetPreset = .square2 {
didSet {
contentInset = InsetsPresetToValue(preset: contentInsetPreset)
contentInset = InsetPresetToValue(preset: contentInsetPreset)
}
}
/**
:name: contentInset
*/
@IBInspectable public var contentInset = InsetsPresetToValue(preset: .square2) {
@IBInspectable public var contentInset = InsetPresetToValue(preset: .square2) {
didSet {
reloadView()
}
......@@ -93,16 +93,16 @@ public class CardView : PulseView {
/**
:name: titleLabelInsets
*/
public var titleLabelInsetPreset: InsetsPreset = .square2 {
public var titleLabelInsetPreset: InsetPreset = .square2 {
didSet {
titleLabelInset = InsetsPresetToValue(preset: titleLabelInsetPreset)
titleLabelInset = InsetPresetToValue(preset: titleLabelInsetPreset)
}
}
/**
:name: titleLabelInset
*/
@IBInspectable public var titleLabelInset = InsetsPresetToValue(preset: .square2) {
@IBInspectable public var titleLabelInset = InsetPresetToValue(preset: .square2) {
didSet {
reloadView()
}
......@@ -120,16 +120,16 @@ public class CardView : PulseView {
/**
:name: contentViewInsets
*/
public var contentViewInsetPreset: InsetsPreset = .square2 {
public var contentViewInsetPreset: InsetPreset = .square2 {
didSet {
contentViewInset = InsetsPresetToValue(preset: contentViewInsetPreset)
contentViewInset = InsetPresetToValue(preset: contentViewInsetPreset)
}
}
/**
:name: contentViewInset
*/
@IBInspectable public var contentViewInset = InsetsPresetToValue(preset: .square2) {
@IBInspectable public var contentViewInset = InsetPresetToValue(preset: .square2) {
didSet {
reloadView()
}
......@@ -147,16 +147,16 @@ public class CardView : PulseView {
/**
:name: leftButtonsInsets
*/
public var leftButtonsInsetPreset: InsetsPreset = .none {
public var leftButtonsInsetPreset: InsetPreset = .none {
didSet {
leftButtonsInset = InsetsPresetToValue(preset: leftButtonsInsetPreset)
leftButtonsInset = InsetPresetToValue(preset: leftButtonsInsetPreset)
}
}
/**
:name: leftButtonsInset
*/
@IBInspectable public var leftButtonsInset = Insets.zero {
@IBInspectable public var leftButtonsInset = Inset.zero {
didSet {
reloadView()
}
......@@ -174,16 +174,16 @@ public class CardView : PulseView {
/**
:name: rightButtonsInsets
*/
public var rightButtonsInsetPreset: InsetsPreset = .none {
public var rightButtonsInsetPreset: InsetPreset = .none {
didSet {
rightButtonsInset = InsetsPresetToValue(preset: rightButtonsInsetPreset)
rightButtonsInset = InsetPresetToValue(preset: rightButtonsInsetPreset)
}
}
/**
:name: rightButtonsInset
*/
@IBInspectable public var rightButtonsInset = Insets.zero {
@IBInspectable public var rightButtonsInset = Inset.zero {
didSet {
reloadView()
}
......@@ -391,7 +391,7 @@ public class CardView : PulseView {
*/
public override func prepareView() {
super.prepareView()
depth = .depth1
depthPreset = .depth1
dividerColor = Color.grey.lighten3
cornerRadiusPreset = .Radius1
}
......
......@@ -37,7 +37,7 @@ public class ControlView : View {
}
/// A preset wrapper around contentInset.
public var contentInsetPreset: InsetsPreset {
public var contentInsetPreset: InsetPreset {
get {
return grid.contentInsetPreset
}
......@@ -47,7 +47,7 @@ public class ControlView : View {
}
/// A wrapper around grid.contentInset.
@IBInspectable public var contentInset: Insets {
@IBInspectable public var contentInset: Inset {
get {
return grid.contentInset
}
......
......@@ -49,6 +49,11 @@ public struct Depth {
/// Radius.
public var radius: CGFloat
/// Offset as size.
public var offsetAsSize: CGSize {
return CGSize(width: offset.horizontal, height: offset.vertical)
}
/**
Initializer.
- Parameter offset: UIOffset.
......
......@@ -34,7 +34,7 @@ public class ErrorTextField : TextField {
/// Controls the visibility of detailLabel
@IBInspectable public var revealError: Bool = false {
didSet {
detailLabel.hidden = !revealError
detailLabel.isHidden = !revealError
}
}
......
......@@ -32,15 +32,15 @@ import UIKit
public class FabButton: Button {
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
public override func prepareView() {
super.prepareView()
depth = .depth1
depthPreset = .depth1
shape = .Circle
pulseAnimation = .CenterWithBacking
pulseColor = Color.white
......
......@@ -32,15 +32,15 @@ import UIKit
public class FlatButton: Button {
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
public override func prepareView() {
super.prepareView()
cornerRadiusPreset = .Radius1
contentEdgeInsetsPreset = .WideRectangle3
contentInsetPreset = .wideRectangle3
}
}
\ No newline at end of file
}
......@@ -129,28 +129,28 @@ public class Grid {
public private(set) var axis: GridAxis!
/// Preset inset value for grid.
public var layoutInsetsPreset: InsetsPreset = .none {
public var layoutInsetPreset: InsetPreset = .none {
didSet {
layoutInsets = InsetsPresetToValue(preset: contentInsetsPreset)
layoutInset = InsetPresetToValue(preset: contentInsetPreset)
}
}
/// Insets value for grid.
public var layoutInsets: Insets = InsetsPresetToValue(preset: .none) {
public var layoutInset = Inset.zero {
didSet {
reload()
}
}
/// Preset inset value for grid.
public var contentInsetsPreset: InsetsPreset = .none {
public var contentInsetPreset: InsetPreset = .none {
didSet {
contentInsets = InsetsPresetToValue(preset: contentInsetsPreset)
contentInset = InsetPresetToValue(preset: contentInsetPreset)
}
}
/// Insets value for grid.
public var contentInsets: Insets = InsetsPresetToValue(preset: .none) {
public var contentInset: Inset = InsetPresetToValue(preset: .none) {
didSet {
reload()
}
......@@ -208,34 +208,34 @@ public class Grid {
parent.layoutIfNeeded()
switch axis.direction {
case .horizontal:
let w: CGFloat = (parent.bounds.width - contentInsets.left - contentInsets.right - layoutInsets.left - layoutInsets.right + interimSpace) / CGFloat(gc)
let c: Int = child.grid.columns
let co: Int = child.grid.offset.columns
let vh: CGFloat = parent.bounds.height - contentInsets.top - contentInsets.bottom - layoutInsets.top - layoutInsets.bottom
let vl: CGFloat = CGFloat(i + n + co) * w + contentInsets.left + layoutInsets.left
let vw: CGFloat = w * CGFloat(c) - interimSpace
child.frame = CGRect(x: vl, y: contentInsets.top + layoutInsets.top, width: vw, height: vh)
let w = (parent.bounds.width - contentInset.left - contentInset.right - layoutInset.left - layoutInset.right + interimSpace) / CGFloat(gc)
let c = child.grid.columns
let co = child.grid.offset.columns
let vh = parent.bounds.height - contentInset.top - contentInset.bottom - layoutInset.top - layoutInset.bottom
let vl = CGFloat(i + n + co) * w + contentInset.left + layoutInset.left
let vw = w * CGFloat(c) - interimSpace
child.frame = CGRect(x: vl, y: contentInset.top + layoutInset.top, width: vw, height: vh)
n += c + co - 1
case .vertical:
let h: CGFloat = (parent.bounds.height - contentInsets.top - contentInsets.bottom - layoutInsets.top - layoutInsets.bottom + interimSpace) / CGFloat(gr)
let r: Int = child.grid.rows
let ro: Int = child.grid.offset.rows
let vw: CGFloat = parent.bounds.width - contentInsets.left - contentInsets.right - layoutInsets.left - layoutInsets.right
let vt: CGFloat = CGFloat(i + n + ro) * h + contentInsets.top + layoutInsets.top
let vh: CGFloat = h * CGFloat(r) - interimSpace
child.frame = CGRect(x: contentInsets.left + layoutInsets.left, y: vt, width: vw, height: vh)
let h = (parent.bounds.height - contentInset.top - contentInset.bottom - layoutInset.top - layoutInset.bottom + interimSpace) / CGFloat(gr)
let r = child.grid.rows
let ro = child.grid.offset.rows
let vw = parent.bounds.width - contentInset.left - contentInset.right - layoutInset.left - layoutInset.right
let vt = CGFloat(i + n + ro) * h + contentInset.top + layoutInset.top
let vh = h * CGFloat(r) - interimSpace
child.frame = CGRect(x: contentInset.left + layoutInset.left, y: vt, width: vw, height: vh)
n += r + ro - 1
case .none:
let w: CGFloat = (parent.bounds.width - contentInsets.left - contentInsets.right - layoutInsets.left - layoutInsets.right + interimSpace) / CGFloat(gc)
let c: Int = child.grid.columns
let co: Int = child.grid.offset.columns
let h: CGFloat = (parent.bounds.height - contentInsets.top - contentInsets.bottom - layoutInsets.top - layoutInsets.bottom + interimSpace) / CGFloat(gr)
let r: Int = child.grid.rows
let ro: Int = child.grid.offset.rows
let vt: CGFloat = CGFloat(ro) * h + contentInsets.top + layoutInsets.top
let vl: CGFloat = CGFloat(co) * w + contentInsets.left + layoutInsets.left
let vh: CGFloat = h * CGFloat(r) - interimSpace
let vw: CGFloat = w * CGFloat(c) - interimSpace
let w = (parent.bounds.width - contentInset.left - contentInset.right - layoutInset.left - layoutInset.right + interimSpace) / CGFloat(gc)
let c = child.grid.columns
let co = child.grid.offset.columns
let h = (parent.bounds.height - contentInset.top - contentInset.bottom - layoutInset.top - layoutInset.bottom + interimSpace) / CGFloat(gr)
let r = child.grid.rows
let ro = child.grid.offset.rows
let vt = CGFloat(ro) * h + contentInset.top + layoutInset.top
let vl = CGFloat(co) * w + contentInset.left + layoutInset.left
let vh = h * CGFloat(r) - interimSpace
let vw = w * CGFloat(c) - interimSpace
child.frame = CGRect(x: vl, y: vt, width: vw, height: vh)
}
}
......
......@@ -32,16 +32,15 @@ import UIKit
public class IconButton: Button {
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
public override func prepareView() {
super.prepareView()
cornerRadiusPreset = .Radius1
contentEdgeInsetsPreset = .WideRectangle3
pulseAnimation = .Center
}
}
\ No newline at end of file
}
......@@ -30,7 +30,7 @@
import UIKit
public class ImageCardView : PulseView {
public class ImageCard: PulseView {
/**
:name: dividerLayer
*/
......@@ -41,7 +41,7 @@ public class ImageCardView : PulseView {
*/
@IBInspectable public var dividerColor: UIColor? {
didSet {
dividerLayer?.backgroundColor = dividerColor?.CGColor
dividerLayer?.backgroundColor = dividerColor?.cgColor
}
}
......@@ -57,16 +57,16 @@ public class ImageCardView : PulseView {
/**
:name: dividerInsets
*/
public var dividerInsetPreset: InsetsPreset = .none {
public var dividerInsetPreset: InsetPreset = .none {
didSet {
dividerInset = InsetsPresetToValue(preset: dividerInsetPreset)
dividerInset = InsetPresetToValue(preset: dividerInsetPreset)
}
}
/**
:name: dividerInset
*/
@IBInspectable public var dividerInset = Insets(top: 8, left: 0, bottom: 8, right: 0) {
@IBInspectable public var dividerInset = Inset(top: 8, left: 0, bottom: 8, right: 0) {
didSet {
reloadView()
}
......@@ -82,23 +82,23 @@ public class ImageCardView : PulseView {
*/
@IBInspectable public override var image: UIImage? {
get {
return nil == imageLayer?.contents ? nil : UIImage(CGImage: imageLayer?.contents as! CGImage)
return nil == imageLayer?.contents ? nil : UIImage(cgImage: imageLayer?.contents as! CGImage)
}
set(value) {
if let v = value {
prepareImageLayer()
imageLayer?.contents = v.CGImage
imageLayer?.contents = v.cgImage
if 0 == maxImageHeight {
imageLayer?.frame.size.height = image!.size.height / contentsScale
} else {
let h: CGFloat = image!.size.height / contentsScale
imageLayer?.frame.size.height = maxImageHeight < h ? maxImageHeight : h
}
imageLayer?.hidden = false
imageLayer?.isHidden = false
} else {
imageLayer?.contents = nil
imageLayer?.frame = CGRect.zero
imageLayer?.hidden = true
imageLayer?.isHidden = true
imageLayer?.removeFromSuperlayer()
}
reloadView()
......@@ -168,16 +168,16 @@ public class ImageCardView : PulseView {
/**
:name: contentInsets
*/
public var contentInsetPreset: InsetsPreset = .square2 {
public var contentInsetPreset: InsetPreset = .square2 {
didSet {
contentInset = InsetsPresetToValue(preset: contentInsetPreset)
contentInset = InsetPresetToValue(preset: contentInsetPreset)
}
}
/**
:name: contentInset
*/
@IBInspectable public var contentInset = InsetsPresetToValue(preset: .square2) {
@IBInspectable public var contentInset = InsetPresetToValue(preset: .square2) {
didSet {
reloadView()
}
......@@ -186,16 +186,16 @@ public class ImageCardView : PulseView {
/**
:name: titleLabelInsets
*/
public var titleLabelInsetPreset: InsetsPreset = .square2 {
public var titleLabelInsetPreset: InsetPreset = .square2 {
didSet {
titleLabelInset = InsetsPresetToValue(preset: titleLabelInsetPreset)
titleLabelInset = InsetPresetToValue(preset: titleLabelInsetPreset)
}
}
/**
:name: titleLabelInset
*/
@IBInspectable public var titleLabelInset = InsetsPresetToValue(preset: .square2) {
@IBInspectable public var titleLabelInset = InsetPresetToValue(preset: .square2) {
didSet {
reloadView()
}
......@@ -213,16 +213,16 @@ public class ImageCardView : PulseView {
/**
:name: contentViewInsets
*/
public var contentViewInsetPreset: InsetsPreset = .square2 {
public var contentViewInsetPreset: InsetPreset = .square2 {
didSet {
contentViewInset = InsetsPresetToValue(preset: contentViewInsetPreset)
contentViewInset = InsetPresetToValue(preset: contentViewInsetPreset)
}
}
/**
:name: contentViewInset
*/
@IBInspectable public var contentViewInset = InsetsPresetToValue(preset: .square2) {
@IBInspectable public var contentViewInset = InsetPresetToValue(preset: .square2) {
didSet {
reloadView()
}
......@@ -240,16 +240,16 @@ public class ImageCardView : PulseView {
/**
:name: leftButtonsInsets
*/
public var leftButtonsInsetPreset: InsetsPreset = .none {
public var leftButtonsInsetPreset: InsetPreset = .none {
didSet {
leftButtonsInset = InsetsPresetToValue(preset: leftButtonsInsetPreset)
leftButtonsInset = InsetPresetToValue(preset: leftButtonsInsetPreset)
}
}
/**
:name: leftButtonsInset
*/
@IBInspectable public var leftButtonsInset = Insets.zero {
@IBInspectable public var leftButtonsInset = Inset.zero {
didSet {
reloadView()
}
......@@ -267,16 +267,16 @@ public class ImageCardView : PulseView {
/**
:name: rightButtonsInsets
*/
public var rightButtonsInsetPreset: InsetsPreset = .none {
public var rightButtonsInsetPreset: InsetPreset = .none {
didSet {
rightButtonsInset = InsetsPresetToValue(preset: rightButtonsInsetPreset)
rightButtonsInset = InsetPresetToValue(preset: rightButtonsInsetPreset)
}
}
/**
:name: rightButtonsInset
*/
@IBInspectable public var rightButtonsInset = Insets.zero {
@IBInspectable public var rightButtonsInset = Inset.zero {
didSet {
reloadView()
}
......@@ -532,7 +532,7 @@ public class ImageCardView : PulseView {
*/
public override func prepareView() {
super.prepareView()
depth = .depth1
depthPreset = .depth1
dividerColor = Color.grey.lighten3
cornerRadiusPreset = .Radius1
}
......
......@@ -32,7 +32,7 @@ import UIKit
import UIKit
public enum InsetsPreset {
public enum InsetPreset {
case none
// square
......@@ -69,7 +69,7 @@ public enum InsetsPreset {
case tallRectangle9
}
public struct Insets {
public struct Inset {
/// Top inset.
public var top: CGFloat
......@@ -82,6 +82,10 @@ public struct Insets {
/// Right inset.
public var right: CGFloat
public var asEdgeInsets: UIEdgeInsets {
return UIEdgeInsets(top: top, left: left, bottom: bottom, right: right)
}
/**
Initializer.
- Parameter top: Top inset.
......@@ -97,78 +101,78 @@ public struct Insets {
}
/**
Static constructor for Insets with values of 0.
- Returns: An Insets struct with values of 0.
Static constructor for Inset with values of 0.
- Returns: An Inset struct with values of 0.
*/
static var zero: Insets {
return Insets()
static var zero: Inset {
return Inset()
}
}
/// Converts the InsetsPreset to a Insets value.
public func InsetsPresetToValue(preset: InsetsPreset) -> Insets {
/// Converts the InsetPreset to a Inset value.
public func InsetPresetToValue(preset: InsetPreset) -> Inset {
switch preset {
case .none:
return Insets.zero
return Inset.zero
// square
case .square1:
return Insets(top: 4, left: 4, bottom: 4, right: 4)
return Inset(top: 4, left: 4, bottom: 4, right: 4)
case .square2:
return Insets(top: 8, left: 8, bottom: 8, right: 8)
return Inset(top: 8, left: 8, bottom: 8, right: 8)
case .square3:
return Insets(top: 16, left: 16, bottom: 16, right: 16)
return Inset(top: 16, left: 16, bottom: 16, right: 16)
case .square4:
return Insets(top: 24, left: 24, bottom: 24, right: 24)
return Inset(top: 24, left: 24, bottom: 24, right: 24)
case .square5:
return Insets(top: 32, left: 32, bottom: 32, right: 32)
return Inset(top: 32, left: 32, bottom: 32, right: 32)
case .square6:
return Insets(top: 40, left: 40, bottom: 40, right: 40)
return Inset(top: 40, left: 40, bottom: 40, right: 40)
case .square7:
return Insets(top: 48, left: 48, bottom: 48, right: 48)
return Inset(top: 48, left: 48, bottom: 48, right: 48)
case .square8:
return Insets(top: 56, left: 56, bottom: 56, right: 56)
return Inset(top: 56, left: 56, bottom: 56, right: 56)
case .square9:
return Insets(top: 64, left: 64, bottom: 64, right: 64)
return Inset(top: 64, left: 64, bottom: 64, right: 64)
// rectangle
case .wideRectangle1:
return Insets(top: 2, left: 4, bottom: 2, right: 4)
return Inset(top: 2, left: 4, bottom: 2, right: 4)
case .wideRectangle2:
return Insets(top: 4, left: 8, bottom: 4, right: 8)
return Inset(top: 4, left: 8, bottom: 4, right: 8)
case .wideRectangle3:
return Insets(top: 8, left: 16, bottom: 8, right: 16)
return Inset(top: 8, left: 16, bottom: 8, right: 16)
case .wideRectangle4:
return Insets(top: 12, left: 24, bottom: 12, right: 24)
return Inset(top: 12, left: 24, bottom: 12, right: 24)
case .wideRectangle5:
return Insets(top: 16, left: 32, bottom: 16, right: 32)
return Inset(top: 16, left: 32, bottom: 16, right: 32)
case .wideRectangle6:
return Insets(top: 20, left: 40, bottom: 20, right: 40)
return Inset(top: 20, left: 40, bottom: 20, right: 40)
case .wideRectangle7:
return Insets(top: 24, left: 48, bottom: 24, right: 48)
return Inset(top: 24, left: 48, bottom: 24, right: 48)
case .wideRectangle8:
return Insets(top: 28, left: 56, bottom: 28, right: 56)
return Inset(top: 28, left: 56, bottom: 28, right: 56)
case .wideRectangle9:
return Insets(top: 32, left: 64, bottom: 32, right: 64)
return Inset(top: 32, left: 64, bottom: 32, right: 64)
// flipped rectangle
case .tallRectangle1:
return Insets(top: 4, left: 2, bottom: 4, right: 2)
return Inset(top: 4, left: 2, bottom: 4, right: 2)
case .tallRectangle2:
return Insets(top: 8, left: 4, bottom: 8, right: 4)
return Inset(top: 8, left: 4, bottom: 8, right: 4)
case .tallRectangle3:
return Insets(top: 16, left: 8, bottom: 16, right: 8)
return Inset(top: 16, left: 8, bottom: 16, right: 8)
case .tallRectangle4:
return Insets(top: 24, left: 12, bottom: 24, right: 12)
return Inset(top: 24, left: 12, bottom: 24, right: 12)
case .tallRectangle5:
return Insets(top: 32, left: 16, bottom: 32, right: 16)
return Inset(top: 32, left: 16, bottom: 32, right: 16)
case .tallRectangle6:
return Insets(top: 40, left: 20, bottom: 40, right: 20)
return Inset(top: 40, left: 20, bottom: 40, right: 20)
case .tallRectangle7:
return Insets(top: 48, left: 24, bottom: 48, right: 24)
return Inset(top: 48, left: 24, bottom: 48, right: 24)
case .tallRectangle8:
return Insets(top: 56, left: 28, bottom: 56, right: 28)
return Inset(top: 56, left: 28, bottom: 56, right: 28)
case .tallRectangle9:
return Insets(top: 64, left: 32, bottom: 64, right: 32)
return Inset(top: 64, left: 32, bottom: 64, right: 32)
}
}
......@@ -61,7 +61,7 @@ public extension UIImage {
let effectInContext: CGContext = UIGraphicsGetCurrentContext()!
CGContextScaleCTM(effectInContext, 1.0, -1.0)
CGContextTranslateCTM(effectInContext, 0, -size.height)
CGContextDrawImage(effectInContext, imageRect, self.CGImage)
CGContextDrawImage(effectInContext, imageRect, self.cgImage)
var effectInBuffer: vImage_Buffer = createEffectBuffer(effectInContext)
UIGraphicsBeginImageContextWithOptions(size, false, screenScale)
......@@ -129,12 +129,12 @@ public extension UIImage {
CGContextTranslateCTM(outputContext, 0, -size.height)
// Draw base image.
CGContextDrawImage(outputContext, imageRect, self.CGImage)
CGContextDrawImage(outputContext, imageRect, self.cgImage)
// Draw effect image.
if hasBlur {
CGContextSaveGState(outputContext)
CGContextDrawImage(outputContext, imageRect, effectImage.CGImage)
CGContextDrawImage(outputContext, imageRect, effectImage.cgImage)
CGContextRestoreGState(outputContext)
}
......
......@@ -46,7 +46,7 @@ public extension UIImage {
CGContextSetBlendMode(context, .Multiply)
let rect = CGRectMake(0, 0, size.width, size.height)
CGContextClipToMask(context, rect, CGImage)
CGContextClipToMask(context, rect, cgImage)
color.setFill()
CGContextFillRect(context, rect)
......
......@@ -69,7 +69,7 @@ public class MaterialCollectionReusableView : UICollectionReusableView {
*/
@IBInspectable public var image: UIImage? {
didSet {
visualLayer.contents = image?.CGImage
visualLayer.contents = image?.cgImage
}
}
......
......@@ -69,7 +69,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
*/
@IBInspectable public var image: UIImage? {
didSet {
visualLayer.contents = image?.CGImage
visualLayer.contents = image?.cgImage
}
}
......@@ -133,7 +133,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
}
/// A preset wrapper around contentInset.
public var contentInsetPreset: Insets {
public var contentInsetPreset: InsetPreset {
get {
return contentView.grid.contentInsetPreset
}
......
......@@ -38,14 +38,14 @@ public class MaterialCollectionViewLayout : UICollectionViewLayout {
public var itemSize: CGSize = CGSize.zero
/// A preset wrapper around contentInset.
public var contentInsetPreset: InsetsPreset = .none {
public var contentInsetPreset: InsetPreset = .none {
didSet {
contentInset = InsetsPresetToValue(preset: contentInsetPreset)
contentInset = InsetPresetToValue(preset: contentInsetPreset)
}
}
/// A wrapper around grid.contentInset.
public var contentInset = Insets.zero
public var contentInset = Inset.zero
/// Size of the content.
public private(set) var contentSize: CGSize = CGSize.zero
......
......@@ -176,7 +176,7 @@ public class Menu {
base = v[0]
}
let view: UIView = v[i]
view.hidden = false
view.isHidden = false
UIView.animateWithDuration(Double(i) * duration,
delay: delay,
......@@ -230,7 +230,7 @@ public class Menu {
}
}) { [weak self] _ in
if let s: Menu = self {
view.hidden = true
view.isHidden = true
s.enable(view)
if view == v.last {
s.opened = false
......@@ -261,7 +261,7 @@ public class Menu {
}
let view: UIView = v[i]
view.hidden = false
view.isHidden = false
let h: CGFloat = nil == baseSize ? itemSize.height : baseSize!.height
UIView.animateWithDuration(Double(i) * duration,
......@@ -317,7 +317,7 @@ public class Menu {
}
}) { [weak self] _ in
if let s: Menu = self {
view.hidden = true
view.isHidden = true
s.enable(view)
if view == v.last {
s.opened = false
......@@ -348,7 +348,7 @@ public class Menu {
}
let view: UIView = v[i]
view.hidden = false
view.isHidden = false
UIView.animateWithDuration(Double(i) * duration,
delay: delay,
......@@ -401,7 +401,7 @@ public class Menu {
}
}) { [weak self] _ in
if let s: Menu = self {
view.hidden = true
view.isHidden = true
s.enable(view)
if view == v.last {
s.opened = false
......@@ -431,7 +431,7 @@ public class Menu {
base = v[0]
}
let view: UIView = v[i]
view.hidden = false
view.isHidden = false
let h: CGFloat = nil == baseSize ? itemSize.height : baseSize!.height
UIView.animateWithDuration(Double(i) * duration,
......@@ -487,7 +487,7 @@ public class Menu {
}
}) { [weak self] _ in
if let s: Menu = self {
view.hidden = true
view.isHidden = true
s.enable(view)
if view == v.last {
s.opened = false
......@@ -511,7 +511,7 @@ public class Menu {
view.layer.zPosition = 10000
} else {
view.alpha = 0
view.hidden = true
view.isHidden = true
view.frame.size = itemSize
view.frame.origin.x = origin.x + (size.width - itemSize.width) / 2
view.frame.origin.y = origin.y + (size.height - itemSize.height) / 2
......
......@@ -62,14 +62,14 @@ public class NavigationBar : UINavigationBar {
}
/// A preset wrapper around contentInset.
public var contentInsetPreset: InsetsPreset = .none {
public var contentInsetPreset: InsetPreset = .none {
didSet {
contentInset = InsetsPresetToValue(preset: contentInsetPreset)
contentInset = InsetPresetToValue(preset: contentInsetPreset)
}
}
/// A wrapper around grid.contentInset.
@IBInspectable public var contentInset: Insets = Insets.zero {
@IBInspectable public var contentInset: Insets = Inset.zero {
didSet {
layoutSubviews()
}
......
......@@ -894,7 +894,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
leftView!.backgroundColor = Color.clear
view.addSubview(leftView!)
leftView!.hidden = true
leftView!.isHidden = true
leftView!.position.x = -leftViewWidth / 2
leftView!.zPosition = 2000
prepareLeftViewController()
......@@ -914,7 +914,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
rightView!.backgroundColor = Color.clear
view.addSubview(rightView!)
rightView!.hidden = true
rightView!.isHidden = true
rightView!.position.x = view.bounds.width + rightViewWidth / 2
rightView!.zPosition = 2000
prepareRightViewController()
......@@ -1090,7 +1090,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
*/
private func showView(container: View) {
container.depth = depth
container.hidden = false
container.isHidden = false
}
/**
......@@ -1099,6 +1099,6 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
*/
private func hideView(container: View) {
container.depth = .None
container.hidden = true
container.isHidden = true
}
}
......@@ -32,17 +32,17 @@ import UIKit
public class RaisedButton: Button {
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
public override func prepareView() {
super.prepareView()
depth = .depth1
depthPreset = .depth1
cornerRadiusPreset = .Radius1
contentEdgeInsetsPreset = .WideRectangle3
contentInsetPreset = .wideRectangle3
backgroundColor = Color.white
}
}
......@@ -60,7 +60,7 @@ public class StatusBarController : RootController {
*/
public override func layoutSubviews() {
super.layoutSubviews()
statusBarView.hidden = Device.isLandscape && .phone == Device.userInterfaceIdiom
statusBarView.isHidden = Device.isLandscape && .phone == Device.userInterfaceIdiom
rootViewController.view.frame = view.bounds
}
......
......@@ -286,9 +286,9 @@ public class TextView: UITextView {
Text container UIEdgeInset preset property. This updates the
textContainerInset property with a preset value.
*/
public var textContainerInsetPreset: InsetsPreset = .none {
public var textContainerInsetPreset: InsetPreset = .none {
didSet {
textContainerInset = InsetsPresetToValue(preset: textContainerInsetPreset)
textContainerInset = InsetPresetToValue(preset: textContainerInsetPreset)
}
}
......@@ -417,7 +417,7 @@ public class TextView: UITextView {
/// Notification handler for when text changed.
internal func handleTextViewTextDidChange() {
if let p = placeholderLabel {
p.hidden = !(true == text?.isEmpty)
p.isHidden = !(true == text?.isEmpty)
}
if 0 < text?.utf16.count {
......@@ -459,7 +459,7 @@ public class TextView: UITextView {
*/
public func prepareView() {
contentScaleFactor = Device.scale
textContainerInset = Insets.zero
textContainerInset = Inset.zero
backgroundColor = Color.white
masksToBounds = false
removeNotificationHandlers()
......@@ -483,7 +483,7 @@ public class TextView: UITextView {
/// Prepares the titleLabel property.
private func prepareTitleLabel() {
if let v: UILabel = titleLabel {
v.hidden = true
v.isHidden = true
addSubview(v)
if 0 < text?.utf16.count {
showTitleLabel()
......@@ -496,13 +496,13 @@ public class TextView: UITextView {
/// Shows and animates the titleLabel property.
private func showTitleLabel() {
if let v: UILabel = titleLabel {
if v.hidden {
if v.isHidden {
if let s: String = placeholderLabel?.text {
v.text = s
}
let h: CGFloat = ceil(v.font.lineHeight)
v.frame = CGRectMake(0, -h, bounds.width, h)
v.hidden = false
v.isHidden = false
UIView.animateWithDuration(0.25, animations: { [weak self] in
if let s: TextView = self {
v.alpha = 1
......@@ -516,12 +516,12 @@ public class TextView: UITextView {
/// Hides and animates the titleLabel property.
private func hideTitleLabel() {
if let v: UILabel = titleLabel {
if !v.hidden {
if !v.isHidden {
UIView.animateWithDuration(0.25, animations: {
v.alpha = 0
v.frame.origin.y = -v.frame.height
}) { _ in
v.hidden = true
v.isHidden = true
}
}
}
......
......@@ -114,13 +114,13 @@ public class ToolbarController : RootController {
addChildViewController(v)
v.view.frame = view.bounds
v.view.center.y = 2 * view.bounds.height
v.view.hidden = true
v.view.isHidden = true
view.insertSubview(v.view, aboveSubview: toolbar)
v.view.layer.zPosition = 1500
v.didMoveToParentViewController(self)
// Animate the noteButton out and the noteViewController! in.
v.view.hidden = false
v.view.isHidden = false
v.view.layer.rasterizationScale = Device.scale
v.view.layer.shouldRasterize = true
view.layer.rasterizationScale = Device.scale
......
......@@ -248,20 +248,25 @@ public class View: UIView {
}
}
/**
/// A preset value for Depth.
public var depthPreset: DepthPreset = .none {
didSet {
depth = DepthPresetToValue(preset: depthPreset)
}
}
/**
A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer. This is the preferred method of setting depth
in order to maintain consitency across UI objects.
for the backing layer.
*/
public var depthPreset = .none {
didSet {
let value: Depth = DepthPresetToValue(preset: depth)
shadowOffset = value.offset
shadowOpacity = value.opacity
shadowRadius = value.radius
layoutShadowPath()
}
}
public var depth = Depth.zero {
didSet {
shadowOffset = depth.offsetAsSize
shadowOpacity = depth.opacity
shadowRadius = depth.radius
layoutShadowPath()
}
}
/**
A property that sets the cornerRadius of the backing layer. If the shape
......
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