Compare commits

..

19 Commits

Author SHA1 Message Date
Ivan Vorobei 0463bb7a8e Update to 1.7.8
Fix bug with indicator when device rotation. Add fix indicator style. Need set `indicatorMode` in transition delegate.
2019-08-17 16:23:45 +03:00
Ivan Vorobei 12f8e2bc0d Update Package.swift 2019-08-06 11:29:03 +03:00
Ivan Vorobei 578b3dbb41 Update Package.swift 2019-08-06 11:03:56 +03:00
Ivan Vorobei 223ec2d2c0 Update to 1.7.7
Fix memory leak when use UINavigationController
2019-08-05 23:19:16 +03:00
Ivan Vorobei a0ca7e9e2a Merge pull request #92 from Moriquendi/master
#88 Prevent controller leaking when embedded in UINavigationController
2019-08-05 23:12:42 +03:00
Michał Śmiałko f0a1914145 Check if controller's modalPresentationStyle is custom before accessing presentationController. 2019-08-05 14:33:44 +02:00
Ivan Vorobei 4355f5eb09 Update UserInterfaceState.xcuserstate 2019-07-22 20:34:29 +03:00
Ivan Vorobei 6b080f503d Update README.md 2019-07-22 11:20:40 +03:00
Ivan Vorobei c23ed83bf0 Update UserInterfaceState.xcuserstate 2019-07-22 11:20:00 +03:00
Ivan Vorobei 8b1c77d743 Update README.md 2019-07-18 17:30:44 +03:00
Ivan Vorobei 915ef85cff Update README.md 2019-07-18 17:26:46 +03:00
Ivan Vorobei dc1050be2a Update README.md 2019-07-18 13:04:34 +03:00
Ivan Vorobei 99ba8bf657 Update README.md 2019-07-18 13:03:33 +03:00
Ivan Vorobei 2b7e4198cf Update SPStorkController.podspec 2019-07-16 20:29:33 +03:00
Ivan Vorobei 0969cceac8 Update close method for UIAccessibility
Also update example project
2019-07-16 20:29:24 +03:00
Ivan Vorobei f349dea851 Merge pull request #81 from irskep/irskep-accessibility
Improve accessibility (fix #80)
2019-07-16 20:20:00 +03:00
Ivan Vorobei b8e8f8d0ce Update to 1.7.5
Fix completion for confirmation.
2019-07-11 19:21:29 +03:00
Steve Johnson 97c8e8aa32 Fix indentation 2019-07-04 14:12:16 -07:00
Steve Johnson 7be93d548e Improve accessibility 2019-07-04 14:11:08 -07:00
22 changed files with 352 additions and 171 deletions
+1
View File
@@ -33,6 +33,7 @@ playground.xcworkspace
# Swift Package Manager
.build/
.swiftpm/
# Carthage
Carthage/Build
@@ -14,6 +14,7 @@
F445CA9121AED92700184254 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F445CA8F21AED92700184254 /* LaunchScreen.storyboard */; };
F459D75B21C3AB9A00798524 /* ModalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F459D75A21C3AB9A00798524 /* ModalViewController.swift */; };
F459D75D21C3ABBD00798524 /* ModalTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F459D75C21C3ABBD00798524 /* ModalTableViewController.swift */; };
F4803BF523082FDA0092C9BC /* SPStorkArrowMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4803BF423082FDA0092C9BC /* SPStorkArrowMode.swift */; };
F4DB849622609C05005082AA /* SPVibration.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4DB83F522609C03005082AA /* SPVibration.swift */; };
F4DB849722609C05005082AA /* SPPromoTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4DB83F922609C03005082AA /* SPPromoTableViewCell.swift */; };
F4DB849822609C05005082AA /* SPFormButtonTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4DB83FB22609C03005082AA /* SPFormButtonTableViewCell.swift */; };
@@ -161,6 +162,7 @@
F445CA9221AED92700184254 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
F459D75A21C3AB9A00798524 /* ModalViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalViewController.swift; sourceTree = "<group>"; };
F459D75C21C3ABBD00798524 /* ModalTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalTableViewController.swift; sourceTree = "<group>"; };
F4803BF423082FDA0092C9BC /* SPStorkArrowMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SPStorkArrowMode.swift; sourceTree = "<group>"; };
F4DB83F522609C03005082AA /* SPVibration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPVibration.swift; sourceTree = "<group>"; };
F4DB83F922609C03005082AA /* SPPromoTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPPromoTableViewCell.swift; sourceTree = "<group>"; };
F4DB83FB22609C03005082AA /* SPFormButtonTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPFormButtonTableViewCell.swift; sourceTree = "<group>"; };
@@ -833,6 +835,7 @@
isa = PBXGroup;
children = (
F4E0E37E22CF6B940020D754 /* SPStorkHaptic.swift */,
F4803BF423082FDA0092C9BC /* SPStorkArrowMode.swift */,
);
path = Models;
sourceTree = "<group>";
@@ -988,6 +991,7 @@
F4DB84A622609C05005082AA /* SPSocialButton.swift in Sources */,
F4DB84E022609C05005082AA /* SPUICollectionViewExtenshion.swift in Sources */,
F4E0E39222CF6B940020D754 /* SPStorkCodeDraw.swift in Sources */,
F4803BF523082FDA0092C9BC /* SPStorkArrowMode.swift in Sources */,
F4DB84E222609C05005082AA /* SPUITabBarControllerExtenshion.swift in Sources */,
F4DB84A122609C05005082AA /* SPProposeTableViewCell.swift in Sources */,
F4E0E39922CF6B940020D754 /* SPStorkCloseButton.swift in Sources */,
@@ -0,0 +1,29 @@
// The MIT License (MIT)
// Copyright © 2017 Ivan Vorobei (hello@ivanvorobei.by)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
import UIKit
public enum SPStorkArrowMode {
case auto
case alwaysArrow
case alwaysLine
}
@@ -23,7 +23,7 @@ import UIKit
public enum SPStorkController {
static public func scrollViewDidScroll(_ scrollView: UIScrollView, indicatorInset: CGFloat? = nil) {
static public func scrollViewDidScroll(_ scrollView: UIScrollView) {
if let controller = self.controller(for: scrollView) {
if let presentationController = self.presentationController(for: controller) {
let translation = -(scrollView.contentOffset.y + scrollView.contentInset.top)
@@ -61,7 +61,7 @@ public enum SPStorkController {
static public func dismissWithConfirmation(controller: UIViewController, completion: (()->())?) {
if let controller = self.presentationController(for: controller) {
controller.dismissWithConfirmation(prepare: nil, completion: {
print("Custom completion for confirmation. Confirmation is optional.")
completion?()
})
}
}
@@ -83,6 +83,8 @@ public enum SPStorkController {
}
static private func presentationController(for controller: UIViewController) -> SPStorkPresentationController? {
guard controller.modalPresentationStyle == .custom else { return nil }
if let presentationController = controller.presentationController as? SPStorkPresentationController {
return presentationController
}
@@ -90,7 +92,6 @@ public enum SPStorkController {
if let presentationController = controller.parent?.presentationController as? SPStorkPresentationController {
return presentationController
}
return nil
}
@@ -29,6 +29,7 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
var showIndicator: Bool = true
var indicatorColor: UIColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
var hideIndicatorWhenScroll: Bool = false
var indicatorMode: SPStorkArrowMode = .auto
var customHeight: CGFloat? = nil
var translateForDismiss: CGFloat = 200
var hapticMoments: [SPStorkHapticMoments] = [.willDismissIfRelease]
@@ -105,22 +106,41 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
guard let containerView = self.containerView, let presentedView = self.presentedView, let window = containerView.window else { return }
let closeTitle = NSLocalizedString("Close", comment: "Close")
if self.showIndicator {
self.indicatorView.color = self.indicatorColor
let tap = UITapGestureRecognizer.init(target: self, action: #selector(self.tapIndicator))
tap.cancelsTouchesInView = false
self.indicatorView.addGestureRecognizer(tap)
self.indicatorView.accessibilityLabel = closeTitle
presentedView.addSubview(self.indicatorView)
self.indicatorView.translatesAutoresizingMaskIntoConstraints = false
self.indicatorView.widthAnchor.constraint(equalToConstant: 36).isActive = true
self.indicatorView.heightAnchor.constraint(equalToConstant: 13).isActive = true
self.indicatorView.centerXAnchor.constraint(equalTo: presentedView.centerXAnchor).isActive = true
self.indicatorView.topAnchor.constraint(equalTo: presentedView.topAnchor, constant: 12).isActive = true
self.indicatorView.mode = self.indicatorMode
if UIAccessibility.isVoiceOverRunning {
let accessibleIndicatorOverlayButton = UIButton(type: .custom)
accessibleIndicatorOverlayButton.addTarget(self, action: #selector(self.tapIndicator), for: .touchUpInside)
accessibleIndicatorOverlayButton.accessibilityLabel = closeTitle
presentedView.addSubview(accessibleIndicatorOverlayButton)
accessibleIndicatorOverlayButton.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
accessibleIndicatorOverlayButton.leadingAnchor.constraint(equalTo: presentedView.leadingAnchor),
accessibleIndicatorOverlayButton.trailingAnchor.constraint(equalTo: presentedView.trailingAnchor),
accessibleIndicatorOverlayButton.topAnchor.constraint(equalTo: presentedView.topAnchor),
accessibleIndicatorOverlayButton.bottomAnchor.constraint(equalTo: self.indicatorView.bottomAnchor),
])
}
}
self.updateLayoutIndicator()
self.indicatorView.style = .arrow
self.gradeView.alpha = 0
self.closeButton.accessibilityLabel = closeTitle
if self.showCloseButton {
self.closeButton.addTarget(self, action: #selector(self.tapCloseButton), for: .touchUpInside)
presentedView.addSubview(self.closeButton)
@@ -511,6 +531,7 @@ extension SPStorkPresentationController {
private func updateLayoutIndicator() {
self.indicatorView.style = .line
self.indicatorView.sizeToFit()
self.indicatorView.style = .arrow
}
private func updateLayoutCloseButton() {
@@ -29,6 +29,7 @@ public final class SPStorkTransitioningDelegate: NSObject, UIViewControllerTrans
public var showIndicator: Bool = true
public var indicatorColor: UIColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
public var hideIndicatorWhenScroll: Bool = false
public var indicatorMode: SPStorkArrowMode = .auto
public var customHeight: CGFloat? = nil
public var translateForDismiss: CGFloat = 200
public var cornerRadius: CGFloat = 10
@@ -44,6 +45,7 @@ public final class SPStorkTransitioningDelegate: NSObject, UIViewControllerTrans
controller.showIndicator = self.showIndicator
controller.indicatorColor = self.indicatorColor
controller.hideIndicatorWhenScroll = self.hideIndicatorWhenScroll
controller.indicatorMode = self.indicatorMode
controller.customHeight = self.customHeight
controller.translateForDismiss = self.translateForDismiss
controller.cornerRadius = self.cornerRadius
@@ -25,23 +25,41 @@ open class SPStorkIndicatorView: UIView {
var style: Style = .line {
didSet {
switch self.style {
case .line:
self.animate {
self.leftView.transform = .identity
self.rightView.transform = .identity
}
case .arrow:
self.animate {
let angle = CGFloat(20 * Float.pi / 180)
self.leftView.transform = CGAffineTransform.init(rotationAngle: angle)
self.rightView.transform = CGAffineTransform.init(rotationAngle: -angle)
if self.mode == .auto {
switch self.style {
case .line:
self.animate {
self.leftView.transform = .identity
self.rightView.transform = .identity
}
case .arrow:
self.animate {
let angle = CGFloat(20 * Float.pi / 180)
self.leftView.transform = CGAffineTransform.init(rotationAngle: angle)
self.rightView.transform = CGAffineTransform.init(rotationAngle: -angle)
}
}
}
if self.mode == .alwaysArrow {
self.leftView.removeAllAnimations()
self.rightView.removeAllAnimations()
self.leftView.transform = .identity
self.rightView.transform = .identity
let angle = CGFloat(20 * Float.pi / 180)
self.leftView.transform = CGAffineTransform.init(rotationAngle: angle)
self.rightView.transform = CGAffineTransform.init(rotationAngle: -angle)
}
if self.mode == .alwaysLine {
self.leftView.transform = .identity
self.rightView.transform = .identity
}
}
}
var mode: SPStorkArrowMode = .auto
var color: UIColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1) {
didSet {
self.leftView.backgroundColor = self.color
@@ -66,6 +84,10 @@ open class SPStorkIndicatorView: UIView {
override open func sizeToFit() {
super.sizeToFit()
self.leftView.transform = .identity
self.rightView.transform = .identity
self.frame = CGRect.init(x: self.frame.origin.x, y: self.frame.origin.y, width: 36, height: 13)
let height: CGFloat = 5
@@ -21,6 +21,21 @@
import UIKit
extension UIView {
var isDarkMode: Bool {
if #available(iOS 12.0, *) {
if self.traitCollection.userInterfaceStyle == .dark {
return true
} else {
return false
}
} else {
return false
}
}
}
extension UIView {
var viewController: UIViewController? {
@@ -63,7 +63,7 @@ struct SPLocalNotification {
if let category = self.category {
if #available(iOS 12.0, *) {
let notificationCategory = UNNotificationCategory(identifier: category.identifier, actions: [], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: nil, categorySummaryFormat: category.summary, options: [])
let notificationCategory = UNNotificationCategory(identifier: category.identifier, actions: category.actions, intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: nil, categorySummaryFormat: category.summary, options: [])
UNUserNotificationCenter.current().setNotificationCategories([notificationCategory])
content.categoryIdentifier = notificationCategory.identifier
}
@@ -81,6 +81,7 @@ struct SPLocalNotificationCategory {
var identifier: String
var summary: String
var actions: [UNNotificationAction] = []
static var countSymbol: String {
return "%u"
@@ -24,8 +24,9 @@ import UIKit
class SPFooterActionsView: SPView {
var sectionLabels = SPSectionLabelsView()
private var buttons: [SPFooterActionButton] = []
private var separators: [SPSeparatorView] = []
var buttons: [SPFooterActionButton] = []
var separators: [SPSeparatorView] = []
override func commonInit() {
super.commonInit()
+2
View File
@@ -31,6 +31,8 @@
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
@@ -35,7 +35,7 @@ class ModalViewController: UIViewController {
extension ModalViewController: SPStorkControllerConfirmDelegate {
var needConfirm: Bool {
return true
return false
}
func confirm(_ completion: @escaping (Bool) -> ()) {
+5 -10
View File
@@ -1,21 +1,16 @@
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "SPStorkController",
platforms: [.iOS(.v10)],
platforms: [
.iOS(.v10)
],
products: [
.library(
name: "SPStorkController",
targets: ["SPStorkController"]),
.library(name: "SPStorkController", targets: ["SPStorkController"])
],
targets: [
.target(
name: "SPStorkController",
dependencies: [],
path: "Source/SPStorkController"
)
.target(name: "SPStorkController", dependencies: [], path: "Source/SPStorkController")
]
)
+22 -14
View File
@@ -17,20 +17,24 @@ If you like the project, do not forget to `put star ★` and follow me on GitHub
- [Requirements](#requirements)
- [Installation](#installation)
- [CocoaPods](#cocoapods)
- [Carthage](#carthage)
- [Swift Package Manager](#swift-package-manager)
- [Manually](#manually)
- [Quick Start](#quick-start)
- [Usage](#usage)
- [Light StatusBar](#light-statusbar)
- [Custom Height](#custom-height)
- [Close Button](#close-button)
- [Indicator](#indicator)
- [Arrow Indicator](#arrow-indicator)
- [Dismissing](#dismissing)
- [Corner Radius](#corner-radius)
- [Haptic](#haptic)
- [Snapshots](#snapshots)
- [Add Navigation Bar](#add-navigation-bar)
- [Navigation Bar](#navigation-bar)
- [Working with UIScrollView](#working-with-uiscrollview)
- [UITableView & UICollectionView](#working-with-uitableview--uicollectionview)
- [Confirm](#confirm)
- [Confirm before dismiss](#confirm-before-dismiss)
- [Delegate](#delegate)
- [Storyboard](#storyboard)
- [Sheets in iOS 13](#sheets-in-ios-13)
@@ -148,7 +152,7 @@ Property `showCloseButton` added circle button with dismiss action. Default is `
transitionDelegate.showCloseButton = false
```
### Indicator
### Arrow Indicator
On the top of controller you can add arrow indicator with animatable states. It simple configure.
Property `showIndicator` shows or hides top arrow indicator. Default is `true`:
@@ -169,6 +173,12 @@ Property `hideIndicatorWhenScroll` shows or hides indicator when scrolling. Defa
transitionDelegate.hideIndicatorWhenScroll = true
```
You can set always line or arrow indicator. Set `indicatorMode`:
```swift
transitionDelegate.indicatorMode = .alwaysLine
```
### Dismissing
You can also configure events that will dimiss the controller.
@@ -216,7 +226,13 @@ SPStorkController.updatePresentingController(modal: controller)
and pass the controller, which is modal and uses `SPStorkTransitioningDelegate`.
### Add Navigation Bar
If the parent controller scrollings and you try to show `SPStorkController`, you will see how it froze, and in a second its final position is updated. I recommend before present `SPStorkController` stop scrolling force:
```swift
scrollView.setContentOffset(self.contentOffset, animated: false)
```
### Navigation Bar
You may want to add a navigation bar to your modal controller. Since it became impossible to change or customize the native controller in swift 4 (I couldnt even find a way to change the height of the bar), I had to recreate navigation bar from the ground up. Visually it looks real, but it doesnt execute the necessary functions:
@@ -275,7 +291,7 @@ tableView.scrollIndicatorInsets.top = self.navBar.height
Please, also use `SPStorkController.scrollViewDidScroll` function in scroll delegate for more interactiveness with your collection or table view.
### Confirm
### Confirm before dismiss
For confirm closing by swipe, tap around, close button and indicator use `SPStorkControllerConfirmDelegate`. Implenet protocol:
@@ -349,14 +365,6 @@ controller.modalPresentationStyle = .custom
Its needed for correct presentation and dismissal of all modal controllers.
### Stop scroll
`SPStorkController` use snapshots. If the parent controller scrollings and you try to show `SPStorkController`, you will see how it froze, and in a second its final position is updated. I recommend to stop scrolling force:
```swift
scrollView.setContentOffset(self.contentOffset, animated: false)
```
## Sheets in iOS 13
Apple present in `WWDC 2019` new modal presentation style - `Sheets`. It ready use Support interactive dismiss and work with navigations bars. Available since iOS 13. I will add more information when I study this in more detail. You can see presentation [here](https://developer.apple.com/videos/play/wwdc2019/224/).
+1 -1
View File
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "SPStorkController"
s.version = "1.7.4"
s.version = "1.7.8"
s.summary = "Very similar to the controllers displayed in Apple Music, Podcasts and Mail Apple's applications."
s.homepage = "https://github.com/IvanVorobei/SPStorkController"
s.source = { :git => "https://github.com/IvanVorobei/SPStorkController.git", :tag => s.version }
+116 -112
View File
@@ -7,38 +7,40 @@
objects = {
/* Begin PBXBuildFile section */
F437B76722D62FF000E6074C /* SPStorkHaptic.swift in Sources */ = {isa = PBXBuildFile; fileRef = F437B75422D62FF000E6074C /* SPStorkHaptic.swift */; };
F437B76822D62FF000E6074C /* SPStorkSeque.swift in Sources */ = {isa = PBXBuildFile; fileRef = F437B75522D62FF000E6074C /* SPStorkSeque.swift */; };
F437B76922D62FF000E6074C /* SPStorkCodeDraw.swift in Sources */ = {isa = PBXBuildFile; fileRef = F437B75722D62FF000E6074C /* SPStorkCodeDraw.swift */; };
F437B76A22D62FF000E6074C /* SPStorkController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F437B75822D62FF000E6074C /* SPStorkController.swift */; };
F437B76B22D62FF000E6074C /* SPStorkTransitioningDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F437B75A22D62FF000E6074C /* SPStorkTransitioningDelegate.swift */; };
F437B76C22D62FF000E6074C /* SPStorkPresentingAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F437B75B22D62FF000E6074C /* SPStorkPresentingAnimationController.swift */; };
F437B76D22D62FF000E6074C /* SPStorkPresentationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F437B75C22D62FF000E6074C /* SPStorkPresentationController.swift */; };
F437B76E22D62FF000E6074C /* SPStorkDismissingAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F437B75D22D62FF000E6074C /* SPStorkDismissingAnimationController.swift */; };
F437B76F22D62FF000E6074C /* SPStorkViewControllerExtenshion.swift in Sources */ = {isa = PBXBuildFile; fileRef = F437B75F22D62FF000E6074C /* SPStorkViewControllerExtenshion.swift */; };
F437B77022D62FF000E6074C /* SPStorkCloseButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = F437B76122D62FF000E6074C /* SPStorkCloseButton.swift */; };
F437B77122D62FF000E6074C /* SPStorkIndicatorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F437B76222D62FF000E6074C /* SPStorkIndicatorView.swift */; };
F437B77222D62FF000E6074C /* SPStorkCloseView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F437B76322D62FF000E6074C /* SPStorkCloseView.swift */; };
F437B77322D62FF000E6074C /* SPStorkControllerConfirmDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F437B76522D62FF000E6074C /* SPStorkControllerConfirmDelegate.swift */; };
F437B77422D62FF000E6074C /* SPStorkControllerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F437B76622D62FF000E6074C /* SPStorkControllerDelegate.swift */; };
F4803C0C230836F40092C9BC /* SPStorkHaptic.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4803BF8230836F40092C9BC /* SPStorkHaptic.swift */; };
F4803C0D230836F50092C9BC /* SPStorkArrowMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4803BF9230836F40092C9BC /* SPStorkArrowMode.swift */; };
F4803C0E230836F50092C9BC /* SPStorkSeque.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4803BFA230836F40092C9BC /* SPStorkSeque.swift */; };
F4803C0F230836F50092C9BC /* SPStorkCodeDraw.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4803BFC230836F40092C9BC /* SPStorkCodeDraw.swift */; };
F4803C10230836F50092C9BC /* SPStorkController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4803BFD230836F40092C9BC /* SPStorkController.swift */; };
F4803C11230836F50092C9BC /* SPStorkTransitioningDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4803BFF230836F40092C9BC /* SPStorkTransitioningDelegate.swift */; };
F4803C12230836F50092C9BC /* SPStorkPresentingAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4803C00230836F40092C9BC /* SPStorkPresentingAnimationController.swift */; };
F4803C13230836F50092C9BC /* SPStorkPresentationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4803C01230836F40092C9BC /* SPStorkPresentationController.swift */; };
F4803C14230836F50092C9BC /* SPStorkDismissingAnimationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4803C02230836F40092C9BC /* SPStorkDismissingAnimationController.swift */; };
F4803C15230836F50092C9BC /* SPStorkViewControllerExtenshion.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4803C04230836F40092C9BC /* SPStorkViewControllerExtenshion.swift */; };
F4803C16230836F50092C9BC /* SPStorkCloseButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4803C06230836F40092C9BC /* SPStorkCloseButton.swift */; };
F4803C17230836F50092C9BC /* SPStorkIndicatorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4803C07230836F40092C9BC /* SPStorkIndicatorView.swift */; };
F4803C18230836F50092C9BC /* SPStorkCloseView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4803C08230836F40092C9BC /* SPStorkCloseView.swift */; };
F4803C19230836F50092C9BC /* SPStorkControllerConfirmDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4803C0A230836F40092C9BC /* SPStorkControllerConfirmDelegate.swift */; };
F4803C1A230836F50092C9BC /* SPStorkControllerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4803C0B230836F40092C9BC /* SPStorkControllerDelegate.swift */; };
F4DB85222260A4FD005082AA /* SPStorkController.h in Headers */ = {isa = PBXBuildFile; fileRef = F4DB85202260A4FD005082AA /* SPStorkController.h */; settings = {ATTRIBUTES = (Public, ); }; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
F437B75422D62FF000E6074C /* SPStorkHaptic.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkHaptic.swift; sourceTree = "<group>"; };
F437B75522D62FF000E6074C /* SPStorkSeque.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkSeque.swift; sourceTree = "<group>"; };
F437B75722D62FF000E6074C /* SPStorkCodeDraw.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkCodeDraw.swift; sourceTree = "<group>"; };
F437B75822D62FF000E6074C /* SPStorkController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkController.swift; sourceTree = "<group>"; };
F437B75A22D62FF000E6074C /* SPStorkTransitioningDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkTransitioningDelegate.swift; sourceTree = "<group>"; };
F437B75B22D62FF000E6074C /* SPStorkPresentingAnimationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkPresentingAnimationController.swift; sourceTree = "<group>"; };
F437B75C22D62FF000E6074C /* SPStorkPresentationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkPresentationController.swift; sourceTree = "<group>"; };
F437B75D22D62FF000E6074C /* SPStorkDismissingAnimationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkDismissingAnimationController.swift; sourceTree = "<group>"; };
F437B75F22D62FF000E6074C /* SPStorkViewControllerExtenshion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkViewControllerExtenshion.swift; sourceTree = "<group>"; };
F437B76122D62FF000E6074C /* SPStorkCloseButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkCloseButton.swift; sourceTree = "<group>"; };
F437B76222D62FF000E6074C /* SPStorkIndicatorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkIndicatorView.swift; sourceTree = "<group>"; };
F437B76322D62FF000E6074C /* SPStorkCloseView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkCloseView.swift; sourceTree = "<group>"; };
F437B76522D62FF000E6074C /* SPStorkControllerConfirmDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkControllerConfirmDelegate.swift; sourceTree = "<group>"; };
F437B76622D62FF000E6074C /* SPStorkControllerDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkControllerDelegate.swift; sourceTree = "<group>"; };
F4803BF8230836F40092C9BC /* SPStorkHaptic.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkHaptic.swift; sourceTree = "<group>"; };
F4803BF9230836F40092C9BC /* SPStorkArrowMode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkArrowMode.swift; sourceTree = "<group>"; };
F4803BFA230836F40092C9BC /* SPStorkSeque.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkSeque.swift; sourceTree = "<group>"; };
F4803BFC230836F40092C9BC /* SPStorkCodeDraw.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkCodeDraw.swift; sourceTree = "<group>"; };
F4803BFD230836F40092C9BC /* SPStorkController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkController.swift; sourceTree = "<group>"; };
F4803BFF230836F40092C9BC /* SPStorkTransitioningDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkTransitioningDelegate.swift; sourceTree = "<group>"; };
F4803C00230836F40092C9BC /* SPStorkPresentingAnimationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkPresentingAnimationController.swift; sourceTree = "<group>"; };
F4803C01230836F40092C9BC /* SPStorkPresentationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkPresentationController.swift; sourceTree = "<group>"; };
F4803C02230836F40092C9BC /* SPStorkDismissingAnimationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkDismissingAnimationController.swift; sourceTree = "<group>"; };
F4803C04230836F40092C9BC /* SPStorkViewControllerExtenshion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkViewControllerExtenshion.swift; sourceTree = "<group>"; };
F4803C06230836F40092C9BC /* SPStorkCloseButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkCloseButton.swift; sourceTree = "<group>"; };
F4803C07230836F40092C9BC /* SPStorkIndicatorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkIndicatorView.swift; sourceTree = "<group>"; };
F4803C08230836F40092C9BC /* SPStorkCloseView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkCloseView.swift; sourceTree = "<group>"; };
F4803C0A230836F40092C9BC /* SPStorkControllerConfirmDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkControllerConfirmDelegate.swift; sourceTree = "<group>"; };
F4803C0B230836F40092C9BC /* SPStorkControllerDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPStorkControllerDelegate.swift; sourceTree = "<group>"; };
F4DB851D2260A4FD005082AA /* SPStorkController.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SPStorkController.framework; sourceTree = BUILT_PRODUCTS_DIR; };
F4DB85202260A4FD005082AA /* SPStorkController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SPStorkController.h; sourceTree = "<group>"; };
F4DB85212260A4FD005082AA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -55,75 +57,6 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
F437B75222D62FF000E6074C /* SPStorkController */ = {
isa = PBXGroup;
children = (
F437B75322D62FF000E6074C /* Models */,
F437B75522D62FF000E6074C /* SPStorkSeque.swift */,
F437B75622D62FF000E6074C /* CodeDraw */,
F437B75822D62FF000E6074C /* SPStorkController.swift */,
F437B75922D62FF000E6074C /* TransitioningDelegate */,
F437B75E22D62FF000E6074C /* Extenshion */,
F437B76022D62FF000E6074C /* Views */,
F437B76422D62FF000E6074C /* Protocols */,
);
path = SPStorkController;
sourceTree = "<group>";
};
F437B75322D62FF000E6074C /* Models */ = {
isa = PBXGroup;
children = (
F437B75422D62FF000E6074C /* SPStorkHaptic.swift */,
);
path = Models;
sourceTree = "<group>";
};
F437B75622D62FF000E6074C /* CodeDraw */ = {
isa = PBXGroup;
children = (
F437B75722D62FF000E6074C /* SPStorkCodeDraw.swift */,
);
path = CodeDraw;
sourceTree = "<group>";
};
F437B75922D62FF000E6074C /* TransitioningDelegate */ = {
isa = PBXGroup;
children = (
F437B75A22D62FF000E6074C /* SPStorkTransitioningDelegate.swift */,
F437B75B22D62FF000E6074C /* SPStorkPresentingAnimationController.swift */,
F437B75C22D62FF000E6074C /* SPStorkPresentationController.swift */,
F437B75D22D62FF000E6074C /* SPStorkDismissingAnimationController.swift */,
);
path = TransitioningDelegate;
sourceTree = "<group>";
};
F437B75E22D62FF000E6074C /* Extenshion */ = {
isa = PBXGroup;
children = (
F437B75F22D62FF000E6074C /* SPStorkViewControllerExtenshion.swift */,
);
path = Extenshion;
sourceTree = "<group>";
};
F437B76022D62FF000E6074C /* Views */ = {
isa = PBXGroup;
children = (
F437B76122D62FF000E6074C /* SPStorkCloseButton.swift */,
F437B76222D62FF000E6074C /* SPStorkIndicatorView.swift */,
F437B76322D62FF000E6074C /* SPStorkCloseView.swift */,
);
path = Views;
sourceTree = "<group>";
};
F437B76422D62FF000E6074C /* Protocols */ = {
isa = PBXGroup;
children = (
F437B76522D62FF000E6074C /* SPStorkControllerConfirmDelegate.swift */,
F437B76622D62FF000E6074C /* SPStorkControllerDelegate.swift */,
);
path = Protocols;
sourceTree = "<group>";
};
F4437E4F22B50918006E6498 /* Supporting Files */ = {
isa = PBXGroup;
children = (
@@ -133,6 +66,76 @@
path = "Supporting Files";
sourceTree = "<group>";
};
F4803BF6230836F40092C9BC /* SPStorkController */ = {
isa = PBXGroup;
children = (
F4803BF7230836F40092C9BC /* Models */,
F4803BFA230836F40092C9BC /* SPStorkSeque.swift */,
F4803BFB230836F40092C9BC /* CodeDraw */,
F4803BFD230836F40092C9BC /* SPStorkController.swift */,
F4803BFE230836F40092C9BC /* TransitioningDelegate */,
F4803C03230836F40092C9BC /* Extenshion */,
F4803C05230836F40092C9BC /* Views */,
F4803C09230836F40092C9BC /* Protocols */,
);
path = SPStorkController;
sourceTree = "<group>";
};
F4803BF7230836F40092C9BC /* Models */ = {
isa = PBXGroup;
children = (
F4803BF8230836F40092C9BC /* SPStorkHaptic.swift */,
F4803BF9230836F40092C9BC /* SPStorkArrowMode.swift */,
);
path = Models;
sourceTree = "<group>";
};
F4803BFB230836F40092C9BC /* CodeDraw */ = {
isa = PBXGroup;
children = (
F4803BFC230836F40092C9BC /* SPStorkCodeDraw.swift */,
);
path = CodeDraw;
sourceTree = "<group>";
};
F4803BFE230836F40092C9BC /* TransitioningDelegate */ = {
isa = PBXGroup;
children = (
F4803BFF230836F40092C9BC /* SPStorkTransitioningDelegate.swift */,
F4803C00230836F40092C9BC /* SPStorkPresentingAnimationController.swift */,
F4803C01230836F40092C9BC /* SPStorkPresentationController.swift */,
F4803C02230836F40092C9BC /* SPStorkDismissingAnimationController.swift */,
);
path = TransitioningDelegate;
sourceTree = "<group>";
};
F4803C03230836F40092C9BC /* Extenshion */ = {
isa = PBXGroup;
children = (
F4803C04230836F40092C9BC /* SPStorkViewControllerExtenshion.swift */,
);
path = Extenshion;
sourceTree = "<group>";
};
F4803C05230836F40092C9BC /* Views */ = {
isa = PBXGroup;
children = (
F4803C06230836F40092C9BC /* SPStorkCloseButton.swift */,
F4803C07230836F40092C9BC /* SPStorkIndicatorView.swift */,
F4803C08230836F40092C9BC /* SPStorkCloseView.swift */,
);
path = Views;
sourceTree = "<group>";
};
F4803C09230836F40092C9BC /* Protocols */ = {
isa = PBXGroup;
children = (
F4803C0A230836F40092C9BC /* SPStorkControllerConfirmDelegate.swift */,
F4803C0B230836F40092C9BC /* SPStorkControllerDelegate.swift */,
);
path = Protocols;
sourceTree = "<group>";
};
F4DB85132260A4FD005082AA = {
isa = PBXGroup;
children = (
@@ -152,7 +155,7 @@
F4DB851F2260A4FD005082AA /* Source */ = {
isa = PBXGroup;
children = (
F437B75222D62FF000E6074C /* SPStorkController */,
F4803BF6230836F40092C9BC /* SPStorkController */,
F4437E4F22B50918006E6498 /* Supporting Files */,
);
path = Source;
@@ -236,20 +239,21 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F437B76A22D62FF000E6074C /* SPStorkController.swift in Sources */,
F437B76E22D62FF000E6074C /* SPStorkDismissingAnimationController.swift in Sources */,
F437B76D22D62FF000E6074C /* SPStorkPresentationController.swift in Sources */,
F437B76F22D62FF000E6074C /* SPStorkViewControllerExtenshion.swift in Sources */,
F437B76822D62FF000E6074C /* SPStorkSeque.swift in Sources */,
F437B77422D62FF000E6074C /* SPStorkControllerDelegate.swift in Sources */,
F437B77322D62FF000E6074C /* SPStorkControllerConfirmDelegate.swift in Sources */,
F437B77022D62FF000E6074C /* SPStorkCloseButton.swift in Sources */,
F437B76C22D62FF000E6074C /* SPStorkPresentingAnimationController.swift in Sources */,
F437B77122D62FF000E6074C /* SPStorkIndicatorView.swift in Sources */,
F437B77222D62FF000E6074C /* SPStorkCloseView.swift in Sources */,
F437B76922D62FF000E6074C /* SPStorkCodeDraw.swift in Sources */,
F437B76722D62FF000E6074C /* SPStorkHaptic.swift in Sources */,
F437B76B22D62FF000E6074C /* SPStorkTransitioningDelegate.swift in Sources */,
F4803C10230836F50092C9BC /* SPStorkController.swift in Sources */,
F4803C11230836F50092C9BC /* SPStorkTransitioningDelegate.swift in Sources */,
F4803C19230836F50092C9BC /* SPStorkControllerConfirmDelegate.swift in Sources */,
F4803C1A230836F50092C9BC /* SPStorkControllerDelegate.swift in Sources */,
F4803C15230836F50092C9BC /* SPStorkViewControllerExtenshion.swift in Sources */,
F4803C17230836F50092C9BC /* SPStorkIndicatorView.swift in Sources */,
F4803C0C230836F40092C9BC /* SPStorkHaptic.swift in Sources */,
F4803C12230836F50092C9BC /* SPStorkPresentingAnimationController.swift in Sources */,
F4803C18230836F50092C9BC /* SPStorkCloseView.swift in Sources */,
F4803C13230836F50092C9BC /* SPStorkPresentationController.swift in Sources */,
F4803C0E230836F50092C9BC /* SPStorkSeque.swift in Sources */,
F4803C14230836F50092C9BC /* SPStorkDismissingAnimationController.swift in Sources */,
F4803C0D230836F50092C9BC /* SPStorkArrowMode.swift in Sources */,
F4803C0F230836F50092C9BC /* SPStorkCodeDraw.swift in Sources */,
F4803C16230836F50092C9BC /* SPStorkCloseButton.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -0,0 +1,29 @@
// The MIT License (MIT)
// Copyright © 2017 Ivan Vorobei (hello@ivanvorobei.by)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
import UIKit
public enum SPStorkArrowMode {
case auto
case alwaysArrow
case alwaysLine
}
@@ -23,7 +23,7 @@ import UIKit
public enum SPStorkController {
static public func scrollViewDidScroll(_ scrollView: UIScrollView, indicatorInset: CGFloat? = nil) {
static public func scrollViewDidScroll(_ scrollView: UIScrollView) {
if let controller = self.controller(for: scrollView) {
if let presentationController = self.presentationController(for: controller) {
let translation = -(scrollView.contentOffset.y + scrollView.contentInset.top)
@@ -61,7 +61,7 @@ public enum SPStorkController {
static public func dismissWithConfirmation(controller: UIViewController, completion: (()->())?) {
if let controller = self.presentationController(for: controller) {
controller.dismissWithConfirmation(prepare: nil, completion: {
print("Custom completion for confirmation. Confirmation is optional.")
completion?()
})
}
}
@@ -83,6 +83,8 @@ public enum SPStorkController {
}
static private func presentationController(for controller: UIViewController) -> SPStorkPresentationController? {
guard controller.modalPresentationStyle == .custom else { return nil }
if let presentationController = controller.presentationController as? SPStorkPresentationController {
return presentationController
}
@@ -90,7 +92,6 @@ public enum SPStorkController {
if let presentationController = controller.parent?.presentationController as? SPStorkPresentationController {
return presentationController
}
return nil
}
@@ -29,6 +29,7 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
var showIndicator: Bool = true
var indicatorColor: UIColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
var hideIndicatorWhenScroll: Bool = false
var indicatorMode: SPStorkArrowMode = .auto
var customHeight: CGFloat? = nil
var translateForDismiss: CGFloat = 200
var hapticMoments: [SPStorkHapticMoments] = [.willDismissIfRelease]
@@ -105,22 +106,41 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
guard let containerView = self.containerView, let presentedView = self.presentedView, let window = containerView.window else { return }
let closeTitle = NSLocalizedString("Close", comment: "Close")
if self.showIndicator {
self.indicatorView.color = self.indicatorColor
let tap = UITapGestureRecognizer.init(target: self, action: #selector(self.tapIndicator))
tap.cancelsTouchesInView = false
self.indicatorView.addGestureRecognizer(tap)
self.indicatorView.accessibilityLabel = closeTitle
presentedView.addSubview(self.indicatorView)
self.indicatorView.translatesAutoresizingMaskIntoConstraints = false
self.indicatorView.widthAnchor.constraint(equalToConstant: 36).isActive = true
self.indicatorView.heightAnchor.constraint(equalToConstant: 13).isActive = true
self.indicatorView.centerXAnchor.constraint(equalTo: presentedView.centerXAnchor).isActive = true
self.indicatorView.topAnchor.constraint(equalTo: presentedView.topAnchor, constant: 12).isActive = true
self.indicatorView.mode = self.indicatorMode
if UIAccessibility.isVoiceOverRunning {
let accessibleIndicatorOverlayButton = UIButton(type: .custom)
accessibleIndicatorOverlayButton.addTarget(self, action: #selector(self.tapIndicator), for: .touchUpInside)
accessibleIndicatorOverlayButton.accessibilityLabel = closeTitle
presentedView.addSubview(accessibleIndicatorOverlayButton)
accessibleIndicatorOverlayButton.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
accessibleIndicatorOverlayButton.leadingAnchor.constraint(equalTo: presentedView.leadingAnchor),
accessibleIndicatorOverlayButton.trailingAnchor.constraint(equalTo: presentedView.trailingAnchor),
accessibleIndicatorOverlayButton.topAnchor.constraint(equalTo: presentedView.topAnchor),
accessibleIndicatorOverlayButton.bottomAnchor.constraint(equalTo: self.indicatorView.bottomAnchor),
])
}
}
self.updateLayoutIndicator()
self.indicatorView.style = .arrow
self.gradeView.alpha = 0
self.closeButton.accessibilityLabel = closeTitle
if self.showCloseButton {
self.closeButton.addTarget(self, action: #selector(self.tapCloseButton), for: .touchUpInside)
presentedView.addSubview(self.closeButton)
@@ -511,6 +531,7 @@ extension SPStorkPresentationController {
private func updateLayoutIndicator() {
self.indicatorView.style = .line
self.indicatorView.sizeToFit()
self.indicatorView.style = .arrow
}
private func updateLayoutCloseButton() {
@@ -29,6 +29,7 @@ public final class SPStorkTransitioningDelegate: NSObject, UIViewControllerTrans
public var showIndicator: Bool = true
public var indicatorColor: UIColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1)
public var hideIndicatorWhenScroll: Bool = false
public var indicatorMode: SPStorkArrowMode = .auto
public var customHeight: CGFloat? = nil
public var translateForDismiss: CGFloat = 200
public var cornerRadius: CGFloat = 10
@@ -44,6 +45,7 @@ public final class SPStorkTransitioningDelegate: NSObject, UIViewControllerTrans
controller.showIndicator = self.showIndicator
controller.indicatorColor = self.indicatorColor
controller.hideIndicatorWhenScroll = self.hideIndicatorWhenScroll
controller.indicatorMode = self.indicatorMode
controller.customHeight = self.customHeight
controller.translateForDismiss = self.translateForDismiss
controller.cornerRadius = self.cornerRadius
@@ -25,23 +25,41 @@ open class SPStorkIndicatorView: UIView {
var style: Style = .line {
didSet {
switch self.style {
case .line:
self.animate {
self.leftView.transform = .identity
self.rightView.transform = .identity
}
case .arrow:
self.animate {
let angle = CGFloat(20 * Float.pi / 180)
self.leftView.transform = CGAffineTransform.init(rotationAngle: angle)
self.rightView.transform = CGAffineTransform.init(rotationAngle: -angle)
if self.mode == .auto {
switch self.style {
case .line:
self.animate {
self.leftView.transform = .identity
self.rightView.transform = .identity
}
case .arrow:
self.animate {
let angle = CGFloat(20 * Float.pi / 180)
self.leftView.transform = CGAffineTransform.init(rotationAngle: angle)
self.rightView.transform = CGAffineTransform.init(rotationAngle: -angle)
}
}
}
if self.mode == .alwaysArrow {
self.leftView.removeAllAnimations()
self.rightView.removeAllAnimations()
self.leftView.transform = .identity
self.rightView.transform = .identity
let angle = CGFloat(20 * Float.pi / 180)
self.leftView.transform = CGAffineTransform.init(rotationAngle: angle)
self.rightView.transform = CGAffineTransform.init(rotationAngle: -angle)
}
if self.mode == .alwaysLine {
self.leftView.transform = .identity
self.rightView.transform = .identity
}
}
}
var mode: SPStorkArrowMode = .auto
var color: UIColor = UIColor.init(red: 202/255, green: 201/255, blue: 207/255, alpha: 1) {
didSet {
self.leftView.backgroundColor = self.color
@@ -66,6 +84,10 @@ open class SPStorkIndicatorView: UIView {
override open func sizeToFit() {
super.sizeToFit()
self.leftView.transform = .identity
self.rightView.transform = .identity
self.frame = CGRect.init(x: self.frame.origin.x, y: self.frame.origin.y, width: 36, height: 13)
let height: CGFloat = 5