Skip to content

Commit

Permalink
Merge pull request #18 from Yalantis/feature/swift5.2
Browse files Browse the repository at this point in the history
Feature/swift5.2
  • Loading branch information
PravdaEvgen authored Apr 9, 2020
2 parents fbe5266 + 5db8e2a commit 3bd7687
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 149 deletions.
36 changes: 28 additions & 8 deletions Example/StarWarsAnimations.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -306,22 +306,22 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 1140;
ORGANIZATIONNAME = Yalantis;
TargetAttributes = {
2A89D8941BD6633300A2C503 = {
CreatedOnToolsVersion = 7.0.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 1140;
};
2ACECE361BA2BF2E005689AD = {
CreatedOnToolsVersion = 7.0;
LastSwiftMigration = 0800;
LastSwiftMigration = 1140;
};
};
};
buildConfigurationList = 2ACECE321BA2BF2E005689AD /* Build configuration list for PBXProject "StarWarsAnimations" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -441,7 +441,8 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -464,7 +465,8 @@
PRODUCT_BUNDLE_IDENTIFIER = com.Yalantis.StarWars.Animation;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -478,14 +480,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -525,14 +535,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -569,7 +587,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.Yalantis.StarWars;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -584,7 +603,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.Yalantis.StarWars;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
190 changes: 70 additions & 120 deletions Example/StarWarsAnimations/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CircularRevealAnimator {

mask = CAShapeLayer()
mask.path = endPath
mask.fillRule = kCAFillRuleEvenOdd
mask.fillRule = CAShapeLayerFillRule.evenOdd

animation = CABasicAnimation(keyPath: "path")
animation.fromValue = startPath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class IntroViewController: UIViewController {
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let destination = segue.destination
destination.transitioningDelegate = self
if #available(iOS 13.0, *) {
destination.modalPresentationStyle = .fullScreen
}
if let navigation = destination as? UINavigationController,
let settings = navigation.topViewController as? MainSettingsViewController {
settings.theme = .light
Expand All @@ -52,8 +55,8 @@ class IntroViewController: UIViewController {
extension IntroViewController: UIViewControllerTransitioningDelegate {

func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
// return StarWarsUIDynamicAnimator()
// return StarWarsUIViewAnimator()
return StarWarsGLAnimator()
// StarWarsUIDynamicAnimator()
// StarWarsUIViewAnimator()
StarWarsGLAnimator()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class MainSettingsViewController: UIViewController {
navigationController!.navigationBar.shadowImage = UIImage()
navigationController!.navigationBar.isTranslucent = true
navigationController!.navigationBar.titleTextAttributes = [
NSAttributedStringKey.font: UIFont(name: "GothamPro", size: 20)!,
NSAttributedStringKey.foregroundColor: UIColor.white
NSAttributedString.Key.font: UIFont(name: "GothamPro", size: 20)!,
NSAttributedString.Key.foregroundColor: UIColor.white
]
}

Expand Down
6 changes: 3 additions & 3 deletions Example/StarWarsAnimations/View/StarsOverlay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class StarsOverlay: UIView {
fileprivate var particle: CAEmitterCell!

func setup() {
emitter.emitterMode = kCAEmitterLayerOutline
emitter.emitterShape = kCAEmitterLayerCircle
emitter.renderMode = kCAEmitterLayerOldestFirst
emitter.emitterMode = CAEmitterLayerEmitterMode.outline
emitter.emitterShape = CAEmitterLayerEmitterShape.circle
emitter.renderMode = CAEmitterLayerRenderMode.oldestFirst
emitter.preservesDepth = true

particle = CAEmitterCell()
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ Then just implement class of *UIViewControllerTransitioningDelegate* that will r

```swift
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
let destination = segue.destinationViewController
destination.transitioningDelegate = self
let destination = segue.destinationViewController
destination.transitioningDelegate = self
}

func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return StarWarsGLAnimator()
return StarWarsGLAnimator()
}
```

Expand All @@ -67,6 +67,7 @@ P.S. We’re going to publish more awesomeness wrapped in code and a tutorial on
- `1.0` Swift 2.0
- `2.0` Adds Swift 3.0 support
- `3.0` Adds Swift 4.0 support
- `4.0` Adds Swift 5.0 support

## License

Expand Down
2 changes: 1 addition & 1 deletion StarWars.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "StarWars"
s.version = "3.0"
s.version = "4.0"
s.summary = "This component implements transition animation to crumble view-controller into tiny pieces"

s.homepage = "https://yalantis.com/blog/uidynamics-uikit-or-opengl-3-types-of-ios-animations-for-the-star-wars/"
Expand Down
8 changes: 4 additions & 4 deletions StarWars/StarWarsGLAnimator/StarWarsGLAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ open class StarWarsGLAnimator: NSObject, UIViewControllerAnimatedTransitioning {
fileprivate var render: SpriteRender!

open func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return duration
duration
}

open func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
Expand All @@ -34,7 +34,7 @@ open class StarWarsGLAnimator: NSObject, UIViewControllerAnimatedTransitioning {
let toView = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!.view

containerView.addSubview(toView!)
containerView.sendSubview(toBack: toView!)
containerView.sendSubviewToBack(toView!)

func randomFloatBetween(_ smallNumber: CGFloat, and bigNumber: CGFloat) -> Float {
let diff = bigNumber - smallNumber
Expand Down Expand Up @@ -81,9 +81,9 @@ open class StarWarsGLAnimator: NSObject, UIViewControllerAnimatedTransitioning {

displayLink = CADisplayLink(target: self, selector: #selector(StarWarsGLAnimator.displayLinkTick(_:)))
displayLink.isPaused = false
displayLink.add(to: RunLoop.main, forMode: RunLoopMode.commonModes)
displayLink.add(to: RunLoop.main, forMode: RunLoop.Mode.common)

self.startTransitionTime = Date.timeIntervalSinceReferenceDate
self.startTransitionTime = Date.timeIntervalSinceReferenceDate
}

open func animationEnded(_ transitionCompleted: Bool) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ open class StarWarsUIDynamicAnimator: NSObject, UIViewControllerAnimatedTransiti
let toView = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!.view

containerView.addSubview(toView!)
containerView.sendSubview(toBack: toView!)
containerView.sendSubviewToBack(toView!)

let size = fromView!.frame.size

Expand Down
6 changes: 3 additions & 3 deletions StarWars/StarWarsUIViewAnimator/StarWarsUIViewAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ open class StarWarsUIViewAnimator: NSObject, UIViewControllerAnimatedTransitioni
let toView = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to)!.view

containerView.addSubview(toView!)
containerView.sendSubview(toBack: toView!)
containerView.sendSubviewToBack(toView!)

var snapshots:[UIView] = []
let size = fromView?.frame.size
Expand Down Expand Up @@ -52,13 +52,13 @@ open class StarWarsUIViewAnimator: NSObject, UIViewControllerAnimatedTransitioni
}
}

containerView.sendSubview(toBack: fromView!)
containerView.sendSubviewToBack(fromView!)

UIView.animate(
withDuration:
duration,
delay: 0,
options: UIViewAnimationOptions.curveLinear,
options: UIView.AnimationOptions.curveLinear,
animations: {
for view in snapshots {
let xOffset = randomFloatBetween(-200 , and: 200)
Expand Down

0 comments on commit 3bd7687

Please sign in to comment.