Skip to content

Commit

Permalink
Merge branch 'release/1.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
danlozano committed Mar 24, 2017
2 parents 8aad816 + 64892c7 commit 60f3e0b
Show file tree
Hide file tree
Showing 23 changed files with 1,092 additions and 505 deletions.
8 changes: 4 additions & 4 deletions Presentr.podspec
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Pod::Spec.new do |s|
s.name = "Presentr"
s.version = "1.1.1"
s.summary = "A simple Swift wrapper for typical custom view controller presentations."
s.version = "1.2.0"
s.summary = "A simple Swift wrapper for 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
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
DESC
s.homepage = "http://github.com/icalialabs/Presentr"
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "Daniel Lozano" => "[email protected]" }
s.social_media_url = "http://twitter.com/danlozanov"
s.platform = :ios, "8.0"
s.source = { :git => "https://github.com/icalialabs/Presentr.git", :tag => "1.1.1" }
s.source = { :git => "https://github.com/icalialabs/Presentr.git", :tag => "1.2.0" }
s.source_files = "Presentr/**/*.{swift}"
s.resources = "Presentr/**/*.{xib,ttf}"
end
36 changes: 36 additions & 0 deletions Presentr/BackgroundView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// BackgroundView.swift
// Pods
//
// Created by Daniel Lozano Valdés on 3/20/17.
//
//

import UIKit

class PassthroughBackgroundView: UIView {

var passthroughViews: [UIView] = []

var shouldPassthrough = true

override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
var view = super.hitTest(point, with: event)

if !shouldPassthrough {
return view
}

if view == self {
for passthroughView in passthroughViews {
view = passthroughView.hitTest(convert(point, to: passthroughView), with: event)
if view != nil {
break
}
}
}

return view
}

}
6 changes: 3 additions & 3 deletions Presentr/CoverHorizontalAnimation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

import Foundation

