Skip to content
This repository has been archived by the owner on Apr 27, 2019. It is now read-only.

Commit

Permalink
Fixes #35, Adds animation timing property, Version Bump
Browse files Browse the repository at this point in the history
  • Loading branch information
Carson Perrotti committed Jul 14, 2016
1 parent f88967d commit 56fe681
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 119 deletions.
112 changes: 3 additions & 109 deletions CNPPopupController.podspec
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
#
# Be sure to run `pod spec lint CNPPopupController.podspec' to ensure this is a
# valid spec and to remove all comments including this before submitting the spec.
#
# To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html
# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
#

Pod::Spec.new do |s|

# ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# These will help people to find your library, and whilst it
# can feel like a chore to fill in it's definitely to your advantage. The
# summary should be tweet-length, and the description more in depth.
#

s.name = "CNPPopupController"
s.version = "0.3.1"
s.version = "0.3.2"
s.summary = "A versatile popup for iOS"

s.description = <<-DESC
Expand All @@ -31,102 +15,12 @@ Pod::Spec.new do |s|

s.homepage = "https://github.com/carsonperrotti/CNPPopupController"
s.screenshots = "https://raw.githubusercontent.com/carsonperrotti/CNPPopupController/master/CNPPopupControllerExample/CNPPopupController.gif"


# ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Licensing your code is important. See http://choosealicense.com for more info.
# CocoaPods will detect a license file if there is a named LICENSE*
# Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'.
#

s.license = { :type => "Apache License, Version 2.0", :file => "LICENSE" }


# ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Specify the authors of the library, with email addresses. Email addresses
# of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also
# accepts just a name if you'd rather not provide an email address.
#
# Specify a social_media_url where others can refer to, for example a twitter
# profile URL.
#

# s.author = { "Carson Perrotti" => "carsonperrotti@gmail.com" }
s.author = "Carson Perrotti"
# s.authors = { "Carson Perrotti" => "carsonperrotti@gmail.com" }
# s.social_media_url = "http://twitter.com/Carson Perrotti"

# ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# If this Pod runs only on iOS or OS X, then specify the platform and
# the deployment target. You can optionally include the target after the platform.
#

s.social_media_url = "http://twitter.com/carsonp"
s.platform = :ios, "6.0"

# When using multiple platforms
# s.ios.deployment_target = "5.0"
# s.osx.deployment_target = "10.7"


# ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Specify the location from where the source should be retrieved.
# Supports git, hg, bzr, svn and HTTP.
#

s.source = { :git => "https://github.com/carsonperrotti/CNPPopupController.git", :tag => "0.3.1" }


# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# CocoaPods is smart about how it includes source code. For source files
# giving a folder will include any h, m, mm, c & cpp files. For header
# files it will include any header in the folder.
# Not including the public_header_files will make all headers public.
#

s.source = { :git => "https://github.com/carsonperrotti/CNPPopupController.git", :tag => "0.3.2" }
s.source_files = "CNPPopupController", "CNPPopupController/*.{h,m}"
# s.public_header_files = "Classes/**/*.h"


# ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# A list of resources included with the Pod. These are copied into the
# target bundle with a build phase script. Anything else will be cleaned.
# You can preserve files from being cleaned, please don't preserve
# non-essential files like tests, examples and documentation.
#

# s.resource = "icon.png"
# s.resources = "Resources/*.png"

# s.preserve_paths = "FilesToSave", "MoreFilesToSave"


# ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Link your library with frameworks, or libraries. Libraries do not include
# the lib prefix of their name.
#

s.framework = "UIKit"
# s.frameworks = "SomeFramework", "AnotherFramework"

# s.library = "iconv"
# s.libraries = "iconv", "xml2"


# ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# If your library depends on compiler flags you can set them in the xcconfig hash
# where they will only apply to your library. If you depend on other Podspecs
# you can include multiple dependencies to ensure it works.

s.requires_arc = true

# s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }

