Skip to content

Commit

Permalink
Merge branch 'release/0.1.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
danlozano committed Jul 6, 2016
2 parents e7575b2 + f1d3914 commit 2f15866
Show file tree
Hide file tree
Showing 26 changed files with 477 additions and 259 deletions.
2 changes: 1 addition & 1 deletion 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 = "0.1.5"
s.version = "0.1.6"
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 Down
28 changes: 28 additions & 0 deletions Presentr.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
0680CC4F1CE3EFC500CBAE4F /* PresentrController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0680CC4B1CE3EFC500CBAE4F /* PresentrController.swift */; };
0680CC531CE3EFFA00CBAE4F /* Alert.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0680CC511CE3EFFA00CBAE4F /* Alert.xib */; };
0680CC541CE3EFFA00CBAE4F /* AlertViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0680CC521CE3EFFA00CBAE4F /* AlertViewController.swift */; };
06B585471D2D5FDB0045C8DA /* Presentr+Equatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B585461D2D5FDB0045C8DA /* Presentr+Equatable.swift */; };
06B585581D2D6F4B0045C8DA /* PresentationType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B585571D2D6F4B0045C8DA /* PresentationType.swift */; };
06B5855B1D2D6F8B0045C8DA /* TransitionType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B5855A1D2D6F8B0045C8DA /* TransitionType.swift */; };
06B5855D1D2D6FB00045C8DA /* ModalSize.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B5855C1D2D6FB00045C8DA /* ModalSize.swift */; };
06B5855F1D2D6FE20045C8DA /* ModalCenterPosition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B5855E1D2D6FE20045C8DA /* ModalCenterPosition.swift */; };
06BE3E4C1CED58DB0052424E /* SourceSansPro-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 06BE3E4B1CED58DB0052424E /* SourceSansPro-Regular.ttf */; };
06BE3E4E1CED58EA0052424E /* Montserrat-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 06BE3E4D1CED58EA0052424E /* Montserrat-Regular.ttf */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -45,6 +50,11 @@
0680CC4B1CE3EFC500CBAE4F /* PresentrController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PresentrController.swift; sourceTree = "<group>"; };
0680CC511CE3EFFA00CBAE4F /* Alert.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = Alert.xib; sourceTree = "<group>"; };
0680CC521CE3EFFA00CBAE4F /* AlertViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AlertViewController.swift; sourceTree = "<group>"; };
06B585461D2D5FDB0045C8DA /* Presentr+Equatable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Presentr+Equatable.swift"; sourceTree = "<group>"; };
06B585571D2D6F4B0045C8DA /* PresentationType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PresentationType.swift; sourceTree = "<group>"; };
06B5855A1D2D6F8B0045C8DA /* TransitionType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransitionType.swift; sourceTree = "<group>"; };
06B5855C1D2D6FB00045C8DA /* ModalSize.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ModalSize.swift; sourceTree = "<group>"; };
06B5855E1D2D6FE20045C8DA /* ModalCenterPosition.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ModalCenterPosition.swift; sourceTree = "<group>"; };
06BE3E4B1CED58DB0052424E /* SourceSansPro-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "SourceSansPro-Regular.ttf"; sourceTree = "<group>"; };
06BE3E4D1CED58EA0052424E /* Montserrat-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Montserrat-Regular.ttf"; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -102,8 +112,13 @@
0680CC321CE3EFA900CBAE4F /* Presentr.h */,
0680CC491CE3EFC500CBAE4F /* Presentr.swift */,
0680CC4B1CE3EFC500CBAE4F /* PresentrController.swift */,
06B585571D2D6F4B0045C8DA /* PresentationType.swift */,
06B5855A1D2D6F8B0045C8DA /* TransitionType.swift */,
06B5855C1D2D6FB00045C8DA /* ModalSize.swift */,
06B5855E1D2D6FE20045C8DA /* ModalCenterPosition.swift */,
06686CB41CE96DCE00F88216 /* Animation */,
06D8AE8E1CE40BF300E00A6C /* Alert */,
06B585591D2D6F550045C8DA /* Utils */,
06A1F0C51CF3D1C70057C79B /* Assets */,
);
path = Presentr;
Expand All @@ -128,6 +143,14 @@
name = Assets;
sourceTree = "<group>";
};
06B585591D2D6F550045C8DA /* Utils */ = {
isa = PBXGroup;
children = (
06B585461D2D5FDB0045C8DA /* Presentr+Equatable.swift */,
);
name = Utils;
sourceTree = "<group>";
};
06D8AE8E1CE40BF300E00A6C /* Alert */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -249,11 +272,16 @@
buildActionMask = 2147483647;
files = (
06686C761CE8250200F88216 /* CoverVerticalFromTopAnimation.swift in Sources */,
06B5855B1D2D6F8B0045C8DA /* TransitionType.swift in Sources */,
06B5855F1D2D6FE20045C8DA /* ModalCenterPosition.swift in Sources */,
06686C9D1CE947E200F88216 /* CoverHorizontalAnimation.swift in Sources */,
0680CC4D1CE3EFC500CBAE4F /* Presentr.swift in Sources */,
0680CC541CE3EFFA00CBAE4F /* AlertViewController.swift in Sources */,
0680CC4F1CE3EFC500CBAE4F /* PresentrController.swift in Sources */,
06B5855D1D2D6FB00045C8DA /* ModalSize.swift in Sources */,
06B585471D2D5FDB0045C8DA /* Presentr+Equatable.swift in Sources */,
06686C741CE8248D00F88216 /* PresentrAnimation.swift in Sources */,
06B585581D2D6F4B0045C8DA /* PresentationType.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
12 changes: 6 additions & 6 deletions Presentr/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIAppFonts</key>
<array>
<string>Montserrat-Regular.ttf</string>
<string>SourceSansPro-Regular.ttf</string>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
Expand All @@ -20,12 +15,17 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>0.1.6</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
<key>UIAppFonts</key>
<array>
<string>Montserrat-Regular.ttf</string>
<string>SourceSansPro-Regular.ttf</string>
</array>
</dict>
</plist>
59 changes: 59 additions & 0 deletions Presentr/ModalCenterPosition.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// ModalCenterPosition.swift
// Presentr
//
// Created by Daniel Lozano on 7/6/16.
// Copyright © 2016 danielozano. All rights reserved.
//

import Foundation

/**
Describes the presented presented view controller's center position. It is meant to be non-specific, but we can use the 'calculatePoint' method when we want to calculate the exact point by passing in the 'containerBounds' rect that only the presentation controller should be aware of.
- Center: Center of the screen.
- TopCenter: Center of the top half of the screen.
- BottomCenter: Center of the bottom half of the screen.
- Custom: A custom center position using a CGPoint which represents the center point of the presented view controller.
- Custom: A custom center position to be calculated, using a CGPoint which represents the origin of the presented view controller.
*/
public enum ModalCenterPosition {

case Center
case TopCenter
case BottomCenter
case Custom(centerPoint: CGPoint)
case CustomOrigin(origin: CGPoint)

/**
Calculates the exact position for the presented view controller center.
- parameter containerBounds: The container bounds the controller is being presented in.
- returns: CGPoint representing the presented view controller's center point.
*/
func calculatePoint(containerBounds: CGRect) -> CGPoint?{
switch self {
case .Center:
return CGPointMake(containerBounds.width / 2, containerBounds.height / 2)
case .TopCenter:
return CGPointMake(containerBounds.width / 2, containerBounds.height * (1 / 4) - 1)
case .BottomCenter:
return CGPointMake(containerBounds.width / 2, containerBounds.height * (3 / 4))
case .Custom(let point):
return point
case .CustomOrigin(_):
return nil
}
}

func calculateOrigin() -> CGPoint?{
switch self {
case .CustomOrigin(let origin):
return origin
default:
return nil
}
}

}
66 changes: 66 additions & 0 deletions Presentr/ModalSize.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//
// ModalSize.swift
// Presentr
//
// Created by Daniel Lozano on 7/6/16.
// Copyright © 2016 danielozano. All rights reserved.
//

import Foundation

/**
Descibes a presented modal's size dimension (width or height). It is meant to be non-specific, but the exact position can be calculated by calling the 'calculate' methods, passing in the 'parentSize' which only the Presentation Controller should be aware of.
- Default: Default size. Will use Presentr's default margins to calculate size of presented controller. This is the size the .Popup presentation type uses.
- Half: Half of the screen.
- Full: Full screen.
- Custom: Custom fixed size.
*/
public enum ModalSize {

case Default
case Half
case Full
case Custom(size: Float)

/**
Calculates the exact width value for the presented view controller.
- parameter parentSize: The presenting view controller's size. Provided by the presentation controller.
- returns: Exact float width value.
*/
func calculateWidth(parentSize: CGSize) -> Float{
switch self {
case .Default:
return floorf(Float(parentSize.width) - (PresentrConstants.Values.defaultSideMargin * 2.0))
case .Half:
return floorf(Float(parentSize.width) / 2.0)
case .Full:
return Float(parentSize.width)
case .Custom(let size):
return size
}
}

/**
Calculates the exact height value for the presented view controller.
- parameter parentSize: The presenting view controller's size. Provided by the presentation controller.
- returns: Exact float height value.
*/
func calculateHeight(parentSize: CGSize) -> Float{
switch self {
case .Default:
return floorf(Float(parentSize.height) * PresentrConstants.Values.defaultHeightPercentage)
case .Half:
return floorf(Float(parentSize.height) / 2.0)
case .Full:
return Float(parentSize.height)
case .Custom(let size):
return size
}
}

}
78 changes: 78 additions & 0 deletions Presentr/PresentationType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
//
// PresentationType.swift
// Presentr
//
// Created by Daniel Lozano on 7/6/16.
// Copyright © 2016 danielozano. All rights reserved.
//

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.
- Custom: Provide a custom width, height and center position.
*/
public enum PresentationType {

case Alert
case Popup
case TopHalf
case BottomHalf
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) {
switch self {
case .Alert:
return (.Custom(size: 270), .Custom(size: 180))
case .Popup:
return (.Default, .Default)
case .TopHalf, .BottomHalf:
return (.Full, .Half)
case .Custom(let width, let height, _):
return (width, height)
}
}

/**
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:
return .Center
case .TopHalf:
return .TopCenter
case .BottomHalf:
return .BottomCenter
case .Custom(_, _, 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.
*/
func defaultTransitionType() -> TransitionType{
switch self {
case .TopHalf:
return .CoverVerticalFromTop
default:
return .CoverVertical
}
}

}
59 changes: 59 additions & 0 deletions Presentr/Presentr+Equatable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// Presentr+Equatable.swift
// Presentr
//
// Created by Daniel Lozano on 7/6/16.
// Copyright © 2016 danielozano. All rights reserved.
//

