Commit d2cb2d46 by Daniel Dahan

progression commit

parent ac53a489
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
9679CEAB1CC69E080021685B /* Material+UIImage+TintColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9679CEAA1CC69E080021685B /* Material+UIImage+TintColor.swift */; }; 9679CEAB1CC69E080021685B /* Material+UIImage+TintColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9679CEAA1CC69E080021685B /* Material+UIImage+TintColor.swift */; };
967A48191D0F425A00B8CEB7 /* StatusBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967A48181D0F425A00B8CEB7 /* StatusBarController.swift */; }; 967A48191D0F425A00B8CEB7 /* StatusBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967A48181D0F425A00B8CEB7 /* StatusBarController.swift */; };
96815B381CA07BA20006CBE2 /* MaterialViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967887881C9777CB0037F6C9 /* MaterialViewTests.swift */; }; 96815B381CA07BA20006CBE2 /* MaterialViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967887881C9777CB0037F6C9 /* MaterialViewTests.swift */; };
968C99451D37730B000074FF /* Direction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 968C99441D37730B000074FF /* Direction.swift */; };
968C99471D377849000074FF /* Offset.swift in Sources */ = {isa = PBXBuildFile; fileRef = 968C99461D377849000074FF /* Offset.swift */; };
96977DA61CBB2E49000BEFC4 /* Material+UIImage+FilterBlur.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96977DA51CBB2E49000BEFC4 /* Material+UIImage+FilterBlur.swift */; }; 96977DA61CBB2E49000BEFC4 /* Material+UIImage+FilterBlur.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96977DA51CBB2E49000BEFC4 /* Material+UIImage+FilterBlur.swift */; };
96BCB7A11CB40DC500C806FE /* BottomNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7581CB40DC500C806FE /* BottomNavigationController.swift */; }; 96BCB7A11CB40DC500C806FE /* BottomNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7581CB40DC500C806FE /* BottomNavigationController.swift */; };
96BCB7A21CB40DC500C806FE /* BottomTabBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7591CB40DC500C806FE /* BottomTabBar.swift */; }; 96BCB7A21CB40DC500C806FE /* BottomTabBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7591CB40DC500C806FE /* BottomTabBar.swift */; };
...@@ -208,6 +210,8 @@ ...@@ -208,6 +210,8 @@
967887881C9777CB0037F6C9 /* MaterialViewTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialViewTests.swift; sourceTree = "<group>"; }; 967887881C9777CB0037F6C9 /* MaterialViewTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialViewTests.swift; sourceTree = "<group>"; };
9679CEAA1CC69E080021685B /* Material+UIImage+TintColor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Material+UIImage+TintColor.swift"; sourceTree = "<group>"; }; 9679CEAA1CC69E080021685B /* Material+UIImage+TintColor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Material+UIImage+TintColor.swift"; sourceTree = "<group>"; };
967A48181D0F425A00B8CEB7 /* StatusBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusBarController.swift; sourceTree = "<group>"; }; 967A48181D0F425A00B8CEB7 /* StatusBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusBarController.swift; sourceTree = "<group>"; };
968C99441D37730B000074FF /* Direction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Direction.swift; sourceTree = "<group>"; };
968C99461D377849000074FF /* Offset.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Offset.swift; sourceTree = "<group>"; };
96977DA51CBB2E49000BEFC4 /* Material+UIImage+FilterBlur.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Material+UIImage+FilterBlur.swift"; sourceTree = "<group>"; }; 96977DA51CBB2E49000BEFC4 /* Material+UIImage+FilterBlur.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Material+UIImage+FilterBlur.swift"; sourceTree = "<group>"; };
96BCB7581CB40DC500C806FE /* BottomNavigationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BottomNavigationController.swift; sourceTree = "<group>"; }; 96BCB7581CB40DC500C806FE /* BottomNavigationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BottomNavigationController.swift; sourceTree = "<group>"; };
96BCB7591CB40DC500C806FE /* BottomTabBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BottomTabBar.swift; sourceTree = "<group>"; }; 96BCB7591CB40DC500C806FE /* BottomTabBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BottomTabBar.swift; sourceTree = "<group>"; };
...@@ -538,6 +542,8 @@ ...@@ -538,6 +542,8 @@
96BCB77C1CB40DC500C806FE /* MaterialGravity.swift */, 96BCB77C1CB40DC500C806FE /* MaterialGravity.swift */,
96BCB7851CB40DC500C806FE /* MaterialRadius.swift */, 96BCB7851CB40DC500C806FE /* MaterialRadius.swift */,
96BCB7861CB40DC500C806FE /* MaterialShape.swift */, 96BCB7861CB40DC500C806FE /* MaterialShape.swift */,
968C99441D37730B000074FF /* Direction.swift */,
968C99461D377849000074FF /* Offset.swift */,
); );
name = Type; name = Type;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -825,7 +831,7 @@ ...@@ -825,7 +831,7 @@
attributes = { attributes = {
LastSwiftMigration = 0710; LastSwiftMigration = 0710;
LastSwiftUpdateCheck = 0730; LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0700; LastUpgradeCheck = 0800;
ORGANIZATIONNAME = "CosmicMind, Inc."; ORGANIZATIONNAME = "CosmicMind, Inc.";
TargetAttributes = { TargetAttributes = {
963832351B88DFD80015F710 = { 963832351B88DFD80015F710 = {
...@@ -923,6 +929,7 @@ ...@@ -923,6 +929,7 @@
96BCB7C11CB40DC500C806FE /* Depth.swift in Sources */, 96BCB7C11CB40DC500C806FE /* Depth.swift in Sources */,
96BCB7D61CB40DC500C806FE /* Menu.swift in Sources */, 96BCB7D61CB40DC500C806FE /* Menu.swift in Sources */,
96BCB7E61CB40DC500C806FE /* TextStorage.swift in Sources */, 96BCB7E61CB40DC500C806FE /* TextStorage.swift in Sources */,
968C99451D37730B000074FF /* Direction.swift in Sources */,
96BCB7B21CB40DC500C806FE /* Material+UIImage+Network.swift in Sources */, 96BCB7B21CB40DC500C806FE /* Material+UIImage+Network.swift in Sources */,
96BCB7A91CB40DC500C806FE /* FlatButton.swift in Sources */, 96BCB7A91CB40DC500C806FE /* FlatButton.swift in Sources */,
96BCB7CA1CB40DC500C806FE /* Layout.swift in Sources */, 96BCB7CA1CB40DC500C806FE /* Layout.swift in Sources */,
...@@ -957,6 +964,7 @@ ...@@ -957,6 +964,7 @@
96BCB7C21CB40DC500C806FE /* Device.swift in Sources */, 96BCB7C21CB40DC500C806FE /* Device.swift in Sources */,
96BCB7A41CB40DC500C806FE /* CaptureSession.swift in Sources */, 96BCB7A41CB40DC500C806FE /* CaptureSession.swift in Sources */,
96BCB7C51CB40DC500C806FE /* MaterialGravity.swift in Sources */, 96BCB7C51CB40DC500C806FE /* MaterialGravity.swift in Sources */,
968C99471D377849000074FF /* Offset.swift in Sources */,
96BCB7D51CB40DC500C806FE /* View.swift in Sources */, 96BCB7D51CB40DC500C806FE /* View.swift in Sources */,
96BCB7DE1CB40DC500C806FE /* SearchBar.swift in Sources */, 96BCB7DE1CB40DC500C806FE /* SearchBar.swift in Sources */,
96BCB7B11CB40DC500C806FE /* Material+UIImage+Crop.swift in Sources */, 96BCB7B11CB40DC500C806FE /* Material+UIImage+Crop.swift in Sources */,
...@@ -1170,6 +1178,7 @@ ...@@ -1170,6 +1178,7 @@
PRODUCT_NAME = Material; PRODUCT_NAME = Material;
PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE = "";
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
}; };
name = Release; name = Release;
}; };
...@@ -1205,6 +1214,7 @@ ...@@ -1205,6 +1214,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "io.cosmicmind.Material-iOS-Tests"; PRODUCT_BUNDLE_IDENTIFIER = "io.cosmicmind.Material-iOS-Tests";
PRODUCT_NAME = Material; PRODUCT_NAME = Material;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
}; };
name = Release; name = Release;
}; };
...@@ -1251,6 +1261,7 @@ ...@@ -1251,6 +1261,7 @@
PRODUCT_NAME = Material; PRODUCT_NAME = Material;
SDKROOT = macosx; SDKROOT = macosx;
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
}; };
name = Release; name = Release;
}; };
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "0720" LastUpgradeVersion = "0800"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"
......
...@@ -48,7 +48,7 @@ public class BottomNavigationFadeAnimatedTransitioning : NSObject, UIViewControl ...@@ -48,7 +48,7 @@ public class BottomNavigationFadeAnimatedTransitioning : NSObject, UIViewControl
} }
} }
public func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval { public func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.35 return 0.35
} }
} }
......
...@@ -33,12 +33,12 @@ import UIKit ...@@ -33,12 +33,12 @@ import UIKit
public extension UITabBarItem { public extension UITabBarItem {
/// Sets the color of the title color for a state. /// Sets the color of the title color for a state.
public func setTitleColor(color: UIColor, forState state: UIControlState) { public func setTitleColor(color: UIColor, forState state: UIControlState) {
setTitleTextAttributes([NSForegroundColorAttributeName: color], forState: state) setTitleTextAttributes([NSForegroundColorAttributeName: color], for: state)
} }
} }
@IBDesignable @IBDesignable
public class BottomTabBar : UITabBar { public class BottomTabBar: UITabBar {
/// Automatically aligns the BottomNavigationBar to the superview. /// Automatically aligns the BottomNavigationBar to the superview.
public var autoLayoutToSuperview: Bool = true public var autoLayoutToSuperview: Bool = true
...@@ -117,7 +117,7 @@ public class BottomTabBar : UITabBar { ...@@ -117,7 +117,7 @@ public class BottomTabBar : UITabBar {
/// A property that accesses the backing layer's shadowColor. /// A property that accesses the backing layer's shadowColor.
@IBInspectable public var shadowColor: UIColor? { @IBInspectable public var shadowColor: UIColor? {
didSet { didSet {
layer.shadowColor = shadowColor?.CGColor layer.shadowColor = shadowColor?.cgColor
} }
} }
...@@ -154,7 +154,7 @@ public class BottomTabBar : UITabBar { ...@@ -154,7 +154,7 @@ public class BottomTabBar : UITabBar {
/// A preset property to set the borderWidth. /// A preset property to set the borderWidth.
public var borderWidthPreset: MaterialBorder = .None { public var borderWidthPreset: MaterialBorder = .None {
didSet { didSet {
borderWidth = MaterialBorderToValue(borderWidthPreset) borderWidth = MaterialBorderToValue(border: borderWidthPreset)
} }
} }
...@@ -171,10 +171,10 @@ public class BottomTabBar : UITabBar { ...@@ -171,10 +171,10 @@ public class BottomTabBar : UITabBar {
/// A property that accesses the layer.borderColor property. /// A property that accesses the layer.borderColor property.
@IBInspectable public var borderColor: UIColor? { @IBInspectable public var borderColor: UIColor? {
get { get {
return nil == layer.borderColor ? nil : UIColor(CGColor: layer.borderColor!) return nil == layer.borderColor ? nil : UIColor(cgColor: layer.borderColor!)
} }
set(value) { set(value) {
layer.borderColor = value?.CGColor layer.borderColor = value?.cgColor
} }
} }
...@@ -246,10 +246,10 @@ public class BottomTabBar : UITabBar { ...@@ -246,10 +246,10 @@ public class BottomTabBar : UITabBar {
when subclassing. when subclassing.
*/ */
public func prepareView() { public func prepareView() {
depth = .depth1 depthPreset = .depth1
contentScaleFactor = Device.scale contentScaleFactor = Device.scale
backgroundColor = Color.white backgroundColor = Color.white
let image: UIImage? = UIImage.imageWithColor(Color.clear, size: CGSizeMake(1, 1)) let image: UIImage? = UIImage.imageWithColor(color: Color.clear, size: CGSize(width: 1, height: 1))
shadowImage = image shadowImage = image
backgroundImage = image backgroundImage = image
} }
...@@ -264,10 +264,10 @@ public class MaterialAssociatedObjectTabBar { ...@@ -264,10 +264,10 @@ public class MaterialAssociatedObjectTabBar {
for the backing layer. This is the preferred method of setting depth for the backing layer. This is the preferred method of setting depth
in order to maintain consitency across UI objects. in order to maintain consitency across UI objects.
*/ */
public var depthPreset public var depthPreset: DepthPreset
public init(depthPreset) { public init(depthPreset: DepthPreset) {
self.depth = depth self.depthPreset = depthPreset
} }
} }
...@@ -276,7 +276,7 @@ public extension UITabBar { ...@@ -276,7 +276,7 @@ public extension UITabBar {
public internal(set) var item: MaterialAssociatedObjectTabBar { public internal(set) var item: MaterialAssociatedObjectTabBar {
get { get {
return AssociatedObject(base: self, key: &MaterialAssociatedObjectTabBarKey) { return AssociatedObject(base: self, key: &MaterialAssociatedObjectTabBarKey) {
return MaterialAssociatedObjectTabBar(depth: .none) return MaterialAssociatedObjectTabBar(depthPreset: .none)
} }
} }
set(value) { set(value) {
...@@ -289,13 +289,13 @@ public extension UITabBar { ...@@ -289,13 +289,13 @@ public extension UITabBar {
for the backing layer. This is the preferred method of setting depth for the backing layer. This is the preferred method of setting depth
in order to maintain consitency across UI objects. in order to maintain consitency across UI objects.
*/ */
public var depthPreset { public var depthPreset: DepthPreset {
get { get {
return item.depth return item.depthPreset
} }
set(value) { set(value) {
let v = DepthPresetToValue(preset: value) let v = DepthPresetToValue(preset: value)
layer.shadowOffset = v.offset layer.shadowOffset = v.offset.asSize
layer.shadowOpacity = v.opacity layer.shadowOpacity = v.opacity
layer.shadowRadius = v.radius layer.shadowRadius = v.radius
} }
......
...@@ -209,7 +209,7 @@ public class Button: UIButton { ...@@ -209,7 +209,7 @@ public class Button: UIButton {
*/ */
public var depth = Depth.zero { public var depth = Depth.zero {
didSet { didSet {
shadowOffset = depth.offsetAsSize shadowOffset = depth.offset.asSize
shadowOpacity = depth.opacity shadowOpacity = depth.opacity
shadowRadius = depth.radius shadowRadius = depth.radius
layoutShadowPath() layoutShadowPath()
......
...@@ -41,7 +41,7 @@ public enum DepthPreset { ...@@ -41,7 +41,7 @@ public enum DepthPreset {
public struct Depth { public struct Depth {
/// Offset. /// Offset.
public var offset: UIOffset public var offset: Offset
/// Opacity. /// Opacity.
public var opacity: Float public var opacity: Float
...@@ -49,18 +49,13 @@ public struct Depth { ...@@ -49,18 +49,13 @@ public struct Depth {
/// Radius. /// Radius.
public var radius: CGFloat public var radius: CGFloat
/// Offset as size.
public var offsetAsSize: CGSize {
return CGSize(width: offset.horizontal, height: offset.vertical)
}
/** /**
Initializer. Initializer.
- Parameter offset: UIOffset. - Parameter offset: UIOffset.
- Parameter opacity: Float. - Parameter opacity: Float.
- Parameter radius: CGFloat. - Parameter radius: CGFloat.
*/ */
public init(offset: UIOffset = UIOffset.zero, opacity: Float = 0, radius: CGFloat = 0) { public init(offset: Offset = Offset.zero, opacity: Float = 0, radius: CGFloat = 0) {
self.offset = offset self.offset = offset
self.opacity = opacity self.opacity = opacity
self.radius = radius self.radius = radius
...@@ -81,14 +76,14 @@ public func DepthPresetToValue(preset: DepthPreset) -> Depth { ...@@ -81,14 +76,14 @@ public func DepthPresetToValue(preset: DepthPreset) -> Depth {
case .none: case .none:
return Depth.zero return Depth.zero
case .depth1: case .depth1:
return Depth(offset: UIOffset(horizontal: 0, vertical: 1), opacity: 0.3, radius: 1) return Depth(offset: Offset(horizontal: 0, vertical: 1), opacity: 0.3, radius: 1)
case .depth2: case .depth2:
return Depth(offset: UIOffset(horizontal: 0, vertical: 2), opacity: 0.3, radius: 2) return Depth(offset: Offset(horizontal: 0, vertical: 2), opacity: 0.3, radius: 2)
case .depth3: case .depth3:
return Depth(offset: UIOffset(horizontal: 0, vertical: 3), opacity: 0.3, radius: 3) return Depth(offset: Offset(horizontal: 0, vertical: 3), opacity: 0.3, radius: 3)
case .depth4: case .depth4:
return Depth(offset: UIOffset(horizontal: 0, vertical: 4), opacity: 0.3, radius: 4) return Depth(offset: Offset(horizontal: 0, vertical: 4), opacity: 0.3, radius: 4)
case .depth5: case .depth5:
return Depth(offset: UIOffset(horizontal: 0, vertical: 5), opacity: 0.3, radius: 5) return Depth(offset: Offset(horizontal: 0, vertical: 5), opacity: 0.3, radius: 5)
} }
} }
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of CosmicMind nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
public enum Direction {
case up
case down
case left
case right
}
...@@ -171,7 +171,7 @@ public class Grid { ...@@ -171,7 +171,7 @@ public class Grid {
} }
/// An Array of UIButtons. /// An Array of UIButtons.
public var views: Array<UIView>? { public var views: [UIView]? {
didSet { didSet {
reload() reload()
} }
...@@ -194,9 +194,9 @@ public class Grid { ...@@ -194,9 +194,9 @@ public class Grid {
/// Reload the button layout. /// Reload the button layout.
public func reload() { public func reload() {
if let v: Array<UIView> = views { if let v = views {
let gc: Int = axis.inherited ? columns : axis.columns let gc = axis.inherited ? columns : axis.columns
let gr: Int = axis.inherited ? rows : axis.rows let gr = axis.inherited ? rows : axis.rows
var n: Int = 0 var n: Int = 0
for i in 0..<v.count { for i in 0..<v.count {
let child: UIView = v[i] let child: UIView = v[i]
......
...@@ -41,6 +41,6 @@ public class IconButton: Button { ...@@ -41,6 +41,6 @@ public class IconButton: Button {
public override func prepareView() { public override func prepareView() {
super.prepareView() super.prepareView()
cornerRadiusPreset = .Radius1 cornerRadiusPreset = .Radius1
pulseAnimation = .Center pulseAnimation = .center
} }
} }
...@@ -36,21 +36,23 @@ public extension UIImage { ...@@ -36,21 +36,23 @@ public extension UIImage {
- Parameter color: The UIColor to create the image from. - Parameter color: The UIColor to create the image from.
- Returns: A UIImage that is the color passed in. - Returns: A UIImage that is the color passed in.
*/ */
public func tintWithColor(color: UIColor) -> UIImage { public func tintWithColor(color: UIColor) -> UIImage? {
UIGraphicsBeginImageContextWithOptions(size, false, Device.scale) UIGraphicsBeginImageContextWithOptions(size, false, Device.scale)
let context = UIGraphicsGetCurrentContext() guard let context = UIGraphicsGetCurrentContext() else {
return nil
}
CGContextScaleCTM(context, 1.0, -1.0) context.scale(x: 1.0, y: -1.0)
CGContextTranslateCTM(context, 0.0, -size.height) context.translate(x: 0.0, y: -size.height)
CGContextSetBlendMode(context, .Multiply) context.setBlendMode(.multiply)
let rect = CGRectMake(0, 0, size.width, size.height) let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
CGContextClipToMask(context, rect, cgImage) context.clipToMask(rect, mask: cgImage!)
color.setFill() color.setFill()
CGContextFillRect(context, rect) context.fill(rect)
let image: UIImage = UIGraphicsGetImageFromCurrentImageContext() let image: UIImage = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext() UIGraphicsEndImageContext()
return image return image
} }
......
...@@ -65,7 +65,7 @@ public typealias MaterialAnimationDelayCancelBlock = (cancel : Bool) -> Void ...@@ -65,7 +65,7 @@ public typealias MaterialAnimationDelayCancelBlock = (cancel : Bool) -> Void
public struct MaterialAnimation { public struct MaterialAnimation {
/// Delay helper method. /// Delay helper method.
public static func delay(time: NSTimeInterval, completion: ()-> Void) -> MaterialAnimationDelayCancelBlock? { public static func delay(time: TimeInterval, completion: ()-> Void) -> MaterialAnimationDelayCancelBlock? {
func dispatch_later(completion: ()-> Void) { func dispatch_later(completion: ()-> Void) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(time * Double(NSEC_PER_SEC))), dispatch_get_main_queue(), completion) dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(time * Double(NSEC_PER_SEC))), dispatch_get_main_queue(), completion)
......
...@@ -31,13 +31,13 @@ ...@@ -31,13 +31,13 @@
import UIKit import UIKit
public enum PulseAnimation { public enum PulseAnimation {
case None case none
case Center case center
case CenterWithBacking case centerWithBacking
case CenterRadialBeyondBounds case centerRadialBeyondBounds
case Backing case backing
case AtPoint case point
case AtPointWithBacking case pointWithBacking
} }
internal extension MaterialAnimation { internal extension MaterialAnimation {
...@@ -52,47 +52,56 @@ internal extension MaterialAnimation { ...@@ -52,47 +52,56 @@ internal extension MaterialAnimation {
- Parameter duration: Animation duration. - Parameter duration: Animation duration.
- Parameter pulseLayers: An Array of CAShapeLayers used in the animation. - Parameter pulseLayers: An Array of CAShapeLayers used in the animation.
*/ */
internal static func pulseExpandAnimation(layer: CALayer, visualLayer: CALayer, pulseColor: UIColor, pulseOpacity: CGFloat, point: CGPoint, width: CGFloat, height: CGFloat, inout pulseLayers: Array<CAShapeLayer>, pulseAnimation: PulseAnimation) { internal static func pulseExpandAnimation(layer: CALayer, visualLayer: CALayer, pulseColor: UIColor, pulseOpacity: CGFloat, point: CGPoint, width: CGFloat, height: CGFloat, pulseLayers: inout Array<CAShapeLayer>, pulseAnimation: PulseAnimation) {
if .None != pulseAnimation { guard .none != pulseAnimation else {
if let n: CGFloat = .Center == pulseAnimation ? width < height ? width : height : width < height ? height : width { return
}
let n = .center == pulseAnimation ? width < height ? width : height : width < height ? height : width
let bLayer: CAShapeLayer = CAShapeLayer() let bLayer: CAShapeLayer = CAShapeLayer()
let pLayer: CAShapeLayer = CAShapeLayer() let pLayer: CAShapeLayer = CAShapeLayer()
bLayer.addSublayer(pLayer) bLayer.addSublayer(pLayer)
pulseLayers.insert(bLayer, atIndex: 0) pulseLayers.insert(bLayer, at: 0)
visualLayer.addSublayer(bLayer) visualLayer.addSublayer(bLayer)
MaterialAnimation.animationDisabled({
MaterialAnimation.animationDisabled(animations: {
bLayer.frame = visualLayer.bounds bLayer.frame = visualLayer.bounds
pLayer.bounds = CGRectMake(0, 0, n, n) pLayer.bounds = CGRect(x: 0, y: 0, width: n, height: n)
switch pulseAnimation { switch pulseAnimation {
case .Center, .CenterWithBacking, .CenterRadialBeyondBounds: case .center, .centerWithBacking, .centerRadialBeyondBounds:
pLayer.position = CGPointMake(width / 2, height / 2) pLayer.position = CGPoint(x: width / 2, y: height / 2)
default: default:
pLayer.position = point pLayer.position = point
} }
pLayer.cornerRadius = n / 2 pLayer.cornerRadius = n / 2
pLayer.backgroundColor = pulseColor.colorWithAlphaComponent(pulseOpacity).CGColor pLayer.backgroundColor = pulseColor.withAlphaComponent(pulseOpacity).cgColor
pLayer.transform = CATransform3DMakeAffineTransform(CGAffineTransformMakeScale(0, 0)) pLayer.transform = CATransform3DMakeAffineTransform(CGAffineTransform(scaleX: 0, y: 0))
}) })
bLayer.setValue(false, forKey: "animated") bLayer.setValue(false, forKey: "animated")
let duration: CFTimeInterval = .Center == pulseAnimation ? 0.16125 : 0.325 let duration: CFTimeInterval = .center == pulseAnimation ? 0.16125 : 0.325
switch pulseAnimation { switch pulseAnimation {
case .CenterWithBacking, .Backing, .AtPointWithBacking: case .centerWithBacking, .backing, .pointWithBacking:
bLayer.addAnimation(MaterialAnimation.backgroundColor(pulseColor.colorWithAlphaComponent(pulseOpacity / 2), duration: duration), forKey: nil) bLayer.add(MaterialAnimation.backgroundColor(color: pulseColor.withAlphaComponent(pulseOpacity / 2), duration: duration), forKey: nil)
default:break default:break
} }
switch pulseAnimation { switch pulseAnimation {
case .Center, .CenterWithBacking, .CenterRadialBeyondBounds, .AtPoint, .AtPointWithBacking: case .center, .centerWithBacking, .centerRadialBeyondBounds, .point, .pointWithBacking:
pLayer.addAnimation(MaterialAnimation.scale(1, duration: duration), forKey: nil) pLayer.add(MaterialAnimation.scale(scale: 1, duration: duration), forKey: nil)
default:break default:break
} }
MaterialAnimation.delay(duration, completion: {
MaterialAnimation.delay(time: duration, completion: {
bLayer.setValue(true, forKey: "animated") bLayer.setValue(true, forKey: "animated")
}) })
} }
}
}
/** /**
Triggers the contracting animation. Triggers the contracting animation.
...@@ -100,32 +109,36 @@ internal extension MaterialAnimation { ...@@ -100,32 +109,36 @@ internal extension MaterialAnimation {
- Parameter pulseColor: The UIColor for the pulse. - Parameter pulseColor: The UIColor for the pulse.
- Parameter pulseLayers: An Array of CAShapeLayers used in the animation. - Parameter pulseLayers: An Array of CAShapeLayers used in the animation.
*/ */
internal static func pulseContractAnimation(layer: CALayer, visualLayer: CALayer, pulseColor: UIColor, inout pulseLayers: Array<CAShapeLayer>, pulseAnimation: PulseAnimation) { internal static func pulseContractAnimation(layer: CALayer, visualLayer: CALayer, pulseColor: UIColor, pulseLayers: inout Array<CAShapeLayer>, pulseAnimation: PulseAnimation) {
if let bLayer: CAShapeLayer = pulseLayers.popLast() { guard let bLayer: CAShapeLayer = pulseLayers.popLast() else {
let animated: Bool? = bLayer.valueForKey("animated") as? Bool return
MaterialAnimation.delay(true == animated ? 0 : 0.15) { }
let animated: Bool? = bLayer.value(forKey: "animated") as? Bool
MaterialAnimation.delay(time: true == animated ? 0 : 0.15) {
if let pLayer: CAShapeLayer = bLayer.sublayers?.first as? CAShapeLayer { if let pLayer: CAShapeLayer = bLayer.sublayers?.first as? CAShapeLayer {
let duration: CFTimeInterval = 0.325 let duration: CFTimeInterval = 0.325
switch pulseAnimation { switch pulseAnimation {
case .CenterWithBacking, .Backing, .AtPointWithBacking: case .centerWithBacking, .backing, .pointWithBacking:
bLayer.addAnimation(MaterialAnimation.backgroundColor(pulseColor.colorWithAlphaComponent(0), duration: 0.325), forKey: nil) bLayer.add(MaterialAnimation.backgroundColor(color: pulseColor.withAlphaComponent(0), duration: 0.325), forKey: nil)
default:break default:break
} }
switch pulseAnimation { switch pulseAnimation {
case .Center, .CenterWithBacking, .CenterRadialBeyondBounds, .AtPoint, .AtPointWithBacking: case .center, .centerWithBacking, .centerRadialBeyondBounds, .point, .pointWithBacking:
pLayer.addAnimation(MaterialAnimation.animationGroup([ pLayer.addAnimation(MaterialAnimation.animationGroup(animations: [
MaterialAnimation.scale(.Center == pulseAnimation ? 1 : 1.325), MaterialAnimation.scale(scale: .Center == pulseAnimation ? 1 : 1.325),
MaterialAnimation.backgroundColor(pulseColor.colorWithAlphaComponent(0)) MaterialAnimation.backgroundColor(pulseColor.colorWithAlphaComponent(0))
], duration: duration), forKey: nil) ], duration: duration), forKey: nil)
default:break default:break
} }
MaterialAnimation.delay(duration) {
MaterialAnimation.delay(time: duration, completion: {
pLayer.removeFromSuperlayer() pLayer.removeFromSuperlayer()
bLayer.removeFromSuperlayer() bLayer.removeFromSuperlayer()
} })
}
} }
} }
} }
......
...@@ -438,7 +438,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel ...@@ -438,7 +438,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
- Parameter animated: A Boolean value that indicates to animate - Parameter animated: A Boolean value that indicates to animate
the leftView width change. the leftView width change.
*/ */
public func setLeftViewWidth(width: CGFloat, hidden: Bool, animated: Bool, duration: NSTimeInterval = 0.5) { public func setLeftViewWidth(width: CGFloat, hidden: Bool, animated: Bool, duration: TimeInterval = 0.5) {
if let v: View = leftView { if let v: View = leftView {
leftViewWidth = width leftViewWidth = width
...@@ -512,7 +512,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel ...@@ -512,7 +512,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
- Parameter animated: A Boolean value that indicates to animate - Parameter animated: A Boolean value that indicates to animate
the rightView width change. the rightView width change.
*/ */
public func setRightViewWidth(width: CGFloat, hidden: Bool, animated: Bool, duration: NSTimeInterval = 0.5) { public func setRightViewWidth(width: CGFloat, hidden: Bool, animated: Bool, duration: TimeInterval = 0.5) {
if let v: View = rightView { if let v: View = rightView {
rightViewWidth = width rightViewWidth = width
......
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of CosmicMind nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import UIKit
public typealias Offset = UIOffset
public extension Offset {
public var asSize: CGSize {
return CGSize(width: horizontal, height: vertical)
}
}
...@@ -101,7 +101,7 @@ public class RootController : UIViewController { ...@@ -101,7 +101,7 @@ public class RootController : UIViewController {
A method to swap rootViewController objects. A method to swap rootViewController objects.
- Parameter toViewController: The UIViewController to swap - Parameter toViewController: The UIViewController to swap
with the active rootViewController. with the active rootViewController.
- Parameter duration: A NSTimeInterval that sets the - Parameter duration: A TimeInterval that sets the
animation duration of the transition. animation duration of the transition.
- Parameter options: UIViewAnimationOptions thst are used - Parameter options: UIViewAnimationOptions thst are used
when animating the transition from the active rootViewController when animating the transition from the active rootViewController
...@@ -113,7 +113,7 @@ public class RootController : UIViewController { ...@@ -113,7 +113,7 @@ public class RootController : UIViewController {
the transition animation from the active rootViewController the transition animation from the active rootViewController
to the toViewController has completed. to the toViewController has completed.
*/ */
public func transitionFromRootViewController(toViewController: UIViewController, duration: NSTimeInterval = 0.5, options: UIViewAnimationOptions = [], animations: (() -> Void)? = nil, completion: ((Bool) -> Void)? = nil) { public func transitionFromRootViewController(toViewController: UIViewController, duration: TimeInterval = 0.5, options: UIViewAnimationOptions = [], animations: (() -> Void)? = nil, completion: ((Bool) -> Void)? = nil) {
rootViewController.willMoveToParentViewController(nil) rootViewController.willMoveToParentViewController(nil)
addChildViewController(toViewController) addChildViewController(toViewController)
toViewController.view.frame = rootViewController.view.frame toViewController.view.frame = rootViewController.view.frame
......
...@@ -82,7 +82,7 @@ public class TabBar : View { ...@@ -82,7 +82,7 @@ public class TabBar : View {
b.removeTarget(self, action: #selector(handleButton(_:)), forControlEvents: .TouchUpInside) b.removeTarget(self, action: #selector(handleButton(_:)), forControlEvents: .TouchUpInside)
b.addTarget(self, action: #selector(handleButton(_:)), forControlEvents: .TouchUpInside) b.addTarget(self, action: #selector(handleButton(_:)), forControlEvents: .TouchUpInside)
} }
grid.views = v as Array<UIView> grid.views = v as [UIView]
line.frame = CGRectMake(0, .Bottom == lineAlignment ? height - 3 : 0, v.first!.frame.width, 3) line.frame = CGRectMake(0, .Bottom == lineAlignment ? height - 3 : 0, v.first!.frame.width, 3)
} }
} }
......
...@@ -261,7 +261,7 @@ public class View: UIView { ...@@ -261,7 +261,7 @@ public class View: UIView {
*/ */
public var depth = Depth.zero { public var depth = Depth.zero {
didSet { didSet {
shadowOffset = depth.offsetAsSize shadowOffset = depth.offset.asSize
shadowOpacity = depth.opacity shadowOpacity = depth.opacity
shadowRadius = depth.radius shadowRadius = depth.radius
layoutShadowPath() layoutShadowPath()
......
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