class CoverHorizontalAnimation: PresentrAnimation {
public class CoverHorizontalAnimation: PresentrAnimation {

private var fromRight: Bool

init(fromRight: Bool = true) {
public init(fromRight: Bool = true) {
self.fromRight = fromRight
}

override func transform(containerFrame: CGRect, finalFrame: CGRect) -> CGRect {
override public func transform(containerFrame: CGRect, finalFrame: CGRect) -> CGRect {
var initialFrame = finalFrame
if fromRight {
initialFrame.origin.x = containerFrame.size.width + initialFrame.size.width
Expand Down
19 changes: 19 additions & 0 deletions Presentr/CoverVerticalAnimation.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// CoverVerticalAnimation.swift
// Pods
//
// Created by Daniel Lozano Valdés on 3/21/17.
//
//

import Foundation

public class CoverVerticalAnimation: PresentrAnimation {

override public func transform(containerFrame: CGRect, finalFrame: CGRect) -> CGRect {
var initialFrame = finalFrame
initialFrame.origin.y = containerFrame.height + initialFrame.height
return initialFrame
}

}
4 changes: 2 additions & 2 deletions Presentr/CoverVerticalFromTopAnimation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

import Foundation

class CoverVerticalFromTopAnimation: PresentrAnimation {
public class CoverVerticalFromTopAnimation: PresentrAnimation {

override func transform(containerFrame: CGRect, finalFrame: CGRect) -> CGRect {
override public func transform(containerFrame: CGRect, finalFrame: CGRect) -> CGRect {
var initialFrame = finalFrame
initialFrame.origin.y = 0 - initialFrame.size.height
return initialFrame
Expand Down
27 changes: 0 additions & 27 deletions Presentr/CoverVerticalWithSpring.swift

This file was deleted.

25 changes: 25 additions & 0 deletions Presentr/CrossDissolveAnimation.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// CrossDissolveAnimation.swift
// Pods
//
// Created by Daniel Lozano Valdés on 3/21/17.
//
//

import Foundation

public class CrossDissolveAnimation: PresentrAnimation {

override public func beforeAnimation(using transitionContext: PresentrTransitionContext) {
transitionContext.animatingView?.alpha = transitionContext.isPresenting ? 0.0 : 1.0
}

override public func performAnimation(using transitionContext: PresentrTransitionContext) {
transitionContext.animatingView?.alpha = transitionContext.isPresenting ? 1.0 : 0.0
}

override public func afterAnimation(using transitionContext: PresentrTransitionContext) {
transitionContext.animatingView?.alpha = 1.0
}

}
11 changes: 7 additions & 4 deletions Presentr/ModalCenterPosition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,17 @@ public enum ModalCenterPosition {
- returns: CGPoint representing the presented view controller's center point.
*/
func calculatePoint(_ containerBounds: CGRect) -> CGPoint? {
func calculateCenterPoint(_ containerFrame: CGRect) -> CGPoint? {
switch self {
case .center:
return CGPoint(x: containerBounds.width / 2, y: containerBounds.height / 2)
return CGPoint(x: containerFrame.origin.x + (containerFrame.width / 2),
y: containerFrame.origin.y + (containerFrame.height / 2))
case .topCenter:
return CGPoint(x: containerBounds.width / 2, y: containerBounds.height * (1 / 4) - 1)
return CGPoint(x: containerFrame.origin.x + (containerFrame.width / 2),
y: containerFrame.origin.y + (containerFrame.height * (1 / 4) - 1))
case .bottomCenter:
return CGPoint(x: containerBounds.width / 2, y: containerBounds.height * (3 / 4))
return CGPoint(x: containerFrame.origin.x + (containerFrame.width / 2),
y: containerFrame.origin.y + (containerFrame.height * (3 / 4)))
case .custom(let point):
return point
case .customOrigin(_):
Expand Down
60 changes: 34 additions & 26 deletions Presentr/PresentationType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,29 @@

import Foundation

/**
Basic Presentr type. Its job is to describe the 'type' of presentation. The type describes the size and position of the presented view controller.
- Alert: This is a small 270 x 180 alert which is the same size as the default iOS alert.
- Popup: This is a average/default size 'popup' modal.
- TopHalf: This takes up half of the screen, on the top side.
- BottomHalf: This takes up half of the screen, on the bottom side.
- FullScreen: This takes up the entire screen.
- Custom: Provide a custom width, height and center position.
*/
/// Basic Presentr type. Its job is to describe the 'type' of presentation. The type describes the size and position of the presented view controller.
///
/// - alert: This is a small 270 x 180 alert which is the same size as the default iOS alert.
/// - popup: This is a average/default size 'popup' modal.
/// - topHalf: This takes up half of the screen, on the top side.
/// - bottomHalf: This takes up half of the screen, on the bottom side.
/// - fullScreen: This takes up the entire screen.
/// - dynamic: Uses autolayout to calculate width & height. Have to provide center position.
/// - custom: User provided custom width, height & center position.
public enum PresentationType {

case alert
case popup
case topHalf
case bottomHalf
case fullScreen
case dynamic(center: ModalCenterPosition)
case custom(width: ModalSize, height: ModalSize, center: ModalCenterPosition)

/**
Describes the sizing for each Presentr type. It is meant to be non device/width specific, except for the .Custom case.
- returns: A tuple containing two 'ModalSize' enums, describing its width and height.
*/
func size() -> (width: ModalSize, height: ModalSize) {
/// Describes the sizing for each Presentr type. It is meant to be non device/width specific, except for the .custom case.
///
/// - Returns: A tuple containing two 'ModalSize' enums, describing its width and height.
func size() -> (width: ModalSize, height: ModalSize)? {
switch self {
case .alert:
return (.custom(size: 270), .custom(size: 180))
Expand All @@ -44,14 +42,14 @@ public enum PresentationType {
return (.full, .full)
case .custom(let width, let height, _):
return (width, height)
case .dynamic:
return nil
}
}

/**
Describes the position for each Presentr type. It is meant to be non device/width specific, except for the .Custom case.
- returns: Returns a 'ModalCenterPosition' enum describing the center point for the presented modal.
*/
/// Describes the position for each Presentr type. It is meant to be non device/width specific, except for the .custom case.
///
/// - Returns: Returns a 'ModalCenterPosition' enum describing the center point for the presented modal.
func position() -> ModalCenterPosition {
switch self {
case .alert, .popup:
Expand All @@ -64,14 +62,14 @@ public enum PresentationType {
return .center
case .custom(_, _, let center):
return center
case .dynamic(let center):
return center
}
}

/**
Associates each Presentr type with a default transition type, in case one is not provided to the Presentr object.
- returns: Return a 'TransitionType' which describes a system provided or custom transition animation.
*/
/// Associates each Presentr type with a default transition type, in case one is not provided to the Presentr object.
///
/// - Returns: Return a 'TransitionType' which describes a transition animation.
func defaultTransitionType() -> TransitionType {
switch self {
case .topHalf:
Expand All @@ -81,4 +79,14 @@ public enum PresentationType {
}
}

/// Default round corners setting.
var shouldRoundCorners: Bool {
switch self {
case .alert, .popup:
return true
default:
return false
}
}

}
2 changes: 2 additions & 0 deletions Presentr/Presentr+Equatable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public func == (lhs: PresentationType, rhs: PresentationType) -> Bool {
return true
case (.bottomHalf, .bottomHalf):
return true
case (.dynamic, .dynamic):
return true
default:
return false
}
Expand Down

0 comments on commit 60f3e0b

Please sign in to comment.