Skip to content

Commit

Permalink
Merge pull request #241 from Orderella/development
Browse files Browse the repository at this point in the history
Separate tap and pan gesture dismissal
  • Loading branch information
mwfire authored Jul 9, 2018
2 parents c79db63 + fc2e6b2 commit 25d9f17
Show file tree
Hide file tree
Showing 15 changed files with 82 additions and 46 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Changelog

* **0.8.0** Separated tap and pan gesture dismissal
* **0.7.1** Fixes Objective-C compatability<br>Improved Carthage handling
* **0.7.0** Removed FXBlurView while switching to DynamicBlurView
* **0.6.2** Added preferredWidth option for iPads
Expand Down
6 changes: 6 additions & 0 deletions Example/.swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,9 @@ line_length:
type_body_length:
- 400 #warning
- 500 #error

identifier_name:
excluded:
- id
- vc
- to
8 changes: 4 additions & 4 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ PODS:
- FBSnapshotTestCase/SwiftSupport (2.1.4):
- FBSnapshotTestCase/Core
- Nimble (7.0.3)
- PopupDialog (0.7.1):
- PopupDialog (0.8.0):
- DynamicBlurView (~> 2.0)
- SwiftLint (0.25.0)
- SwiftLint (0.26.0)

DEPENDENCIES:
- FBSnapshotTestCase (from `https://github.com/facebook/ios-snapshot-test-case.git`, commit `ed4e6a6`)
Expand All @@ -32,8 +32,8 @@ SPEC CHECKSUMS:
DynamicBlurView: aa6db4defc6e537eb86fc5e58dd3991666178399
FBSnapshotTestCase: 094f9f314decbabe373b87cc339bea235a63e07a
Nimble: 7f5a9c447a33002645a071bddafbfb24ea70e0ac
PopupDialog: 7b2ad0681c470eb159c33a17c4c3109debd65d5a
SwiftLint: e14651157288e9e01d6e1a71db7014fb5744a8ea
PopupDialog: 764c106b6ab9175958cf189175fad612a334d87d
SwiftLint: f6b83e8d95ee1e91e11932d843af4fdcbf3fc764

PODFILE CHECKSUM: 7a27ac877c3a93aa83583a4625417841e72145e5

