Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a Completion Handler, removed 'AppDelegate' dependency, added a better gitignore #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 17 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
.DS_Store
RECurtainViewControllerExample.xcodeproj/project.xcworkspace/xcuserdata/roman.xcuserdatad/UserInterfaceState.xcuserstate
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
*.xcworkspace
!default.xcworkspace
xcuserdata
profile
*.moved-aside
DerivedData
.idea/

Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ typedef enum _RECurtainTransitionStyle {
@interface UIViewController (RECurtainViewController)

- (void)curtainRevealViewController:(UIViewController *)viewControllerToReveal transitionStyle:(RECurtainTransitionStyle)transitionStyle;
- (void)curtainRevealViewController:(UIViewController *)viewControllerToReveal transitionStyle:(RECurtainTransitionStyle)transitionStyle withCompletionHandler:(void(^)(void))callback;

@end
19 changes: 13 additions & 6 deletions RECurtainViewController/UIViewController+RECurtainViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
// THE SOFTWARE.

#import "UIViewController+RECurtainViewController.h"
#import "AppDelegate.h"

@implementation UIViewController (RECurtainViewController)

Expand All @@ -37,14 +36,18 @@ - (UIImage *)imageWithView:(UIView *)view

- (void)curtainRevealViewController:(UIViewController *)viewControllerToReveal transitionStyle:(RECurtainTransitionStyle)transitionStyle
{
AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
[self curtainRevealViewController:viewControllerToReveal transitionStyle:transitionStyle withCompletionHandler:nil];
}

- (void)curtainRevealViewController:(UIViewController *)viewControllerToReveal transitionStyle:(RECurtainTransitionStyle)transitionStyle withCompletionHandler:(void (^)(void))callback {
id appDelegate = [UIApplication sharedApplication].delegate;

UIImage *selfPortrait = [self imageWithView:appDelegate.window];
UIImage *selfPortrait = [self imageWithView:[appDelegate window]];
UIImage *controllerScreenshot = [self imageWithView:viewControllerToReveal.view];

UIView *coverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, selfPortrait.size.width, selfPortrait.size.height)];
coverView.backgroundColor = [UIColor blackColor];
[appDelegate.window addSubview:coverView];
[[appDelegate window] addSubview:coverView];

int offset = 20;
if (controllerScreenshot.size.height == [UIScreen mainScreen].bounds.size.height) {
Expand Down Expand Up @@ -95,12 +98,16 @@ - (void)curtainRevealViewController:(UIViewController *)viewControllerToReveal t
fadedView.frame = CGRectMake(0, offset, controllerScreenshot.size.width, controllerScreenshot.size.height);
fadedView.alpha = 1;
} completion:^(BOOL finished){
AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
appDelegate.window.rootViewController = viewControllerToReveal;
id appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate window].rootViewController = viewControllerToReveal;

[leftCurtain removeFromSuperview];
[rightCurtain removeFromSuperview];
[fadedView removeFromSuperview];
[coverView removeFromSuperview];

if (callback)
callback();
}];
}

Expand Down

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?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>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>82153F19-FB0D-4F0C-9BE3-6B598BADF859</string>
<key>IDESourceControlProjectName</key>
<string>RECurtainViewControllerExample</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>9E7F947D-C47A-455C-A456-AEA44BEAC70F</key>
<string>https://github.com/KiranPanesar/RECurtainViewController.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>RECurtainViewControllerExample/RECurtainViewControllerExample.xcodeproj/project.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>9E7F947D-C47A-455C-A456-AEA44BEAC70F</key>
<string>../../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>https://github.com/KiranPanesar/RECurtainViewController.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>9E7F947D-C47A-455C-A456-AEA44BEAC70F</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>9E7F947D-C47A-455C-A456-AEA44BEAC70F</string>
<key>IDESourceControlWCCName</key>
<string>RECurtainViewController</string>
</dict>
</array>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "30BFA94A15AA042D00C05D32"
BuildableName = "RECurtainViewControllerExample.app"
BlueprintName = "RECurtainViewControllerExample"
ReferencedContainer = "container:RECurtainViewControllerExample.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "30BFA94A15AA042D00C05D32"
BuildableName = "RECurtainViewControllerExample.app"
BlueprintName = "RECurtainViewControllerExample"
ReferencedContainer = "container:RECurtainViewControllerExample.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 = "30BFA94A15AA042D00C05D32"
BuildableName = "RECurtainViewControllerExample.app"
BlueprintName = "RECurtainViewControllerExample"
ReferencedContainer = "container:RECurtainViewControllerExample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "30BFA94A15AA042D00C05D32"
BuildableName = "RECurtainViewControllerExample.app"
BlueprintName = "RECurtainViewControllerExample"
ReferencedContainer = "container:RECurtainViewControllerExample.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,22 @@
<?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>RECurtainViewControllerExample.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>30BFA94A15AA042D00C05D32</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@ @implementation CurtainViewController
- (void)dismissHorizontalPressed
{
DemoViewController *test = [[DemoViewController alloc] init];
[self curtainRevealViewController:test transitionStyle:RECurtainTransitionHorizontal];
[self curtainRevealViewController:test transitionStyle:RECurtainTransitionHorizontal withCompletionHandler:^{
NSLog(@"Done");
}];
}

- (void)dismissVerticalPressed
{
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[UITableViewController alloc] initWithStyle:UITableViewStyleGrouped]];

[self curtainRevealViewController:nav transitionStyle:RECurtainTransitionVertical];
[self curtainRevealViewController:nav transitionStyle:RECurtainTransitionVertical withCompletionHandler:^{
NSLog(@"Done");
}];
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ @implementation DemoViewController
- (void)buttonPressed
{
CurtainViewController *test = [[CurtainViewController alloc] init];
[self curtainRevealViewController:test transitionStyle:RECurtainTransitionHorizontal];

[self curtainRevealViewController:test transitionStyle:RECurtainTransitionHorizontal withCompletionHandler:^{
NSLog(@"Done");
}];
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
Expand Down