Skip to content

Commit

Permalink
0.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
ArLupin committed Jan 16, 2019
1 parent ee9c89f commit d849a61
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Configs/Sheet.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.2.4</string>
<string>0.2.5</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@

### CocoaPods
```bash
pod 'Sheet', '~> 0.2.4'
pod 'Sheet', '~> 0.2.5'
```

### Carthage
```bash
github "ParkGwangBeom/Sheet" ~> 0.2.4
github "ParkGwangBeom/Sheet" ~> 0.2.5
```

### Manually
Expand Down
2 changes: 1 addition & 1 deletion Sheet.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Sheet"
s.version = "0.2.4"
s.version = "0.2.5"
s.swift_version = '4.0'
s.summary = "Navigationable Action Sheet"
s.description = "💦 Navigable custom action sheet like Flipboard"
Expand Down
9 changes: 7 additions & 2 deletions Sources/Animator/SheetFadeAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ class SheetFadeAnimator: NSObject, UIViewControllerAnimatedTransitioning {
private var options: SheetOptions {
return SheetManager.shared.options
}

private var animationOption: SheetAnimationOption {
return SheetManager.shared.animationOption
}

private var toTopMargin: CGFloat = 0
private var fromTopMargin: CGFloat = 0

Expand All @@ -27,7 +32,7 @@ class SheetFadeAnimator: NSObject, UIViewControllerAnimatedTransitioning {
}

func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.4
return animationOption.pushAnimationItem.duration
}

func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
Expand Down Expand Up @@ -56,7 +61,7 @@ class SheetFadeAnimator: NSObject, UIViewControllerAnimatedTransitioning {

onReady?()

UIView.animate(withDuration: 0.4, delay: 0, usingSpringWithDamping: 0.75, initialSpringVelocity: 1, options: [.curveEaseOut], animations: {
UIView.animate(withDuration: animationOption.pushAnimationItem.duration, delay: 0, usingSpringWithDamping: animationOption.pushAnimationItem.springDumping, initialSpringVelocity: animationOption.pushAnimationItem.initialSpringVelocity, options: animationOption.pushAnimationItem.options, animations: {
fromContainer?.alpha = 0
fromContainer?.contentOffset.y += diff

Expand Down
9 changes: 7 additions & 2 deletions Sources/Controller/SheetNavigationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ public class SheetNavigationController: UINavigationController {
private var options: SheetOptions {
return SheetManager.shared.options
}

private var animationItem: AnimationItem {
return SheetManager.shared.animationOption.presentAnimationItem
}

/// Height constraints of the Sheet Toolbar
public var toolBarHeightConstraint: NSLayoutConstraint?
Expand Down Expand Up @@ -55,11 +59,12 @@ public class SheetNavigationController: UINavigationController {
rootViewController?.collectionView?.transform = CGAffineTransform(translationX: 0, y: visibleHeight + options.sheetToolBarHeight)
sheetToolBarContainerView?.transform = CGAffineTransform(translationX: 0, y: SheetManager.shared.options.sheetToolBarHeight + UIEdgeInsets.safeAreaInsets.bottom)

UIView.animate(withDuration: 0.45, delay: 0, usingSpringWithDamping: 0.75, initialSpringVelocity: 1, options: [.curveEaseOut], animations: {

UIView.animate(withDuration: animationItem.duration, delay: 0, usingSpringWithDamping: animationItem.springDumping, initialSpringVelocity: animationItem.initialSpringVelocity, options: animationItem.options, animations: {
rootViewController?.collectionView?.transform = .identity
}, completion: nil)

UIView.animate(withDuration: 0.2) {
UIView.animate(withDuration: 0.3) {
self.backgroundView?.alpha = 1
self.sheetToolBarContainerView?.transform = .identity
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/Manager/SheetManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ import UIKit
public static let shared = SheetManager()

public var options = SheetOptions()

public var animationOption = SheetAnimationOption()
}
31 changes: 31 additions & 0 deletions Sources/Manager/SheetOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,34 @@ public struct SheetOptions {
/// sheet background color
public var sheetBackgroundColor: UIColor = .white
}

public struct SheetAnimationOption {

public init() { }

public var presentAnimationItem = AnimationItem()

public var pushAnimationItem = AnimationItem(duration: 0.5, springDumping: 0.8, initialSpringVelocity: 1)
}

public struct AnimationItem {

public init(duration: TimeInterval = 0.6, springDumping: CGFloat = 0.8, initialSpringVelocity: CGFloat = 1, options: UIView.AnimationOptions = [.curveEaseOut]) {
self.duration = duration
self.springDumping = springDumping
self.initialSpringVelocity = initialSpringVelocity
self.options = options
}

/// sheet present animation duration. Defaults to 0.6
public var duration: TimeInterval = 0.6

/// sheet present animation spring dumping value. Defaults to 0.8
public var springDumping: CGFloat = 0.8

/// sheet present animation initial spring velocity. Defaults to 1
public var initialSpringVelocity: CGFloat = 1

/// sheet present animation options.
public var options: UIView.AnimationOptions = [.curveEaseOut]
}

0 comments on commit d849a61

Please sign in to comment.