Skip to content

Commit

Permalink
Update to 1.7.8
Browse files Browse the repository at this point in the history
Fix bug with indicator when device rotation. Add fix indicator style. Need set `indicatorMode` in transition delegate.
  • Loading branch information
ivanvorobei committed Aug 17, 2019
1 parent 12f8e2b commit 0463bb7
Show file tree
Hide file tree
Showing 15 changed files with 231 additions and 102 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ playground.xcworkspace

# Swift Package Manager
.build/
.swiftpm/

# Carthage
Carthage/Build
4 changes: 4 additions & 0 deletions Example/stork-controller.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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>"; };
Expand Down Expand Up @@ -833,6 +835,7 @@
isa = PBXGroup;
children = (
F4E0E37E22CF6B940020D754 /* SPStorkHaptic.swift */,
F4803BF423082FDA0092C9BC /* SPStorkArrowMode.swift */,
);
path = Models;
sourceTree = "<group>";
Expand Down Expand Up @@ -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 */,
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -119,6 +120,7 @@ class SPStorkPresentationController: UIPresentationController, UIGestureRecogniz
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)
Expand Down Expand Up @@ -529,6 +531,7 @@ extension SPStorkPresentationController {
private func updateLayoutIndicator() {
self.indicatorView.style = .line
self.indicatorView.sizeToFit()
self.indicatorView.style = .arrow
}

private func updateLayoutCloseButton() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Example/stork-controller/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,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.
Expand Down
2 changes: 1 addition & 1 deletion SPStorkController.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "SPStorkController"
s.version = "1.7.7"
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 }
Expand Down
Loading

0 comments on commit 0463bb7

Please sign in to comment.