Compare commits

...

6 Commits

Author SHA1 Message Date
Ivan Vorobei 34f267d43c Update SPStorkController.podspec 2018-11-29 12:55:29 +03:00
Ivan Vorobei 425f8ec1ca Fix layout for SPStorkController
- Fix layout for SPStorkController
- Add extenshion for `CGRect` static var `displayFrame`. It is rect for screen size
- Set clear background color for `SPStorkIndicatorView`
2018-11-29 12:49:56 +03:00
Ivan Vorobei 25ea7eab4c Add more interactive to SPStorkController 2018-11-29 11:10:18 +03:00
Ivan Vorobei 16f060820f Update README.md 2018-11-28 20:11:41 +03:00
Ivan Vorobei 4c8faf7695 Update README.md 2018-11-28 17:49:37 +03:00
Ivan Vorobei 5b843582d4 Update README.md 2018-11-28 17:30:29 +03:00
9 changed files with 62 additions and 37 deletions
@@ -344,12 +344,12 @@
F445CA9821AED98500184254 /* Frameworks */ = {
isa = PBXGroup;
children = (
F445CA9921AED98500184254 /* sparrow */,
F445CA9921AED98500184254 /* Sparrow */,
);
path = Frameworks;
sourceTree = "<group>";
};
F445CA9921AED98500184254 /* sparrow */ = {
F445CA9921AED98500184254 /* Sparrow */ = {
isa = PBXGroup;
children = (
F445CA9A21AED98500184254 /* internet-connection */,
@@ -382,7 +382,7 @@
F445CB5121AED98500184254 /* share */,
F445CB5321AED98500184254 /* badge */,
);
path = sparrow;
path = Sparrow;
sourceTree = "<group>";
};
F445CA9A21AED98500184254 /* internet-connection */ = {
@@ -23,6 +23,11 @@ import UIKit
extension CGRect {
static var displayFrame: CGRect {
let screenSize = UIScreen.main.bounds
return CGRect.init(origin: .zero, size: screenSize.size)
}
var bottomXPosition: CGFloat {
get {
return self.origin.x + self.width
@@ -276,6 +276,10 @@ extension UIView {
self.isHidden = true
})
}
func removeAllAnimations() {
self.layer.removeAllAnimations()
}
}
// MARK: - corner radius
@@ -31,7 +31,6 @@ final class SPStorkDismissingAnimationController: NSObject, UIViewControllerAnim
let containerView = transitionContext.containerView
let offscreenFrame = CGRect(x: 0, y: containerView.bounds.height, width: containerView.bounds.width, height: containerView.bounds.height)
UIView.animate(
withDuration: transitionDuration(using: transitionContext),
delay: 0,
@@ -41,7 +40,7 @@ final class SPStorkDismissingAnimationController: NSObject, UIViewControllerAnim
animations: {
presentedViewController.view.frame = offscreenFrame
}) { finished in
transitionContext.completeTransition(finished)
transitionContext.completeTransition(finished)
}
}
@@ -47,6 +47,7 @@ class SPStorkIndicatorView: UIView {
init() {
super.init(frame: .zero)
self.backgroundColor = UIColor.clear
self.addSubview(self.leftView)
self.addSubview(self.rightView)
self.leftView.backgroundColor = UIColor.init(hex: "CAC9CF")
@@ -58,6 +58,7 @@ final class SPStorkPresentationController: UIPresentationController, UIGestureRe
private func updateLayout() {
guard let presentedView = self.presentedView else { return }
self.indicatorView.style = .line
self.indicatorView.sizeToFit()
self.indicatorView.frame.origin.y = 12
self.indicatorView.center.x = presentedView.frame.width / 2
@@ -65,7 +66,7 @@ final class SPStorkPresentationController: UIPresentationController, UIGestureRe
override var frameOfPresentedViewInContainerView: CGRect {
if let containerView = self.containerView {
let yOffset = topSpace + 13
let yOffset: CGFloat = topSpace + 13
return CGRect(x: 0, y: yOffset, width: containerView.bounds.width, height: containerView.bounds.height - yOffset)
} else {
return .zero
@@ -88,8 +89,10 @@ final class SPStorkPresentationController: UIPresentationController, UIGestureRe
guard let transitionCoordinator = self.presentingViewController.transitionCoordinator else { return }
transitionCoordinator.animateAlongsideTransition(in: self.presentingViewController.view, animation: { _ in
self.presentingViewController.view.transform = self.transform
self.presentingViewController.view.alpha = self.alpha
if !self.isPresentingControllerUseStork {
self.presentingViewController.view.transform = self.transform
self.presentingViewController.view.alpha = self.alpha
}
})
}
@@ -112,15 +115,22 @@ final class SPStorkPresentationController: UIPresentationController, UIGestureRe
transitionCoordinator.animateAlongsideTransition(in: presentingViewController.view, animation: { _ in
self.presentingViewController.view.transform = CGAffineTransform.identity
if self.presentingViewController.view.frame.origin != CGPoint.zero {
self.presentingViewController.view.frame = CGRect.displayFrame
}
})
self.presentingViewController.view.addCornerRadiusAnimation(to: 0, duration: 0.6)
if !self.isPresentingControllerUseStork {
self.presentingViewController.view.addCornerRadiusAnimation(to: 0, duration: 0.6)
}
}
override func dismissalTransitionDidEnd(_ completed: Bool) {
if let presentingView = self.presentingViewController.view {
presentingView.layer.cornerRadius = 0
presentingView.layer.masksToBounds = false
if !self.isPresentingControllerUseStork {
if let presentingView = self.presentingViewController.view {
presentingView.layer.cornerRadius = 0
presentingView.layer.masksToBounds = false
}
}
}
}
@@ -134,16 +144,8 @@ extension SPStorkPresentationController {
switch gestureRecognizer.state {
case .began:
/*UIView.animate(
withDuration: 0.25,
delay: 0,
usingSpringWithDamping: 1,
initialSpringVelocity: 1,
options: .curveEaseOut,
animations: {
self.indicatorView.transform = CGAffineTransform.init(scaleX: 1.2, y: 1.2)
})*/
self.indicatorView.style = .line
self.presentingViewController.view.removeAllAnimations()
gestureRecognizer.setTranslation(CGPoint(x: 0, y: 0), in: containerView)
case .changed:
if self.isSwipeToDismissEnabled {
@@ -163,11 +165,13 @@ extension SPStorkPresentationController {
delay: 0,
usingSpringWithDamping: 1,
initialSpringVelocity: 1,
options: .curveEaseOut,
options: [.curveEaseOut, .allowUserInteraction],
animations: {
self.presentedView?.transform = .identity
self.presentingViewController.view.transform = self.transform
self.presentingViewController.view.alpha = self.alpha
if !self.isPresentingControllerUseStork {
self.presentingViewController.view.transform = self.transform
self.presentingViewController.view.alpha = self.alpha
}
})
}
default:
@@ -193,9 +197,19 @@ extension SPStorkPresentationController {
self.presentedView?.transform = CGAffineTransform(translationX: 0, y: translationForModal)
let factor = 1 + (translationForModal / 6000)
self.presentingViewController.view.transform = self.transform.scaledBy(x: factor, y: factor)
self.presentingViewController.view.alpha = self.alpha + ((factor - 1) * 15)
if !self.isPresentingControllerUseStork {
let factor = 1 + (translationForModal / 6000)
self.presentingViewController.view.transform = self.transform.scaledBy(x: factor, y: factor)
self.presentingViewController.view.alpha = self.alpha + ((factor - 1) * 15)
}
}
}
private var isPresentingControllerUseStork: Bool {
let controller = self.presentingViewController
return controller.transitioningDelegate is SPStorkTransitioningDelegate
&& controller.modalPresentationStyle == .custom
&& controller.presentingViewController != nil
}
}
+10 -8
View File
@@ -1,5 +1,5 @@
# SPStorkController
Modal controller as in mail or Apple music application. Similar animation and transition. Now in develop
Modal controller as in mail or Apple music application. Similar animation and transition. I tried to repeat all the animations, corner radius and frames. The controller supports gestures
Preview GIF loading `4mb`. Please, wait
@@ -15,7 +15,7 @@ The project is absolutely free, but but it takes time to support and update it.
Swift 4.2. Ready for use on iOS 10+
## Integration
Drop in `source/sparrow` folder to your Xcode project. Make sure to enable `Copy items if needed` and `Create groups`
Drop in `Source/Sparrow` folder to your Xcode project. Make sure to enable `Copy items if needed` and `Create groups`
Or via CocoaPods:
```ruby
@@ -28,17 +28,19 @@ import SparrowKit
```
## How to use
Init controller (please, set background, it maybe clear color) and set `transitioningDelegate`. Use `present` or `dissmiss` funcs:
Create controller (please, set background, it maybe clear color) and set `transitioningDelegate` to `SPStorkTransitioningDelegate()`. Use `present` or `dismiss` functions:
```swift
import SparrowKit
let controller = UIViewController()
let transitionDelegate = SPStorkTransitioningDelegate()
controller.transitioningDelegate = transitionDelegate
controller.transitioningDelegate = SPStorkTransitioningDelegate()
controller.modalPresentationStyle = .custom
present(controller, animated: true, completion: nil)
```
## My projects
Project [SPPermission](https://github.com/IvanVorobei/SPPermission) about managing permissions with the customizable visual effects. Beautiful dialog increases the chance of approval (which is important when we request notification). Simple control of this module saves you hours of development. You can start using this project with just two lines of code and easy customization!
<img src="https://rawcdn.githack.com/IvanVorobei/RequestPermission/fb53d20f152a3e76e053e6af529306611fb794f0/resources/request-permission - mockup_preview.gif" width="500">
## License
`SPStorkController` is released under the MIT license. Check LICENSE.md for details
@@ -47,4 +49,4 @@ If you need develop application or UI, write me to hello@ivanvorobei.by. I am de
[hello.ivanvorobei.by](https://hello.ivanvorobei.by) & [ivanvorobei.by](https://hello.ivanvorobei.by)
My apps [in AppStore](https://itunes.apple.com/us/developer/polina-zubarik/id1434528595) & [in AppStore 2](https://itunes.apple.com/us/developer/mikalai-varabei/id1435792103)
My apps [in AppStore](https://itunes.apple.com/us/developer/polina-zubarik/id1434528595) & [in AppStore 2](https://itunes.apple.com/us/developer/mikalai-varabei/id1435792103)
+2 -2
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "SPStorkController"
s.version = "1.0.4"
s.version = "1.0.6"
s.summary = "Modal controller as mail or Apple music application"
s.homepage = "https://github.com/IvanVorobei/SPStorkController"
s.source = { :git => "https://github.com/IvanVorobei/SPStorkController.git", :tag => s.version }
@@ -13,7 +13,7 @@ Pod::Spec.new do |s|
s.platform = :ios
s.ios.deployment_target = "10.0"
s.dependency 'SparrowKit', '~> 1.0.0'
s.dependency 'SparrowKit', '~> 1.0.1'
end