Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions WYPopoverController.podspec
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Pod::Spec.new do |s|
s.name = 'WYPopoverController'
s.version = '0.1.8'
s.version = '0.2.3'
s.summary = 'An iOS Popover for iPhone and iPad. Very customizable.'
s.description = <<-DESC
WYPopoverController is for the presentation of content in popover on iPhone / iPad devices. Very customizable.
DESC
s.homepage = 'https://github.com/nicolaschengdev/WYPopoverController'
s.homepage = 'https://github.com/jschwendt/WYPopoverController'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Nicolas CHENG' => 'nicolas.cheng.dev@gmail.com' }

s.source = { :git => 'https://github.com/nicolaschengdev/WYPopoverController.git' }
s.source = { :git => 'https://github.com/jschwendt/WYPopoverController.git' }

s.source_files = 'WYPopoverController/*.{h,m}'
s.requires_arc = true
Expand Down
31 changes: 16 additions & 15 deletions WYPopoverController/WYPopoverController.h
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
/*
Version 0.2.2
Version 0.2.3

WYPopoverController is available under the MIT license.

Copyright © 2013 Nicolas CHENG

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
*/

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
Expand All @@ -31,11 +31,11 @@
@class WYPopoverTheme;

#ifndef WY_POPOVER_DEFAULT_ANIMATION_DURATION
#define WY_POPOVER_DEFAULT_ANIMATION_DURATION .25f
#define WY_POPOVER_DEFAULT_ANIMATION_DURATION .25f
#endif

#ifndef WY_POPOVER_MIN_SIZE
#define WY_POPOVER_MIN_SIZE CGSizeMake(240, 160)
#define WY_POPOVER_MIN_SIZE CGSizeMake(240, 160)
#endif

typedef NS_OPTIONS(NSUInteger, WYPopoverArrowDirection) {
Expand All @@ -51,6 +51,7 @@ typedef NS_OPTIONS(NSUInteger, WYPopoverArrowDirection) {
typedef NS_OPTIONS(NSUInteger, WYPopoverAnimationOptions) {
WYPopoverAnimationOptionFade = 1UL << 0, // default
WYPopoverAnimationOptionScale = 1UL << 1,
WYPopoverAnimationOptionSlideFromBottom = 1UL << 2,
WYPopoverAnimationOptionFadeWithScale = WYPopoverAnimationOptionFade | WYPopoverAnimationOptionScale
};

Expand Down
63 changes: 37 additions & 26 deletions WYPopoverController/WYPopoverController.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Version 0.2.2
Version 0.2.3

WYPopoverController is available under the MIT license.

Expand Down Expand Up @@ -867,17 +867,17 @@ - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event

- (BOOL)isPassthroughView:(UIView *)view
{
if (view == nil)
if (view == nil)
{
return NO;
}
if ([self.passthroughViews containsObject:view])
return NO;
}
if ([self.passthroughViews containsObject:view])
{
return YES;
}
return [self isPassthroughView:view.superview];
return YES;
}
return [self isPassthroughView:view.superview];
}

#pragma mark - UIAccessibility
Expand Down Expand Up @@ -1673,7 +1673,7 @@ - (id)init
theme.innerCornerRadius = appearance.innerCornerRadius;
theme.viewContentInsets = appearance.viewContentInsets;
theme.overlayColor = appearance.overlayColor;

themeIsUpdating = NO;
themeUpdatesEnabled = YES;

Expand Down Expand Up @@ -1711,8 +1711,8 @@ - (void)registerTheme

NSArray *keypaths = [theme observableKeypaths];
for (NSString *keypath in keypaths) {
[theme addObserver:self forKeyPath:keypath options:NSKeyValueObservingOptionNew context:NULL];
}
[theme addObserver:self forKeyPath:keypath options:NSKeyValueObservingOptionNew context:NULL];
}
}

- (void)unregisterTheme
Expand Down Expand Up @@ -1986,6 +1986,7 @@ - (void)presentPopoverFromRect:(CGRect)aRect
CGAffineTransform startTransform = [self transformForArrowDirection:backgroundView.arrowDirection];
backgroundView.transform = startTransform;
}
backgroundView.frame = CGRectMake(backgroundView.frame.origin.x, overlayView.frame.size.height, backgroundView.frame.size.width, backgroundView.frame.size.height);

[UIView animateWithDuration:animationDuration animations:^{
__typeof__(self) strongSelf = weakSelf;
Expand All @@ -1995,6 +1996,11 @@ - (void)presentPopoverFromRect:(CGRect)aRect
strongSelf->overlayView.alpha = 1;
strongSelf->backgroundView.alpha = 1;
strongSelf->backgroundView.transform = endTransform;
if ((options & WYPopoverAnimationOptionSlideFromBottom) == WYPopoverAnimationOptionSlideFromBottom)
{
strongSelf->backgroundView.frame = CGRectMake(strongSelf->backgroundView.frame.origin.x, strongSelf->overlayView.frame.size.height - strongSelf->viewController.view.frame.size.height, strongSelf->backgroundView.frame.size.width, strongSelf->backgroundView.frame.size.height);
}

}
} completion:^(BOOL finished) {
completionBlock(YES);
Expand Down Expand Up @@ -2123,7 +2129,7 @@ - (CGAffineTransform)transformForArrowDirection:(WYPopoverArrowDirection)arrowDi
CGAffineTransform transform = backgroundView.transform;

UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];

CGSize containerViewSize = backgroundView.frame.size;

if (backgroundView.arrowHeight > 0)
Expand Down Expand Up @@ -2503,7 +2509,7 @@ - (void)positionPopover:(BOOL)aAnimated
containerFrame = backgroundView.frame;

containerFrame.origin = WYPointRelativeToOrientation(containerOrigin, containerFrame.size, orientation);

if (aAnimated == YES) {
backgroundView.frame = savedContainerFrame;
__weak __typeof__(self) weakSelf = self;
Expand Down Expand Up @@ -2678,6 +2684,11 @@ - (void)dismissPopoverAnimated:(BOOL)aAnimated
CGAffineTransform endTransform = [self transformForArrowDirection:strongSelf->backgroundView.arrowDirection];
strongSelf->backgroundView.transform = endTransform;
}

if ((style & WYPopoverAnimationOptionSlideFromBottom) == WYPopoverAnimationOptionSlideFromBottom)
{
strongSelf->backgroundView.frame = CGRectMake(strongSelf->backgroundView.frame.origin.x, strongSelf->overlayView.frame.size.height, strongSelf->backgroundView.frame.size.width, strongSelf->backgroundView.frame.size.height);
}
}
} completion:^(BOOL finished) {
completionBlock();
Expand Down Expand Up @@ -2718,17 +2729,17 @@ - (void)popoverOverlayViewDidTouch:(WYPopoverOverlayView *)aOverlayView

//if (!isTouched)
//{
BOOL shouldDismiss = !viewController.modalInPopover;
if (shouldDismiss && delegate && [delegate respondsToSelector:@selector(popoverControllerShouldDismissPopover:)])
{
shouldDismiss = [delegate popoverControllerShouldDismissPopover:self];
}
if (shouldDismiss)
{
[self dismissPopoverAnimated:animated options:options completion:nil callDelegate:YES];
}
BOOL shouldDismiss = !viewController.modalInPopover;

if (shouldDismiss && delegate && [delegate respondsToSelector:@selector(popoverControllerShouldDismissPopover:)])
{
shouldDismiss = [delegate popoverControllerShouldDismissPopover:self];
}

if (shouldDismiss)
{
[self dismissPopoverAnimated:animated options:options completion:nil callDelegate:YES];
}
//}
}

Expand Down