Commit 5e8d2dec by Daniel Dahan

initial commit

parent ebfbb737
...@@ -21,28 +21,28 @@ import AVFoundation ...@@ -21,28 +21,28 @@ import AVFoundation
@objc(PreviewDelegate) @objc(PreviewDelegate)
public protocol PreviewDelegate { public protocol PreviewDelegate {
optional func preview(preview: Preview!, tappedToFocusAt point: CGPoint) optional func previewTappedToFocusAt(preview: Preview, point: CGPoint)
optional func preview(preview: Preview!, tappedToExposeAt point: CGPoint) optional func previewTappedToExposeAt(preview: Preview, point: CGPoint)
optional func preview(preview: Preview!, tappedToReset focus: UIView!, exposure: UIView!) optional func previewTappedToReset(preview: Preview, focus: UIView, exposure: UIView)
} }
public class Preview: UIView { public class Preview: UIView {
/** /**
* boxBounds :name: boxBounds
* A static property that sets the initial size of the focusBox and exposureBox properties. :description: A static property that sets the initial size of the focusBox and exposureBox properties.
*/ */
static public var boxBounds: CGRect = CGRectMake(0, 0, 150, 150) static public var boxBounds: CGRect = CGRectMake(0, 0, 150, 150)
/** /**
* delegate :name: delegate
* An optional instance of PreviewDelegate to handle events that are triggered during various :description: An optional instance of PreviewDelegate to handle events that are triggered during various
* stages of engagement. stages of engagement.
*/ */
public weak var delegate: PreviewDelegate? public weak var delegate: PreviewDelegate?
/** /**
* tapToFocusEnabled :name: tapToFocusEnabled
* A mutator and accessor that enables and disables tap to focus gesture. :description: A mutator and accessor that enables and disables tap to focus gesture.
*/ */
public var tapToFocusEnabled: Bool { public var tapToFocusEnabled: Bool {
get { get {
...@@ -54,8 +54,8 @@ public class Preview: UIView { ...@@ -54,8 +54,8 @@ public class Preview: UIView {
} }
/** /**
* tapToExposeEnabled :name: tapToExposeEnabled
* A mutator and accessor that enables and disables tap to expose gesture. :description: A mutator and accessor that enables and disables tap to expose gesture.
*/ */
public var tapToExposeEnabled: Bool { public var tapToExposeEnabled: Bool {
get { get {
...@@ -66,9 +66,9 @@ public class Preview: UIView { ...@@ -66,9 +66,9 @@ public class Preview: UIView {
} }
} }
/** //
* override for layerClass // override for layerClass
*/ //
override public class func layerClass() -> AnyClass { override public class func layerClass() -> AnyClass {
return AVCaptureVideoPreviewLayer.self return AVCaptureVideoPreviewLayer.self
} }
...@@ -142,7 +142,7 @@ public class Preview: UIView { ...@@ -142,7 +142,7 @@ public class Preview: UIView {
internal func handleSingleTap(recognizer: UIGestureRecognizer) { internal func handleSingleTap(recognizer: UIGestureRecognizer) {
let point: CGPoint = recognizer.locationInView(self) let point: CGPoint = recognizer.locationInView(self)
runBoxAnimationOnView(focusBox, point: point) runBoxAnimationOnView(focusBox, point: point)
delegate?.preview?(self, tappedToFocusAt: captureDevicePointForPoint(point)) delegate?.previewTappedToFocusAt?(self, point: captureDevicePointForPoint(point))
} }
/** /**
...@@ -153,7 +153,7 @@ public class Preview: UIView { ...@@ -153,7 +153,7 @@ public class Preview: UIView {
internal func handleDoubleTap(recognizer: UIGestureRecognizer) { internal func handleDoubleTap(recognizer: UIGestureRecognizer) {
let point: CGPoint = recognizer.locationInView(self) let point: CGPoint = recognizer.locationInView(self)
runBoxAnimationOnView(exposureBox, point: point) runBoxAnimationOnView(exposureBox, point: point)
delegate?.preview?(self, tappedToExposeAt: captureDevicePointForPoint(point)) delegate?.previewTappedToExposeAt?(self, point: captureDevicePointForPoint(point))
} }
/** /**
...@@ -270,7 +270,7 @@ public class Preview: UIView { ...@@ -270,7 +270,7 @@ public class Preview: UIView {
self.exposureBox!.hidden = true self.exposureBox!.hidden = true
self.focusBox!.transform = CGAffineTransformIdentity self.focusBox!.transform = CGAffineTransformIdentity
self.exposureBox!.transform = CGAffineTransformIdentity self.exposureBox!.transform = CGAffineTransformIdentity
self.delegate?.preview?(self, tappedToReset: self.focusBox!, exposure: self.exposureBox!) self.delegate?.previewTappedToReset?(self, focus: self.focusBox!, exposure: self.exposureBox!)
} }
} }
} }
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
import UIKit import UIKit
class FabButton : UIButton { public class FabButton : UIButton {
var lineWidth: CGFloat = 2.0 var lineWidth: CGFloat = 2.0
...@@ -30,19 +30,23 @@ class FabButton : UIButton { ...@@ -30,19 +30,23 @@ class FabButton : UIButton {
private var backgroundColorView: UIView? private var backgroundColorView: UIView?
private var pulseView: UIView? private var pulseView: UIView?
override func drawRect(rect: CGRect) { public convenience init() {
self.init(frame: CGRectZero)
}
public override func drawRect(rect: CGRect) {
setupContext(rect) setupContext(rect)
setupBackgroundColorView() setupBackgroundColorView()
setupPlus() setupPlus()
} }
required init(coder aDecoder: NSCoder) { public required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder) super.init(coder: aDecoder)
initialize() initialize()
applyShadow() applyShadow()
} }
required override init(frame: CGRect) { public required override init(frame: CGRect) {
super.init(frame: frame) super.init(frame: frame)
initialize() initialize()
applyShadow() applyShadow()
...@@ -67,11 +71,11 @@ class FabButton : UIButton { ...@@ -67,11 +71,11 @@ class FabButton : UIButton {
// so the pulse doesn't animate off the button // so the pulse doesn't animate off the button
func setupBackgroundColorView() { func setupBackgroundColorView() {
backgroundColorView = UIView() backgroundColorView = UIView()
backgroundColorView!.frame = self.bounds backgroundColorView!.frame = bounds
backgroundColorView!.layer.cornerRadius = boundsW() / 2.0 backgroundColorView!.layer.cornerRadius = bounds.width / 2.0
backgroundColorView!.backgroundColor = color backgroundColorView!.backgroundColor = color
backgroundColorView!.layer.masksToBounds = true backgroundColorView!.layer.masksToBounds = true
self.insertSubview(backgroundColorView!, atIndex: 0) insertSubview(backgroundColorView!, atIndex: 0)
} }
// I make the + with two views because // I make the + with two views because
...@@ -103,11 +107,13 @@ class FabButton : UIButton { ...@@ -103,11 +107,13 @@ class FabButton : UIButton {
layer.shadowRadius = 5 layer.shadowRadius = 5
} }
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) { override public func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
super.touchesBegan(touches, withEvent: event)
pulseTouches(touches) pulseTouches(touches)
} }
override func touchesEnded(touches: Set<NSObject>, withEvent event: UIEvent) { override public func touchesEnded(touches: Set<NSObject>, withEvent event: UIEvent) {
super.touchesEnded(touches, withEvent: event)
shrink() shrink()
removePulse() removePulse()
} }
...@@ -116,8 +122,8 @@ class FabButton : UIButton { ...@@ -116,8 +122,8 @@ class FabButton : UIButton {
let touch = touches.allObjects.last as! UITouch let touch = touches.allObjects.last as! UITouch
let touchLocation = touch.locationInView(self) let touchLocation = touch.locationInView(self)
pulseView = UIView() pulseView = UIView()
pulseView!.frame = CGRectMake(0, 0, boundsW(), boundsH()) pulseView!.frame = CGRectMake(0, 0, bounds.width, bounds.height)
pulseView!.layer.cornerRadius = boundsW() / 2.0 pulseView!.layer.cornerRadius = bounds.width / 2.0
pulseView!.center = touchLocation pulseView!.center = touchLocation
pulseView!.backgroundColor = pulseColor!.colorWithAlphaComponent(0.5) pulseView!.backgroundColor = pulseColor!.colorWithAlphaComponent(0.5)
backgroundColorView!.addSubview(pulseView!) backgroundColorView!.addSubview(pulseView!)
...@@ -134,7 +140,7 @@ class FabButton : UIButton { ...@@ -134,7 +140,7 @@ class FabButton : UIButton {
} }
func removePulse() { func removePulse() {
UIView.animateWithDuration(0.3, animations: { () -> Void in UIView.animateWithDuration(0.3, animations: { _ in
self.pulseView?.alpha = 0.0 self.pulseView?.alpha = 0.0
}) { (finished) -> Void in }) { (finished) -> Void in
self.pulseView?.removeFromSuperview() self.pulseView?.removeFromSuperview()
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
import UIKit import UIKit
class FlatButton : UIButton { public class FlatButton : UIButton {
var textColor: UIColor? var textColor: UIColor?
var pulseColor: UIColor? var pulseColor: UIColor?
...@@ -28,18 +28,18 @@ class FlatButton : UIButton { ...@@ -28,18 +28,18 @@ class FlatButton : UIButton {
private var backgroundColorView: UIView = UIView() private var backgroundColorView: UIView = UIView()
private var pulseView: UIView? private var pulseView: UIView?
override func drawRect(rect: CGRect) { public override func drawRect(rect: CGRect) {
setupContext(rect) setupContext(rect)
setupBackgroundColorView() setupBackgroundColorView()
} }
required init(coder aDecoder: NSCoder) { public required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder) super.init(coder: aDecoder)
initialize() initialize()
applyShadow() applyShadow()
} }
required override init(frame: CGRect) { public required override init(frame: CGRect) {
super.init(frame: frame) super.init(frame: frame)
initialize() initialize()
applyShadow() applyShadow()
...@@ -75,11 +75,11 @@ class FlatButton : UIButton { ...@@ -75,11 +75,11 @@ class FlatButton : UIButton {
layer.shadowRadius = 5 layer.shadowRadius = 5
} }
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) { public override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
pulseTouches(touches) pulseTouches(touches)
} }
override func touchesEnded(touches: Set<NSObject>, withEvent event: UIEvent) { public override func touchesEnded(touches: Set<NSObject>, withEvent event: UIEvent) {
shrink() shrink()
removePulse() removePulse()
} }
...@@ -89,7 +89,7 @@ class FlatButton : UIButton { ...@@ -89,7 +89,7 @@ class FlatButton : UIButton {
let touchLocation = touch.locationInView(self) let touchLocation = touch.locationInView(self)
pulseView = UIView() pulseView = UIView()
pulseView!.frame = CGRectMake(0, 0, self.bounds.size.height, self.bounds.size.height) pulseView!.frame = CGRectMake(0, 0, self.bounds.size.height, self.bounds.size.height)
pulseView!.layer.cornerRadius = boundsH() / 2.0 pulseView!.layer.cornerRadius = bounds.height / 2.0
pulseView!.center = touchLocation pulseView!.center = touchLocation
pulseView!.backgroundColor = pulseColor!.colorWithAlphaComponent(0.5) pulseView!.backgroundColor = pulseColor!.colorWithAlphaComponent(0.5)
backgroundColorView.addSubview(pulseView!) backgroundColorView.addSubview(pulseView!)
......
//
// 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 struct Layout {
public static func topRight(parent: UIView, child: UIView, width: CGFloat, height: CGFloat, top: CGFloat, right: CGFloat) {
parent.addSubview(child)
var metrics = ["width" : width, "height" : height, "top" : top, "right" : right]
var views = ["view" : child]
var viewBindingsDict: NSMutableDictionary = NSMutableDictionary()
viewBindingsDict.setValue(child, forKey: "child")
parent.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:[child(width)]-(right)-|", options: nil, metrics: metrics, views: viewBindingsDict as [NSObject : AnyObject]))
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)
var metrics = ["width" : width, "height" : height, "top" : top, "left" : left]
var views = ["view" : child]
var viewBindingsDict: NSMutableDictionary = NSMutableDictionary()
viewBindingsDict.setValue(child, forKey: "child")
parent.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-(left)-[child(width)]", options: nil, metrics: metrics, views: viewBindingsDict as [NSObject : AnyObject]))
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)
var metrics = ["width" : width, "height" : height, "bottom" : bottom, "right" : right]
var views = ["view" : child]
var viewBindingsDict: NSMutableDictionary = NSMutableDictionary()
viewBindingsDict.setValue(child, forKey: "child")
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)
var metrics = ["width" : width, "height" : height, "bottom" : bottom, "left" : left]
var views = ["view" : child]
var viewBindingsDict: NSMutableDictionary = NSMutableDictionary()
viewBindingsDict.setValue(child, forKey: "child")
parent.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-(left)-[child(width)]", 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]))
}
}
//
// Copyright (C) 2015 Adam Dahan <https://github.com/adamdahan>.
// Copyright (C) 2015 Daniel Dahan <https://github.com/danieldahan>.
//
// 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
extension UIView {
func frameW() -> CGFloat {
return self.frame.size.width
}
func frameH() -> CGFloat {
return self.frame.size.height
}
func frameX() -> CGFloat {
return self.frame.origin.x
}
func frameY() -> CGFloat {
return self.frame.origin.y
}
func boundsW() -> CGFloat {
return self.bounds.size.width
}
func boundsH() -> CGFloat {
return self.bounds.size.height
}
func boundsX() -> CGFloat {
return self.bounds.origin.x
}
func boundsY() -> CGFloat {
return self.bounds.origin.y
}
}
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
import UIKit import UIKit
class RaisedButton : UIButton { public class RaisedButton : UIButton {
var color: UIColor? var color: UIColor?
var pulseColor: UIColor? var pulseColor: UIColor?
...@@ -28,18 +28,18 @@ class RaisedButton : UIButton { ...@@ -28,18 +28,18 @@ class RaisedButton : UIButton {
private var backgroundColorView: UIView = UIView() private var backgroundColorView: UIView = UIView()
private var pulseView: UIView? private var pulseView: UIView?
override func drawRect(rect: CGRect) { public override func drawRect(rect: CGRect) {
setupContext(rect) setupContext(rect)
setupBackgroundColorView() setupBackgroundColorView()
} }
required init(coder aDecoder: NSCoder) { public required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder) super.init(coder: aDecoder)
initialize() initialize()
applyShadow() applyShadow()
} }
required override init(frame: CGRect) { public required override init(frame: CGRect) {
super.init(frame: frame) super.init(frame: frame)
initialize() initialize()
applyShadow() applyShadow()
...@@ -76,11 +76,11 @@ class RaisedButton : UIButton { ...@@ -76,11 +76,11 @@ class RaisedButton : UIButton {
layer.shadowRadius = 5 layer.shadowRadius = 5
} }
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) { public override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
pulseTouches(touches) pulseTouches(touches)
} }
override func touchesEnded(touches: Set<NSObject>, withEvent event: UIEvent) { public override func touchesEnded(touches: Set<NSObject>, withEvent event: UIEvent) {
shrink() shrink()
removePulse() removePulse()
} }
...@@ -90,7 +90,7 @@ class RaisedButton : UIButton { ...@@ -90,7 +90,7 @@ class RaisedButton : UIButton {
let touchLocation = touch.locationInView(self) let touchLocation = touch.locationInView(self)
pulseView = UIView() pulseView = UIView()
pulseView!.frame = CGRectMake(0, 0, self.bounds.size.height, self.bounds.size.height) pulseView!.frame = CGRectMake(0, 0, self.bounds.size.height, self.bounds.size.height)
pulseView!.layer.cornerRadius = boundsH() / 2.0 pulseView!.layer.cornerRadius = bounds.height / 2.0
pulseView!.center = touchLocation pulseView!.center = touchLocation
pulseView!.backgroundColor = pulseColor!.colorWithAlphaComponent(0.5) pulseView!.backgroundColor = pulseColor!.colorWithAlphaComponent(0.5)
backgroundColorView.addSubview(pulseView!) backgroundColorView.addSubview(pulseView!)
......
...@@ -26,10 +26,10 @@ public protocol TextDelegate { ...@@ -26,10 +26,10 @@ public protocol TextDelegate {
public class Text: NSObject { public class Text: NSObject {
/** /**
* searchPattern :name: searchPattern
* A string representation of the regular expression that matches text within :description: A string representation of the regular expression that matches text within
* the TextStorage string property. By default, the search pattern recognizes the TextStorage string property. By default, the search pattern recognizes words and emoji
* words and emoji characters beginning with hashtags. haracters beginning with hashtags.
*/ */
public var searchPattern: 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}]+" { public var searchPattern: 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 { didSet {
...@@ -38,15 +38,14 @@ public class Text: NSObject { ...@@ -38,15 +38,14 @@ public class Text: NSObject {
} }
/** /**
* textStorage :name: textStorage
* Reference to wrapped NSTextStorage :description: Reference to wrapped NSTextStorage
*/ */
public let textStorage: TextStorage public let textStorage: TextStorage
/** /**
* delegate :name: delegate
* An optional instance of TextDelegate to handle text processing events :description: An optional instance of TextDelegate to handle text processing events.
*
*/ */
public weak var delegate: TextDelegate? public weak var delegate: TextDelegate?
...@@ -63,8 +62,8 @@ public class Text: NSObject { ...@@ -63,8 +62,8 @@ public class Text: NSObject {
} }
/** /**
* string :name: string
* Managed string value. :description: Managed string value.
*/ */
public var string: String { public var string: String {
get { get {
...@@ -73,9 +72,9 @@ public class Text: NSObject { ...@@ -73,9 +72,9 @@ public class Text: NSObject {
} }
/** /**
* matches :name: matches
* An array of matches found in the TextStorage string property based on the :description: An array of matches found in the TextStorage string property based on the
* searchPattern property. searchPattern property.
*/ */
public var matches: Array<String> { public var matches: Array<String> {
get { get {
...@@ -85,8 +84,8 @@ public class Text: NSObject { ...@@ -85,8 +84,8 @@ public class Text: NSObject {
} }
/** /**
* unique :name: unique
* Ensures a unique value in the matches return array. :description: Ensures a unique value in the matches return array.
*/ */
private func unique<S: SequenceType, E: Hashable where E == S.Generator.Element>(source: S) -> [E] { private func unique<S: SequenceType, E: Hashable where E == S.Generator.Element>(source: S) -> [E] {
var seen: [E:Bool] = [:] var seen: [E:Bool] = [:]
......
...@@ -23,28 +23,28 @@ internal typealias TextStorageDidProcessEdit = (TextStorage!, NSTextCheckingResu ...@@ -23,28 +23,28 @@ internal typealias TextStorageDidProcessEdit = (TextStorage!, NSTextCheckingResu
public class TextStorage: NSTextStorage { public class TextStorage: NSTextStorage {
/** /**
* store :name: store
* Acts as the model, storing the string value. :description: Acts as the model, storing the string value.
*/ */
private lazy var store: NSMutableAttributedString = NSMutableAttributedString() private lazy var store: NSMutableAttributedString = NSMutableAttributedString()
/** /**
* searchExpression :name: searchExpression
* Matches text within the TextStorage string property. :description: Matches text within the TextStorage string property.
*/ */
internal var searchExpression: NSRegularExpression? internal var searchExpression: NSRegularExpression?
/** /**
* textStorageWillProcessEdit :name: textStorageWillProcessEdit
* If set, this block callback executes when there is a change in the TextStorage :description: If set, this block callback executes when there is a change in the TextStorage
* string value. string value.
*/ */
internal var textStorageWillProcessEdit: TextStorageWillProcessEdit? internal var textStorageWillProcessEdit: TextStorageWillProcessEdit?
/** /**
* textStorageDidProcessEdit :name: textStorageDidProcessEdit
* If set, this block callback executes when a match is detected after a change in :description: If set, this block callback executes when a match is detected after a change in
* the TextStorage string value. the TextStorage string value.
*/ */
internal var textStorageDidProcessEdit: TextStorageDidProcessEdit? internal var textStorageDidProcessEdit: TextStorageDidProcessEdit?
...@@ -57,8 +57,8 @@ public class TextStorage: NSTextStorage { ...@@ -57,8 +57,8 @@ public class TextStorage: NSTextStorage {
} }
/** /**
* string :name: string
* Managed string value. :description: Managed string value.
*/ */
override public var string: String { override public var string: String {
get { get {
......
...@@ -22,16 +22,16 @@ private var defaultTextColor: UIColor = UIColor(red: 33/255, green: 33/255, blue ...@@ -22,16 +22,16 @@ private var defaultTextColor: UIColor = UIColor(red: 33/255, green: 33/255, blue
private var defaultPlaceholderColor: UIColor = UIColor(red: 159/255, green: 160/255, blue: 164/255, alpha: 1) private var defaultPlaceholderColor: UIColor = UIColor(red: 159/255, green: 160/255, blue: 164/255, alpha: 1)
public class TextView: UITextView { public class TextView: UITextView {
/** //
* label // :name: label
* Placeholder label. // :description: Placeholder label.
*/ //
private lazy var label: UILabel = UILabel() private lazy var label: UILabel = UILabel()
/** //
* labelConstraints // :name: labelConstraints
* Autoresize constraints for the placeholder label. // :description: Autoresize constraints for the placeholder label.
*/ //
private var labelConstraints: Array<NSLayoutConstraint>? private var labelConstraints: Array<NSLayoutConstraint>?
required public init(coder aDecoder: NSCoder) { required public init(coder aDecoder: NSCoder) {
...@@ -47,17 +47,17 @@ public class TextView: UITextView { ...@@ -47,17 +47,17 @@ public class TextView: UITextView {
setupView() setupView()
} }
/** //
* deinit // :name: deinit
* Notification observer removed from UITextView. // :description: Notification observer removed from UITextView.
*/ //
deinit { deinit {
NSNotificationCenter.defaultCenter().removeObserver(self, name: UITextViewTextDidChangeNotification, object: nil) NSNotificationCenter.defaultCenter().removeObserver(self, name: UITextViewTextDidChangeNotification, object: nil)
} }
/** /**
* placeholder :name: placeholder
* The placeholder label string. :description: The placeholder label string.
*/ */
public var placeholder: String = "" { public var placeholder: String = "" {
didSet { didSet {
...@@ -66,8 +66,8 @@ public class TextView: UITextView { ...@@ -66,8 +66,8 @@ public class TextView: UITextView {
} }
/** /**
* placeholderColor :name: placeholderColor
* The placeholder color. :description: The placeholder color.
*/ */
public var placeholderColor: UIColor = defaultPlaceholderColor { public var placeholderColor: UIColor = defaultPlaceholderColor {
didSet { didSet {
...@@ -76,8 +76,8 @@ public class TextView: UITextView { ...@@ -76,8 +76,8 @@ public class TextView: UITextView {
} }
/** /**
* font :name: font
* Font to use for placeholder based on UITextView font. :description: Font to use for placeholder based on UITextView font.
*/ */
override public var font: UIFont! { override public var font: UIFont! {
didSet { didSet {
...@@ -86,8 +86,8 @@ public class TextView: UITextView { ...@@ -86,8 +86,8 @@ public class TextView: UITextView {
} }
/** /**
* textAlignment :name: textAlignment
* Sets placeholder textAlignment based on UITextView textAlignment. :description: Sets placeholder textAlignment based on UITextView textAlignment.
*/ */
override public var textAlignment: NSTextAlignment { override public var textAlignment: NSTextAlignment {
didSet { didSet {
...@@ -96,8 +96,8 @@ public class TextView: UITextView { ...@@ -96,8 +96,8 @@ public class TextView: UITextView {
} }
/** /**
* text :name: text
* When set, updates the placeholder text. :description: When set, updates the placeholder text.
*/ */
override public var text: String! { override public var text: String! {
didSet { didSet {
...@@ -106,8 +106,8 @@ public class TextView: UITextView { ...@@ -106,8 +106,8 @@ public class TextView: UITextView {
} }
/** /**
* attributedText :name: attributedText
* When set, updates the placeholder attributedText. :description: When set, updates the placeholder attributedText.
*/ */
override public var attributedText: NSAttributedString! { override public var attributedText: NSAttributedString! {
didSet { didSet {
...@@ -116,8 +116,8 @@ public class TextView: UITextView { ...@@ -116,8 +116,8 @@ public class TextView: UITextView {
} }
/** /**
* textContainerInset :name: textContainerInset
* When set, updates the placeholder constraints. :description: When set, updates the placeholder constraints.
*/ */
override public var textContainerInset: UIEdgeInsets { override public var textContainerInset: UIEdgeInsets {
didSet { didSet {
...@@ -130,18 +130,18 @@ public class TextView: UITextView { ...@@ -130,18 +130,18 @@ public class TextView: UITextView {
label.preferredMaxLayoutWidth = textContainer.size.width - textContainer.lineFragmentPadding * 2.0 label.preferredMaxLayoutWidth = textContainer.size.width - textContainer.lineFragmentPadding * 2.0
} }
/** //
* textViewTextDidChange // :name: textViewTextDidChange
* Updates the label visibility when text is empty or not. // :description: Updates the label visibility when text is empty or not.
*/ //
internal func textViewTextDidChange() { internal func textViewTextDidChange() {
label.hidden = !text.isEmpty label.hidden = !text.isEmpty
} }
/** //
* setupView // :name: setupView
* Sets up the common initilized values. // :description: Sets up the common initilized values.
*/ //
private func setupView() { private func setupView() {
backgroundColor = .clearColor() backgroundColor = .clearColor()
textColor = defaultTextColor textColor = defaultTextColor
...@@ -162,10 +162,10 @@ public class TextView: UITextView { ...@@ -162,10 +162,10 @@ public class TextView: UITextView {
updateLabelConstraints() updateLabelConstraints()
} }
/** //
* updateLabelConstraints // :name: updateLabelConstraints
* Updates the placeholder constraints. // :description: Updates the placeholder constraints.
*/ //
private func updateLabelConstraints() { private func updateLabelConstraints() {
if nil != labelConstraints { if nil != labelConstraints {
removeConstraints(labelConstraints!) removeConstraints(labelConstraints!)
......
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