Skip to content

Commit

Permalink
Swift 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AugustRush committed Jan 23, 2017
1 parent 41e2f06 commit 20b198b
Show file tree
Hide file tree
Showing 154 changed files with 1,031 additions and 1,296 deletions.
Empty file.
Empty file.
Empty file modified Carthage/Build/iOS/Stellar.framework.dSYM/Contents/Info.plist
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified Carthage/Build/iOS/Stellar.framework/Headers/Chainable.swift
100644 → 100755
Empty file.
Empty file.
Empty file modified Carthage/Build/iOS/Stellar.framework/Headers/DynamicItem.swift
100644 → 100755
Empty file.
Empty file modified Carthage/Build/iOS/Stellar.framework/Headers/DynamicItem2.swift
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified Carthage/Build/iOS/Stellar.framework/Headers/Physical.swift
100644 → 100755
Empty file.
Empty file.
Empty file modified Carthage/Build/iOS/Stellar.framework/Headers/Stellar.h
100644 → 100755
Empty file.
Empty file.
Empty file modified Carthage/Build/iOS/Stellar.framework/Headers/TimingType.swift
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified Carthage/Build/iOS/Stellar.framework/Headers/UnitBezier.swift
100644 → 100755
Empty file.
Empty file.
Empty file modified Carthage/Build/iOS/Stellar.framework/Headers/Vectorial.swift
100644 → 100755
Empty file.
Empty file modified Carthage/Build/iOS/Stellar.framework/Info.plist
100644 → 100755
Empty file.
Empty file modified Carthage/Build/iOS/Stellar.framework/Modules/module.modulemap
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
31 changes: 16 additions & 15 deletions Sources/AnimationContext.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,51 +9,51 @@
import UIKit

