Compare commits

...

5 Commits

Author SHA1 Message Date
Ivan Vorobei 962d1a937d Update to 1.2.2
Add new parametr - `colorIndicator` for change color arrow. Update example & Readme. Fix `SPStorkIndicatorView `
2019-01-31 21:20:53 +03:00
Ivan Vorobei bc6c7ff45e Update README.md 2019-01-31 08:06:47 +03:00
Ivan Vorobei ec7abd4a2a Update example
Update `SparrowKit` pod
2019-01-26 14:01:36 +03:00
Ivan Vorobei 6904e0916a Update UserInterfaceState.xcuserstate 2019-01-21 16:33:48 +03:00
Ivan Vorobei 90ee3d35da Add navigation controller for example 2019-01-21 15:15:54 +03:00
20 changed files with 1927 additions and 1023 deletions
File diff suppressed because it is too large Load Diff
+4 -1
View File
@@ -7,7 +7,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
self.launch(rootViewController: Controller())
let navigationController = UINavigationController(rootViewController: Controller())
self.launch(rootViewController: navigationController)
return true
}
+2 -2
View File
@@ -30,7 +30,7 @@ class Controller: UIViewController {
let transitionDelegate = SPStorkTransitioningDelegate()
modal.transitioningDelegate = transitionDelegate
modal.modalPresentationStyle = .custom
present(modal, animated: true, completion: nil)
self.present(modal, animated: true, completion: nil)
}
@objc func presentModalTableViewController() {
@@ -38,6 +38,6 @@ class Controller: UIViewController {
let transitionDelegate = SPStorkTransitioningDelegate()
modal.transitioningDelegate = transitionDelegate
modal.modalPresentationStyle = .custom
present(modal, animated: true, completion: nil)
self.present(modal, animated: true, completion: nil)
}
}
@@ -42,6 +42,13 @@ class SPStorkIndicatorView: UIView {
}
}
var color: UIColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1) {
didSet {
self.leftView.backgroundColor = self.color
self.rightView.backgroundColor = self.color
}
}
private var leftView: UIView = UIView()
private var rightView: UIView = UIView()
@@ -50,8 +57,7 @@ class SPStorkIndicatorView: UIView {
self.backgroundColor = UIColor.clear
self.addSubview(self.leftView)
self.addSubview(self.rightView)
self.leftView.backgroundColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
self.rightView.backgroundColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
self.color = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
}
required init?(coder aDecoder: NSCoder) {
@@ -26,6 +26,7 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
var isSwipeToDismissEnabled: Bool = true
var isTapAroundToDismissEnabled: Bool = true
var showIndicator: Bool = true
var indicatorColor: UIColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
var customHeight: CGFloat? = nil
var transitioningDelegate: SPStorkTransitioningDelegate?
@@ -82,6 +83,7 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
guard let containerView = self.containerView, let presentedView = self.presentedView, let window = containerView.window else { return }
if self.showIndicator {
self.indicatorView.color = self.indicatorColor
presentedView.addSubview(self.indicatorView)
}
self.updateLayoutIndicator()
@@ -268,6 +270,8 @@ extension SPStorkPresentationController {
self.workGester = true
self.indicatorView.style = .line
self.presentingViewController.view.layer.removeAllAnimations()
self.presentingViewController.view.endEditing(true)
self.presentedViewController.view.endEditing(true)
gestureRecognizer.setTranslation(CGPoint(x: 0, y: 0), in: containerView)
case .changed:
self.workGester = true
@@ -26,6 +26,7 @@ public final class SPStorkTransitioningDelegate: NSObject, UIViewControllerTrans
public var isSwipeToDismissEnabled: Bool = true
public var isTapAroundToDismissEnabled: Bool = true
public var showIndicator: Bool = true
public var indicatorColor: UIColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
public var customHeight: CGFloat? = nil
public func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
@@ -33,6 +34,7 @@ public final class SPStorkTransitioningDelegate: NSObject, UIViewControllerTrans
controller.isSwipeToDismissEnabled = self.isSwipeToDismissEnabled
controller.isTapAroundToDismissEnabled = self.isTapAroundToDismissEnabled
controller.showIndicator = self.showIndicator
controller.indicatorColor = self.indicatorColor
controller.customHeight = self.customHeight
controller.transitioningDelegate = self
return controller
@@ -21,7 +21,4 @@
import UIKit
struct SPCodeDraw {
private init() {}
}
struct SPCodeDraw { private init() {} }
@@ -24,11 +24,11 @@ import Photos
extension UIViewController {
func present(_ viewControllerToPresent: UIViewController, completion: (() -> Swift.Void)? = nil) {
public func present(_ viewControllerToPresent: UIViewController, completion: (() -> Swift.Void)? = nil) {
self.present(viewControllerToPresent, animated: true, completion: completion)
}
@objc func dismiss() {
@objc public func dismiss() {
self.dismiss(animated: true, completion: nil)
}
@@ -41,20 +41,20 @@ extension UIViewController {
extension UIViewController {
func dismissKeyboardWhenTappedAround() {
public func dismissKeyboardWhenTappedAround() {
let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(UIViewController.dismissKeyboard))
tap.cancelsTouchesInView = false
view.addGestureRecognizer(tap)
}
@objc func dismissKeyboard() {
@objc public func dismissKeyboard() {
view.endEditing(true)
}
}
extension UIViewController {
func save(image: UIImage) {
public func save(image: UIImage) {
if PHPhotoLibrary.authorizationStatus() == PHAuthorizationStatus.authorized {
UIImageWriteToSavedPhotosAlbum(image, self, #selector(self.image(_:didFinishSavingWithError:contextInfo:)), nil)
} else {
@@ -62,7 +62,7 @@ extension UIViewController {
}
}
func saveVideo(url: String, complection: @escaping (Bool)->()) {
public func saveVideo(url: String, complection: @escaping (Bool)->()) {
DispatchQueue.global(qos: .utility).async {
let urls = URL(string: url)
let urldata = try? Data(contentsOf: urls!)
@@ -141,7 +141,7 @@ extension UIViewController {
extension UIViewController {
var safeArea: UIEdgeInsets {
public var safeArea: UIEdgeInsets {
if #available(iOS 11.0, *) {
return self.view.safeAreaInsets
} else {
@@ -149,18 +149,18 @@ extension UIViewController {
}
}
var navigationBarHeight: CGFloat {
public var navigationBarHeight: CGFloat {
return self.navigationController?.navigationBar.frame.height ?? 0
}
static var statusBarHeight: CGFloat {
public static var statusBarHeight: CGFloat {
return UIApplication.shared.statusBarFrame.height
}
}
extension UIViewController {
var navigationTitleColor: UIColor? {
public var navigationTitleColor: UIColor? {
get {
return (self.navigationController?.navigationBar.titleTextAttributes?[NSAttributedString.Key.foregroundColor] as? UIColor) ?? nil
}
@@ -103,6 +103,9 @@ class SPGolubevIconView: UIView {
case .headphones:
SPCodeDraw.GolubevIconPack.drawHeadphones(frame: rect, resizing: .aspectFit, white: self.whiteColor, light: self.lightColor, medium: self.mediumColor, dark: self.darkColor)
break
case .windmill:
SPCodeDraw.GolubevIconPack.drawWindmill(frame: rect, resizing: .aspectFit, white: self.whiteColor, light: self.lightColor, medium: self.mediumColor, dark: self.darkColor)
break
}
}
@@ -116,6 +119,7 @@ class SPGolubevIconView: UIView {
case documents
case compass
case headphones
case windmill
}
}
@@ -86,8 +86,8 @@ class SPMengTransformCollectionViewCell: SPCollectionViewCell {
self.backgroundImageView.bottomAnchor.constraint(equalTo:
contentView.bottomAnchor, constant: 0).isActive = true
self.gradientView.startColorPosition = .TopLeft
self.gradientView.endColorPosition = .BottomRight
self.gradientView.startColorPosition = .topLeft
self.gradientView.endColorPosition = .bottomRight
self.gradientView.isHidden = true
self.gradientView.translatesAutoresizingMaskIntoConstraints = false
self.gradientView.layer.masksToBounds = false
@@ -23,9 +23,9 @@ import UIKit
class SPSectionLabelsView: SPView {
let titleLabel = UILabel()
let subtitleLabel = UILabel()
let button = UIButton.init(type: UIButton.ButtonType.system)
let titleLabel = SPLabel()
let subtitleLabel = SPLabel()
let button = SPButton()
override func commonInit() {
super.commonInit()
@@ -59,15 +59,18 @@ class SPSectionLabelsView: SPView {
self.titleLabel.sizeToFit()
self.titleLabel.setWidth(self.frame.width)
self.titleLabel.frame.origin = CGPoint.zero
//self.titleLabel.backgroundColor = UIColor.lightGray
self.subtitleLabel.sizeToFit()
self.subtitleLabel.setWidth(self.frame.width)
self.subtitleLabel.frame.origin.x = 0
self.subtitleLabel.frame.origin.y = self.titleLabel.frame.bottomYPosition + 3
//self.subtitleLabel.backgroundColor = UIColor.darkGray
self.button.sizeToFit()
self.button.frame.bottomXPosition = self.frame.width
self.button.frame.bottomYPosition = self.titleLabel.frame.bottomYPosition
self.button.center.y = self.titleLabel.center.y
//self.button.backgroundColor = UIColor.darkGray
self.setHeight(self.subtitleLabel.frame.bottomYPosition)
}
@@ -25,10 +25,10 @@ public class SPGradientView: SPView {
var gradientLayer: CAGradientLayer = CAGradientLayer()
var startColor: UIColor = UIColor.white { didSet { self.updateGradient() }}
var endColor: UIColor = UIColor.black { didSet { self.updateGradient() }}
var startColorPosition: Position = Position.TopLeft { didSet { self.updateGradient() }}
var endColorPosition: Position = Position.BottomRight { didSet { self.updateGradient() }}
var startColor = UIColor.white { didSet { self.updateGradient() }}
var endColor = UIColor.black { didSet { self.updateGradient() }}
var startColorPosition = Position.topLeft { didSet { self.updateGradient() }}
var endColorPosition = Position.bottomRight { didSet { self.updateGradient() }}
override func commonInit() {
super.commonInit()
@@ -48,32 +48,33 @@ public class SPGradientView: SPView {
}
public enum Position {
case TopLeft
case TopCenter
case TopRight
case BottomLeft
case BottomCenter
case BottomRight
case MediumLeft
case MediumRight
case topLeft
case topCenter
case topRight
case bottomLeft
case bottomCenter
case bottomRight
case mediumLeft
case mediumRight
var point: CGPoint {
switch self {
case .TopLeft:
case .topLeft:
return CGPoint.init(x: 0, y: 0)
case .TopCenter:
case .topCenter:
return CGPoint.init(x: 0.5, y: 0)
case .TopRight:
case .topRight:
return CGPoint.init(x: 1, y: 0)
case .BottomLeft:
case .bottomLeft:
return CGPoint.init(x: 0, y: 1)
case .BottomCenter:
case .bottomCenter:
return CGPoint.init(x: 0.5, y: 1)
case .BottomRight:
case .bottomRight:
return CGPoint.init(x: 1, y: 1)
case .MediumLeft:
case .mediumLeft:
return CGPoint.init(x: 0, y: 0.5)
case .MediumRight:
case .mediumRight:
return CGPoint.init(x: 1, y: 0.5)
}
}
@@ -29,14 +29,14 @@ class SPSeparatorView: SPView {
override func commonInit() {
super.commonInit()
self.backgroundColor = UIColor.init(hex: "515B66").withAlphaComponent(0.4)
self.backgroundColor = UIColor.init(hex: "515B66").withAlphaComponent(0.25)
self.round = true
self.setHeight(self.height)
}
func layout(origin: CGPoint, width: CGFloat) {
self.frame.origin = origin
self.set(width: width, height: self.height)
self.frame.origin = CGPoint.init(x: floor(origin.x), y: floor(origin.y))
self.set(width: floor(width), height: self.height)
}
override func layoutSubviews() {
+6 -1
View File
@@ -6,7 +6,7 @@ Preview GIF is loading `3mb`. Please, wait.
<img src="https://github.com/IvanVorobei/SPStorkController/blob/master/Resources/Preview.gif" width="500">
You can download example [from AppStore](https://itunes.apple.com/app/id1446635818). If you want to buy source code of the app shown on the GIF above, please go to [xcode-shop.com](https://xcode-shop.com). Price: $200.
You can download example [from AppStore](https://itunes.apple.com/app/id1446635818). Also in the app you can donate me a cup of coffee. If you want to buy source code of the app shown on the GIF above, please go to [xcode-shop.com](https://xcode-shop.com). Price: $200.
<img src="https://github.com/IvanVorobei/SPStorkController/blob/master/Resources/Shop.svg"/>
@@ -101,6 +101,11 @@ transitionDelegate.isTapAroundToDismissEnabled = true
transitionDelegate.showIndicator = true
```
- Parameter `indicatorColor` for customize color of arrow. Default is `gray`:
```swift
transitionDelegate.indicatorColor = UIColor.white
```
- Parameter `customHeight` sets custom height for modal controller. Default is `nil`:
```swift
transitionDelegate.customHeight = 350
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "SPStorkController"
s.version = "1.2.1"
s.version = "1.2.2"
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 }
@@ -42,6 +42,13 @@ class SPStorkIndicatorView: UIView {
}
}
var color: UIColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1) {
didSet {
self.leftView.backgroundColor = self.color
self.rightView.backgroundColor = self.color
}
}
private var leftView: UIView = UIView()
private var rightView: UIView = UIView()
@@ -50,8 +57,7 @@ class SPStorkIndicatorView: UIView {
self.backgroundColor = UIColor.clear
self.addSubview(self.leftView)
self.addSubview(self.rightView)
self.leftView.backgroundColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
self.rightView.backgroundColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
self.color = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
}
required init?(coder aDecoder: NSCoder) {
@@ -26,6 +26,7 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
var isSwipeToDismissEnabled: Bool = true
var isTapAroundToDismissEnabled: Bool = true
var showIndicator: Bool = true
var indicatorColor: UIColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
var customHeight: CGFloat? = nil
var transitioningDelegate: SPStorkTransitioningDelegate?
@@ -82,6 +83,7 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
guard let containerView = self.containerView, let presentedView = self.presentedView, let window = containerView.window else { return }
if self.showIndicator {
self.indicatorView.color = self.indicatorColor
presentedView.addSubview(self.indicatorView)
}
self.updateLayoutIndicator()
@@ -268,6 +270,8 @@ extension SPStorkPresentationController {
self.workGester = true
self.indicatorView.style = .line
self.presentingViewController.view.layer.removeAllAnimations()
self.presentingViewController.view.endEditing(true)
self.presentedViewController.view.endEditing(true)
gestureRecognizer.setTranslation(CGPoint(x: 0, y: 0), in: containerView)
case .changed:
self.workGester = true
@@ -26,6 +26,7 @@ public final class SPStorkTransitioningDelegate: NSObject, UIViewControllerTrans
public var isSwipeToDismissEnabled: Bool = true
public var isTapAroundToDismissEnabled: Bool = true
public var showIndicator: Bool = true
public var indicatorColor: UIColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
public var customHeight: CGFloat? = nil
public func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
@@ -33,6 +34,7 @@ public final class SPStorkTransitioningDelegate: NSObject, UIViewControllerTrans
controller.isSwipeToDismissEnabled = self.isSwipeToDismissEnabled
controller.isTapAroundToDismissEnabled = self.isTapAroundToDismissEnabled
controller.showIndicator = self.showIndicator
controller.indicatorColor = self.indicatorColor
controller.customHeight = self.customHeight
controller.transitioningDelegate = self
return controller