Expand Down
4 changes: 2 additions & 2 deletions Example/Pods/Local Podspecs/PopupDialog.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Example/Pods/SwiftLint/swiftlint
Binary file not shown.
2 changes: 1 addition & 1 deletion Example/Pods/Target Support Files/PopupDialog/Info.plist

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 18 additions & 2 deletions Example/PopupDialog.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
C7A6674A1D3D030200DE5036 /* Tests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Tests.swift; path = ../Tests/Tests.swift; sourceTree = SOURCE_ROOT; };
C7EA1E081E2A181A009D3044 /* PopupDialog_UITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PopupDialog_UITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
C7EA1E381E2D57FE009D3044 /* SnapshotTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SnapshotTests.swift; path = ../Tests/SnapshotTests.swift; sourceTree = SOURCE_ROOT; };
DF1B9919BA34CE12A9B2990A /* PopupDialog.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = PopupDialog.podspec; path = ../PopupDialog.podspec; sourceTree = "<group>"; };
DF1B9919BA34CE12A9B2990A /* PopupDialog.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = PopupDialog.podspec; path = ../PopupDialog.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
F2AE7E70D898C743E01C0374 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -288,7 +288,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0820;
LastUpgradeCheck = 0820;
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = CocoaPods;
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
Expand Down Expand Up @@ -561,14 +561,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -612,14 +620,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -41,9 +41,8 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
disableMainThreadChecker = "YES"
language = ""
shouldUseLaunchSchemeArgsEnv = "NO"
codeCoverageEnabled = "YES">
codeCoverageEnabled = "YES"
shouldUseLaunchSchemeArgsEnv = "NO">
<Testables>
<TestableReference
skipped = "NO">
Expand Down Expand Up @@ -94,7 +93,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
11 changes: 8 additions & 3 deletions Example/PopupDialog/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ class ViewController: UIViewController {
message: message,
buttonAlignment: .horizontal,
transitionStyle: .zoomIn,
gestureDismissal: true,
tapGestureDismissal: true,
panGestureDismissal: true,
hideStatusBar: true) {
print("Completed")
}
Expand Down Expand Up @@ -129,8 +130,12 @@ class ViewController: UIViewController {
let ratingVC = RatingViewController(nibName: "RatingViewController", bundle: nil)

// Create the dialog
let popup = PopupDialog(viewController: ratingVC, buttonAlignment: .horizontal, transitionStyle: .bounceDown, gestureDismissal: true)

let popup = PopupDialog(viewController: ratingVC,
buttonAlignment: .horizontal,
transitionStyle: .bounceDown,
tapGestureDismissal: true,
panGestureDismissal: false)

// Create first button
let buttonOne = CancelButton(title: "CANCEL", height: 60) {
self.label.text = "You canceled the rating dialog"
Expand Down
2 changes: 1 addition & 1 deletion PopupDialog.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'PopupDialog'
s.version = '0.7.1'
s.version = '0.8.0'
s.summary = 'A simple custom popup dialog view controller'
s.homepage = 'https://github.com/orderella/PopupDialog'
s.license = { :type => 'MIT', :file => 'LICENSE' }
Expand Down
28 changes: 18 additions & 10 deletions PopupDialog/Classes/PopupDialog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ final public class PopupDialog: UIViewController {
- parameter buttonAlignment: The dialog button alignment
- parameter transitionStyle: The dialog transition style
- parameter preferredWidth: The preferred width for iPad screens
- parameter gestureDismissal: Indicates if dialog can be dismissed via pan gesture
- parameter tapGestureDismissal: Indicates if dialog can be dismissed via tap gesture
- parameter panGestureDismissal: Indicates if dialog can be dismissed via pan gesture
- parameter hideStatusBar: Whether to hide the status bar on PopupDialog presentation
- parameter completion: Completion block invoked when dialog was dismissed
Expand All @@ -96,7 +97,8 @@ final public class PopupDialog: UIViewController {
buttonAlignment: UILayoutConstraintAxis = .vertical,
transitionStyle: PopupDialogTransitionStyle = .bounceUp,
preferredWidth: CGFloat = 340,
gestureDismissal: Bool = true,
tapGestureDismissal: Bool = true,
panGestureDismissal: Bool = true,
hideStatusBar: Bool = false,
completion: (() -> Void)? = nil) {

Expand All @@ -111,7 +113,8 @@ final public class PopupDialog: UIViewController {
buttonAlignment: buttonAlignment,
transitionStyle: transitionStyle,
preferredWidth: preferredWidth,
gestureDismissal: gestureDismissal,
tapGestureDismissal: tapGestureDismissal,
panGestureDismissal: panGestureDismissal,
hideStatusBar: hideStatusBar,
completion: completion)
}
Expand All @@ -123,7 +126,8 @@ final public class PopupDialog: UIViewController {
- parameter buttonAlignment: The dialog button alignment
- parameter transitionStyle: The dialog transition style
- parameter preferredWidth: The preferred width for iPad screens
- parameter gestureDismissal: Indicates if dialog can be dismissed via pan gesture
- parameter tapGestureDismissal: Indicates if dialog can be dismissed via tap gesture
- parameter panGestureDismissal: Indicates if dialog can be dismissed via pan gesture
- parameter hideStatusBar: Whether to hide the status bar on PopupDialog presentation
- parameter completion: Completion block invoked when dialog was dismissed
Expand All @@ -134,7 +138,8 @@ final public class PopupDialog: UIViewController {
buttonAlignment: UILayoutConstraintAxis = .vertical,
transitionStyle: PopupDialogTransitionStyle = .bounceUp,
preferredWidth: CGFloat = 340,
gestureDismissal: Bool = true,
tapGestureDismissal: Bool = true,
panGestureDismissal: Bool = true,
hideStatusBar: Bool = false,
completion: (() -> Void)? = nil) {

Expand Down Expand Up @@ -163,15 +168,18 @@ final public class PopupDialog: UIViewController {
popupContainerView.buttonStackView.axis = buttonAlignment
viewController.didMove(toParentViewController: self)

// Allow for dialog dismissal on background tap and dialog pan gesture
if gestureDismissal {
let panRecognizer = UIPanGestureRecognizer(target: interactor, action: #selector(InteractiveTransition.handlePan))
popupContainerView.stackView.addGestureRecognizer(panRecognizer)
// Allow for dialog dismissal on background tap
if tapGestureDismissal {
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleTap))
tapRecognizer.cancelsTouchesInView = false
panRecognizer.cancelsTouchesInView = false
popupContainerView.addGestureRecognizer(tapRecognizer)
}
// Allow for dialog dismissal on dialog pan gesture
if panGestureDismissal {
let panRecognizer = UIPanGestureRecognizer(target: interactor, action: #selector(InteractiveTransition.handlePan))
panRecognizer.cancelsTouchesInView = false
popupContainerView.stackView.addGestureRecognizer(panRecognizer)
}
}

// Init with coder not implemented
Expand Down
2 changes: 1 addition & 1 deletion PopupDialog/Classes/TransitionAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import UIKit
/// Base class for custom transition animations
internal class TransitionAnimator: NSObject, UIViewControllerAnimatedTransitioning {

var to: UIViewController! // swiftlint:disable:this identifier_name
var to: UIViewController!
var from: UIViewController!
let inDuration: TimeInterval
let outDuration: TimeInterval
Expand Down
Loading

0 comments on commit 25d9f17

Please sign in to comment.