Commit 710ad186 by Daniel Dahan

various updates for next release

parent b8659bb0
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
......@@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
960B23541C3870A500E96216 /* MaterialKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 960B23531C3870A500E96216 /* MaterialKit.framework */; };
960B23551C3870A500E96216 /* MaterialKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 960B23531C3870A500E96216 /* MaterialKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
967513CA1C136BB7009F455A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967513C91C136BB7009F455A /* AppDelegate.swift */; };
967513CC1C136BB7009F455A /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967513CB1C136BB7009F455A /* ViewController.swift */; };
967513D11C136BB7009F455A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 967513D01C136BB7009F455A /* Assets.xcassets */; };
......@@ -20,6 +22,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
960B23551C3870A500E96216 /* MaterialKit.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
......@@ -27,6 +30,7 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
960B23531C3870A500E96216 /* MaterialKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = MaterialKit.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/MaterialKit-gdulktuccbcfwbdfadtpxkworhyc/Build/Products/Debug-iphoneos/MaterialKit.framework"; sourceTree = "<absolute>"; };
967513C61C136BB7009F455A /* CardView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CardView.app; sourceTree = BUILT_PRODUCTS_DIR; };
967513C91C136BB7009F455A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
967513CB1C136BB7009F455A /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
......@@ -40,6 +44,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
960B23541C3870A500E96216 /* MaterialKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -49,6 +54,7 @@
967513BD1C136BB7009F455A = {
isa = PBXGroup;
children = (
960B23531C3870A500E96216 /* MaterialKit.framework */,
967513C81C136BB7009F455A /* CardView */,
967513C71C136BB7009F455A /* Products */,
);
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......@@ -27,8 +27,8 @@ class ViewController: UIViewController {
// Examples of using CardView.
// Uncomment different examples and read
// the comments below.
// prepareGeneralCardViewExample()
prepareCardViewWithoutPulseBackgroundImageExample()
prepareGeneralCardViewExample()
// prepareCardViewWithoutPulseBackgroundImageExample()
// prepareCardViewWithAlteredAlignmentExample()
// prepareCardViewButtonBarExample()
}
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>.
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved..
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......@@ -65,7 +65,7 @@ public class MaterialButton : UIButton {
/**
:name: pulseColorOpacity
*/
public var pulseColorOpacity: CGFloat = MaterialTheme.pulseView.pulseColorOpacity {
public var pulseColorOpacity: CGFloat = 0.25 {
didSet {
updatePulseLayer()
}
......@@ -428,7 +428,7 @@ public class MaterialButton : UIButton {
*/
public override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesEnded(touches, withEvent: event)
shrink()
shrinkAnimation()
}
/**
......@@ -436,7 +436,7 @@ public class MaterialButton : UIButton {
*/
public override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) {
super.touchesCancelled(touches, withEvent: event)
shrink()
shrinkAnimation()
}
/**
......@@ -500,7 +500,7 @@ public class MaterialButton : UIButton {
/**
:name: shrink
*/
internal func shrink() {
internal func shrinkAnimation() {
let t: CFTimeInterval = 0.25
let s: CGFloat = 1
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......@@ -22,13 +22,13 @@ public extension UIImage {
/**
:name: contentsOfURL
*/
public class func contentsOfURL(URL: NSURL, completion: ((image: UIImage?, error: NSError?) -> Void)?) {
public class func contentsOfURL(URL: NSURL, completion: ((image: UIImage?, error: NSError?) -> Void)) {
let request: NSURLRequest = NSURLRequest(URL: URL)
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()) { (response: NSURLResponse?, data: NSData?, error: NSError?) -> Void in
if let v: NSError = error {
completion?(image: nil, error: v)
completion(image: nil, error: v)
} else if let v: NSData = data {
completion?(image: UIImage(data: v), error: nil)
completion(image: UIImage(data: v), error: nil)
}
}
}
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......@@ -19,19 +19,13 @@
import UIKit
public class MaterialPulseView : MaterialView {
/**
:name: pulseLayer
*/
/// A CAShapeLayer used in the pulse animation.
public private(set) lazy var pulseLayer: CAShapeLayer = CAShapeLayer()
/**
:name: pulseScale
*/
/// Sets whether the scaling animation should be used.
public lazy var pulseScale: Bool = true
/**
:name: spotlight
*/
/// Enables and disables the spotlight effect.
public var spotlight: Bool = false {
didSet {
if spotlight {
......@@ -41,7 +35,8 @@ public class MaterialPulseView : MaterialView {
}
/**
:name: pulseFill
Determines if the pulse animation should fill the entire
view.
*/
public var pulseFill: Bool = false {
didSet {
......@@ -51,18 +46,14 @@ public class MaterialPulseView : MaterialView {
}
}
/**
:name: pulseColorOpacity
*/
public var pulseColorOpacity: CGFloat = MaterialTheme.pulseView.pulseColorOpacity {
/// The opcaity value for the pulse animation.
public var pulseColorOpacity: CGFloat = 0.25 {
didSet {
updatedPulseLayer()
}
}
/**
:name: pulseColor
*/
/// The color of the pulse effect.
public var pulseColor: UIColor? {
didSet {
updatedPulseLayer()
......@@ -70,7 +61,10 @@ public class MaterialPulseView : MaterialView {
}
/**
:name: touchesBegan
A delegation method that is executed when the view has began a
touch event.
- Parameter touches: A set of UITouch objects.
- Parameter event: A UIEvent object.
*/
public override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesBegan(touches, withEvent: event)
......@@ -100,7 +94,10 @@ public class MaterialPulseView : MaterialView {
}
/**
:name: touchesMoved
A delegation method that is executed when the view touch event is
moving.
- Parameter touches: A set of UITouch objects.
- Parameter event: A UIEvent object.
*/
public override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesMoved(touches, withEvent: event)
......@@ -115,63 +112,54 @@ public class MaterialPulseView : MaterialView {
}
/**
:name: touchesEnded
A delegation method that is executed when the view touch event has
ended.
- Parameter touches: A set of UITouch objects.
- Parameter event: A UIEvent object.
*/
public override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesEnded(touches, withEvent: event)
shrink()
shrinkAnimation()
}
/**
:name: touchesCancelled
A delegation method that is executed when the view touch event has
been cancelled.
- Parameter touches: A set of UITouch objects.
- Parameter event: A UIEvent object.
*/
public override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) {
super.touchesCancelled(touches, withEvent: event)
shrink()
shrinkAnimation()
}
/**
:name: prepareView
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()
userInteractionEnabled = MaterialTheme.pulseView.userInteractionEnabled
backgroundColor = MaterialTheme.pulseView.backgroundColor
pulseColor = MaterialTheme.pulseView.pulseColor
contentsRect = MaterialTheme.pulseView.contentsRect
contentsCenter = MaterialTheme.pulseView.contentsCenter
contentsScale = MaterialTheme.pulseView.contentsScale
contentsGravity = MaterialTheme.pulseView.contentsGravity
depth = MaterialTheme.pulseView.depth
shadowColor = MaterialTheme.pulseView.shadowColor
zPosition = MaterialTheme.pulseView.zPosition
borderWidth = MaterialTheme.pulseView.borderWidth
borderColor = MaterialTheme.pulseView.bordercolor
pulseColor = MaterialColor.white
preparePulseLayer()
}
/**
:name: preparePulseLayer
*/
/// Prepares the pulseLayer property.
internal func preparePulseLayer() {
pulseLayer.hidden = true
pulseLayer.zPosition = 1
visualLayer.addSublayer(pulseLayer)
}
/**
:name: updatedPulseLayer
*/
/// Updates the pulseLayer when settings have changed.
internal func updatedPulseLayer() {
pulseLayer.backgroundColor = pulseColor?.colorWithAlphaComponent(pulseColorOpacity).CGColor
}
/**
:name: shrink
*/
internal func shrink() {
/// Executes the shrink animation for the pulse effect.
internal func shrinkAnimation() {
let t: CFTimeInterval = 0.25
let s: CGFloat = 1
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......@@ -19,8 +19,6 @@
import UIKit
public struct MaterialTheme {
public struct view {}
public struct pulseView {}
public struct basicCardView {}
public struct imageCardView {}
public struct navigationBarView {}
......@@ -32,60 +30,6 @@ public struct MaterialTheme {
public struct fabButton {}
}
// view
public extension MaterialTheme.view {
// shadow
public static var depth: MaterialDepth = .None
public static var shadowColor: UIColor = MaterialColor.black
// border
public static var borderWidth: MaterialBorder = .None
public static var bordercolor: UIColor = MaterialColor.black
// color
public static var backgroundColor: UIColor = MaterialColor.white
// interaction
public static var userInteractionEnabled: Bool = true
// image
public static var contentsRect: CGRect = CGRectMake(0, 0, 1, 1)
public static var contentsCenter: CGRect = CGRectMake(0, 0, 1, 1)
public static var contentsScale: CGFloat = UIScreen.mainScreen().scale
public static var contentsGravity: MaterialGravity = .ResizeAspectFill
// position
public static var zPosition: CGFloat = 0
}
// pulseView
public extension MaterialTheme.pulseView {
// shadow
public static var depth: MaterialDepth = .None
public static var shadowColor: UIColor = MaterialColor.black
// border
public static var borderWidth: MaterialBorder = .None
public static var bordercolor: UIColor = MaterialColor.black
// color
public static var backgroundColor: UIColor = MaterialColor.clear
public static var pulseColor: UIColor = MaterialColor.white
public static var pulseColorOpacity: CGFloat = 0.25
// interaction
public static var userInteractionEnabled: Bool = true
// image
public static var contentsRect: CGRect = CGRectMake(0, 0, 1, 1)
public static var contentsCenter: CGRect = CGRectMake(0, 0, 1, 1)
public static var contentsScale: CGFloat = UIScreen.mainScreen().scale
public static var contentsGravity: MaterialGravity = .ResizeAspectFill
// position
public static var zPosition: CGFloat = 0
}
// basicCardView
public extension MaterialTheme.basicCardView {
// shadow
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......@@ -248,7 +248,8 @@ public class MaterialView : UIView {
}
/**
:name: borderWidth
A property that accesses the layer.borderWith using a MaterialBorder
enum preset.
*/
public var borderWidth: MaterialBorder {
didSet {
......@@ -256,18 +257,14 @@ public class MaterialView : UIView {
}
}
/**
:name: borderColor
*/
/// A property that accesses the layer.borderColor property.
public var borderColor: UIColor? {
didSet {
layer.borderColor = borderColor?.CGColor
}
}
/**
:name: position
*/
/// A property that accesses the layer.position property.
public var position: CGPoint {
get {
return layer.position
......@@ -277,9 +274,7 @@ public class MaterialView : UIView {
}
}
/**
:name: zPosition
*/
/// A property that accesses the layer.zPosition property.
public var zPosition: CGFloat {
get {
return layer.zPosition
......@@ -290,15 +285,16 @@ public class MaterialView : UIView {
}
/**
:name: init
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
*/
public required init?(coder aDecoder: NSCoder) {
contentsRect = MaterialTheme.view.contentsRect
contentsCenter = MaterialTheme.view.contentsCenter
contentsScale = MaterialTheme.view.contentsScale
contentsGravity = MaterialTheme.view.contentsGravity
borderWidth = MaterialTheme.view.borderWidth
depth = MaterialTheme.view.depth
contentsRect = CGRectMake(0, 0, 1, 1)
contentsCenter = CGRectMake(0, 0, 1, 1)
contentsScale = UIScreen.mainScreen().scale
contentsGravity = .ResizeAspectFill
borderWidth = .None
depth = .None
shape = .None
cornerRadius = .None
super.init(coder: aDecoder)
......@@ -306,31 +302,30 @@ public class MaterialView : UIView {
}
/**
:name: init
An initializer that initializes the object with a CGRect object.
If AutoLayout is used, it is better to initilize the instance
using the init() initializer.
- Parameter frame: A CGRect instance.
*/
public override init(frame: CGRect) {
contentsRect = MaterialTheme.view.contentsRect
contentsCenter = MaterialTheme.view.contentsCenter
contentsScale = MaterialTheme.view.contentsScale
contentsGravity = MaterialTheme.view.contentsGravity
borderWidth = MaterialTheme.view.borderWidth
depth = MaterialTheme.view.depth
contentsRect = CGRectMake(0, 0, 1, 1)
contentsCenter = CGRectMake(0, 0, 1, 1)
contentsScale = UIScreen.mainScreen().scale
contentsGravity = .ResizeAspectFill
borderWidth = .None
depth = .None
shape = .None
cornerRadius = .None
super.init(frame: frame)
prepareView()
}
/**
:name: init
*/
/// A convenience initializer that is mostly used with AutoLayout.
public convenience init() {
self.init(frame: CGRectNull)
}
/**
:name: layoutSublayersOfLayer
*/
/// Overriding the layout callback for layer sublayers.
public override func layoutSublayersOfLayer(layer: CALayer) {
super.layoutSublayersOfLayer(layer)
if self.layer == layer {
......@@ -340,14 +335,19 @@ public class MaterialView : UIView {
}
/**
:name: actionForLayer
By default CALayer values are animated. The UIView class supresses this
behavior for its backing layer. By overrinding the actionForLayer method
and returning nil, the backing layer's default animation behavior
is enabled.
*/
public override func actionForLayer(layer: CALayer, forKey event: String) -> CAAction? {
return nil
}
/**
:name: animate
A method that accepts CAAnimation objects and executes them on the
view's backing layer.
- Parameter animation: A CAAnimation instance.
*/
public func animate(animation: CAAnimation) {
animation.delegate = self
......@@ -364,14 +364,21 @@ public class MaterialView : UIView {
}
/**
:name: animationDidStart
A delegation method that is executed when the backing layer starts
running an animation.
- Parameter anim: The currently running CAAnimation instance.
*/
public override func animationDidStart(anim: CAAnimation) {
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStart?(anim)
}
/**
:name: animationDidStop
A delegation method that is executed when the backing layer stops
running an animation.
- Parameter anim: The CAAnimation instance that stopped running.
- Parameter flag: A boolean that indicates if the animation stopped
because it was completed or interrupted. True if completed, false
if interrupted.
*/
public override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
if let a: CAPropertyAnimation = anim as? CAPropertyAnimation {
......@@ -391,40 +398,33 @@ public class MaterialView : UIView {
}
/**
:name: prepareView
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 func prepareView() {
userInteractionEnabled = MaterialTheme.view.userInteractionEnabled
backgroundColor = MaterialTheme.view.backgroundColor
shadowColor = MaterialTheme.view.shadowColor
zPosition = MaterialTheme.view.zPosition
borderColor = MaterialTheme.view.bordercolor
prepareVisualLayer()
shadowColor = MaterialColor.black
borderColor = MaterialColor.black
}
/**
:name: prepareVisualLayer
*/
/// Prepares the visualLayer property.
internal func prepareVisualLayer() {
visualLayer.zPosition = 0
visualLayer.masksToBounds = true
layer.addSublayer(visualLayer)
}
/**
:name: layoutVisualLayer
*/
/// Manages the layout for the visualLayer property.
internal func layoutVisualLayer() {
visualLayer.frame = bounds
visualLayer.position = CGPointMake(width / 2, height / 2)
visualLayer.cornerRadius = layer.cornerRadius
}
/**
:name: layoutShape
*/
/// Manages the layout for the shape of the view instance.
internal func layoutShape() {
if .Circle == shape {
layer.cornerRadius = width / 2
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......@@ -18,75 +18,97 @@
import UIKit
/**
:name: unique
*/
public func unique<S: SequenceType, E: Hashable where E == S.Generator.Element>(source: S) -> [E] {
var seen: [E: Bool] = [:]
return source.filter { nil == seen.updateValue(true, forKey: $0) }
}
@objc(TextDelegate)
public protocol TextDelegate {
/**
An optional delegation method that is executed when
text will be processed during editing.
- Parameter text: The Text instance assodicated with the
delegation object.
- Parameter textStorage: The TextStorage instance
associated with the delegation object.
- Parameter string: The string value that is currently
being edited.
- Parameter range: The range of characters that are being
edited.
*/
optional func textWillProcessEdit(text: Text, textStorage: TextStorage, string: String, range: NSRange)
/**
An optional delegation method that is executed after
the edit processing has completed.
- Parameter text: The Text instance assodicated with the
delegation object.
- Parameter textStorage: The TextStorage instance
associated with the delegation object.
- Parameter string: The string value that was edited.
- Parameter result: A NSTextCheckingResult associated
with the processing result.
- Parameter flags: Matching flags.
- Parameter stop: Halts a service which is either
publishing or resolving.
*/
optional func textDidProcessEdit(text: Text, textStorage: TextStorage, string: String, result: NSTextCheckingResult?, flags: NSMatchingFlags, stop: UnsafeMutablePointer<ObjCBool>)
}
@objc(Text)
public class Text : NSObject {
/**
:name: pattern
*/
/// The string pattern to match within the textStorage.
public var pattern: String = "(^|\\s)#[\\d\\w_\u{203C}\u{2049}\u{20E3}\u{2122}\u{2139}\u{2194}-\u{2199}\u{21A9}-\u{21AA}\u{231A}-\u{231B}\u{23E9}-\u{23EC}\u{23F0}\u{23F3}\u{24C2}\u{25AA}-\u{25AB}\u{25B6}\u{25C0}\u{25FB}-\u{25FE}\u{2600}-\u{2601}\u{260E}\u{2611}\u{2614}-\u{2615}\u{261D}\u{263A}\u{2648}-\u{2653}\u{2660}\u{2663}\u{2665}-\u{2666}\u{2668}\u{267B}\u{267F}\u{2693}\u{26A0}-\u{26A1}\u{26AA}-\u{26AB}\u{26BD}-\u{26BE}\u{26C4}-\u{26C5}\u{26CE}\u{26D4}\u{26EA}\u{26F2}-\u{26F3}\u{26F5}\u{26FA}\u{26FD}\u{2702}\u{2705}\u{2708}-\u{270C}\u{270F}\u{2712}\u{2714}\u{2716}\u{2728}\u{2733}-\u{2734}\u{2744}\u{2747}\u{274C}\u{274E}\u{2753}-\u{2755}\u{2757}\u{2764}\u{2795}-\u{2797}\u{27A1}\u{27B0}\u{2934}-\u{2935}\u{2B05}-\u{2B07}\u{2B1B}-\u{2B1C}\u{2B50}\u{2B55}\u{3030}\u{303D}\u{3297}\u{3299}\u{1F004}\u{1F0CF}\u{1F170}-\u{1F171}\u{1F17E}-\u{1F17F}\u{1F18E}\u{1F191}-\u{1F19A}\u{1F1E7}-\u{1F1EC}\u{1F1EE}-\u{1F1F0}\u{1F1F3}\u{1F1F5}\u{1F1F7}-\u{1F1FA}\u{1F201}-\u{1F202}\u{1F21A}\u{1F22F}\u{1F232}-\u{1F23A}\u{1F250}-\u{1F251}\u{1F300}-\u{1F320}\u{1F330}-\u{1F335}\u{1F337}-\u{1F37C}\u{1F380}-\u{1F393}\u{1F3A0}-\u{1F3C4}\u{1F3C6}-\u{1F3CA}\u{1F3E0}-\u{1F3F0}\u{1F400}-\u{1F43E}\u{1F440}\u{1F442}-\u{1F4F7}\u{1F4F9}-\u{1F4FC}\u{1F500}-\u{1F507}\u{1F509}-\u{1F53D}\u{1F550}-\u{1F567}\u{1F5FB}-\u{1F640}\u{1F645}-\u{1F64F}\u{1F680}-\u{1F68A}]+" {
didSet {
textStorage.expression = try? NSRegularExpression(pattern: pattern, options: [])
prepareTextStorageExpression()
}
}
/**
:name: textStorage
*/
/// TextStorage instance that is observed while editing.
public private(set) var textStorage: TextStorage = TextStorage()
/**
:name: delegate
*/
/// Delegation object for pre and post text processing.
public weak var delegate: TextDelegate?
/**
:name: init
*/
/// Initializer.
public override init() {
super.init()
textStorage.expression = try? NSRegularExpression(pattern: pattern, options: [])
textStorage.textWillProcessEdit = { (textStorage: TextStorage, string: String, range: NSRange) -> Void in
self.delegate?.textWillProcessEdit?(self, textStorage: textStorage, string: string, range: range)
}
textStorage.textDidProcessEdit = { (textStorage: TextStorage, result: NSTextCheckingResult?, flags: NSMatchingFlags, stop: UnsafeMutablePointer<ObjCBool>) -> Void in
self.delegate?.textDidProcessEdit?(self, textStorage: textStorage, string: textStorage.string, result: result, flags: flags, stop: stop)
}
prepareTextStorageExpression()
prepareTextStorageProcessingCallbacks()
}
/**
:name: string
A convenience property that accesses the textStorage
string.
*/
public var string: String {
return textStorage.string
}
/**
:name: matches
*/
/// An Array of matches that match the pattern expression.
public var matches: Array<String> {
return textStorage.expression!.matchesInString(string, options: [], range: NSMakeRange(0, string.utf16.count)).map {
(self.string as NSString).substringWithRange($0.range).stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
(self.string as NSString).substringWithRange($0.range).trim()
}
}
/**
:name: uniqueMatches
An Array of unique matches that match the pattern
expression.
*/
public var uniqueMatches: Array<String> {
return unique(matches)
var seen: [String: Bool] = [:]
return matches.filter { nil == seen.updateValue(true, forKey: $0) }
}
/// Prepares the TextStorage regular expression for matching.
private func prepareTextStorageExpression() {
textStorage.expression = try? NSRegularExpression(pattern: pattern, options: [])
}
/// Prepares the pre and post processing callbacks.
private func prepareTextStorageProcessingCallbacks() {
textStorage.textWillProcessEdit = { [unowned self] (textStorage: TextStorage, string: String, range: NSRange) -> Void in
self.delegate?.textWillProcessEdit?(self, textStorage: textStorage, string: string, range: range)
}
textStorage.textDidProcessEdit = { [unowned self] (textStorage: TextStorage, result: NSTextCheckingResult?, flags: NSMatchingFlags, stop: UnsafeMutablePointer<ObjCBool>) -> Void in
self.delegate?.textDidProcessEdit?(self, textStorage: textStorage, string: textStorage.string, result: result, flags: flags, stop: stop)
}
}
}
\ No newline at end of file
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......@@ -21,23 +21,17 @@ import UIKit
public protocol TextFieldDelegate : UITextFieldDelegate {}
public class TextField : UITextField {
/**
:name: bottomBorderLayer
*/
/// The bottom border layer.
public private(set) lazy var bottomBorderLayer: CAShapeLayer = CAShapeLayer()
/**
:name: backgroundColor
*/
/// A property that accesses the backing layer's backgroundColor.
public override var backgroundColor: UIColor? {
didSet {
layer.backgroundColor = backgroundColor?.CGColor
}
}
/**
:name: x
*/
/// A property that accesses the layer.frame.origin.x property.
public var x: CGFloat {
get {
return layer.frame.origin.x
......@@ -47,9 +41,7 @@ public class TextField : UITextField {
}
}
/**
:name: y
*/
/// A property that accesses the layer.frame.origin.y property.
public var y: CGFloat {
get {
return layer.frame.origin.y
......@@ -60,7 +52,10 @@ public class TextField : UITextField {
}
/**
:name: width
A property that accesses the layer.frame.origin.width property.
When setting this property in conjunction with the shape property having a
value that is not .None, the height will be adjusted to maintain the correct
shape.
*/
public var width: CGFloat {
get {
......@@ -72,7 +67,10 @@ public class TextField : UITextField {
}
/**
:name: height
A property that accesses the layer.frame.origin.height property.
When setting this property in conjunction with the shape property having a
value that is not .None, the width will be adjusted to maintain the correct
shape.
*/
public var height: CGFloat {
get {
......@@ -84,7 +82,8 @@ public class TextField : UITextField {
}
/**
:name: borderWidth
A property that accesses the layer.borderWith using a MaterialBorder
enum preset.
*/
public var borderWidth: MaterialBorder {
didSet {
......@@ -92,18 +91,14 @@ public class TextField : UITextField {
}
}
/**
:name: borderColor
*/
/// A property that accesses the layer.borderColor property.
public var borderColor: UIColor? {
didSet {
layer.borderColor = borderColor?.CGColor
}
}
/**
:name: position
*/
/// A property that accesses the layer.position property.
public var position: CGPoint {
get {
return layer.position
......@@ -113,9 +108,7 @@ public class TextField : UITextField {
}
}
/**
:name: zPosition
*/
/// A property that accesses the layer.zPosition property.
public var zPosition: CGFloat {
get {
return layer.zPosition
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......@@ -22,55 +22,39 @@ internal typealias TextWillProcessEdit = (TextStorage, String, NSRange) -> Void
internal typealias TextDidProcessEdit = (TextStorage, NSTextCheckingResult?, NSMatchingFlags, UnsafeMutablePointer<ObjCBool>) -> Void
public class TextStorage: NSTextStorage {
/**
:name: store
*/
private lazy var store: NSMutableAttributedString = NSMutableAttributedString()
/**
:name: expression
*/
internal var expression: NSRegularExpression?
/**
:name: textWillProcessEdit
*/
/// A callback that is executed when a process edit will happen.
internal var textWillProcessEdit: TextWillProcessEdit?
/**
:name: textDidProcessEdit
*/
/// A callback that is executed when a process edit did happen.
internal var textDidProcessEdit: TextDidProcessEdit?
/**
:name: init
*/
/// A storage facility for attributed text.
public lazy var store: NSMutableAttributedString = NSMutableAttributedString()
/// The regular expression to match text fragments against.
public var expression: NSRegularExpression?
/// Initializer.
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
/**
:name: init
*/
/// Initializer.
public override init() {
super.init()
}
/**
:name: string
*/
override public var string: String {
get {
return store.string
}
/// A String value of the attirbutedString property.
public override var string: String {
return store.string
}
/**
:name: processEditing
*/
/// Processes the text when editing.
public override func processEditing() {
let range: NSRange = (string as NSString).paragraphRangeForRange(editedRange)
textWillProcessEdit?(self, string, range)
expression!.enumerateMatchesInString(string, options: [], range: range) { (result: NSTextCheckingResult?, flags: NSMatchingFlags, stop: UnsafeMutablePointer<ObjCBool>) -> Void in
self.textDidProcessEdit?(self, result, flags, stop)
}
......@@ -78,14 +62,26 @@ public class TextStorage: NSTextStorage {
}
/**
:name: attributesAtIndex
Returns the attributes for the character at a given index.
- Parameter location: The index for which to return attributes.
This value must lie within the bounds of the receiver.
- Parameter range: Upon return, the range over which the
attributes and values are the same as those at index. This range
isn’t necessarily the maximum range covered, and its extent is
implementation-dependent. If you need the maximum range, use
attributesAtIndex:longestEffectiveRange:inRange:.
If you don't need this value, pass NULL.
- Returns: The attributes for the character at index.
*/
public override func attributesAtIndex(location: Int, effectiveRange range: NSRangePointer) -> [String : AnyObject] {
return store.attributesAtIndex(location, effectiveRange: range)
}
/**
:name: replaceCharactersInRange
Replaces a range of text with a string value.
- Parameter range: The character range to replace.
- Parameter str: The string value that the characters
will be replaced with.
*/
public override func replaceCharactersInRange(range: NSRange, withString str: String) {
store.replaceCharactersInRange(range, withString: str)
......@@ -93,7 +89,10 @@ public class TextStorage: NSTextStorage {
}
/**
:name: setAttributes
Sets the attributedString attribute values.
- Parameter attrs: The attributes to set.
- Parameter range: A range of characters that will have their
attributes updated.
*/
public override func setAttributes(attrs: [String : AnyObject]?, range: NSRange) {
store.setAttributes(attrs, range: range)
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io>
// Copyright (C) 2015 - 2016 CosmicMind, Inc. <http://cosmicmind.io>. All rights reserved.
//
// 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
......
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