end
1 change: 1 addition & 0 deletions CNPPopupController/CNPPopupController.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ typedef NS_ENUM(NSInteger, CNPPopupMaskType) {
@property (nonatomic, assign) BOOL movesAboveKeyboard; // Popup should move up when the keyboard appears (Default yes)
@property (nonatomic, assign) CGFloat contentVerticalPadding; // Spacing between each vertical element (Default 12.0)
@property (nonatomic, assign) CGFloat maxPopupWidth; // Maxiumum width that the popup should be (Default 300)
@property (nonatomic, assign) CGFloat animationDuration; // Duration of presentation animations (Default 0.3s)

// Factory method to help build a default theme
+ (CNPPopupTheme *)defaultTheme;
Expand Down
18 changes: 12 additions & 6 deletions CNPPopupController/CNPPopupController.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ - (void)dealloc {

- (void)orientationWillChange {

[UIView animateWithDuration:0.3 animations:^{
[UIView animateWithDuration:self.theme.animationDuration animations:^{
self.maskView.frame = self.applicationWindow.bounds;
self.popupView.center = [self endingPoint];
}];
Expand All @@ -88,7 +88,7 @@ - (void)orientationChanged {
CGFloat angle = CNP_UIInterfaceOrientationAngleOfOrientation(statusBarOrientation);
CGAffineTransform transform = CGAffineTransformMakeRotation(angle);

[UIView animateWithDuration:0.3 animations:^{
[UIView animateWithDuration:self.theme.animationDuration animations:^{
self.maskView.frame = self.applicationWindow.bounds;
self.popupView.center = [self endingPoint];
if (CNP_SYSTEM_VERSION_LESS_THAN(@"8.0")) {
Expand Down Expand Up @@ -172,7 +172,7 @@ - (CGSize)calculateContentSizeThatFits:(CGSize)size andUpdateLayout:(BOOL)update
}
else {
if (update) {
view.frame = CGRectMake((size.width-_size.width+inset.left+inset.right)*0.5, result.height, _size.width, _size.height);
view.frame = CGRectMake(0, result.height, _size.width, _size.height);
}
}
result.height += _size.height + self.theme.contentVerticalPadding;
Expand All @@ -183,7 +183,12 @@ - (CGSize)calculateContentSizeThatFits:(CGSize)size andUpdateLayout:(BOOL)update
result.height -= self.theme.contentVerticalPadding;
result.width += inset.left + inset.right;
result.height = MIN(INFINITY, MAX(0.0f, result.height + inset.bottom));
if (update) self.popupView.frame = CGRectMake(0, 0, result.width, result.height);
if (update) {
for (UIView *view in self.popupView.subviews) {
view.frame = CGRectMake((result.width - view.frame.size.width) * 0.5, view.frame.origin.y, view.frame.size.width, view.frame.size.height);
}
self.popupView.frame = CGRectMake(0, 0, result.width, result.height);
}
return result;
}

Expand Down Expand Up @@ -254,7 +259,7 @@ - (void)presentPopupControllerAnimated:(BOOL)flag {
self.popupView.center = [self originPoint];
[self.applicationWindow addSubview:self.maskView];
self.maskView.alpha = 0;
[UIView animateWithDuration:flag?0.3:0.0 animations:^{
[UIView animateWithDuration:flag?self.theme.animationDuration:0.0 animations:^{
self.maskView.alpha = 1.0;
self.popupView.center = [self endingPoint];;
} completion:^(BOOL finished) {
Expand All @@ -269,7 +274,7 @@ - (void)dismissPopupControllerAnimated:(BOOL)flag {
if ([self.delegate respondsToSelector:@selector(popupControllerWillDismiss:)]) {
[self.delegate popupControllerWillDismiss:self];
}
[UIView animateWithDuration:flag?0.3:0.0 animations:^{
[UIView animateWithDuration:flag?self.theme.animationDuration:0.0 animations:^{
self.maskView.alpha = 0.0;
self.popupView.center = [self dismissedPoint];;
} completion:^(BOOL finished) {
Expand Down Expand Up @@ -411,6 +416,7 @@ + (CNPPopupTheme *)defaultTheme {
defaultTheme.movesAboveKeyboard = YES;
defaultTheme.contentVerticalPadding = 16.0f;
defaultTheme.maxPopupWidth = 300.0f;
defaultTheme.animationDuration = 0.3f;
return defaultTheme;
}

Expand Down
4 changes: 2 additions & 2 deletions CNPPopupControllerExample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.3.0</string>
<string>0.3.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>551</string>
<string>554</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down
2 changes: 1 addition & 1 deletion CNPPopupControllerExampleSwift/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>0.3.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,23 @@ A `CNPPopupTheme` instance can be created and assigned to the `theme` property o

`@property (nonatomic, assign) CGFloat maxPopupWidth;`

`@property (nonatomic, assign) CGFloat animationDuration;`

## Notes

### Deployment
`CNPPopupController ` works on **iOS 6 - iOS 9**
`CNPPopupController ` works on **iOS 6 - iOS 10**

##Credits
CNPPopupController was created by [Carson Perrotti](http://carsonperrotti.com)

##Version History

**July 14, 2016 v0.3.2**
- Fixes an issue where content would not be perfectly centred.
- Project compatibility fixes to prevent ‘duplicate symbols` errors.
- Added property to adjust animation transition duration.

**September 13, 2015 v0.3.1**
- Sets `movesAboveKeyboard` to `YES` in the default theme.

Expand Down

0 comments on commit 56fe681

Please sign in to comment.