Commit 5580bc33 by adamdahan

Merge branch 'development' of https://github.com/GraphKit/MaterialKit into development

parents 0b5cc8ce e38fa3f5
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
65B965721B8A578D0055B139 /* MaterialViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65B965711B8A578D0055B139 /* MaterialViewController.swift */; };
65B965751B8A60A00055B139 /* MaterialView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65B965741B8A60A00055B139 /* MaterialView.swift */; };
963832421B88DFD80015F710 /* MaterialKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 963832361B88DFD80015F710 /* MaterialKit.framework */; }; 963832421B88DFD80015F710 /* MaterialKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 963832361B88DFD80015F710 /* MaterialKit.framework */; };
9638325A1B88E31A0015F710 /* MaterialKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 963832581B88E31A0015F710 /* MaterialKitTests.swift */; }; 9638325A1B88E31A0015F710 /* MaterialKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 963832581B88E31A0015F710 /* MaterialKitTests.swift */; };
963832691B88E5BF0015F710 /* Capture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9638325E1B88E5BF0015F710 /* Capture.swift */; }; 963832691B88E5BF0015F710 /* Capture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9638325E1B88E5BF0015F710 /* Capture.swift */; };
...@@ -50,6 +52,8 @@ ...@@ -50,6 +52,8 @@
/* End PBXContainerItemProxy section */ /* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
65B965711B8A578D0055B139 /* MaterialViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialViewController.swift; sourceTree = "<group>"; };
65B965741B8A60A00055B139 /* MaterialView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialView.swift; sourceTree = "<group>"; };
963832361B88DFD80015F710 /* MaterialKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MaterialKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 963832361B88DFD80015F710 /* MaterialKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MaterialKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
963832411B88DFD80015F710 /* MaterialKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MaterialKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 963832411B88DFD80015F710 /* MaterialKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MaterialKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
963832541B88E30F0015F710 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 963832541B88E30F0015F710 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
...@@ -93,6 +97,15 @@ ...@@ -93,6 +97,15 @@
/* End PBXFrameworksBuildPhase section */ /* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */ /* Begin PBXGroup section */
65B965731B8A58E60055B139 /* View */ = {
isa = PBXGroup;
children = (
65B965741B8A60A00055B139 /* MaterialView.swift */,
65B965711B8A578D0055B139 /* MaterialViewController.swift */,
);
name = View;
sourceTree = "<group>";
};
9638322C1B88DFD80015F710 = { 9638322C1B88DFD80015F710 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -119,6 +132,7 @@ ...@@ -119,6 +132,7 @@
9638325C1B88E3420015F710 /* Supporting Files */, 9638325C1B88E3420015F710 /* Supporting Files */,
9AAC38521B89553800FE6B2D /* Font */, 9AAC38521B89553800FE6B2D /* Font */,
963832861B8907FE0015F710 /* Layout */, 963832861B8907FE0015F710 /* Layout */,
65B965731B8A58E60055B139 /* View */,
963832761B88E8990015F710 /* Text */, 963832761B88E8990015F710 /* Text */,
963832751B88E87B0015F710 /* Button */, 963832751B88E87B0015F710 /* Button */,
9AAC384B1B89524E00FE6B2D /* Card */, 9AAC384B1B89524E00FE6B2D /* Card */,
...@@ -343,8 +357,10 @@ ...@@ -343,8 +357,10 @@
9638326B1B88E5BF0015F710 /* FabButton.swift in Sources */, 9638326B1B88E5BF0015F710 /* FabButton.swift in Sources */,
9A94D1091B8A3F5100F586A5 /* PulseView.swift in Sources */, 9A94D1091B8A3F5100F586A5 /* PulseView.swift in Sources */,
9638326C1B88E5BF0015F710 /* FlatButton.swift in Sources */, 9638326C1B88E5BF0015F710 /* FlatButton.swift in Sources */,
65B965751B8A60A00055B139 /* MaterialView.swift in Sources */,
963832711B88E5BF0015F710 /* Text.swift in Sources */, 963832711B88E5BF0015F710 /* Text.swift in Sources */,
9638326A1B88E5BF0015F710 /* CapturePreview.swift in Sources */, 9638326A1B88E5BF0015F710 /* CapturePreview.swift in Sources */,
65B965721B8A578D0055B139 /* MaterialViewController.swift in Sources */,
9AAC38541B89559900FE6B2D /* Roboto.swift in Sources */, 9AAC38541B89559900FE6B2D /* Roboto.swift in Sources */,
963832881B8908180015F710 /* Layout.swift in Sources */, 963832881B8908180015F710 /* Layout.swift in Sources */,
9AAC384D1B89528900FE6B2D /* BasicCard.swift in Sources */, 9AAC384D1B89528900FE6B2D /* BasicCard.swift in Sources */,
......
...@@ -23,9 +23,9 @@ public class FlatButton : UIButton { ...@@ -23,9 +23,9 @@ public class FlatButton : UIButton {
public var textColor: UIColor? public var textColor: UIColor?
public var pulseColor: UIColor? public var pulseColor: UIColor?
private var vLine: UIView = UIView() private lazy var vLine: UIView = UIView()
private var hLine: UIView = UIView() private lazy var hLine: UIView = UIView()
private var backgroundColorView: UIView = UIView() private lazy var backgroundColorView: UIView = UIView()
private var pulseView: UIView? private var pulseView: UIView?
public override func drawRect(rect: CGRect) { public override func drawRect(rect: CGRect) {
...@@ -65,6 +65,7 @@ public class FlatButton : UIButton { ...@@ -65,6 +65,7 @@ public class FlatButton : UIButton {
backgroundColorView.layer.cornerRadius = 3.0 backgroundColorView.layer.cornerRadius = 3.0
backgroundColorView.backgroundColor = UIColor.clearColor() backgroundColorView.backgroundColor = UIColor.clearColor()
backgroundColorView.layer.masksToBounds = true backgroundColorView.layer.masksToBounds = true
backgroundColorView.userInteractionEnabled = false
self.insertSubview(backgroundColorView, atIndex: 0) self.insertSubview(backgroundColorView, atIndex: 0)
} }
......
...@@ -19,43 +19,81 @@ ...@@ -19,43 +19,81 @@
import UIKit import UIKit
public struct Layout { public struct Layout {
public static func topRight(parent: UIView, child: UIView, width: CGFloat, height: CGFloat, top: CGFloat, right: CGFloat) { /**
parent.addSubview(child) :name: width
var metrics = ["width" : width, "height" : height, "top" : top, "right" : right] */
var views = ["view" : child] public static func width(parent: UIView, child: UIView, width: CGFloat) {
var viewBindingsDict: NSMutableDictionary = NSMutableDictionary() let metrics: Dictionary<String, AnyObject> = ["width" : width]
viewBindingsDict.setValue(child, forKey: "child") let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:[child(width)]-(right)-|", options: nil, metrics: metrics, views: viewBindingsDict as [NSObject : AnyObject])) parent.addConstraints(constraint(parent, constraint: "H:[child(width)]", options: nil, metrics: metrics, views: views))
parent.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-(top)-[child(height)]", options: nil, metrics: metrics, views: viewBindingsDict as [NSObject : AnyObject]))
} }
public static func topLeft(parent: UIView, child: UIView, width: CGFloat, height: CGFloat, top: CGFloat, left: CGFloat) { /**
parent.addSubview(child) :name: height
var metrics = ["width" : width, "height" : height, "top" : top, "left" : left] */
var views = ["view" : child] public static func height(parent: UIView, child: UIView, height: CGFloat) {
var viewBindingsDict: NSMutableDictionary = NSMutableDictionary() let metrics: Dictionary<String, AnyObject> = ["height" : height]
viewBindingsDict.setValue(child, forKey: "child") let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-(left)-[child(width)]", options: nil, metrics: metrics, views: viewBindingsDict as [NSObject : AnyObject])) parent.addConstraints(constraint(parent, constraint: "V:[child(height)]", options: nil, metrics: metrics, views: views))
parent.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-(top)-[child(height)]", options: nil, metrics: metrics, views: viewBindingsDict as [NSObject : AnyObject]))
} }
public static func bottomRight(parent: UIView, child: UIView, width: CGFloat, height: CGFloat, bottom: CGFloat, right: CGFloat) { /**
parent.addSubview(child) :name: size
var metrics = ["width" : width, "height" : height, "bottom" : bottom, "right" : right] */
var views = ["view" : child] public static func size(parent: UIView, child: UIView, width: CGFloat, height: CGFloat) {
var viewBindingsDict: NSMutableDictionary = NSMutableDictionary() Layout.width(parent, child: child, width: width)
viewBindingsDict.setValue(child, forKey: "child") Layout.height(parent, child: child, height: height)
parent.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:[child(width)]-(right)-|", options: nil, metrics: metrics, views: viewBindingsDict as [NSObject : AnyObject]))
parent.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:[child(height)]-(bottom)-|", options: nil, metrics: metrics, views: viewBindingsDict as [NSObject : AnyObject]))
} }
public static func bottomLeft(parent: UIView, child: UIView, width: CGFloat, height: CGFloat, bottom: CGFloat, left: CGFloat) { /**
parent.addSubview(child) :name: alignFromTopLeft
var metrics = ["width" : width, "height" : height, "bottom" : bottom, "left" : left] */
var views = ["view" : child] public static func alignFromTopLeft(parent: UIView, child: UIView, top: CGFloat, left: CGFloat) {
var viewBindingsDict: NSMutableDictionary = NSMutableDictionary() let metrics: Dictionary<String, AnyObject> = ["top" : top, "left" : left]
viewBindingsDict.setValue(child, forKey: "child") let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-(left)-[child(width)]", options: nil, metrics: metrics, views: viewBindingsDict as [NSObject : AnyObject])) parent.addConstraints(constraint(parent, constraint: "H:|-(left)-[child]", options: nil, metrics: metrics, views: views))
parent.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:[child(height)]-(bottom)-|", options: nil, metrics: metrics, views: viewBindingsDict as [NSObject : AnyObject])) parent.addConstraints(constraint(parent, constraint: "V:|-(top)-[child]", options: nil, metrics: metrics, views: views))
}
/**
:name: alignFromTopRight
*/
public static func alignFromTopRight(parent: UIView, child: UIView, top: CGFloat, right: CGFloat) {
let metrics: Dictionary<String, AnyObject> = ["top" : top, "right" : right]
let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(constraint(parent, constraint: "H:[child]-(right)-|", options: nil, metrics: metrics, views: views))
parent.addConstraints(constraint(parent, constraint: "V:|-(top)-[child]", options: nil, metrics: metrics, views: views))
}
/**
:name: alignFromBottomLeft
*/
public static func alignFromBottomLeft(parent: UIView, child: UIView, bottom: CGFloat, left: CGFloat) {
let metrics: Dictionary<String, AnyObject> = ["bottom" : bottom, "left" : left]
let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(constraint(parent, constraint: "H:|-(left)-[child]", options: nil, metrics: metrics, views: views))
parent.addConstraints(constraint(parent, constraint: "V:[child]-(bottom)-|", options: nil, metrics: metrics, views: views))
}
/**
:name: alignFromBottomRight
*/
public static func alignFromBottomRight(parent: UIView, child: UIView, bottom: CGFloat, right: CGFloat) {
let metrics: Dictionary<String, AnyObject> = ["bottom" : bottom, "right" : right]
let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(constraint(parent, constraint: "H:[child]-(right)-|", options: nil, metrics: metrics, views: views))
parent.addConstraints(constraint(parent, constraint: "V:[child]-(bottom)-|", options: nil, metrics: metrics, views: views))
}
/**
:name: constraint
*/
public static func constraint(parent: UIView, constraint: String, options: NSLayoutFormatOptions, metrics: Dictionary<String, AnyObject>, views: Dictionary<String, AnyObject>) -> Array<NSLayoutConstraint> {
return NSLayoutConstraint.constraintsWithVisualFormat(
constraint,
options: options,
metrics: metrics,
views: views
) as! Array<NSLayoutConstraint>
} }
} }
//
// Copyright (C) 2015 GraphKit, Inc. <http://graphkit.io> and other GraphKit 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 class MaterialView : UIView {
/**
:name: topLeft
*/
public func topLeft(child: UIView, top: CGFloat, left: CGFloat) {
Layout.alignFromTopLeft(self, child: child, top: top, left: left)
}
/**
:name: topRight
*/
public func topRight(child: UIView, top: CGFloat, right: CGFloat) {
Layout.alignFromTopRight(self, child: child, top: top, right: right)
}
/**
:name: bottomLeft
*/
public func bottomLeft(child: UIView, bottom: CGFloat, left: CGFloat) {
Layout.alignFromBottomLeft(self, child: child, bottom: bottom, left: left)
}
/**
:name: bottomRight
*/
public func bottomRight(child: UIView, bottom: CGFloat, right: CGFloat) {
Layout.alignFromBottomRight(self, child: child, bottom: bottom, right: right)
}
}
//
// Copyright (C) 2015 GraphKit, Inc. <http://graphkit.io> and other GraphKit 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 class MaterialViewController : UIViewController {
/**
:name: topLeft
*/
public func topLeft(child: UIView, top: CGFloat, left: CGFloat) {
Layout.alignFromTopLeft(view, child: child, top: top, left: left)
}
/**
:name: topRight
*/
public func topRight(child: UIView, top: CGFloat, right: CGFloat) {
Layout.alignFromTopRight(view, child: child, top: top, right: right)
}
/**
:name: bottomLeft
*/
public func bottomLeft(child: UIView, bottom: CGFloat, left: CGFloat) {
Layout.alignFromBottomLeft(view, child: child, bottom: bottom, left: left)
}
/**
:name: bottomRight
*/
public func bottomRight(child: UIView, bottom: CGFloat, right: CGFloat) {
Layout.alignFromBottomRight(view, child: child, bottom: bottom, right: right)
}
}
...@@ -66,6 +66,7 @@ public class RaisedButton : UIButton { ...@@ -66,6 +66,7 @@ public class RaisedButton : UIButton {
backgroundColorView.layer.cornerRadius = 3.0 backgroundColorView.layer.cornerRadius = 3.0
backgroundColorView.backgroundColor = color backgroundColorView.backgroundColor = color
backgroundColorView.layer.masksToBounds = true backgroundColorView.layer.masksToBounds = true
backgroundColorView.userInteractionEnabled = false
self.insertSubview(backgroundColorView, atIndex: 0) self.insertSubview(backgroundColorView, atIndex: 0)
} }
......
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