Skip to content

Commit

Permalink
Adds demo project
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroFranco committed Mar 8, 2014
1 parent 368ca73 commit 03f1bd1
Show file tree
Hide file tree
Showing 25 changed files with 1,278 additions and 0 deletions.
Binary file added Demo/.DS_Store
Binary file not shown.
493 changes: 493 additions & 0 deletions Demo/AFPopup-Demo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A716C7BE18CA28EF008FE0CA"
BuildableName = "AFPopup-Demo.app"
BlueprintName = "AFPopup-Demo"
ReferencedContainer = "container:AFPopup-Demo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A716C7DF18CA28EF008FE0CA"
BuildableName = "AFPopup-DemoTests.xctest"
BlueprintName = "AFPopup-DemoTests"
ReferencedContainer = "container:AFPopup-Demo.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A716C7BE18CA28EF008FE0CA"
BuildableName = "AFPopup-Demo.app"
BlueprintName = "AFPopup-Demo"
ReferencedContainer = "container:AFPopup-Demo.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A716C7BE18CA28EF008FE0CA"
BuildableName = "AFPopup-Demo.app"
BlueprintName = "AFPopup-Demo"
ReferencedContainer = "container:AFPopup-Demo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A716C7BE18CA28EF008FE0CA"
BuildableName = "AFPopup-Demo.app"
BlueprintName = "AFPopup-Demo"
ReferencedContainer = "container:AFPopup-Demo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>AFPopup-Demo.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>A716C7BE18CA28EF008FE0CA</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>A716C7DF18CA28EF008FE0CA</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
Binary file added Demo/AFPopup-Demo/.DS_Store
Binary file not shown.
40 changes: 40 additions & 0 deletions Demo/AFPopup-Demo/AFPopup-Demo-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.alvarofranco.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
16 changes: 16 additions & 0 deletions Demo/AFPopup-Demo/AFPopup-Demo-Prefix.pch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// Prefix header
//
// The contents of this file are implicitly included at the beginning of every source file.
//

#import <Availability.h>

#ifndef __IPHONE_5_0
#warning "This project uses features only available in iOS SDK 5.0 and later."
#endif

#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
18 changes: 18 additions & 0 deletions Demo/AFPopup-Demo/AFPopupView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// AFPopupView.h
// AFPopup
//
// Created by Alvaro Franco on 3/7/14.
// Copyright (c) 2014 AlvaroFranco. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface AFPopupView : UIView

+(AFPopupView *)popupWithView:(UIView *)popupView;

-(void)show;
-(void)hide;

@end
176 changes: 176 additions & 0 deletions Demo/AFPopup-Demo/AFPopupView.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
//
// AFPopupView.m
// AFPopup
//
// Created by Alvaro Franco on 3/7/14.
// Copyright (c) 2014 AlvaroFranco. All rights reserved.
//

#import "AFPopupView.h"
#import <QuartzCore/QuartzCore.h>

#define CATransform3DPerspective(t, x, y) (CATransform3DConcat(t, CATransform3DMake(1, 0, 0, x, 0, 1, 0, y, 0, 0, 1, 0, 0, 0, 0, 1)))
#define CATransform3DMakePerspective(x, y) (CATransform3DPerspective(CATransform3DIdentity, x, y))

CG_INLINE CATransform3D
CATransform3DMake(CGFloat m11, CGFloat m12, CGFloat m13, CGFloat m14,
CGFloat m21, CGFloat m22, CGFloat m23, CGFloat m24,
CGFloat m31, CGFloat m32, CGFloat m33, CGFloat m34,
CGFloat m41, CGFloat m42, CGFloat m43, CGFloat m44)
{
CATransform3D t;
t.m11 = m11; t.m12 = m12; t.m13 = m13; t.m14 = m14;
t.m21 = m21; t.m22 = m22; t.m23 = m23; t.m24 = m24;
t.m31 = m31; t.m32 = m32; t.m33 = m33; t.m34 = m34;
t.m41 = m41; t.m42 = m42; t.m43 = m43; t.m44 = m44;
return t;
}

@interface AFPopupView ()

@property (nonatomic, strong) UIView *modalView;
@property (nonatomic, strong) UIView *blackView;
@property (nonatomic, strong) UIView *backgroundShadowView;
@property (nonatomic, strong) UIImageView *renderImage;