internal class AnimationContext: NSObject, UIDynamicAnimatorDelegate, AnimationSequenceDelegate {
private weak var object: DriveAnimateBehaviors!
private var mutipleSequences = [AnimationSequence]()
fileprivate weak var object: DriveAnimateBehaviors!
fileprivate var mutipleSequences = [AnimationSequence]()

//MARK: init method
init(object: DriveAnimateBehaviors) {
self.object = object
}

//MARK: public methods
func addAnimationType(type: AnimationType) {
func addAnimationType(_ type: AnimationType) {
let step = lastStep()
step.types.append(type)
}

func changeDuration(d: CFTimeInterval) {
func changeDuration(_ d: CFTimeInterval) {
let step = lastStep()
step.duration = d
}

func changeDelay(d: CFTimeInterval) {
func changeDelay(_ d: CFTimeInterval) {
let step = lastStep()
step.delay = d
}

func changeAutoreverses(a: Bool) {
func changeAutoreverses(_ a: Bool) {
let step = lastStep()
step.autoreverses = a
}

func changeRepeatCount(count: Int) {
func changeRepeatCount(_ count: Int) {
let step = lastStep()
step.repeatCount = count
}

func changeCompletion(c: () -> Void) {
func changeCompletion(_ c: @escaping () -> Void) {
let step = lastStep()
step.completion = c
}

func changeEasing(e: TimingFunctionType) {
func changeEasing(_ e: TimingFunctionType) {
let step = lastStep()
step.timing = e
}

func changeMainType(type: AnimationStyle) {
func changeMainType(_ type: AnimationStyle) {
let step = lastStep()
let lastAnimationType = step.types.last
guard let _ = lastAnimationType else {
Expand All @@ -69,6 +69,7 @@ internal class AnimationContext: NSObject, UIDynamicAnimatorDelegate, AnimationS
lastSequence().addStep(step)
}

@discardableResult
func makeNextSequence() -> AnimationSequence {
let sequence = AnimationSequence(object: self.object)
sequence.delegate = self
Expand Down Expand Up @@ -96,7 +97,7 @@ internal class AnimationContext: NSObject, UIDynamicAnimatorDelegate, AnimationS

//MARK: private methods

private func lastSequence() -> AnimationSequence {
fileprivate func lastSequence() -> AnimationSequence {
var sequence = mutipleSequences.last
if sequence == nil {
sequence = makeNextSequence()
Expand All @@ -105,7 +106,7 @@ internal class AnimationContext: NSObject, UIDynamicAnimatorDelegate, AnimationS
return sequence!
}

private func lastStep() -> AnimationStep {
fileprivate func lastStep() -> AnimationStep {
let sequence = lastSequence()
var step = sequence.last()
if step == nil {
Expand All @@ -117,10 +118,10 @@ internal class AnimationContext: NSObject, UIDynamicAnimatorDelegate, AnimationS

//MARK: AnimationSequenceDelegate methods

func animationSequenceDidComplete(sequence: AnimationSequence) {
let index = mutipleSequences.indexOf(sequence)
func animationSequenceDidComplete(_ sequence: AnimationSequence) {
let index = mutipleSequences.index(of: sequence)
if index != nil {
mutipleSequences.removeAtIndex(index!)
mutipleSequences.remove(at: index!)
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions Sources/AnimationSequence.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import UIKit

protocol AnimationSequenceDelegate: class {
func animationSequenceDidComplete(sequence: AnimationSequence);
func animationSequenceDidComplete(_ sequence: AnimationSequence);
}

internal class AnimationSequence: NSObject, UIDynamicAnimatorDelegate {
Expand All @@ -30,7 +30,7 @@ internal class AnimationSequence: NSObject, UIDynamicAnimatorDelegate {
}

//MARK: internal method
func addStep(step: AnimationStep) {
func addStep(_ step: AnimationStep) {
steps.append(step)
}

Expand All @@ -49,7 +49,7 @@ internal class AnimationSequence: NSObject, UIDynamicAnimatorDelegate {
steps.removeAll()
}

private func excuteFirstStepIfExist() {
fileprivate func excuteFirstStepIfExist() {

if self.view == nil {
return
Expand All @@ -75,7 +75,7 @@ internal class AnimationSequence: NSObject, UIDynamicAnimatorDelegate {
}
}

private func popFirstStepIfExsist() {
fileprivate func popFirstStepIfExsist() {
if !steps.isEmpty {
let step = steps.first!
//excute completion
Expand All @@ -88,13 +88,13 @@ internal class AnimationSequence: NSObject, UIDynamicAnimatorDelegate {
}

//MARK: UIDynamicAnimatorDelegate methods
func dynamicAnimatorDidPause(animator: UIDynamicAnimator) {
func dynamicAnimatorDidPause(_ animator: UIDynamicAnimator) {
animator.removeAllBehaviors()
popFirstStepIfExsist()
excuteFirstStepIfExist()
}

func dynamicAnimatorWillResume(animator: UIDynamicAnimator) {
func dynamicAnimatorWillResume(_ animator: UIDynamicAnimator) {

}
}
2 changes: 1 addition & 1 deletion Sources/AnimationStep.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import UIKit
internal class AnimationStep {
var types = [AnimationType]()
var duration: CFTimeInterval = 0.25
var timing: TimingFunctionType = .Default
var timing: TimingFunctionType = .default
var delay: CFTimeInterval = 0.0
var autoreverses: Bool = false
var repeatCount: Int = 0
Expand Down
58 changes: 29 additions & 29 deletions Sources/AnimationType.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,35 @@
import UIKit

enum AnimationSubType {
case MoveX(CGFloat)
case MoveY(CGFloat)
case MoveXY(CGFloat,CGFloat)//Layer
case MoveTo(CGPoint)
case Color(UIColor)
case Alpha(CGFloat)
case Opacity(Float)//Layer
case RotateX(CGFloat)
case RotateY(CGFloat)
case Rotate(CGFloat)
case RotateXY(CGFloat)
case Width(CGFloat)
case Height(CGFloat)
case Size(CGSize)
case Frame(CGRect)
case Bounds(CGRect)
case ScaleX(CGFloat)
case ScaleY(CGFloat)
case ScaleXY(CGFloat,CGFloat)
case CornerRadius(CGFloat)
case BorderWidth(CGFloat)
case ShadowRadius(CGFloat)
case ZPosition(CGFloat)
case AnchorPoint(CGPoint)
case AnchorPointZ(CGFloat)
case ShadowOffset(CGSize)
case ShadowColor(UIColor)
case ShadowOpacity(Float)
case TintColor(UIColor)
case moveX(CGFloat)
case moveY(CGFloat)
case moveXY(CGFloat,CGFloat)//Layer
case moveTo(CGPoint)
case color(UIColor)
case alpha(CGFloat)
case opacity(Float)//Layer
case rotateX(CGFloat)
case rotateY(CGFloat)
case rotate(CGFloat)
case rotateXY(CGFloat)
case width(CGFloat)
case height(CGFloat)
case size(CGSize)
case frame(CGRect)
case bounds(CGRect)
case scaleX(CGFloat)
case scaleY(CGFloat)
case scaleXY(CGFloat,CGFloat)
case cornerRadius(CGFloat)
case borderWidth(CGFloat)
case shadowRadius(CGFloat)
case zPosition(CGFloat)
case anchorPoint(CGPoint)
case anchorPointZ(CGFloat)
case shadowOffset(CGSize)
case shadowColor(UIColor)
case shadowOpacity(Float)
case tintColor(UIColor)
// UILabel,UITextView...
// case TextColor(UIColor)
}
Expand Down
20 changes: 10 additions & 10 deletions Sources/AnimatorCoordinator.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ import UIKit

internal class AnimatorCoordinator: NSObject, UIDynamicAnimatorDelegate {
static let shared = AnimatorCoordinator()
private var activedAnimators: [UIDynamicAnimator] = Array()
private var basicAnimator = UIDynamicAnimator()
fileprivate var activedAnimators: [UIDynamicAnimator] = Array()
fileprivate var basicAnimator = UIDynamicAnimator()

//MARK: public methods
func addBasicBehavior(b: UIDynamicBehavior) {
func addBasicBehavior(_ b: UIDynamicBehavior) {
basicAnimator.addBehavior(b)
}
func addBehavior(b: UIDynamicBehavior) {
func addBehavior(_ b: UIDynamicBehavior) {
addBehaviors([b])
}

func addBehaviors(behaviors: [UIDynamicBehavior]) {
func addBehaviors(_ behaviors: [UIDynamicBehavior]) {

let animator = activedAnimators.last
for b in behaviors {
Expand All @@ -42,7 +42,7 @@ internal class AnimatorCoordinator: NSObject, UIDynamicAnimatorDelegate {
}
}

private func createAnimator(behavior: UIDynamicBehavior) {
fileprivate func createAnimator(_ behavior: UIDynamicBehavior) {
let animator = UIDynamicAnimator()
animator.delegate = self
animator.addBehavior(behavior)
Expand All @@ -52,12 +52,12 @@ internal class AnimatorCoordinator: NSObject, UIDynamicAnimatorDelegate {

//MARK: UIDynamicAnimatorDelegate methods

func dynamicAnimatorDidPause(animator: UIDynamicAnimator) {
let index = activedAnimators.indexOf(animator)
activedAnimators.removeAtIndex(index!)
func dynamicAnimatorDidPause(_ animator: UIDynamicAnimator) {
let index = activedAnimators.index(of: animator)
activedAnimators.remove(at: index!)
}

func dynamicAnimatorWillResume(animator: UIDynamicAnimator) {
func dynamicAnimatorWillResume(_ animator: UIDynamicAnimator) {
//
}
}
6 changes: 3 additions & 3 deletions Sources/AttachmentConfigurable.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import UIKit

public protocol AttachmentConfigurable: BasicChainable {
func attachment(damping: CGFloat, frequency: CGFloat) -> AttachmentConfigurable
func attachment(_ damping: CGFloat, frequency: CGFloat) -> AttachmentConfigurable
}

public protocol AttachmentConfigurable1: BasicChainable1 {
func attachment(damping: CGFloat, frequency: CGFloat) -> AttachmentConfigurable1
}
func attachment(_ damping: CGFloat, frequency: CGFloat) -> AttachmentConfigurable1
}
Loading

0 comments on commit 20b198b

Please sign in to comment.