Skip to content

Commit

Permalink
Insert one whitespace after colon and before opening brace (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shunki Tan authored and lkzhao committed Feb 4, 2017
1 parent 573a385 commit af38a2d
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 90 deletions.
6 changes: 3 additions & 3 deletions Sources/BasePreprocessor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import UIKit

class BasePreprocessor:HeroPreprocessor {
var context:HeroContext { return Hero.shared.context }
func process(fromViews:[UIView], toViews:[UIView]) {}
class BasePreprocessor: HeroPreprocessor {
var context: HeroContext { return Hero.shared.context }
func process(fromViews: [UIView], toViews: [UIView]) {}
}
6 changes: 3 additions & 3 deletions Sources/CascadePreprocessor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ public enum CascadeDirection {
}
}

class CascadePreprocessor:BasePreprocessor {
override func process(fromViews:[UIView], toViews:[UIView]) {
class CascadePreprocessor: BasePreprocessor {
override func process(fromViews: [UIView], toViews: [UIView]) {
process(views:fromViews)
process(views:toViews)
}

func process(views:[UIView]){
func process(views: [UIView]) {
for (viewIndex, fv) in views.enumerated() {
guard let (deltaTime, direction, delayMatchedViews) = context[fv]?.cascade else { continue }

Expand Down
68 changes: 34 additions & 34 deletions Sources/Hero.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import UIKit
func apply(modifiers:[HeroModifier], to view:UIView)
```
*/
public class Hero:NSObject {
public class Hero: NSObject {
// MARK: Shared Access

/// Shared singleton object for controlling the transition
Expand All @@ -47,24 +47,24 @@ public class Hero:NSObject {
// MARK: Properties

/// destination view controller
public fileprivate(set) weak var toViewController:UIViewController?
public fileprivate(set) weak var toViewController: UIViewController?
/// source view controller
public fileprivate(set) weak var fromViewController:UIViewController?
public fileprivate(set) weak var fromViewController: UIViewController?
/// context object holding transition informations
public fileprivate(set) var context: HeroContext!
/// whether or not we are presenting the destination view controller
public fileprivate(set) var presenting = true
/// whether or not we are handling transition interactively
public var interactive:Bool {
public var interactive: Bool {
return displayLink == nil
}
/// progress of the current transition. 0 if no transition is happening
public fileprivate(set) var progress:Double = 0 {
didSet{
public fileprivate(set) var progress: Double = 0 {
didSet {
if transitioning, progress != oldValue {
transitionContext?.updateInteractiveTransition(CGFloat(progress))
if let progressUpdateObservers = progressUpdateObservers{
for observer in progressUpdateObservers{
if let progressUpdateObservers = progressUpdateObservers {
for observer in progressUpdateObservers {
observer.heroDidUpdateProgress(progress: progress)
}
}
Expand Down Expand Up @@ -94,7 +94,7 @@ public class Hero:NSObject {
public fileprivate(set) var container: UIView!

/// this is the container supplied by UIKit
fileprivate var transitionContainer:UIView!
fileprivate var transitionContainer: UIView!

/// a UIViewControllerContextTransitioning object provided by UIKit,
/// might be nil when transitioning. This happens when calling heroReplaceViewController
Expand All @@ -103,17 +103,17 @@ public class Hero:NSObject {
fileprivate var completionCallback: ((Bool) -> Void)?
internal var forceNotInteractive = false

fileprivate var displayLink:CADisplayLink?
fileprivate var progressUpdateObservers:[HeroProgressUpdateObserver]?

fileprivate var displayLink: CADisplayLink?
fileprivate var progressUpdateObservers: [HeroProgressUpdateObserver]?

/// max duration needed by the default animator and plugins
fileprivate var totalDuration: TimeInterval = 0.0
fileprivate var duration: TimeInterval = 0.0
fileprivate var beginTime:TimeInterval?{
didSet{
fileprivate var beginTime: TimeInterval? {
didSet {
if beginTime != nil {
if displayLink == nil{
if displayLink == nil {
displayLink = CADisplayLink(target: self, selector: #selector(displayUpdate(_:)))
displayLink!.add(to: RunLoop.main, forMode: RunLoopMode(rawValue: RunLoopMode.commonModes.rawValue))
}
Expand All @@ -124,7 +124,7 @@ public class Hero:NSObject {
}
}
}
func displayUpdate(_ link:CADisplayLink){
func displayUpdate(_ link: CADisplayLink) {
if transitioning, duration > 0, let beginTime = beginTime {
let timePassed = CACurrentMediaTime() - beginTime

Expand All @@ -134,7 +134,7 @@ public class Hero:NSObject {
complete(finished: finishing)
} else {
var completed = timePassed / totalDuration
if !finishing{
if !finishing {
completed = 1 - completed
}
completed = max(0, min(1, completed))
Expand All @@ -144,7 +144,7 @@ public class Hero:NSObject {
}


fileprivate var finishing:Bool = true
fileprivate var finishing: Bool = true
/// true if transitioning inside a UINavigationController or UITabBarController
fileprivate var inContainerController = false

Expand All @@ -157,7 +157,7 @@ public class Hero:NSObject {

fileprivate static var enabledPlugins: [HeroPlugin.Type] = []

fileprivate override init(){}
fileprivate override init() {}
}

public extension Hero {
Expand All @@ -180,13 +180,13 @@ public extension Hero {
Will stop the interactive transition and animate from the
current state to the **end** state
*/
public func end(animate:Bool = true) {
public func end(animate: Bool = true) {
guard transitioning && interactive else { return }
if !animate {
complete(finished:true)
return
}
var maxTime:TimeInterval = 0
var maxTime: TimeInterval = 0
for animator in animators {
maxTime = max(maxTime, animator.resume(timePassed:progress * totalDuration, reverse: false))
}
Expand All @@ -198,13 +198,13 @@ public extension Hero {
Will stop the interactive transition and animate from the
current state to the **begining** state
*/
public func cancel(animate:Bool = true) {
public func cancel(animate: Bool = true) {
guard transitioning && interactive else { return }
if !animate {
complete(finished:false)
return
}
var maxTime:TimeInterval = 0
var maxTime: TimeInterval = 0
for animator in animators {
maxTime = max(maxTime, animator.resume(timePassed:progress * totalDuration, reverse: true))
}
Expand All @@ -223,10 +223,10 @@ public extension Hero {
- modifiers: the modifiers to override
- view: the view to override to
*/
public func apply(modifiers:[HeroModifier], to view:UIView) {
public func apply(modifiers: [HeroModifier], to view: UIView) {
guard transitioning && interactive else { return }
let targetState = HeroTargetState(modifiers: modifiers)
if let otherView = context.pairedView(for: view){
if let otherView = context.pairedView(for: view) {
for animator in animators {
animator.apply(state: targetState, to: otherView)
}
Expand All @@ -237,7 +237,7 @@ public extension Hero {
}
}

public extension Hero{
public extension Hero {
// MARK: Observe Progress

/**
Expand All @@ -247,8 +247,8 @@ public extension Hero{
- Parameters:
- observer: the observer
*/
func observeForProgressUpdate(observer:HeroProgressUpdateObserver){
if progressUpdateObservers == nil{
func observeForProgressUpdate(observer: HeroProgressUpdateObserver) {
if progressUpdateObservers == nil {
progressUpdateObservers = []
}
progressUpdateObservers!.append(observer)
Expand Down Expand Up @@ -316,10 +316,10 @@ internal extension Hero {
var skipDefaultAnimation = false
var animatingViews = [([UIView], [UIView])]()
for animator in animators {
let currentFromViews = context.fromViews.filter{ (view:UIView) -> Bool in
let currentFromViews = context.fromViews.filter { (view: UIView) -> Bool in
return animator.canAnimate(view: view, appearing: false)
}
let currentToViews = context.toViews.filter{ (view:UIView) -> Bool in
let currentToViews = context.toViews.filter { (view: UIView) -> Bool in
return animator.canAnimate(view: view, appearing: true)
}
if currentFromViews.first == fromView || currentToViews.first == toView {
Expand Down Expand Up @@ -347,7 +347,7 @@ internal extension Hero {
}
}

var totalDuration:TimeInterval = 0
var totalDuration: TimeInterval = 0
var animatorWantsInteractive = false
for (i, animator) in self.animators.enumerated() {
let duration = animator.animate(fromViews: animatingViews[i].0,
Expand Down Expand Up @@ -382,7 +382,7 @@ internal extension Hero {
start()
}

func complete(after:TimeInterval, finishing:Bool) {
func complete(after: TimeInterval, finishing: Bool) {
if after <= 0.001 {
complete(finished: finishing)
return
Expand Down Expand Up @@ -443,7 +443,7 @@ internal extension Hero {
}
}

if finished{
if finished {
tContext?.finishInteractiveTransition()
} else {
tContext?.cancelInteractiveTransition()
Expand Down Expand Up @@ -527,7 +527,7 @@ extension Hero: UIViewControllerAnimatedTransitioning {
}

extension Hero:UIViewControllerTransitioningDelegate {
var interactiveTransitioning:UIViewControllerInteractiveTransitioning?{
var interactiveTransitioning: UIViewControllerInteractiveTransitioning? {
return forceNotInteractive ? nil : self
}

Expand All @@ -554,7 +554,7 @@ extension Hero:UIViewControllerTransitioningDelegate {
}

extension Hero: UIViewControllerInteractiveTransitioning {
public var wantsInteractiveStart: Bool{
public var wantsInteractiveStart: Bool {
return true
}
public func startInteractiveTransition(_ transitionContext: UIViewControllerContextTransitioning) {
Expand Down
8 changes: 4 additions & 4 deletions Sources/HeroDebugPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
import UIKit

public class HeroDebugPlugin: HeroPlugin {
static var showOnTop:Bool = false
static var showOnTop: Bool = false

var debugView:HeroDebugView?
var zPositionMap = [UIView:CGFloat]()
var addedLayers:[CALayer] = []
var debugView: HeroDebugView?
var zPositionMap = [UIView: CGFloat]()
var addedLayers: [CALayer] = []
var updating = false

override public func animate(fromViews: [UIView], toViews: [UIView]) -> TimeInterval {
Expand Down
12 changes: 6 additions & 6 deletions Sources/HeroDebugView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ class HeroDebugView: UIView {
}
}

var showOnTop:Bool = false
var rotation:CGFloat = CGFloat(M_PI / 6)
var scale:CGFloat = 0.6
var translation:CGPoint = .zero
var progress:Float{
var showOnTop: Bool = false
var rotation: CGFloat = CGFloat(M_PI / 6)
var scale: CGFloat = 0.6
var translation: CGPoint = .zero
var progress: Float {
return debugSlider.value
}

init(initialProcess:Float, showCurveButton:Bool, showOnTop:Bool) {
init(initialProcess: Float, showCurveButton: Bool, showOnTop: Bool) {
super.init(frame:.zero)
self.showOnTop = showOnTop
backgroundView = UIView(frame:.zero)
Expand Down
16 changes: 8 additions & 8 deletions Sources/HeroDefaultAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

import UIKit

public class HeroDefaultAnimator:HeroAnimator{
var context:HeroContext { return Hero.shared.context }
var viewContexts:[UIView: HeroDefaultAnimatorViewContext] = [:]
public class HeroDefaultAnimator: HeroAnimator {
var context: HeroContext { return Hero.shared.context }
var viewContexts: [UIView: HeroDefaultAnimatorViewContext] = [:]

public func seekTo(timePassed: TimeInterval) {
for viewContext in viewContexts.values {
Expand All @@ -41,15 +41,15 @@ public class HeroDefaultAnimator:HeroAnimator{
return duration
}

public func apply(state:HeroTargetState, to view:UIView){
public func apply(state: HeroTargetState, to view: UIView) {
guard let context = viewContexts[view] else {
print("HERO: unable to temporarily set to \(view). The view must be running at least one animation before it can be interactively changed")
return
}
context.apply(state:state)
}

public func canAnimate(view:UIView, appearing:Bool) -> Bool{
public func canAnimate(view: UIView, appearing: Bool) -> Bool {
guard let state = context[view] else { return false }
return state.position != nil ||
state.size != nil ||
Expand All @@ -58,8 +58,8 @@ public class HeroDefaultAnimator:HeroAnimator{
state.opacity != nil
}

public func animate(fromViews:[UIView], toViews:[UIView]) -> TimeInterval{
var duration:TimeInterval = 0
public func animate(fromViews: [UIView], toViews: [UIView]) -> TimeInterval {
var duration: TimeInterval = 0

// animate
for v in fromViews {
Expand All @@ -82,7 +82,7 @@ public class HeroDefaultAnimator:HeroAnimator{
viewContexts[view] = viewContext
}

public func clean(){
public func clean() {
viewContexts.removeAll()
}
}
6 changes: 3 additions & 3 deletions Sources/HeroDefaultAnimatorViewContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ internal class HeroDefaultAnimatorViewContext {
}
}

func apply(state:HeroTargetState){
func apply(state: HeroTargetState) {
let targetState = viewState(targetState: state)
for (key, targetValue) in targetState{
if self.state[key] == nil{
for (key, targetValue) in targetState {
if self.state[key] == nil {
let currentValue = snapshot.layer.value(forKeyPath: key)!
self.state[key] = (currentValue, currentValue)
}
Expand Down
Loading

0 comments on commit af38a2d

Please sign in to comment.