Commit d2cb2d46 by Daniel Dahan

progression commit

parent ac53a489
......@@ -17,6 +17,8 @@
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 */; };
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 */; };
96BCB7A11CB40DC500C806FE /* BottomNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7581CB40DC500C806FE /* BottomNavigationController.swift */; };
96BCB7A21CB40DC500C806FE /* BottomTabBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96BCB7591CB40DC500C806FE /* BottomTabBar.swift */; };
......@@ -208,6 +210,8 @@
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>"; };
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>"; };
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>"; };
......@@ -538,6 +542,8 @@
96BCB77C1CB40DC500C806FE /* MaterialGravity.swift */,
96BCB7851CB40DC500C806FE /* MaterialRadius.swift */,
96BCB7861CB40DC500C806FE /* MaterialShape.swift */,
968C99441D37730B000074FF /* Direction.swift */,
968C99461D377849000074FF /* Offset.swift */,
);
name = Type;
sourceTree = "<group>";
......@@ -825,7 +831,7 @@
attributes = {
LastSwiftMigration = 0710;
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0700;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = "CosmicMind, Inc.";
TargetAttributes = {
963832351B88DFD80015F710 = {
......@@ -923,6 +929,7 @@
96BCB7C11CB40DC500C806FE /* Depth.swift in Sources */,
96BCB7D61CB40DC500C806FE /* Menu.swift in Sources */,
96BCB7E61CB40DC500C806FE /* TextStorage.swift in Sources */,
968C99451D37730B000074FF /* Direction.swift in Sources */,
96BCB7B21CB40DC500C806FE /* Material+UIImage+Network.swift in Sources */,
96BCB7A91CB40DC500C806FE /* FlatButton.swift in Sources */,
96BCB7CA1CB40DC500C806FE /* Layout.swift in Sources */,
......@@ -957,6 +964,7 @@
96BCB7C21CB40DC500C806FE /* Device.swift in Sources */,
96BCB7A41CB40DC500C806FE /* CaptureSession.swift in Sources */,
96BCB7C51CB40DC500C806FE /* MaterialGravity.swift in Sources */,
968C99471D377849000074FF /* Offset.swift in Sources */,
96BCB7D51CB40DC500C806FE /* View.swift in Sources */,
96BCB7DE1CB40DC500C806FE /* SearchBar.swift in Sources */,
96BCB7B11CB40DC500C806FE /* Material+UIImage+Crop.swift in Sources */,
......@@ -1170,6 +1178,7 @@
PRODUCT_NAME = Material;
PROVISIONING_PROFILE = "";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
};
name = Release;
};
......@@ -1205,6 +1214,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "io.cosmicmind.Material-iOS-Tests";
PRODUCT_NAME = Material;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
};
name = Release;
};
......@@ -1251,6 +1261,7 @@
PRODUCT_NAME = Material;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
};
name = Release;
};
......
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
......
......@@ -48,7 +48,7 @@ public class BottomNavigationFadeAnimatedTransitioning : NSObject, UIViewControl
}
}
public func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval {
public func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.35
}
}
......
......@@ -33,12 +33,12 @@ import UIKit
public extension UITabBarItem {
/// Sets the color of the title color for a state.
public func setTitleColor(color: UIColor, forState state: UIControlState) {
setTitleTextAttributes([NSForegroundColorAttributeName: color], forState: state)
setTitleTextAttributes([NSForegroundColorAttributeName: color], for: state)
}
}
@IBDesignable
public class BottomTabBar : UITabBar {
public class BottomTabBar: UITabBar {
/// Automatically aligns the BottomNavigationBar to the superview.
public var autoLayoutToSuperview: Bool = true
......@@ -117,7 +117,7 @@ public class BottomTabBar : UITabBar {
/// A property that accesses the backing layer's shadowColor.
@IBInspectable public var shadowColor: UIColor? {
didSet {
layer.shadowColor = shadowColor?.CGColor
layer.shadowColor = shadowColor?.cgColor
}
}
......@@ -154,7 +154,7 @@ public class BottomTabBar : UITabBar {
/// A preset property to set the borderWidth.
public var borderWidthPreset: MaterialBorder = .None {
didSet {
borderWidth = MaterialBorderToValue(borderWidthPreset)
borderWidth = MaterialBorderToValue(border: borderWidthPreset)
}
}
......@@ -171,10 +171,10 @@ public class BottomTabBar : UITabBar {
/// A property that accesses the layer.borderColor property.
@IBInspectable public var borderColor: UIColor? {
get {
return nil == layer.borderColor ? nil : UIColor(CGColor: layer.borderColor!)
return nil == layer.borderColor ? nil : UIColor(cgColor: layer.borderColor!)
}
set(value) {
layer.borderColor = value?.CGColor
layer.borderColor = value?.cgColor
}
}
......@@ -246,10 +246,10 @@ public class BottomTabBar : UITabBar {
when subclassing.
*/
public func prepareView() {
depth = .depth1
depthPreset = .depth1
contentScaleFactor = Device.scale
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
backgroundImage = image
}
......@@ -260,14 +260,14 @@ private var MaterialAssociatedObjectTabBarKey: UInt8 = 0
public class MaterialAssociatedObjectTabBar {
/**
A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer. This is the preferred method of setting depth
in order to maintain consitency across UI objects.
*/
public var depthPreset
A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer. This is the preferred method of setting depth
in order to maintain consitency across UI objects.
*/
public var depthPreset: DepthPreset
public init(depthPreset) {
self.depth = depth
public init(depthPreset: DepthPreset) {
self.depthPreset = depthPreset
}
}
......@@ -276,7 +276,7 @@ public extension UITabBar {
public internal(set) var item: MaterialAssociatedObjectTabBar {
get {
return AssociatedObject(base: self, key: &MaterialAssociatedObjectTabBarKey) {
return MaterialAssociatedObjectTabBar(depth: .none)
return MaterialAssociatedObjectTabBar(depthPreset: .none)
}
}
set(value) {
......@@ -285,17 +285,17 @@ public extension UITabBar {
}
/**
A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer. This is the preferred method of setting depth
in order to maintain consitency across UI objects.
*/
public var depthPreset {
A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer. This is the preferred method of setting depth
in order to maintain consitency across UI objects.
*/
public var depthPreset: DepthPreset {
get {
return item.depth
return item.depthPreset
}
set(value) {
let v = DepthPresetToValue(preset: value)
layer.shadowOffset = v.offset
layer.shadowOffset = v.offset.asSize
layer.shadowOpacity = v.opacity
layer.shadowRadius = v.radius
}
......
......@@ -209,7 +209,7 @@ public class Button: UIButton {
*/
public var depth = Depth.zero {
didSet {
shadowOffset = depth.offsetAsSize
shadowOffset = depth.offset.asSize
shadowOpacity = depth.opacity
shadowRadius = depth.radius
layoutShadowPath()
......
......@@ -41,7 +41,7 @@ public enum DepthPreset {
public struct Depth {
/// Offset.
public var offset: UIOffset
public var offset: Offset
/// Opacity.
public var opacity: Float
......@@ -49,18 +49,13 @@ public struct Depth {
/// Radius.
public var radius: CGFloat
/// Offset as size.
public var offsetAsSize: CGSize {
return CGSize(width: offset.horizontal, height: offset.vertical)
}
/**
Initializer.
- Parameter offset: UIOffset.
- Parameter opacity: Float.
- 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.opacity = opacity
self.radius = radius
......@@ -81,14 +76,14 @@ public func DepthPresetToValue(preset: DepthPreset) -> Depth {
case .none:
return Depth.zero
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:
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:
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:
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:
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 {
}
/// An Array of UIButtons.
public var views: Array<UIView>? {
public var views: [UIView]? {
didSet {
reload()
}
......@@ -194,9 +194,9 @@ public class Grid {
/// Reload the button layout.
public func reload() {
if let v: Array<UIView> = views {
let gc: Int = axis.inherited ? columns : axis.columns
let gr: Int = axis.inherited ? rows : axis.rows
if let v = views {
let gc = axis.inherited ? columns : axis.columns
let gr = axis.inherited ? rows : axis.rows
var n: Int = 0
for i in 0..<v.count {
let child: UIView = v[i]
......
......@@ -41,6 +41,6 @@ public class IconButton: Button {
public override func prepareView() {
super.prepareView()
cornerRadiusPreset = .Radius1
pulseAnimation = .Center
pulseAnimation = .center
}
}
......@@ -36,21 +36,23 @@ public extension UIImage {
- Parameter color: The UIColor to create the image from.
- 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)
let context = UIGraphicsGetCurrentContext()
guard let context = UIGraphicsGetCurrentContext() else {
return nil
}
CGContextScaleCTM(context, 1.0, -1.0)
CGContextTranslateCTM(context, 0.0, -size.height)
context.scale(x: 1.0, y: -1.0)
context.translate(x: 0.0, y: -size.height)
CGContextSetBlendMode(context, .Multiply)
context.setBlendMode(.multiply)
let rect = CGRectMake(0, 0, size.width, size.height)
CGContextClipToMask(context, rect, cgImage)
let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
context.clipToMask(rect, mask: cgImage!)
color.setFill()
CGContextFillRect(context, rect)
context.fill(rect)
let image: UIImage = UIGraphicsGetImageFromCurrentImageContext()
let image: UIImage = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
return image
}
......
......@@ -65,7 +65,7 @@ public typealias MaterialAnimationDelayCancelBlock = (cancel : Bool) -> Void
public struct MaterialAnimation {
/// 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) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(time * Double(NSEC_PER_SEC))), dispatch_get_main_queue(), completion)
......
......@@ -31,102 +31,115 @@
import UIKit
public enum PulseAnimation {
case None
case Center
case CenterWithBacking
case CenterRadialBeyondBounds
case Backing
case AtPoint
case AtPointWithBacking
case none
case center
case centerWithBacking
case centerRadialBeyondBounds
case backing
case point
case pointWithBacking
}
internal extension MaterialAnimation {
/**
Triggers the expanding animation.
- Parameter layer: Container CALayer.
- Parameter visualLayer: A CAShapeLayer for the pulseLayer.
- Parameter pulseColor: The UIColor for the pulse.
- Parameter point: A point to pulse from.
- Parameter width: Container width.
- Parameter height: Container height.
- Parameter duration: Animation duration.
- 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) {
if .None != pulseAnimation {
if let n: CGFloat = .Center == pulseAnimation ? width < height ? width : height : width < height ? height : width {
let bLayer: CAShapeLayer = CAShapeLayer()
let pLayer: CAShapeLayer = CAShapeLayer()
bLayer.addSublayer(pLayer)
pulseLayers.insert(bLayer, atIndex: 0)
visualLayer.addSublayer(bLayer)
MaterialAnimation.animationDisabled({
bLayer.frame = visualLayer.bounds
pLayer.bounds = CGRectMake(0, 0, n, n)
switch pulseAnimation {
case .Center, .CenterWithBacking, .CenterRadialBeyondBounds:
pLayer.position = CGPointMake(width / 2, height / 2)
default:
pLayer.position = point
}
pLayer.cornerRadius = n / 2
pLayer.backgroundColor = pulseColor.colorWithAlphaComponent(pulseOpacity).CGColor
pLayer.transform = CATransform3DMakeAffineTransform(CGAffineTransformMakeScale(0, 0))
})
bLayer.setValue(false, forKey: "animated")
let duration: CFTimeInterval = .Center == pulseAnimation ? 0.16125 : 0.325
switch pulseAnimation {
case .CenterWithBacking, .Backing, .AtPointWithBacking:
bLayer.addAnimation(MaterialAnimation.backgroundColor(pulseColor.colorWithAlphaComponent(pulseOpacity / 2), duration: duration), forKey: nil)
default:break
}
switch pulseAnimation {
case .Center, .CenterWithBacking, .CenterRadialBeyondBounds, .AtPoint, .AtPointWithBacking:
pLayer.addAnimation(MaterialAnimation.scale(1, duration: duration), forKey: nil)
default:break
}
MaterialAnimation.delay(duration, completion: {
bLayer.setValue(true, forKey: "animated")
})
}
}
Triggers the expanding animation.
- Parameter layer: Container CALayer.
- Parameter visualLayer: A CAShapeLayer for the pulseLayer.
- Parameter pulseColor: The UIColor for the pulse.
- Parameter point: A point to pulse from.
- Parameter width: Container width.
- Parameter height: Container height.
- Parameter duration: Animation duration.
- 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, pulseLayers: inout Array<CAShapeLayer>, pulseAnimation: PulseAnimation) {
guard .none != pulseAnimation else {
return
}
let n = .center == pulseAnimation ? width < height ? width : height : width < height ? height : width
let bLayer: CAShapeLayer = CAShapeLayer()
let pLayer: CAShapeLayer = CAShapeLayer()
bLayer.addSublayer(pLayer)
pulseLayers.insert(bLayer, at: 0)
visualLayer.addSublayer(bLayer)
MaterialAnimation.animationDisabled(animations: {
bLayer.frame = visualLayer.bounds
pLayer.bounds = CGRect(x: 0, y: 0, width: n, height: n)
switch pulseAnimation {
case .center, .centerWithBacking, .centerRadialBeyondBounds:
pLayer.position = CGPoint(x: width / 2, y: height / 2)
default:
pLayer.position = point
}
pLayer.cornerRadius = n / 2
pLayer.backgroundColor = pulseColor.withAlphaComponent(pulseOpacity).cgColor
pLayer.transform = CATransform3DMakeAffineTransform(CGAffineTransform(scaleX: 0, y: 0))
})
bLayer.setValue(false, forKey: "animated")
let duration: CFTimeInterval = .center == pulseAnimation ? 0.16125 : 0.325
switch pulseAnimation {
case .centerWithBacking, .backing, .pointWithBacking:
bLayer.add(MaterialAnimation.backgroundColor(color: pulseColor.withAlphaComponent(pulseOpacity / 2), duration: duration), forKey: nil)
default:break
}
switch pulseAnimation {
case .center, .centerWithBacking, .centerRadialBeyondBounds, .point, .pointWithBacking:
pLayer.add(MaterialAnimation.scale(scale: 1, duration: duration), forKey: nil)
default:break
}
MaterialAnimation.delay(time: duration, completion: {
bLayer.setValue(true, forKey: "animated")
})
}
/**
Triggers the contracting animation.
- Parameter layer: Container CALayer.
- Parameter pulseColor: The UIColor for the pulse.
- 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) {
if let bLayer: CAShapeLayer = pulseLayers.popLast() {
let animated: Bool? = bLayer.valueForKey("animated") as? Bool
MaterialAnimation.delay(true == animated ? 0 : 0.15) {
if let pLayer: CAShapeLayer = bLayer.sublayers?.first as? CAShapeLayer {
let duration: CFTimeInterval = 0.325
switch pulseAnimation {
case .CenterWithBacking, .Backing, .AtPointWithBacking:
bLayer.addAnimation(MaterialAnimation.backgroundColor(pulseColor.colorWithAlphaComponent(0), duration: 0.325), forKey: nil)
default:break
}
switch pulseAnimation {
case .Center, .CenterWithBacking, .CenterRadialBeyondBounds, .AtPoint, .AtPointWithBacking:
pLayer.addAnimation(MaterialAnimation.animationGroup([
MaterialAnimation.scale(.Center == pulseAnimation ? 1 : 1.325),
MaterialAnimation.backgroundColor(pulseColor.colorWithAlphaComponent(0))
], duration: duration), forKey: nil)
default:break
}
MaterialAnimation.delay(duration) {
pLayer.removeFromSuperlayer()
bLayer.removeFromSuperlayer()
}
}
}
}
Triggers the contracting animation.
- Parameter layer: Container CALayer.
- Parameter pulseColor: The UIColor for the pulse.
- Parameter pulseLayers: An Array of CAShapeLayers used in the animation.
*/
internal static func pulseContractAnimation(layer: CALayer, visualLayer: CALayer, pulseColor: UIColor, pulseLayers: inout Array<CAShapeLayer>, pulseAnimation: PulseAnimation) {
guard let bLayer: CAShapeLayer = pulseLayers.popLast() else {
return
}
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 {
let duration: CFTimeInterval = 0.325
switch pulseAnimation {
case .centerWithBacking, .backing, .pointWithBacking:
bLayer.add(MaterialAnimation.backgroundColor(color: pulseColor.withAlphaComponent(0), duration: 0.325), forKey: nil)
default:break
}
switch pulseAnimation {
case .center, .centerWithBacking, .centerRadialBeyondBounds, .point, .pointWithBacking:
pLayer.addAnimation(MaterialAnimation.animationGroup(animations: [
MaterialAnimation.scale(scale: .Center == pulseAnimation ? 1 : 1.325),
MaterialAnimation.backgroundColor(pulseColor.colorWithAlphaComponent(0))
], duration: duration), forKey: nil)
default:break
}
MaterialAnimation.delay(time: duration, completion: {
pLayer.removeFromSuperlayer()
bLayer.removeFromSuperlayer()
})
}
}
}
}
\ No newline at end of file
}
......@@ -438,7 +438,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
- Parameter animated: A Boolean value that indicates to animate
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 {
leftViewWidth = width
......@@ -512,7 +512,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
- Parameter animated: A Boolean value that indicates to animate
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 {
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 {
A method to swap rootViewController objects.
- Parameter toViewController: The UIViewController to swap
with the active rootViewController.
- Parameter duration: A NSTimeInterval that sets the
- Parameter duration: A TimeInterval that sets the
animation duration of the transition.
- Parameter options: UIViewAnimationOptions thst are used
when animating the transition from the active rootViewController
......@@ -113,7 +113,7 @@ public class RootController : UIViewController {
the transition animation from the active rootViewController
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)
addChildViewController(toViewController)
toViewController.view.frame = rootViewController.view.frame
......
......@@ -82,7 +82,7 @@ public class TabBar : View {
b.removeTarget(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)
}
}
......
......@@ -261,7 +261,7 @@ public class View: UIView {
*/
public var depth = Depth.zero {
didSet {
shadowOffset = depth.offsetAsSize
shadowOffset = depth.offset.asSize
shadowOpacity = depth.opacity
shadowRadius = depth.radius
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