Commit 0c9e543e by Daniel Dahan

updated MaterialInsets to use UIEdgeInsets

parent d6db0226
......@@ -25,7 +25,7 @@
96D88C2D1C1328D800B91418 /* MaterialDepth.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88C041C1328D800B91418 /* MaterialDepth.swift */; };
96D88C2E1C1328D800B91418 /* MaterialFont.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88C051C1328D800B91418 /* MaterialFont.swift */; };
96D88C2F1C1328D800B91418 /* MaterialGravity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88C061C1328D800B91418 /* MaterialGravity.swift */; };
96D88C301C1328D800B91418 /* MaterialInsets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88C071C1328D800B91418 /* MaterialInsets.swift */; };
96D88C301C1328D800B91418 /* MaterialEdgeInsets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88C071C1328D800B91418 /* MaterialEdgeInsets.swift */; };
96D88C311C1328D800B91418 /* MaterialKeyframeAnimation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88C081C1328D800B91418 /* MaterialKeyframeAnimation.swift */; };
96D88C321C1328D800B91418 /* MaterialKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 96D88C091C1328D800B91418 /* MaterialKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
96D88C331C1328D800B91418 /* MaterialLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96D88C0A1C1328D800B91418 /* MaterialLabel.swift */; };
......@@ -59,7 +59,7 @@
96D88C5D1C132ABF00B91418 /* MaterialColor.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96D88C031C1328D800B91418 /* MaterialColor.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96D88C5E1C132ABF00B91418 /* MaterialDepth.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96D88C041C1328D800B91418 /* MaterialDepth.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96D88C5F1C132ABF00B91418 /* MaterialGravity.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96D88C061C1328D800B91418 /* MaterialGravity.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96D88C601C132ABF00B91418 /* MaterialInsets.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96D88C071C1328D800B91418 /* MaterialInsets.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96D88C601C132ABF00B91418 /* MaterialEdgeInsets.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96D88C071C1328D800B91418 /* MaterialEdgeInsets.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96D88C611C132ABF00B91418 /* CaptureView.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96D88BF51C1328D800B91418 /* CaptureView.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96D88C621C132ABF00B91418 /* CapturePreviewView.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96D88BF71C1328D800B91418 /* CapturePreviewView.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96D88C631C132ABF00B91418 /* CaptureSession.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96D88BF81C1328D800B91418 /* CaptureSession.swift */; settings = {ATTRIBUTES = (Public, ); }; };
......@@ -116,7 +116,7 @@
96D88C041C1328D800B91418 /* MaterialDepth.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialDepth.swift; sourceTree = "<group>"; };
96D88C051C1328D800B91418 /* MaterialFont.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialFont.swift; sourceTree = "<group>"; };
96D88C061C1328D800B91418 /* MaterialGravity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialGravity.swift; sourceTree = "<group>"; };
96D88C071C1328D800B91418 /* MaterialInsets.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialInsets.swift; sourceTree = "<group>"; };
96D88C071C1328D800B91418 /* MaterialEdgeInsets.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialEdgeInsets.swift; sourceTree = "<group>"; };
96D88C081C1328D800B91418 /* MaterialKeyframeAnimation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialKeyframeAnimation.swift; sourceTree = "<group>"; };
96D88C091C1328D800B91418 /* MaterialKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MaterialKit.h; sourceTree = "<group>"; };
96D88C0A1C1328D800B91418 /* MaterialLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialLabel.swift; sourceTree = "<group>"; };
......@@ -252,7 +252,7 @@
96D88C011C1328D800B91418 /* MaterialBorder.swift */,
96D88C041C1328D800B91418 /* MaterialDepth.swift */,
96D88C061C1328D800B91418 /* MaterialGravity.swift */,
96D88C071C1328D800B91418 /* MaterialInsets.swift */,
96D88C071C1328D800B91418 /* MaterialEdgeInsets.swift */,
);
name = Type;
sourceTree = "<group>";
......@@ -389,7 +389,7 @@
96D88C5D1C132ABF00B91418 /* MaterialColor.swift in Headers */,
96D88C5E1C132ABF00B91418 /* MaterialDepth.swift in Headers */,
96D88C5F1C132ABF00B91418 /* MaterialGravity.swift in Headers */,
96D88C601C132ABF00B91418 /* MaterialInsets.swift in Headers */,
96D88C601C132ABF00B91418 /* MaterialEdgeInsets.swift in Headers */,
96D88C611C132ABF00B91418 /* CaptureView.swift in Headers */,
96D88C621C132ABF00B91418 /* CapturePreviewView.swift in Headers */,
96D88C631C132ABF00B91418 /* CaptureSession.swift in Headers */,
......@@ -528,7 +528,7 @@
96D88C451C1328D800B91418 /* RobotoFont.swift in Sources */,
96D88C1F1C1328D800B91418 /* CardView.swift in Sources */,
96D88C2C1C1328D800B91418 /* MaterialColor.swift in Sources */,
96D88C301C1328D800B91418 /* MaterialInsets.swift in Sources */,
96D88C301C1328D800B91418 /* MaterialEdgeInsets.swift in Sources */,
96D88C211C1328D800B91418 /* CaptureSession.swift in Sources */,
96D88C341C1328D800B91418 /* MaterialLayer.swift in Sources */,
96D88C461C1328D800B91418 /* SideNavigationViewController.swift in Sources */,
......
......@@ -58,16 +58,16 @@ public class CaptureView : MaterialView, CaptureSessionDelegate, CapturePreviewV
/**
:name: contentInsets
*/
public var contentInsets: MaterialInsets = .None {
public var contentInsets: MaterialEdgeInsets = .None {
didSet {
contentInsetsRef = MaterialInsetsToValue(contentInsets)
contentInsetsRef = MaterialEdgeInsetsToValue(contentInsets)
}
}
/**
:name: contentInsetsRef
*/
public var contentInsetsRef: MaterialInsetsType = MaterialTheme.basicCaptureView.contentInsetsRef {
public var contentInsetsRef: UIEdgeInsets = MaterialTheme.basicCaptureView.contentInsetsRef {
didSet {
reloadView()
}
......
......@@ -45,16 +45,16 @@ public class CardView : MaterialPulseView {
/**
:name: dividerInsets
*/
public var dividerInsets: MaterialInsets = .None {
public var dividerInsets: MaterialEdgeInsets = .None {
didSet {
dividerInsetsRef = MaterialInsetsToValue(dividerInsets)
dividerInsetsRef = MaterialEdgeInsetsToValue(dividerInsets)
}
}
/**
:name: dividerInsetsRef
*/
public var dividerInsetsRef: MaterialInsetsType = MaterialTheme.basicCardView.dividerInsetsRef {
public var dividerInsetsRef: UIEdgeInsets = MaterialTheme.basicCardView.dividerInsetsRef {
didSet {
reloadView()
}
......@@ -63,16 +63,16 @@ public class CardView : MaterialPulseView {
/**
:name: contentInsets
*/
public var contentInsets: MaterialInsets = .None {
public var contentInsets: MaterialEdgeInsets = .None {
didSet {
contentInsetsRef = MaterialInsetsToValue(contentInsets)
contentInsetsRef = MaterialEdgeInsetsToValue(contentInsets)
}
}
/**
:name: contentInsetsRef
*/
public var contentInsetsRef: MaterialInsetsType = MaterialTheme.basicCardView.contentInsetsRef {
public var contentInsetsRef: UIEdgeInsets = MaterialTheme.basicCardView.contentInsetsRef {
didSet {
reloadView()
}
......@@ -81,16 +81,16 @@ public class CardView : MaterialPulseView {
/**
:name: titleLabelInsets
*/
public var titleLabelInsets: MaterialInsets = .None {
public var titleLabelInsets: MaterialEdgeInsets = .None {
didSet {
titleLabelInsetsRef = MaterialInsetsToValue(titleLabelInsets)
titleLabelInsetsRef = MaterialEdgeInsetsToValue(titleLabelInsets)
}
}
/**
:name: titleLabelInsetsRef
*/
public var titleLabelInsetsRef: MaterialInsetsType = MaterialTheme.basicCardView.titleLabelInsetsRef {
public var titleLabelInsetsRef: UIEdgeInsets = MaterialTheme.basicCardView.titleLabelInsetsRef {
didSet {
reloadView()
}
......@@ -109,16 +109,16 @@ public class CardView : MaterialPulseView {
/**
:name: detailLabelInsets
*/
public var detailLabelInsets: MaterialInsets = .None {
public var detailLabelInsets: MaterialEdgeInsets = .None {
didSet {
detailLabelInsetsRef = MaterialInsetsToValue(detailLabelInsets)
detailLabelInsetsRef = MaterialEdgeInsetsToValue(detailLabelInsets)
}
}
/**
:name: detailLabelInsetsRef
*/
public var detailLabelInsetsRef: MaterialInsetsType = MaterialTheme.basicCardView.detailLabelInsetsRef {
public var detailLabelInsetsRef: UIEdgeInsets = MaterialTheme.basicCardView.detailLabelInsetsRef {
didSet {
reloadView()
}
......@@ -137,16 +137,16 @@ public class CardView : MaterialPulseView {
/**
:name: leftButtonsInsets
*/
public var leftButtonsInsets: MaterialInsets = .None {
public var leftButtonsInsets: MaterialEdgeInsets = .None {
didSet {
leftButtonsInsetsRef = MaterialInsetsToValue(leftButtonsInsets)
leftButtonsInsetsRef = MaterialEdgeInsetsToValue(leftButtonsInsets)
}
}
/**
:name: leftButtonsInsetsRef
*/
public var leftButtonsInsetsRef: MaterialInsetsType = MaterialTheme.basicCardView.leftButtonsInsetsRef {
public var leftButtonsInsetsRef: UIEdgeInsets = MaterialTheme.basicCardView.leftButtonsInsetsRef {
didSet {
reloadView()
}
......@@ -169,16 +169,16 @@ public class CardView : MaterialPulseView {
/**
:name: rightButtonsInsets
*/
public var rightButtonsInsets: MaterialInsets = .None {
public var rightButtonsInsets: MaterialEdgeInsets = .None {
didSet {
rightButtonsInsetsRef = MaterialInsetsToValue(rightButtonsInsets)
rightButtonsInsetsRef = MaterialEdgeInsetsToValue(rightButtonsInsets)
}
}
/**
:name: rightButtonsInsetsRef
*/
public var rightButtonsInsetsRef: MaterialInsetsType = MaterialTheme.basicCardView.rightButtonsInsetsRef {
public var rightButtonsInsetsRef: UIEdgeInsets = MaterialTheme.basicCardView.rightButtonsInsetsRef {
didSet {
reloadView()
}
......
......@@ -45,16 +45,16 @@ public class ImageCardView : MaterialPulseView {
/**
:name: dividerInsets
*/
public var dividerInsets: MaterialInsets = .None {
public var dividerInsets: MaterialEdgeInsets = .None {
didSet {
dividerInsetsRef = MaterialInsetsToValue(dividerInsets)
dividerInsetsRef = MaterialEdgeInsetsToValue(dividerInsets)
}
}
/**
:name: dividerInsetsRef
*/
public var dividerInsetsRef: MaterialInsetsType = MaterialTheme.imageCardView.dividerInsetsRef {
public var dividerInsetsRef: UIEdgeInsets = MaterialTheme.imageCardView.dividerInsetsRef {
didSet {
reloadView()
}
......@@ -153,16 +153,16 @@ public class ImageCardView : MaterialPulseView {
/**
:name: contentInsets
*/
public var contentInsets: MaterialInsets = .None {
public var contentInsets: MaterialEdgeInsets = .None {
didSet {
contentInsetsRef = MaterialInsetsToValue(contentInsets)
contentInsetsRef = MaterialEdgeInsetsToValue(contentInsets)
}
}
/**
:name: contentInsetsRef
*/
public var contentInsetsRef: MaterialInsetsType = MaterialTheme.imageCardView.contentInsetsRef {
public var contentInsetsRef: UIEdgeInsets = MaterialTheme.imageCardView.contentInsetsRef {
didSet {
reloadView()
}
......@@ -171,16 +171,16 @@ public class ImageCardView : MaterialPulseView {
/**
:name: titleLabelInsets
*/
public var titleLabelInsets: MaterialInsets = .None {
public var titleLabelInsets: MaterialEdgeInsets = .None {
didSet {
titleLabelInsetsRef = MaterialInsetsToValue(titleLabelInsets)
titleLabelInsetsRef = MaterialEdgeInsetsToValue(titleLabelInsets)
}
}
/**
:name: titleLabelInsetsRef
*/
public var titleLabelInsetsRef: MaterialInsetsType = MaterialTheme.imageCardView.titleLabelInsetsRef {
public var titleLabelInsetsRef: UIEdgeInsets = MaterialTheme.imageCardView.titleLabelInsetsRef {
didSet {
reloadView()
}
......@@ -199,16 +199,16 @@ public class ImageCardView : MaterialPulseView {
/**
:name: detailLabelInsets
*/
public var detailLabelInsets: MaterialInsets = .None {
public var detailLabelInsets: MaterialEdgeInsets = .None {
didSet {
detailLabelInsetsRef = MaterialInsetsToValue(detailLabelInsets)
detailLabelInsetsRef = MaterialEdgeInsetsToValue(detailLabelInsets)
}
}
/**
:name: detailLabelInsetsRef
*/
public var detailLabelInsetsRef: MaterialInsetsType = MaterialTheme.imageCardView.detailLabelInsetsRef {
public var detailLabelInsetsRef: UIEdgeInsets = MaterialTheme.imageCardView.detailLabelInsetsRef {
didSet {
reloadView()
}
......@@ -227,16 +227,16 @@ public class ImageCardView : MaterialPulseView {
/**
:name: leftButtonsInsets
*/
public var leftButtonsInsets: MaterialInsets = .None {
public var leftButtonsInsets: MaterialEdgeInsets = .None {
didSet {
leftButtonsInsetsRef = MaterialInsetsToValue(leftButtonsInsets)
leftButtonsInsetsRef = MaterialEdgeInsetsToValue(leftButtonsInsets)
}
}
/**
:name: leftButtonsInsetsRef
*/
public var leftButtonsInsetsRef: MaterialInsetsType = MaterialTheme.imageCardView.leftButtonsInsetsRef {
public var leftButtonsInsetsRef: UIEdgeInsets = MaterialTheme.imageCardView.leftButtonsInsetsRef {
didSet {
reloadView()
}
......@@ -259,16 +259,16 @@ public class ImageCardView : MaterialPulseView {
/**
:name: rightButtonsInsets
*/
public var rightButtonsInsets: MaterialInsets = .None {
public var rightButtonsInsets: MaterialEdgeInsets = .None {
didSet {
rightButtonsInsetsRef = MaterialInsetsToValue(rightButtonsInsets)
rightButtonsInsetsRef = MaterialEdgeInsetsToValue(rightButtonsInsets)
}
}
/**
:name: rightButtonsInsetsRef
*/
public var rightButtonsInsetsRef: MaterialInsetsType = MaterialTheme.imageCardView.rightButtonsInsetsRef {
public var rightButtonsInsetsRef: UIEdgeInsets = MaterialTheme.imageCardView.rightButtonsInsetsRef {
didSet {
reloadView()
}
......
......@@ -286,9 +286,9 @@ public class MaterialButton : UIButton {
/**
:name: contentInsets
*/
public var contentInsets: MaterialInsets {
public var contentInsets: MaterialEdgeInsets {
didSet {
let value: MaterialInsetsType = MaterialInsetsToValue(contentInsets)
let value: UIEdgeInsets = MaterialEdgeInsetsToValue(contentInsets)
contentEdgeInsets = UIEdgeInsetsMake(value.top, value.left, value.bottom, value.right)
}
}
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io> and other CosmicMind contributors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program located at the root of the software package
// in a file called LICENSE. If not, see <http://www.gnu.org/licenses/>.
//
import UIKit
public enum MaterialEdgeInsets {
case None
// square
case Square1
case Square2
case Square3
case Square4
case Square5
case Square6
case Square7
case Square8
case Square9
// rectangle
case WideRectangle1
case WideRectangle2
case WideRectangle3
case WideRectangle4
case WideRectangle5
case WideRectangle6
case WideRectangle7
case WideRectangle8
case WideRectangle9
// flipped rectangle
case TallRectangle1
case TallRectangle2
case TallRectangle3
case TallRectangle4
case TallRectangle5
case TallRectangle6
case TallRectangle7
case TallRectangle8
case TallRectangle9
}
/**
:name: MaterialEdgeInsetsToValue
*/
public func MaterialEdgeInsetsToValue(inset: MaterialEdgeInsets) -> UIEdgeInsets {
switch inset {
case .None:
return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
// square
case .Square1:
return UIEdgeInsets(top: 4, left: 4, bottom: 4, right: 4)
case .Square2:
return UIEdgeInsets(top: 8, left: 8, bottom: 8, right: 8)
case .Square3:
return UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
case .Square4:
return UIEdgeInsets(top: 24, left: 24, bottom: 24, right: 24)
case .Square5:
return UIEdgeInsets(top: 32, left: 32, bottom: 32, right: 32)
case .Square6:
return UIEdgeInsets(top: 40, left: 40, bottom: 40, right: 40)
case .Square7:
return UIEdgeInsets(top: 48, left: 48, bottom: 48, right: 48)
case .Square8:
return UIEdgeInsets(top: 56, left: 56, bottom: 56, right: 56)
case .Square9:
return UIEdgeInsets(top: 64, left: 64, bottom: 64, right: 64)
// rectangle
case .WideRectangle1:
return UIEdgeInsets(top: 2, left: 4, bottom: 2, right: 4)
case .WideRectangle2:
return UIEdgeInsets(top: 4, left: 8, bottom: 4, right: 8)
case .WideRectangle3:
return UIEdgeInsets(top: 8, left: 16, bottom: 8, right: 16)
case .WideRectangle4:
return UIEdgeInsets(top: 12, left: 24, bottom: 12, right: 24)
case .WideRectangle5:
return UIEdgeInsets(top: 16, left: 32, bottom: 16, right: 32)
case .WideRectangle6:
return UIEdgeInsets(top: 20, left: 40, bottom: 20, right: 40)
case .WideRectangle7:
return UIEdgeInsets(top: 24, left: 48, bottom: 24, right: 48)
case .WideRectangle8:
return UIEdgeInsets(top: 28, left: 56, bottom: 28, right: 56)
case .WideRectangle9:
return UIEdgeInsets(top: 32, left: 64, bottom: 32, right: 64)
// flipped rectangle
case .TallRectangle1:
return UIEdgeInsets(top: 4, left: 2, bottom: 4, right: 2)
case .TallRectangle2:
return UIEdgeInsets(top: 8, left: 4, bottom: 8, right: 4)
case .TallRectangle3:
return UIEdgeInsets(top: 16, left: 8, bottom: 16, right: 8)
case .TallRectangle4:
return UIEdgeInsets(top: 24, left: 12, bottom: 24, right: 12)
case .TallRectangle5:
return UIEdgeInsets(top: 32, left: 16, bottom: 32, right: 16)
case .TallRectangle6:
return UIEdgeInsets(top: 40, left: 20, bottom: 40, right: 20)
case .TallRectangle7:
return UIEdgeInsets(top: 48, left: 24, bottom: 48, right: 24)
case .TallRectangle8:
return UIEdgeInsets(top: 56, left: 28, bottom: 56, right: 28)
case .TallRectangle9:
return UIEdgeInsets(top: 64, left: 32, bottom: 64, right: 32)
}
}
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io> and other CosmicMind contributors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program located at the root of the software package
// in a file called LICENSE. If not, see <http://www.gnu.org/licenses/>.
//
import UIKit
public typealias MaterialInsetsType = (top: CGFloat, left: CGFloat, bottom: CGFloat, right: CGFloat)
public enum MaterialInsets {
case None
// square
case Square1
case Square2
case Square3
case Square4
case Square5
case Square6
case Square7
case Square8
case Square9
// rectangle
case Rectangle1
case Rectangle2
case Rectangle3
case Rectangle4
case Rectangle5
case Rectangle6
case Rectangle7
case Rectangle8
case Rectangle9
// flipped rectangle
case FlippedRectangle1
case FlippedRectangle2
case FlippedRectangle3
case FlippedRectangle4
case FlippedRectangle5
case FlippedRectangle6
case FlippedRectangle7
case FlippedRectangle8
case FlippedRectangle9
}
/**
:name: MaterialInsetsToValue
*/
public func MaterialInsetsToValue(inset: MaterialInsets) -> MaterialInsetsType {
switch inset {
case .None:
return (top: 0, left: 0, bottom: 0, right: 0)
// square
case .Square1:
return (top: 4, left: 4, bottom: 4, right: 4)
case .Square2:
return (top: 8, left: 8, bottom: 8, right: 8)
case .Square3:
return (top: 16, left: 16, bottom: 16, right: 16)
case .Square4:
return (top: 24, left: 24, bottom: 24, right: 24)
case .Square5:
return (top: 32, left: 32, bottom: 32, right: 32)
case .Square6:
return (top: 40, left: 40, bottom: 40, right: 40)
case .Square7:
return (top: 48, left: 48, bottom: 48, right: 48)
case .Square8:
return (top: 56, left: 56, bottom: 56, right: 56)
case .Square9:
return (top: 64, left: 64, bottom: 64, right: 64)
// rectangle
case .Rectangle1:
return (top: 2, left: 4, bottom: 2, right: 4)
case .Rectangle2:
return (top: 4, left: 8, bottom: 4, right: 8)
case .Rectangle3:
return (top: 8, left: 16, bottom: 8, right: 16)
case .Rectangle4:
return (top: 12, left: 24, bottom: 12, right: 24)
case .Rectangle5:
return (top: 16, left: 32, bottom: 16, right: 32)
case .Rectangle6:
return (top: 20, left: 40, bottom: 20, right: 40)
case .Rectangle7:
return (top: 24, left: 48, bottom: 24, right: 48)
case .Rectangle8:
return (top: 28, left: 56, bottom: 28, right: 56)
case .Rectangle9:
return (top: 32, left: 64, bottom: 32, right: 64)
// flipped rectangle
case .FlippedRectangle1:
return (top: 4, left: 2, bottom: 4, right: 2)
case .FlippedRectangle2:
return (top: 8, left: 4, bottom: 8, right: 4)
case .FlippedRectangle3:
return (top: 16, left: 8, bottom: 16, right: 8)
case .FlippedRectangle4:
return (top: 24, left: 12, bottom: 24, right: 12)
case .FlippedRectangle5:
return (top: 32, left: 16, bottom: 32, right: 16)
case .FlippedRectangle6:
return (top: 40, left: 20, bottom: 40, right: 20)
case .FlippedRectangle7:
return (top: 48, left: 24, bottom: 48, right: 24)
case .FlippedRectangle8:
return (top: 56, left: 28, bottom: 56, right: 28)
case .FlippedRectangle9:
return (top: 64, left: 32, bottom: 64, right: 32)
}
}
......@@ -45,39 +45,39 @@ public struct MaterialLayout {
MaterialLayout.height(parent, child: child, height: height)
}
// /**
// :name: alignChildrenToParentHorizontally
// */
// public static func alignChildrenToParentHorizontally(parent: UIView, children: Array<UIView>, left: CGFloat = 0, right: CGFloat = 0, minimumInteritemSpacing: CGFloat = 0, options: NSLayoutFormatOptions = []) {
// if 0 < children.count {
// var format: String = "H:"
// var i: Int = 1
// var views: Dictionary<String, UIView> = Dictionary<String, UIView>()
// for v in children {
// let k: String = "view\(i++)"
// views[k] = v
// format += i > children.count ? "[\(k)]" : "[\(k)]"
// }
// print(format)
// parent.addConstraints(constraint(format, options: options, metrics: ["left" : left, "right": right, "minimumInteritemSpacing": minimumInteritemSpacing], views: views))
// }
// }
//
// /**
// :name: alignChildrenToParentVertically
// */
// public static func alignChildrenToParentVertically(parent: UIView, children: Array<UIView>, top: CGFloat = 0, bottom: CGFloat = 0, minimumLineSpacing: CGFloat = 0, options: NSLayoutFormatOptions = []) {
// if 0 < children.count {
// var format: String = "V:|-(left)-"
// var i: Int = 1
// var views: Dictionary<String, UIView> = Dictionary<String, UIView>()
// for v in children {
// views["view\(i++)"] = v
// format += i == children.count ? "[view\(i++)]-(right)-|" : "[view\(i++)]-(>=minimumLineSpacing)-"
// }
// parent.addConstraints(constraint(format, options: options, metrics: ["top" : top, "bottom": bottom, "minimumLineSpacing": minimumLineSpacing], views: views))
// }
// }
/**
:name: alignChildrenToParentHorizontally
*/
public static func alignChildrenToParentHorizontally(parent: UIView, children: Array<UIView>, left: CGFloat = 0, right: CGFloat = 0, minimumInteritemSpacing: CGFloat = 0, options: NSLayoutFormatOptions = []) {
if 0 < children.count {
var format: String = "H:"
var i: Int = 1
var views: Dictionary<String, UIView> = Dictionary<String, UIView>()
for v in children {
let k: String = "view\(i++)"
views[k] = v
format += i > children.count ? "[\(k)]" : "[\(k)]"
}
print(format)
parent.addConstraints(constraint(format, options: options, metrics: ["left" : left, "right": right, "minimumInteritemSpacing": minimumInteritemSpacing], views: views))
}
}
/**
:name: alignChildrenToParentVertically
*/
public static func alignChildrenToParentVertically(parent: UIView, children: Array<UIView>, top: CGFloat = 0, bottom: CGFloat = 0, minimumLineSpacing: CGFloat = 0, options: NSLayoutFormatOptions = []) {
if 0 < children.count {
var format: String = "V:|-(left)-"
var i: Int = 1
var views: Dictionary<String, UIView> = Dictionary<String, UIView>()
for v in children {
views["view\(i++)"] = v
format += i == children.count ? "[view\(i++)]-(right)-|" : "[view\(i++)]-(>=minimumLineSpacing)-"
}
parent.addConstraints(constraint(format, options: options, metrics: ["top" : top, "bottom": bottom, "minimumLineSpacing": minimumLineSpacing], views: views))
}
}
/**
:name: alignToParentHorizontally
......
......@@ -93,12 +93,12 @@ public extension MaterialTheme.basicCardView {
public static var shadowColor: UIColor = MaterialColor.black
// shape
public static var contentInsetsRef: MaterialInsetsType = MaterialInsetsToValue(.Square2)
public static var titleLabelInsetsRef: MaterialInsetsType = MaterialInsetsToValue(.Square2)
public static var detailLabelInsetsRef: MaterialInsetsType = MaterialInsetsToValue(.Square2)
public static var leftButtonsInsetsRef: MaterialInsetsType = MaterialInsetsToValue(.None)
public static var rightButtonsInsetsRef: MaterialInsetsType = MaterialInsetsToValue(.None)
public static var dividerInsetsRef: MaterialInsetsType = (top: 8, left: 0, bottom: 8, right: 0)
public static var contentInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square2)
public static var titleLabelInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square2)
public static var detailLabelInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square2)
public static var leftButtonsInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.None)
public static var rightButtonsInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.None)
public static var dividerInsetsRef: UIEdgeInsets = UIEdgeInsets(top: 8, left: 0, bottom: 8, right: 0)
// border
public static var borderWidth: MaterialBorder = .None
......@@ -133,12 +133,12 @@ public extension MaterialTheme.imageCardView {
public static var shadowColor: UIColor = MaterialColor.black
// shape
public static var contentInsetsRef: MaterialInsetsType = MaterialInsetsToValue(.Square2)
public static var titleLabelInsetsRef: MaterialInsetsType = MaterialInsetsToValue(.Square2)
public static var detailLabelInsetsRef: MaterialInsetsType = MaterialInsetsToValue(.Square2)
public static var leftButtonsInsetsRef: MaterialInsetsType = MaterialInsetsToValue(.None)
public static var rightButtonsInsetsRef: MaterialInsetsType = MaterialInsetsToValue(.None)
public static var dividerInsetsRef: MaterialInsetsType = (top: 8, left: 0, bottom: 8, right: 0)
public static var contentInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square2)
public static var titleLabelInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square2)
public static var detailLabelInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square2)
public static var leftButtonsInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.None)
public static var rightButtonsInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.None)
public static var dividerInsetsRef: UIEdgeInsets = UIEdgeInsets(top: 8, left: 0, bottom: 8, right: 0)
// border
public static var borderWidth: MaterialBorder = .None
......@@ -179,11 +179,11 @@ public extension MaterialTheme.navigationBarView {
public static var shadowColor: UIColor = MaterialColor.black
// shape
public static var contentInsetsRef: MaterialInsetsType = MaterialInsetsToValue(.Square2)
public static var titleLabelInsetsRef: MaterialInsetsType = (top: 8, left: 0, bottom: 0, right: 0)
public static var detailLabelInsetsRef: MaterialInsetsType = MaterialInsetsToValue(.None)
public static var leftButtonsInsetsRef: MaterialInsetsType = (top: 8, left: 0, bottom: 0, right: 0)
public static var rightButtonsInsetsRef: MaterialInsetsType = (top: 8, left: 0, bottom: 0, right: 0)
public static var contentInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square2)
public static var titleLabelInsetsRef: UIEdgeInsets = UIEdgeInsets(top: 8, left: 0, bottom: 0, right: 0)
public static var detailLabelInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.None)
public static var leftButtonsInsetsRef: UIEdgeInsets = UIEdgeInsets(top: 8, left: 0, bottom: 0, right: 0)
public static var rightButtonsInsetsRef: UIEdgeInsets = UIEdgeInsets(top: 8, left: 0, bottom: 0, right: 0)
// border
public static var borderWidth: MaterialBorder = .None
......@@ -212,7 +212,7 @@ public extension MaterialTheme.basicCaptureView {
public static var shadowColor: UIColor = MaterialColor.black
// shape
public static var contentInsetsRef: MaterialInsetsType = MaterialInsetsToValue(.Square3)
public static var contentInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square3)
// border
public static var borderWidth: MaterialBorder = .None
......@@ -266,7 +266,7 @@ public extension MaterialTheme.flatButton {
// shape
public static var cornerRadius: MaterialRadius = .Radius1
public static var contentInsets: MaterialInsets = .Rectangle3
public static var contentInsets: MaterialEdgeInsets = .WideRectangle3
public static var shape: MaterialShape = .None
// border
......@@ -297,7 +297,7 @@ public extension MaterialTheme.raisedButton {
// shape
public static var cornerRadius: MaterialRadius = .Radius1
public static var contentInsets: MaterialInsets = .Rectangle2
public static var contentInsets: MaterialEdgeInsets = .WideRectangle2
public static var shape: MaterialShape = .None
// border
......@@ -328,7 +328,7 @@ public extension MaterialTheme.fabButton {
public static var shadowColor: UIColor = MaterialColor.black
// shape
public static var contentInsets: MaterialInsets = .None
public static var contentInsets: MaterialEdgeInsets = .None
public static var shape: MaterialShape = .Circle
// border
......
......@@ -31,16 +31,16 @@ public class NavigationBarView : MaterialView {
/**
:name: contentInsets
*/
public var contentInsets: MaterialInsets = .None {
public var contentInsets: MaterialEdgeInsets = .None {
didSet {
contentInsetsRef = MaterialInsetsToValue(contentInsets)
contentInsetsRef = MaterialEdgeInsetsToValue(contentInsets)
}
}
/**
:name: contentInsetsRef
*/
public var contentInsetsRef: MaterialInsetsType = MaterialTheme.navigationBarView.contentInsetsRef {
public var contentInsetsRef: UIEdgeInsets = MaterialTheme.navigationBarView.contentInsetsRef {
didSet {
reloadView()
}
......@@ -49,16 +49,16 @@ public class NavigationBarView : MaterialView {
/**
:name: titleLabelInsets
*/
public var titleLabelInsets: MaterialInsets = .None {
public var titleLabelInsets: MaterialEdgeInsets = .None {
didSet {
titleLabelInsetsRef = MaterialInsetsToValue(titleLabelInsets)
titleLabelInsetsRef = MaterialEdgeInsetsToValue(titleLabelInsets)
}
}
/**
:name: titleLabelInsetsRef
*/
public var titleLabelInsetsRef: MaterialInsetsType = MaterialTheme.navigationBarView.titleLabelInsetsRef {
public var titleLabelInsetsRef: UIEdgeInsets = MaterialTheme.navigationBarView.titleLabelInsetsRef {
didSet {
reloadView()
}
......@@ -77,16 +77,16 @@ public class NavigationBarView : MaterialView {
/**
:name: detailLabelInsets
*/
public var detailLabelInsets: MaterialInsets = .None {
public var detailLabelInsets: MaterialEdgeInsets = .None {
didSet {
detailLabelInsetsRef = MaterialInsetsToValue(detailLabelInsets)
detailLabelInsetsRef = MaterialEdgeInsetsToValue(detailLabelInsets)
}
}
/**
:name: detailLabelInsetsRef
*/
public var detailLabelInsetsRef: MaterialInsetsType = MaterialTheme.navigationBarView.detailLabelInsetsRef {
public var detailLabelInsetsRef: UIEdgeInsets = MaterialTheme.navigationBarView.detailLabelInsetsRef {
didSet {
reloadView()
}
......@@ -105,16 +105,16 @@ public class NavigationBarView : MaterialView {
/**
:name: leftButtonsInsets
*/
public var leftButtonsInsets: MaterialInsets = .None {
public var leftButtonsInsets: MaterialEdgeInsets = .None {
didSet {
leftButtonsInsetsRef = MaterialInsetsToValue(leftButtonsInsets)
leftButtonsInsetsRef = MaterialEdgeInsetsToValue(leftButtonsInsets)
}
}
/**
:name: leftButtonsInsetsRef
*/
public var leftButtonsInsetsRef: MaterialInsetsType = MaterialTheme.navigationBarView.leftButtonsInsetsRef {
public var leftButtonsInsetsRef: UIEdgeInsets = MaterialTheme.navigationBarView.leftButtonsInsetsRef {
didSet {
reloadView()
}
......@@ -137,16 +137,16 @@ public class NavigationBarView : MaterialView {
/**
:name: rightButtonsInsets
*/
public var rightButtonsInsets: MaterialInsets = .None {
public var rightButtonsInsets: MaterialEdgeInsets = .None {
didSet {
rightButtonsInsetsRef = MaterialInsetsToValue(rightButtonsInsets)
rightButtonsInsetsRef = MaterialEdgeInsetsToValue(rightButtonsInsets)
}
}
/**
:name: rightButtonsInsetsRef
*/
public var rightButtonsInsetsRef: MaterialInsetsType = MaterialTheme.navigationBarView.rightButtonsInsetsRef {
public var rightButtonsInsetsRef: UIEdgeInsets = MaterialTheme.navigationBarView.rightButtonsInsetsRef {
didSet {
reloadView()
}
......
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