Skip to content

Commit 60f3e0b

Browse files
committed
Merge branch 'release/1.2.0'
2 parents 8aad816 + 64892c7 commit 60f3e0b

23 files changed

+1092
-505
lines changed

Presentr.podspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
Pod::Spec.new do |s|
22
s.name = "Presentr"
3-
s.version = "1.1.1"
4-
s.summary = "A simple Swift wrapper for typical custom view controller presentations."
3+
s.version = "1.2.0"
4+
s.summary = "A simple Swift wrapper for custom view controller presentations."
55
s.description = <<-DESC
6-
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
6+
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
77
DESC
88
s.homepage = "http://github.com/icalialabs/Presentr"
99
s.license = { :type => "MIT", :file => "LICENSE" }
1010
s.author = { "Daniel Lozano" => "[email protected]" }
1111
s.social_media_url = "http://twitter.com/danlozanov"
1212
s.platform = :ios, "8.0"
13-
s.source = { :git => "https://github.com/icalialabs/Presentr.git", :tag => "1.1.1" }
13+
s.source = { :git => "https://github.com/icalialabs/Presentr.git", :tag => "1.2.0" }
1414
s.source_files = "Presentr/**/*.{swift}"
1515
s.resources = "Presentr/**/*.{xib,ttf}"
1616
end

Presentr/BackgroundView.swift

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// BackgroundView.swift
3+
// Pods
4+
//
5+
// Created by Daniel Lozano Valdés on 3/20/17.
6+
//
7+
//
8+
9+
import UIKit
10+
11+
class PassthroughBackgroundView: UIView {
12+
13+
var passthroughViews: [UIView] = []
14+
15+
var shouldPassthrough = true
16+
17+
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
18+
var view = super.hitTest(point, with: event)
19+
20+
if !shouldPassthrough {
21+
return view
22+
}
23+
24+
if view == self {
25+
for passthroughView in passthroughViews {
26+
view = passthroughView.hitTest(convert(point, to: passthroughView), with: event)
27+
if view != nil {
28+
break
29+
}
30+
}
31+
}
32+
33+
return view
34+
}
35+
36+
}

Presentr/CoverHorizontalAnimation.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88

99
import Foundation
1010