import Foundation

extension PresentationType: Equatable { }
public func ==(lhs: PresentationType, rhs: PresentationType) -> Bool{
switch (lhs, rhs){
case (let .Custom(lhsWidth, lhsHeight, lhsCenter), let .Custom(rhsWidth, rhsHeight, rhsCenter)):
return lhsWidth == rhsWidth && lhsHeight == rhsHeight && lhsCenter == rhsCenter
case (.Alert, .Alert):
return true
case (.Popup, .Popup):
return true
case (.TopHalf, .TopHalf):
return true
case (.BottomHalf, .BottomHalf):
return true
default:
return false
}
}

extension ModalSize: Equatable { }
public func ==(lhs: ModalSize, rhs: ModalSize) -> Bool{
switch (lhs, rhs){
case (let .Custom(lhsSize), let .Custom(rhsSize)):
return lhsSize == rhsSize
case (.Default, .Default):
return true
case (.Half, .Half):
return true
case (.Full, .Full):
return true
default:
return false
}
}

extension ModalCenterPosition: Equatable { }
public func ==(lhs: ModalCenterPosition, rhs: ModalCenterPosition) -> Bool{
switch (lhs, rhs){
case (let .Custom(lhsCenterPoint), let .Custom(rhsCenterPoint)):
return lhsCenterPoint.x == rhsCenterPoint.x && lhsCenterPoint.y == rhsCenterPoint.y
case (.Center, .Center):
return true
case (.TopCenter, .TopCenter):
return true
case (.BottomCenter, .BottomCenter):
return true
default:
return false
}
}
Loading

0 comments on commit 2f15866

Please sign in to comment.