@end

@implementation AFPopupView

+(AFPopupView *)popupWithView:(UIView *)popupView {

UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
UIView *rootView = keyWindow.rootViewController.view;
CGRect rect = CGRectMake(0, 0, rootView.frame.size.width, rootView.frame.size.height);

if (rootView.transform.b != 0 && rootView.transform.c != 0) {
rect = CGRectMake(0, 0, rootView.frame.size.height, rootView.frame.size.width);
}

AFPopupView *view = [[AFPopupView alloc] initWithFrame:rect];

view.modalView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen]bounds].size.width, [[UIScreen mainScreen]bounds].size.height - (50 * 2))];
view.modalView.backgroundColor = [UIColor clearColor];
view.modalView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleHeight |
UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin |
UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth;

view.blackView = [[UIView alloc] initWithFrame:view.frame];
view.blackView.backgroundColor = [UIColor blackColor];
view.blackView.autoresizingMask = view.modalView.autoresizingMask;

view.backgroundShadowView = [[UIView alloc] initWithFrame:view.frame];
view.backgroundShadowView.backgroundColor = [UIColor blackColor];
view.backgroundShadowView.alpha = 0.0;
view.backgroundShadowView.autoresizingMask = view.modalView.autoresizingMask;

view.renderImage = [[UIImageView alloc] initWithFrame:view.frame];
view.renderImage.autoresizingMask = view.modalView.autoresizingMask;
view.renderImage.contentMode = UIViewContentModeScaleToFill;

[view.modalView addSubview:popupView];
[view addSubview:view.blackView];
[view addSubview:view.renderImage];
[view addSubview:view.backgroundShadowView];
[view addSubview:view.modalView];

return view;
}

-(void)show {

UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
UIView *rootView = keyWindow.rootViewController.view;

CGRect rect = CGRectMake(0, 0, rootView.frame.size.width, rootView.frame.size.height);
if(rootView.transform.b != 0 && rootView.transform.c != 0)
rect = CGRectMake(0, 0, rootView.frame.size.height, rootView.frame.size.width);
self.frame = rect;

UIImage *rootViewRenderImage = [self imageWithView:rootView];
_renderImage.image = rootViewRenderImage;

_backgroundShadowView.alpha = 0.0;
[rootView addSubview:self];
_modalView.center = CGPointMake(self.frame.size.width/2.0, _modalView.frame.size.height * 1.5);

[UIView animateWithDuration:0.2
delay:0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{

_backgroundShadowView.alpha = 0.4;
_renderImage.layer.transform = CATransform3DMakePerspective(0, -0.0007);
}

completion:^(BOOL finished) {

[UIView animateWithDuration:0.2 animations:^{

float newWidht = _renderImage.frame.size.width * 0.7;
float newHeight = _renderImage.frame.size.height * 0.7;
_renderImage.frame = CGRectMake(([[UIScreen mainScreen]bounds].size.width - newWidht) / 2, 22, newWidht, newHeight);
_renderImage.layer.transform = CATransform3DMakePerspective(0, 0);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.1 animations:^{
}];
}];
}];

[UIView animateWithDuration:0.4 delay:0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
_modalView.center = self.center;
}
completion:^(BOOL finished) {

}];

}

-(void)hide {

[UIView animateWithDuration:0.4
delay:0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
_modalView.center = CGPointMake(self.frame.size.width/2.0, _modalView.frame.size.height * 1.5);
}
completion:^(BOOL finished) {

}];

[UIView animateWithDuration:0.2
delay:0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{

_backgroundShadowView.alpha = 0.0;
_renderImage.layer.transform = CATransform3DMakePerspective(0, -0.0007);
}

completion:^(BOOL finished) {

[UIView animateWithDuration:0.2 animations:^{

_renderImage.frame = [[UIScreen mainScreen]bounds];
_renderImage.layer.transform = CATransform3DMakePerspective(0, 0);
} completion:^(BOOL finished) {
[self removeFromSuperview];
}];
}];
}

-(UIImage *)imageWithView:(UIView *)view {

UIGraphicsBeginImageContextWithOptions(_renderImage.frame.size, view.opaque, [[UIScreen mainScreen] scale]);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];

UIImage *backgroundImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return backgroundImage;
}

@end
Loading

0 comments on commit 03f1bd1

Please sign in to comment.