11-
class CoverHorizontalAnimation: PresentrAnimation {
11+
public class CoverHorizontalAnimation: PresentrAnimation {
1212

1313
private var fromRight: Bool
1414

15-
init(fromRight: Bool = true) {
15+
public init(fromRight: Bool = true) {
1616
self.fromRight = fromRight
1717
}
1818

19-
override func transform(containerFrame: CGRect, finalFrame: CGRect) -> CGRect {
19+
override public func transform(containerFrame: CGRect, finalFrame: CGRect) -> CGRect {
2020
var initialFrame = finalFrame
2121
if fromRight {
2222
initialFrame.origin.x = containerFrame.size.width + initialFrame.size.width

Presentr/CoverVerticalAnimation.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// CoverVerticalAnimation.swift
3+
// Pods
4+
//
5+
// Created by Daniel Lozano Valdés on 3/21/17.
6+
//
7+
//
8+
9+
import Foundation
10+
11+
public class CoverVerticalAnimation: PresentrAnimation {
12+
13+
override public func transform(containerFrame: CGRect, finalFrame: CGRect) -> CGRect {
14+
var initialFrame = finalFrame
15+
initialFrame.origin.y = containerFrame.height + initialFrame.height
16+
return initialFrame
17+
}
18+
19+
}

Presentr/CoverVerticalFromTopAnimation.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
import Foundation
1010

11-
class CoverVerticalFromTopAnimation: PresentrAnimation {
11+
public class CoverVerticalFromTopAnimation: PresentrAnimation {
1212

13-
override func transform(containerFrame: CGRect, finalFrame: CGRect) -> CGRect {
13+
override public func transform(containerFrame: CGRect, finalFrame: CGRect) -> CGRect {
1414
var initialFrame = finalFrame
1515
initialFrame.origin.y = 0 - initialFrame.size.height
1616
return initialFrame

Presentr/CoverVerticalWithSpring.swift

Lines changed: 0 additions & 27 deletions
This file was deleted.

Presentr/CrossDissolveAnimation.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// CrossDissolveAnimation.swift
3+
// Pods
4+
//
5+
// Created by Daniel Lozano Valdés on 3/21/17.
6+
//
7+
//
8+
9+
import Foundation
10+
11+
public class CrossDissolveAnimation: PresentrAnimation {
12+
13+
override public func beforeAnimation(using transitionContext: PresentrTransitionContext) {
14+
transitionContext.animatingView?.alpha = transitionContext.isPresenting ? 0.0 : 1.0
15+
}
16+
17+
override public func performAnimation(using transitionContext: PresentrTransitionContext) {
18+
transitionContext.animatingView?.alpha = transitionContext.isPresenting ? 1.0 : 0.0
19+
}
20+
21+
override public func afterAnimation(using transitionContext: PresentrTransitionContext) {
22+
transitionContext.animatingView?.alpha = 1.0
23+
}
24+
25+
}

Presentr/ModalCenterPosition.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,17 @@ public enum ModalCenterPosition {
3232

3333
- returns: CGPoint representing the presented view controller's center point.
3434
*/
35-
func calculatePoint(_ containerBounds: CGRect) -> CGPoint? {
35+
func calculateCenterPoint(_ containerFrame: CGRect) -> CGPoint? {
3636
switch self {
3737
case .center:
38-
return CGPoint(x: containerBounds.width / 2, y: containerBounds.height / 2)
38+
return CGPoint(x: containerFrame.origin.x + (containerFrame.width / 2),
39+
y: containerFrame.origin.y + (containerFrame.height / 2))
3940
case .topCenter:
40-
return CGPoint(x: containerBounds.width / 2, y: containerBounds.height * (1 / 4) - 1)
41+
return CGPoint(x: containerFrame.origin.x + (containerFrame.width / 2),
42+
y: containerFrame.origin.y + (containerFrame.height * (1 / 4) - 1))
4143
case .bottomCenter:
42-
return CGPoint(x: containerBounds.width / 2, y: containerBounds.height * (3 / 4))
44+
return CGPoint(x: containerFrame.origin.x + (containerFrame.width / 2),
45+
y: containerFrame.origin.y + (containerFrame.height * (3 / 4)))
4346
case .custom(let point):
4447
return point
4548
case .customOrigin(_):

Presentr/PresentationType.swift

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,29 @@
88

99
import Foundation
1010

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

2322
case alert
2423
case popup
2524
case topHalf
2625
case bottomHalf
2726
case fullScreen
27+
case dynamic(center: ModalCenterPosition)
2828
case custom(width: ModalSize, height: ModalSize, center: ModalCenterPosition)
2929

30-
/**
31-
Describes the sizing for each Presentr type. It is meant to be non device/width specific, except for the .Custom case.
32-
33-
- returns: A tuple containing two 'ModalSize' enums, describing its width and height.
34-
*/
35-
func size() -> (width: ModalSize, height: ModalSize) {
30+
/// Describes the sizing for each Presentr type. It is meant to be non device/width specific, except for the .custom case.
31+
///
32+
/// - Returns: A tuple containing two 'ModalSize' enums, describing its width and height.
33+
func size() -> (width: ModalSize, height: ModalSize)? {
3634
switch self {
3735
case .alert:
3836
return (.custom(size: 270), .custom(size: 180))
@@ -44,14 +42,14 @@ public enum PresentationType {
4442
return (.full, .full)
4543
case .custom(let width, let height, _):
4644
return (width, height)
45+
case .dynamic:
46+
return nil
4747
}
4848
}
4949

50-
/**
51-
Describes the position for each Presentr type. It is meant to be non device/width specific, except for the .Custom case.
52-
53-
- returns: Returns a 'ModalCenterPosition' enum describing the center point for the presented modal.
54-
*/
50+
/// Describes the position for each Presentr type. It is meant to be non device/width specific, except for the .custom case.
51+
///
52+
/// - Returns: Returns a 'ModalCenterPosition' enum describing the center point for the presented modal.
5553
func position() -> ModalCenterPosition {
5654
switch self {
5755
case .alert, .popup:
@@ -64,14 +62,14 @@ public enum PresentationType {
6462
return .center
6563
case .custom(_, _, let center):
6664
return center
65+
case .dynamic(let center):
66+
return center
6767
}
6868
}
6969

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

82+
/// Default round corners setting.
83+
var shouldRoundCorners: Bool {
84+
switch self {
85+
case .alert, .popup:
86+
return true
87+
default:
88+
return false
89+
}
90+
}
91+
8492
}

Presentr/Presentr+Equatable.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public func == (lhs: PresentationType, rhs: PresentationType) -> Bool {
2121
return true
2222
case (.bottomHalf, .bottomHalf):
2323
return true
24+
case (.dynamic, .dynamic):
25+
return true
2426
default:
2527
return false
2628
}

0 commit comments

Comments
 (0)