Skip to content

Commit

Permalink
Merge branch 'release/1.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
danlozano committed Oct 18, 2016
2 parents 60633a1 + abe28ad commit ed40eb3
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Presentr.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Presentr"
s.version = "1.0.1"
s.version = "1.0.2"
s.summary = "A simple Swift wrapper for typical custom view controller presentations."
s.description = <<-DESC
A micro framework created in Swift. Simplifies creating custom view controller presentations. Specially the typical ones we use which are a popup, an alert, or a any non-full-screen modal. Abstracts having to deal with custom presentation controllers and transitioning delegates
Expand All @@ -10,7 +10,7 @@ Pod::Spec.new do |s|
s.author = { "Daniel Lozano" => "[email protected]" }
s.social_media_url = "http://twitter.com/danlozanov"
s.platform = :ios, "9.0"
s.source = { :git => "https://github.com/icalialabs/Presentr.git", :tag => "1.0.1" }
s.source = { :git => "https://github.com/icalialabs/Presentr.git", :tag => "1.0.2" }
s.source_files = "Presentr/**/*.{swift}"
s.resources = "Presentr/**/*.{xib,ttf}"
end
17 changes: 17 additions & 0 deletions Presentr.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
0680CC2B1CE3EFA900CBAE4F /* Frameworks */,
0680CC2C1CE3EFA900CBAE4F /* Headers */,
0680CC2D1CE3EFA900CBAE4F /* Resources */,
06A15EA31DB5A73F005DD3DA /* ShellScript */,
);
buildRules = (
);
Expand Down Expand Up @@ -271,6 +272,22 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
06A15EA31DB5A73F005DD3DA /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
0680CC2A1CE3EFA900CBAE4F /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down
2 changes: 1 addition & 1 deletion Presentr/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.1</string>
<string>1.0.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
6 changes: 3 additions & 3 deletions Presentr/Presentr.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public class Presentr: NSObject {
/// Should the presented controller dismiss on background tap. Default is true.
public var dismissOnTap = true

/// Should the presented controller dismiss on Swipe. Default is true.
public var dismissOnSwipe = true
/// Should the presented controller dismiss on Swipe inside the presented view controller. Default is false.
public var dismissOnSwipe = false

/// Should the presented controller use animation when dismiss on background tap. Default is true.
public var dismissAnimated = true
Expand All @@ -78,7 +78,7 @@ public class Presentr: NSObject {
/// The type of blur to be applied to the background. Ignored if blurBackground is set to false. Default is Dark.
public var blurStyle: UIBlurEffectStyle = .dark

/// How the presented view controller should respond in response to keyboard presentation.
/// How the presented view controller should respond to keyboard presentation.
public var keyboardTranslationType: KeyboardTranslationType = .none

// MARK: Private Helper Properties
Expand Down
26 changes: 18 additions & 8 deletions Presentr/PresentrController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,27 @@ class PresentrController: UIPresentationController, UIAdaptivePresentationContro
} else {
removeCornerRadiusFromPresentedView()
}


if dismissOnSwipe {
setupDismissOnSwipe()
}

if shouldObserveKeyboard {
registerKeyboardObserver()
}

}

// MARK: Setup

fileprivate func setupChromeView(_ backgroundColor: UIColor, backgroundOpacity: Float, blurBackground: Bool, blurStyle: UIBlurEffectStyle) {
let tap = UITapGestureRecognizer(target: self, action: #selector(chromeViewTapped))
chromeView.addGestureRecognizer(tap)

private func setupDismissOnSwipe() {
let swipe = UIPanGestureRecognizer(target: self, action: #selector(presentingViewSwipe))
presentedViewController.view.addGestureRecognizer(swipe)
}

private func setupChromeView(_ backgroundColor: UIColor, backgroundOpacity: Float, blurBackground: Bool, blurStyle: UIBlurEffectStyle) {
let tap = UITapGestureRecognizer(target: self, action: #selector(chromeViewTapped))
chromeView.addGestureRecognizer(tap)

if blurBackground {
let blurEffectView = UIVisualEffectView(effect: UIBlurEffect(style: blurStyle))
Expand All @@ -118,12 +125,12 @@ class PresentrController: UIPresentationController, UIAdaptivePresentationContro
}
}

fileprivate func addCornerRadiusToPresentedView() {
private func addCornerRadiusToPresentedView() {
presentedViewController.view.layer.cornerRadius = 4
presentedViewController.view.layer.masksToBounds = true
}

fileprivate func removeCornerRadiusFromPresentedView() {
private func removeCornerRadiusFromPresentedView() {
presentedViewController.view.layer.cornerRadius = 0
}

Expand Down Expand Up @@ -157,14 +164,17 @@ class PresentrController: UIPresentationController, UIAdaptivePresentationContro
let gestureState: (UIGestureRecognizerState) -> Bool = {
return gesture.state == $0 && self.dismissOnSwipe
}

guard (conformingPresentedController?.presentrShouldDismiss?(keyboardShowing: keyboardIsShowing) ?? true) else {
return
}

if gestureState(.began) {
translationStart = gesture.location(in: presentedViewController.view)

}else if gestureState(.changed) {
let amount = gesture.translation(in: presentedViewController.view)
if amount.y < 0 {return}
if amount.y < 0 { return }

let translation = swipeElasticityFactor * 2
let center = presentedViewController.view.center
Expand Down
2 changes: 1 addition & 1 deletion PresentrExample/PresentrExample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class ViewController: UIViewController {

@IBAction func keyboardTranslation(_ sender: AnyObject) {
presenter.presentationType = .popup
presenter.keyboardTranslationType = .moveUp
presenter.keyboardTranslationType = .compress
customPresentViewController(presenter, viewController: popupViewController, animated: true, completion: nil)
}

Expand Down

0 comments on commit ed40eb3

Please sign in to comment.