diff --git a/.gitmodules b/.gitmodules index 63e650a..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "ios/MMDrawerController"] - path = ios/MMDrawerController - url = https://mattapperson@github.com/mutualmobile/MMDrawerController diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..33dcf44 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2010-2013 Mads Møller + +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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/android/CHANGELOG.txt b/android/CHANGELOG.txt deleted file mode 100644 index de1e091..0000000 --- a/android/CHANGELOG.txt +++ /dev/null @@ -1 +0,0 @@ -Place your change log text here. This file will be incorporated with your app at package time. \ No newline at end of file diff --git a/android/LICENSE b/android/LICENSE deleted file mode 100644 index 6ae867d..0000000 --- a/android/LICENSE +++ /dev/null @@ -1 +0,0 @@ -TODO: place your license here and we'll include it in the module distribution diff --git a/android/LICENSE.txt b/android/LICENSE.txt deleted file mode 100644 index 4124b1d..0000000 --- a/android/LICENSE.txt +++ /dev/null @@ -1 +0,0 @@ -Place your license text here. This file will be incorporated with your app at package time. \ No newline at end of file diff --git a/ios/.clang-format b/ios/.clang-format new file mode 100644 index 0000000..155e5a1 --- /dev/null +++ b/ios/.clang-format @@ -0,0 +1,96 @@ +--- +# BasedOnStyle: WebKit +AccessModifierOffset: -4 +AlignAfterOpenBracket: DontAlign +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlinesLeft: false +AlignOperands: false +AlignTrailingComments: false +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: false +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false +BreakBeforeBinaryOperators: All +BreakBeforeBraces: WebKit +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: true +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 0 +CommentPragmas: '^ IWYU pragma:' +BreakBeforeInheritanceComma: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: false +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: false +ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + - Regex: '^(<|"(gtest|isl|json)/)' + Priority: 3 + - Regex: '.*' + Priority: 1 +IncludeIsMainRegex: '$' +IndentCaseLabels: false +IndentWidth: 2 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: Inner +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: true +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Right +ReflowComments: true +SortIncludes: true +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +TabWidth: 8 +UseTab: Never +... diff --git a/ios/CHANGELOG.txt b/ios/CHANGELOG.txt deleted file mode 100644 index de1e091..0000000 --- a/ios/CHANGELOG.txt +++ /dev/null @@ -1 +0,0 @@ -Place your change log text here. This file will be incorporated with your app at package time. \ No newline at end of file diff --git a/ios/Classes/CustomMMDrawerController.h b/ios/Classes/CustomMMDrawerController.h index 1dfa9cb..6a9df32 100644 --- a/ios/Classes/CustomMMDrawerController.h +++ b/ios/Classes/CustomMMDrawerController.h @@ -13,11 +13,10 @@ typedef void windowAppearanceChange; -@interface CustomMMDrawerController : MMDrawerController -{ - void (^_callback)(NSString *state); +@interface CustomMMDrawerController : MMDrawerController { + void (^_callback)(NSString *state); } --(void)setWindowAppearanceCallback:(void(^)(NSString*))callback; +- (void)setWindowAppearanceCallback:(void (^)(NSString *))callback; @end diff --git a/ios/Classes/CustomMMDrawerController.m b/ios/Classes/CustomMMDrawerController.m index 279e916..ae6d225 100644 --- a/ios/Classes/CustomMMDrawerController.m +++ b/ios/Classes/CustomMMDrawerController.m @@ -13,43 +13,42 @@ @implementation CustomMMDrawerController --(void)openDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated completion:(void (^)(BOOL finished))completion +- (void)openDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated completion:(void (^)(BOOL finished))completion { - [super openDrawerSide:drawerSide animated:animated completion:^(BOOL finished) { - if (finished){ - _callback(@"open"); - } - }]; + [super openDrawerSide:drawerSide + animated:animated + completion:^(BOOL finished) { + if (finished) { + _callback(@"open"); + } + }]; } --(void)closeDrawerAnimated:(BOOL)animated completion:(void (^)(BOOL finished))completion +- (void)closeDrawerAnimated:(BOOL)animated completion:(void (^)(BOOL finished))completion { - [super closeDrawerAnimated:animated completion:^(BOOL finished) { - if (finished){ - _callback(@"close"); - } - }]; + [super closeDrawerAnimated:animated + completion:^(BOOL finished) { + if (finished) { + _callback(@"close"); + } + }]; } --(void)setWindowAppearanceCallback:(void(^)(NSString*))callback +- (void)setWindowAppearanceCallback:(void (^)(NSString *))callback { - _callback = [callback copy]; - - // add callback for the gestures - [super setGestureCompletionBlock:^(MMDrawerController *controller, UIGestureRecognizer *gesture) { - if(controller.openSide == MMDrawerSideNone){ - _callback(@"close"); - } else { - _callback(@"open"); - } - }]; -} + _callback = [callback copy]; + __weak __typeof__(self) weakSelf = self; --(void)dealloc -{ - [super dealloc]; - [_callback release]; - _callback = nil; + // add callback for the gestures + [super setGestureCompletionBlock:^(MMDrawerController *controller, UIGestureRecognizer *gesture) { + __typeof__(self) strongSelf = weakSelf; + + if (controller.openSide == MMDrawerSideNone) { + strongSelf->_callback(@"close"); + } else { + strongSelf->_callback(@"open"); + } + }]; } @end diff --git a/ios/Classes/DkNappDrawerDrawer.h b/ios/Classes/DkNappDrawerDrawer.h index 52dabab..15c4fac 100644 --- a/ios/Classes/DkNappDrawerDrawer.h +++ b/ios/Classes/DkNappDrawerDrawer.h @@ -7,37 +7,38 @@ * and licensed under the Apache Public License (version 2) */ -#import "TiBase.h" -#import "TiUIView.h" #import "CustomMMDrawerController.h" #import "NappDrawerVisualState.h" +#import "TiBase.h" +#import "TiUIView.h" #import "TiUIiOSNavWindowProxy.h" #import @interface DkNappDrawerDrawer : TiUIView { -@private - CustomMMDrawerController *controller; - TiUIiOSNavWindowProxy *navProxy; - - NSMutableArray* _accessibleElements; - - UIView* controllerView_; - - UIView* leftView_; - UIView* rightView_; - UIView* centerView_; + @private + CustomMMDrawerController *controller; + TiUIiOSNavWindowProxy *navProxy; + + NSMutableArray *_accessibleElements; + + UIView *controllerView_; + + UIView *leftView_; + UIView *rightView_; + UIView *centerView_; } --(CustomMMDrawerController*)controller; +- (CustomMMDrawerController *)controller; + +// Public APIs -//API --(void)toggleLeftWindow:(id)args; --(void)toggleRightWindow:(id)args; --(void)bounceLeftWindow:(id)args; --(void)bounceRightWindow:(id)args; --(NSNumber*)isAnyWindowOpen:(id)args; --(NSNumber*)isLeftWindowOpen:(id)args; --(NSNumber*)isRightWindowOpen:(id)args; +- (void)toggleLeftWindow:(id)args; +- (void)toggleRightWindow:(id)args; +- (void)bounceLeftWindow:(id)args; +- (void)bounceRightWindow:(id)args; +- (NSNumber *)isAnyWindowOpen:(id)args; +- (NSNumber *)isLeftWindowOpen:(id)args; +- (NSNumber *)isRightWindowOpen:(id)args; @end diff --git a/ios/Classes/DkNappDrawerDrawer.m b/ios/Classes/DkNappDrawerDrawer.m index 80dafb1..f5c3fc2 100644 --- a/ios/Classes/DkNappDrawerDrawer.m +++ b/ios/Classes/DkNappDrawerDrawer.m @@ -9,429 +9,425 @@ #import "DkNappDrawerDrawer.h" #import "DkNappDrawerDrawerProxy.h" +#import "TiUIiOSNavWindowProxy.h" #import "TiUtils.h" #import "TiViewController.h" -#import "TiUIiOSNavWindowProxy.h" -UIViewController * ControllerForViewProxy(TiViewProxy * proxy); +UIViewController *ControllerForViewProxy(TiViewProxy *proxy); -UIViewController * ControllerForViewProxy(TiViewProxy * proxy) +UIViewController *ControllerForViewProxy(TiViewProxy *proxy) { - [[proxy view] setAutoresizingMask:UIViewAutoresizingNone]; - - //make the proper resize ! - TiThreadPerformOnMainThread(^{ - [proxy windowWillOpen]; - [proxy reposition]; - [proxy windowDidOpen]; - },YES); - return [[[TiViewController alloc] initWithViewProxy:proxy] autorelease]; + [[proxy view] setAutoresizingMask:UIViewAutoresizingNone]; + + //make the proper resize ! + TiThreadPerformOnMainThread(^{ + [proxy windowWillOpen]; + [proxy reposition]; + [proxy windowDidOpen]; + }, + YES); + return [[TiViewController alloc] initWithViewProxy:proxy]; } -UINavigationController * NavigationControllerForViewProxy(TiUIiOSNavWindowProxy *proxy) +UINavigationController *NavigationControllerForViewProxy(TiUIiOSNavWindowProxy *proxy) { - return [proxy controller]; + return [proxy controller]; } @implementation DkNappDrawerDrawer --(void)dealloc -{ - RELEASE_TO_NIL(controller); - [super dealloc]; -} - - (id)accessibilityElement { - return controllerView_; + return controllerView_; } - (NSArray *)accessibleElements { - if ( _accessibleElements != nil ) - { - [_accessibleElements removeAllObjects]; - } - else - { - _accessibleElements = [[NSMutableArray alloc] init]; - } - - if ([[self isLeftWindowOpen:nil] intValue ]) { - [_accessibleElements addObject:leftView_]; - } else if ([[self isRightWindowOpen:nil] intValue ]) { - [_accessibleElements addObject:rightView_]; - } - [_accessibleElements addObject:controllerView_]; - - return _accessibleElements; + if (_accessibleElements != nil) { + [_accessibleElements removeAllObjects]; + } else { + _accessibleElements = [[NSMutableArray alloc] init]; + } + + if ([[self isLeftWindowOpen:nil] intValue]) { + [_accessibleElements addObject:leftView_]; + } else if ([[self isRightWindowOpen:nil] intValue]) { + [_accessibleElements addObject:rightView_]; + } + [_accessibleElements addObject:controllerView_]; + + return _accessibleElements; } /* The container itself is not accessible, so MultiFacetedView should return NO in isAccessiblityElement. */ - (BOOL)isAccessibilityElement { - return NO; + return NO; } /* The following methods are implementations of UIAccessibilityContainer protocol methods. */ - (NSInteger)accessibilityElementCount { - return [[self accessibleElements] count]; + return [[self accessibleElements] count]; } - (id)accessibilityElementAtIndex:(NSInteger)index { - return [[self accessibleElements] objectAtIndex:index]; + return [[self accessibleElements] objectAtIndex:index]; } - (NSInteger)indexOfAccessibilityElement:(id)element { - return [[self accessibleElements] indexOfObject:element]; -} - --(MMDrawerController*)controller -{ - if (controller==nil) - { - - // Check in centerWindow is a UINavigationController - BOOL useNavController = FALSE; - if([[[[self.proxy valueForUndefinedKey:@"centerWindow"] class] description] isEqualToString:@"TiUIiOSNavWindowProxy"]) { - useNavController = TRUE; - } - - // navController or TiWindow ? - UIViewController *centerWindow = useNavController ? NavigationControllerForViewProxy([self.proxy valueForUndefinedKey:@"centerWindow"]) : ControllerForViewProxy([self.proxy valueForUndefinedKey:@"centerWindow"]); - - TiViewProxy *leftWindow = [self.proxy valueForUndefinedKey:@"leftWindow"]; - TiViewProxy *rightWindow = [self.proxy valueForUndefinedKey:@"rightWindow"]; - - if(leftWindow != nil){ - if(rightWindow != nil){ - //both left and right - controller = [[CustomMMDrawerController alloc] initWithCenterViewController: centerWindow - leftDrawerViewController: ControllerForViewProxy(leftWindow) - rightDrawerViewController: ControllerForViewProxy(rightWindow) ]; - } else { - //left only - controller = [[CustomMMDrawerController alloc] initWithCenterViewController: centerWindow - leftDrawerViewController: ControllerForViewProxy(leftWindow)]; - } - } else if(rightWindow != nil){ - //right only - controller = [[CustomMMDrawerController alloc] initWithCenterViewController: centerWindow - rightDrawerViewController: ControllerForViewProxy(rightWindow) ]; - } else { - //error - NSLog(@"[ERROR] NappDrawer: No windows assigned"); - return nil; - } - - // SET PROPERTIES at init - if([self.proxy valueForUndefinedKey:@"openDrawerGestureMode"] != nil){ - [self setOpenDrawerGestureMode_:[self.proxy valueForUndefinedKey:@"openDrawerGestureMode"]]; - } - - if([self.proxy valueForUndefinedKey:@"closeDrawerGestureMode"] != nil){ - [self setCloseDrawerGestureMode_:[self.proxy valueForUndefinedKey:@"closeDrawerGestureMode"]]; - } - - if([self.proxy valueForUndefinedKey:@"leftDrawerWidth"] != nil){ - [self setLeftDrawerWidth_:[self.proxy valueForUndefinedKey:@"leftDrawerWidth"]]; - } - - if([self.proxy valueForUndefinedKey:@"rightDrawerWidth"] != nil){ - [self setRightDrawerWidth_:[self.proxy valueForUndefinedKey:@"rightDrawerWidth"]]; - } - - if([self.proxy valueForUndefinedKey:@"centerHiddenInteractionMode"] != nil){ - [self setCenterHiddenInteractionMode_:[self.proxy valueForUndefinedKey:@"centerHiddenInteractionMode"]]; - } - - if([self.proxy valueForUndefinedKey:@"showShadow"] != nil){ - [self setShowShadow_:[self.proxy valueForUndefinedKey:@"showShadow"]]; - } - - if([self.proxy valueForUndefinedKey:@"animationMode"] != nil) { - [self setAnimationMode_:[self.proxy valueForUndefinedKey:@"animationMode"]]; - } - - if([self.proxy valueForUndefinedKey:@"animationVelocity"] != nil) { - [self setAnimationVelocity_:[self.proxy valueForUndefinedKey:@"animationVelocity"]]; - } - - if([self.proxy valueForUndefinedKey:@"shouldStretchDrawer"] != nil) { - [self setShouldStretchDrawer_:[self.proxy valueForUndefinedKey:@"shouldStretchDrawer"]]; - } - - if([self.proxy valueForUndefinedKey:@"showStatusBarView"] != nil){ - [self setShowsStatusBarBackgroundView_:[self.proxy valueForUndefinedKey:@"showStatusBarView"]]; - } - - if([self.proxy valueForUndefinedKey:@"statusBarStyle"] != nil){ - [self setStatusBarStyle_:[self.proxy valueForUndefinedKey:@"statusBarStyle"]]; - } - - // open/close window - [controller setWindowAppearanceCallback:^(NSString *state) { - if ([state isEqualToString:@"open"]) { - [self.proxy fireEvent:@"windowDidOpen"]; - } - else if ([state isEqualToString:@"close"]) { - [self.proxy fireEvent:@"windowDidClose"]; - } - }]; - - // set frame bounds & add it - controllerView_ = [controller view]; - [controllerView_ setFrame:[self bounds]]; - [self addSubview:controllerView_]; - - leftView_ = leftWindow.view; - rightView_ = rightWindow.view; - centerView_ = centerWindow.view; - - [[NSNotificationCenter defaultCenter] addObserver: self - selector: @selector(orientationDidChange:) - name: UIApplicationDidChangeStatusBarOrientationNotification - object: nil]; - - } - return controller; + return [[self accessibleElements] indexOfObject:element]; } -- (void)orientationDidChange:(NSNotification *)note +- (MMDrawerController *)controller { - UIInterfaceOrientation orientation = [[[note userInfo] objectForKey: UIApplicationStatusBarOrientationUserInfoKey] integerValue]; - - if([self.controller.centerViewController isKindOfClass:[UINavigationController class]]) { - UINavigationController * navCon = (UINavigationController *)self.controller.centerViewController; - UINavigationBar *bar = navCon.navigationBar; - - [[UIApplication sharedApplication] setStatusBarHidden:NO]; - - bar.frame = CGRectMake(0, 0, self.controller.view.bounds.size.width, 64); + if (controller == nil) { + + // Check in centerWindow is a UINavigationController + BOOL useNavController = NO; + if ([[[[self.proxy valueForUndefinedKey:@"centerWindow"] class] description] isEqualToString:@"TiUIiOSNavWindowProxy"]) { + useNavController = YES; } -} --(void)frameSizeChanged:(CGRect)frame bounds:(CGRect)bounds -{ - [[[self controller] view] setFrame:bounds]; - [super frameSizeChanged:frame bounds:bounds]; -} + // navController or TiWindow ? + UIViewController *centerWindow = useNavController ? NavigationControllerForViewProxy([self.proxy valueForUndefinedKey:@"centerWindow"]) : ControllerForViewProxy([self.proxy valueForUndefinedKey:@"centerWindow"]); -// PROPERTIES + TiViewProxy *leftWindow = [self.proxy valueForUndefinedKey:@"leftWindow"]; + TiViewProxy *rightWindow = [self.proxy valueForUndefinedKey:@"rightWindow"]; + __weak __typeof__(self) weakSelf = self; + + if (leftWindow != nil) { + if (rightWindow != nil) { + //both left and right + controller = [[CustomMMDrawerController alloc] initWithCenterViewController:centerWindow + leftDrawerViewController:ControllerForViewProxy(leftWindow) + rightDrawerViewController:ControllerForViewProxy(rightWindow)]; + } else { + //left only + controller = [[CustomMMDrawerController alloc] initWithCenterViewController:centerWindow + leftDrawerViewController:ControllerForViewProxy(leftWindow)]; + } + } else if (rightWindow != nil) { + //right only + controller = [[CustomMMDrawerController alloc] initWithCenterViewController:centerWindow + rightDrawerViewController:ControllerForViewProxy(rightWindow)]; + } else { + //error + NSLog(@"[ERROR] NappDrawer: No windows assigned"); + return nil; + } --(void)setCenterWindow_:(id)args -{ - ENSURE_UI_THREAD(setCenterWindow_, args); - BOOL useNavController = FALSE; - if([[[args class] description] isEqualToString:@"TiUIiOSNavWindowProxy"]) { - useNavController = TRUE; + // SET PROPERTIES at init + if ([self.proxy valueForUndefinedKey:@"openDrawerGestureMode"] != nil) { + [self setOpenDrawerGestureMode_:[self.proxy valueForUndefinedKey:@"openDrawerGestureMode"]]; } - UIViewController *centerWindow = useNavController ? NavigationControllerForViewProxy([self.proxy valueForUndefinedKey:@"centerWindow"]) : ControllerForViewProxy([self.proxy valueForUndefinedKey:@"centerWindow"]); - [controller setCenterViewController: centerWindow]; - - // Cleanup - if( useNavController ) - { - if( navProxy != nil ) - { - NSLog(@"[DEBUG| Destroying old nav proxy"); - [navProxy windowDidClose]; - } - // Save new proxy - navProxy = [self.proxy valueForUndefinedKey:@"centerWindow"]; + + if ([self.proxy valueForUndefinedKey:@"closeDrawerGestureMode"] != nil) { + [self setCloseDrawerGestureMode_:[self.proxy valueForUndefinedKey:@"closeDrawerGestureMode"]]; + } + + if ([self.proxy valueForUndefinedKey:@"leftDrawerWidth"] != nil) { + [self setLeftDrawerWidth_:[self.proxy valueForUndefinedKey:@"leftDrawerWidth"]]; + } + + if ([self.proxy valueForUndefinedKey:@"rightDrawerWidth"] != nil) { + [self setRightDrawerWidth_:[self.proxy valueForUndefinedKey:@"rightDrawerWidth"]]; + } + + if ([self.proxy valueForUndefinedKey:@"centerHiddenInteractionMode"] != nil) { + [self setCenterHiddenInteractionMode_:[self.proxy valueForUndefinedKey:@"centerHiddenInteractionMode"]]; } + + if ([self.proxy valueForUndefinedKey:@"showShadow"] != nil) { + [self setShowShadow_:[self.proxy valueForUndefinedKey:@"showShadow"]]; + } + + if ([self.proxy valueForUndefinedKey:@"animationMode"] != nil) { + [self setAnimationMode_:[self.proxy valueForUndefinedKey:@"animationMode"]]; + } + + if ([self.proxy valueForUndefinedKey:@"animationVelocity"] != nil) { + [self setAnimationVelocity_:[self.proxy valueForUndefinedKey:@"animationVelocity"]]; + } + + if ([self.proxy valueForUndefinedKey:@"shouldStretchDrawer"] != nil) { + [self setShouldStretchDrawer_:[self.proxy valueForUndefinedKey:@"shouldStretchDrawer"]]; + } + + if ([self.proxy valueForUndefinedKey:@"showStatusBarView"] != nil) { + [self setShowsStatusBarBackgroundView_:[self.proxy valueForUndefinedKey:@"showStatusBarView"]]; + } + + if ([self.proxy valueForUndefinedKey:@"statusBarStyle"] != nil) { + [self setStatusBarStyle_:[self.proxy valueForUndefinedKey:@"statusBarStyle"]]; + } + + // open/close window + [controller setWindowAppearanceCallback:^(NSString *state) { + __typeof__(self) strongSelf = weakSelf; + + if ([state isEqualToString:@"open"]) { + [[strongSelf proxy] fireEvent:@"windowDidOpen"]; + } else if ([state isEqualToString:@"close"]) { + [[strongSelf proxy] fireEvent:@"windowDidClose"]; + } + + [strongSelf _fireStateEventForCurrentState]; + }]; + + // set frame bounds & add it + controllerView_ = [controller view]; + [controllerView_ setFrame:[self bounds]]; + [self addSubview:controllerView_]; + + leftView_ = leftWindow.view; + rightView_ = rightWindow.view; + centerView_ = centerWindow.view; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(orientationDidChange:) + name:UIApplicationDidChangeStatusBarOrientationNotification + object:nil]; + } + return controller; } --(void)setLeftWindow_:(id)args +- (void)orientationDidChange:(NSNotification *)note { - ENSURE_UI_THREAD(setLeftWindow_, args); - if([TiUtils boolValue:args] == 0 ){ - [controller setLeftDrawerViewController:nil]; - } else { - [controller setLeftDrawerViewController:ControllerForViewProxy(args)]; - } + if ([self.controller.centerViewController isKindOfClass:[UINavigationController class]]) { + UINavigationController *navCon = (UINavigationController *)self.controller.centerViewController; + UINavigationBar *bar = navCon.navigationBar; + + [[UIApplication sharedApplication] setStatusBarHidden:NO]; + + bar.frame = CGRectMake(0, 0, self.controller.view.bounds.size.width, 64); + } } --(void)setRightWindow_:(id)args +- (void)frameSizeChanged:(CGRect)frame bounds:(CGRect)bounds { - ENSURE_UI_THREAD(setRightWindow_, args); - if([TiUtils boolValue:args] == 0 ){ - [controller setRightDrawerViewController:nil]; - } else { - [controller setRightDrawerViewController:ControllerForViewProxy(args)]; + [[[self controller] view] setFrame:bounds]; + [super frameSizeChanged:frame bounds:bounds]; +} + +// PROPERTIES + +- (void)setCenterWindow_:(id)args +{ + ENSURE_UI_THREAD(setCenterWindow_, args); + BOOL useNavController = NO; + if ([[[args class] description] isEqualToString:@"TiUIiOSNavWindowProxy"]) { + useNavController = YES; + } + UIViewController *centerWindow = useNavController ? NavigationControllerForViewProxy([self.proxy valueForUndefinedKey:@"centerWindow"]) : ControllerForViewProxy([self.proxy valueForUndefinedKey:@"centerWindow"]); + [controller setCenterViewController:centerWindow]; + + // Cleanup + if (useNavController) { + if (navProxy != nil) { + NSLog(@"[DEBUG| Destroying old nav proxy"); + [navProxy windowDidClose]; } + // Save new proxy + navProxy = [self.proxy valueForUndefinedKey:@"centerWindow"]; + } } --(void)setLeftDrawerWidth_:(id)args +- (void)setLeftWindow_:(id)args { - ENSURE_UI_THREAD(setLeftDrawerWidth_,args); - //ENSURE_SINGLE_ARG(args, NSNumber); - if( [args respondsToSelector:@selector(objectForKey:)] ) - { - [controller setMaximumLeftDrawerWidth:[TiUtils floatValue:@"width" properties:args] animated:[TiUtils boolValue:@"animated" properties:args def:NO] completion:nil]; - } else { - [controller setMaximumLeftDrawerWidth:[TiUtils floatValue:args]]; - } + ENSURE_UI_THREAD(setLeftWindow_, args); + if ([TiUtils boolValue:args] == 0) { + [controller setLeftDrawerViewController:nil]; + } else { + [controller setLeftDrawerViewController:ControllerForViewProxy(args)]; + } } --(void)setRightDrawerWidth_:(id)args +- (void)setRightWindow_:(id)args { - ENSURE_UI_THREAD(setRightDrawerWidth_,args); - // ENSURE_SINGLE_ARG(args, NSNumber); - if( [args respondsToSelector:@selector(objectForKey:)] ) - { - [controller setMaximumRightDrawerWidth:[TiUtils floatValue:@"width" properties:args] animated:[TiUtils boolValue:@"animated" properties:args def:NO] completion:nil]; - } else { - [controller setMaximumRightDrawerWidth:[TiUtils floatValue:args]]; - } + ENSURE_UI_THREAD(setRightWindow_, args); + if ([TiUtils boolValue:args] == 0) { + [controller setRightDrawerViewController:nil]; + } else { + [controller setRightDrawerViewController:ControllerForViewProxy(args)]; + } } --(void)setCloseDrawerGestureMode_:(id)args +- (void)setLeftDrawerWidth_:(id)args { - ENSURE_UI_THREAD(setCloseDrawerGestureMode_,args); - ENSURE_SINGLE_ARG(args, NSNumber); - [controller setCloseDrawerGestureModeMask:[TiUtils intValue:args]]; + ENSURE_UI_THREAD(setLeftDrawerWidth_, args); + //ENSURE_SINGLE_ARG(args, NSNumber); + if ([args respondsToSelector:@selector(objectForKey:)]) { + [controller setMaximumLeftDrawerWidth:[TiUtils floatValue:@"width" properties:args] animated:[TiUtils boolValue:@"animated" properties:args def:NO] completion:nil]; + } else { + [controller setMaximumLeftDrawerWidth:[TiUtils floatValue:args]]; + } } --(void)setOpenDrawerGestureMode_:(id)args +- (void)setRightDrawerWidth_:(id)args { - ENSURE_UI_THREAD(setOpenDrawerGestureMode_,args); - ENSURE_SINGLE_ARG(args, NSNumber); - [controller setOpenDrawerGestureModeMask:[TiUtils intValue:args]]; + ENSURE_UI_THREAD(setRightDrawerWidth_, args); + // ENSURE_SINGLE_ARG(args, NSNumber); + if ([args respondsToSelector:@selector(objectForKey:)]) { + [controller setMaximumRightDrawerWidth:[TiUtils floatValue:@"width" properties:args] animated:[TiUtils boolValue:@"animated" properties:args def:NO] completion:nil]; + } else { + [controller setMaximumRightDrawerWidth:[TiUtils floatValue:args]]; + } } --(void)setCenterHiddenInteractionMode_:(id)args +- (void)setCloseDrawerGestureMode_:(id)args { - ENSURE_UI_THREAD(setCenterHiddenInteractionMode_,args); - ENSURE_SINGLE_ARG(args, NSNumber); - [controller setCenterHiddenInteractionMode:[TiUtils intValue:args]]; + ENSURE_UI_THREAD(setCloseDrawerGestureMode_, args); + ENSURE_SINGLE_ARG(args, NSNumber); + [controller setCloseDrawerGestureModeMask:[TiUtils intValue:args]]; } --(void)setAnimationVelocity_:(id)args +- (void)setOpenDrawerGestureMode_:(id)args { - ENSURE_UI_THREAD(setAnimationVelocity_,args); - ENSURE_SINGLE_ARG(args, NSNumber); - [controller setAnimationVelocity:[TiUtils floatValue:args]]; + ENSURE_UI_THREAD(setOpenDrawerGestureMode_, args); + ENSURE_SINGLE_ARG(args, NSNumber); + [controller setOpenDrawerGestureModeMask:[TiUtils intValue:args]]; } --(void)setShowShadow_:(id)args +- (void)setCenterHiddenInteractionMode_:(id)args { - ENSURE_UI_THREAD(setShowShadow_,args); - ENSURE_SINGLE_ARG(args, NSNumber); - [controller setShowsShadow:[TiUtils boolValue:args]]; + ENSURE_UI_THREAD(setCenterHiddenInteractionMode_, args); + ENSURE_SINGLE_ARG(args, NSNumber); + [controller setCenterHiddenInteractionMode:[TiUtils intValue:args]]; } --(void)setShouldStretchDrawer_:(id)args +- (void)setAnimationVelocity_:(id)args { - ENSURE_UI_THREAD(setShouldStretchDrawer_,args); - ENSURE_SINGLE_ARG(args, NSNumber); - [controller setShouldStretchDrawer:[TiUtils boolValue:args]]; - + ENSURE_UI_THREAD(setAnimationVelocity_, args); + ENSURE_SINGLE_ARG(args, NSNumber); + [controller setAnimationVelocity:[TiUtils floatValue:args]]; } --(void)setShowsStatusBarBackgroundView_:(id)args +- (void)setShowShadow_:(id)args { - ENSURE_UI_THREAD(setShowsStatusBarBackgroundView_,args); - ENSURE_SINGLE_ARG(args, NSNumber); - [controller setShowsStatusBarBackgroundView:[TiUtils boolValue:args]]; + ENSURE_UI_THREAD(setShowShadow_, args); + ENSURE_SINGLE_ARG(args, NSNumber); + [controller setShowsShadow:[TiUtils boolValue:args]]; } --(UIStatusBarStyle)preferredStatusBarStyle { - if(self.controller.showsStatusBarBackgroundView){ - return UIStatusBarStyleLightContent; - } - else { - return UIStatusBarStyleDefault; - } +- (void)setShouldStretchDrawer_:(id)args +{ + ENSURE_UI_THREAD(setShouldStretchDrawer_, args); + ENSURE_SINGLE_ARG(args, NSNumber); + [controller setShouldStretchDrawer:[TiUtils boolValue:args]]; } +- (void)setShowsStatusBarBackgroundView_:(id)args +{ + ENSURE_UI_THREAD(setShowsStatusBarBackgroundView_, args); + ENSURE_SINGLE_ARG(args, NSNumber); + [controller setShowsStatusBarBackgroundView:[TiUtils boolValue:args]]; +} --(void)setStatusBarStyle_:(NSNumber *)style -{ - ENSURE_UI_THREAD(setStatusBarStyle_,style); - [[UIApplication sharedApplication] setStatusBarStyle:[style intValue]]; -} - - --(void)setAnimationMode_:(id)args -{ - ENSURE_UI_THREAD(setAnimationMode_,args); - int mode = [TiUtils intValue:args]; - switch (mode) { - case 1: - [controller setDrawerVisualStateBlock:[NappDrawerVisualState slideAndScaleVisualStateBlock]]; - break; - case 2: - [controller setDrawerVisualStateBlock:[NappDrawerVisualState slideVisualStateBlock]]; - break; - case 3: - //[controller setDrawerVisualStateBlock:[NappDrawerVisualState swingingDoorVisualStateBlock]]; - [controller setDrawerVisualStateBlock:[NappDrawerVisualState noneVisualStateBlock]]; - break; - case 4: - [controller setDrawerVisualStateBlock:[NappDrawerVisualState parallax3VisualStateBlock]]; - break; - case 5: - [controller setDrawerVisualStateBlock:[NappDrawerVisualState parallax5VisualStateBlock]]; - break; - case 6: - [controller setDrawerVisualStateBlock:[NappDrawerVisualState parallax7VisualStateBlock]]; - break; - case 7: - [controller setDrawerVisualStateBlock:[NappDrawerVisualState fadeVisualStateBlock]]; - break; - case 100: - [controller setDrawerVisualStateBlock:[NappDrawerVisualState noneVisualStateBlock]]; - default: - [controller setDrawerVisualStateBlock:[NappDrawerVisualState noneVisualStateBlock]]; - break; - } +- (UIStatusBarStyle)preferredStatusBarStyle +{ + if (self.controller.showsStatusBarBackgroundView) { + return UIStatusBarStyleLightContent; + } else { + return UIStatusBarStyleDefault; + } +} +- (void)setStatusBarStyle_:(NSNumber *)style +{ + ENSURE_UI_THREAD(setStatusBarStyle_, style); + [[UIApplication sharedApplication] setStatusBarStyle:[style intValue]]; } +- (void)setAnimationMode_:(id)args +{ + ENSURE_UI_THREAD(setAnimationMode_, args); + int mode = [TiUtils intValue:args]; + switch (mode) { + case 1: + [controller setDrawerVisualStateBlock:[NappDrawerVisualState slideAndScaleVisualStateBlock]]; + break; + case 2: + [controller setDrawerVisualStateBlock:[NappDrawerVisualState slideVisualStateBlock]]; + break; + case 3: + //[controller setDrawerVisualStateBlock:[NappDrawerVisualState swingingDoorVisualStateBlock]]; + [controller setDrawerVisualStateBlock:[NappDrawerVisualState noneVisualStateBlock]]; + break; + case 4: + [controller setDrawerVisualStateBlock:[NappDrawerVisualState parallax3VisualStateBlock]]; + break; + case 5: + [controller setDrawerVisualStateBlock:[NappDrawerVisualState parallax5VisualStateBlock]]; + break; + case 6: + [controller setDrawerVisualStateBlock:[NappDrawerVisualState parallax7VisualStateBlock]]; + break; + case 7: + [controller setDrawerVisualStateBlock:[NappDrawerVisualState fadeVisualStateBlock]]; + break; + case 100: + [controller setDrawerVisualStateBlock:[NappDrawerVisualState noneVisualStateBlock]]; + default: + [controller setDrawerVisualStateBlock:[NappDrawerVisualState noneVisualStateBlock]]; + break; + } +} // API --(void)toggleLeftWindow:(id)args +- (void)toggleLeftWindow:(id)args { - ENSURE_UI_THREAD(toggleLeftWindow,args); - [controller toggleDrawerSide:MMDrawerSideLeft animated:YES completion:nil]; + ENSURE_UI_THREAD(toggleLeftWindow, args); + [controller toggleDrawerSide:MMDrawerSideLeft animated:YES completion:nil]; } --(void)toggleRightWindow:(id)args +- (void)toggleRightWindow:(id)args { - ENSURE_UI_THREAD(toggleRightWindow,args); - [controller toggleDrawerSide:MMDrawerSideRight animated:YES completion:nil]; + ENSURE_UI_THREAD(toggleRightWindow, args); + [controller toggleDrawerSide:MMDrawerSideRight animated:YES completion:nil]; } --(void)bounceLeftWindow:(id)args +- (void)bounceLeftWindow:(id)args { - ENSURE_UI_THREAD(bounceLeftWindow,args); - [controller bouncePreviewForDrawerSide:MMDrawerSideLeft completion:nil]; + ENSURE_UI_THREAD(bounceLeftWindow, args); + [controller bouncePreviewForDrawerSide:MMDrawerSideLeft completion:nil]; } --(void)bounceRightWindow:(id)args +- (void)bounceRightWindow:(id)args { - ENSURE_UI_THREAD(bounceRightWindow,args); - [controller bouncePreviewForDrawerSide:MMDrawerSideRight completion:nil]; + ENSURE_UI_THREAD(bounceRightWindow, args); + [controller bouncePreviewForDrawerSide:MMDrawerSideRight completion:nil]; } --(NSNumber*)isAnyWindowOpen:(id)args +- (NSNumber *)isAnyWindowOpen:(id)args { - return NUMBOOL(controller.openSide != MMDrawerSideNone); + return NUMBOOL(controller.openSide != MMDrawerSideNone); } --(NSNumber*)isLeftWindowOpen:(id)args +- (NSNumber *)isLeftWindowOpen:(id)args { - return NUMBOOL(controller.openSide == MMDrawerSideLeft); + return NUMBOOL(controller.openSide == MMDrawerSideLeft); } --(NSNumber*)isRightWindowOpen:(id)args +- (NSNumber *)isRightWindowOpen:(id)args { - return NUMBOOL(controller.openSide == MMDrawerSideRight); + return NUMBOOL(controller.openSide == MMDrawerSideRight); } +// Little hack to propagate focus/blur events +- (void)_fireStateEventForCurrentState +{ + if ([[self controller] openSide] == MMDrawerSideNone) { + if ([[self proxy] _hasListeners:@"centerWindowDidFocus"]) { + [[self proxy] fireEvent:@"centerWindowDidFocus"]; + } + } else { + if ([[self proxy] _hasListeners:@"centerWindowDidBlur"]) { + [[self proxy] fireEvent:@"centerWindowDidBlur"]; + } + } +} @end diff --git a/ios/Classes/DkNappDrawerDrawerProxy.h b/ios/Classes/DkNappDrawerDrawerProxy.h index 70d4e03..09d7742 100644 --- a/ios/Classes/DkNappDrawerDrawerProxy.h +++ b/ios/Classes/DkNappDrawerDrawerProxy.h @@ -6,12 +6,11 @@ * Appcelerator Titanium is Copyright (c) 2009-2010 by Appcelerator, Inc. * and licensed under the Apache Public License (version 2) */ +#import "MMDrawerController.h" #import "TiBase.h" #import "TiWindowProxy.h" -#import "MMDrawerController.h" @interface DkNappDrawerDrawerProxy : TiWindowProxy { - } @end diff --git a/ios/Classes/DkNappDrawerDrawerProxy.m b/ios/Classes/DkNappDrawerDrawerProxy.m index 9e8c11f..9c98083 100644 --- a/ios/Classes/DkNappDrawerDrawerProxy.m +++ b/ios/Classes/DkNappDrawerDrawerProxy.m @@ -13,71 +13,93 @@ @implementation DkNappDrawerDrawerProxy --(void)windowDidOpen { - [super windowDidOpen]; - [self reposition]; +- (void)windowDidOpen +{ + [super windowDidOpen]; + [self reposition]; } +- (void)windowWillClose +{ + TiViewProxy *leftWinProxy = [self valueForUndefinedKey:@"leftWindow"]; + TiViewProxy *rightWinProxy = [self valueForUndefinedKey:@"rightWindow"]; + TiViewProxy *centerWinProxy = [self valueForUndefinedKey:@"centerWindow"]; + [leftWinProxy windowWillClose]; + [rightWinProxy windowWillClose]; + [centerWinProxy windowWillClose]; --(void)windowWillClose { - TiViewProxy* leftWinProxy = [self valueForUndefinedKey:@"leftWindow"]; - TiViewProxy* rightWinProxy = [self valueForUndefinedKey:@"rightWindow"]; - TiViewProxy* centerWinProxy = [self valueForUndefinedKey:@"centerWindow"]; - [leftWinProxy windowWillClose]; - [rightWinProxy windowWillClose]; - [centerWinProxy windowWillClose]; - - [super windowWillClose]; + [super windowWillClose]; } --(void)windowDidClose{ - TiViewProxy* leftWinProxy = [self valueForUndefinedKey:@"leftWindow"]; - TiViewProxy* rightWinProxy = [self valueForUndefinedKey:@"rightWindow"]; - TiViewProxy* centerWinProxy = [self valueForUndefinedKey:@"centerWindow"]; - [leftWinProxy windowDidClose]; - [rightWinProxy windowDidClose]; - [centerWinProxy windowDidClose]; - - [super windowDidClose]; +- (void)windowDidClose +{ + TiViewProxy *leftWinProxy = [self valueForUndefinedKey:@"leftWindow"]; + TiViewProxy *rightWinProxy = [self valueForUndefinedKey:@"rightWindow"]; + TiViewProxy *centerWinProxy = [self valueForUndefinedKey:@"centerWindow"]; + [leftWinProxy windowDidClose]; + [rightWinProxy windowDidClose]; + [centerWinProxy windowDidClose]; + + [super windowDidClose]; } --(MMDrawerController *)_controller { - return [(DkNappDrawerDrawer*)[self view] controller]; +- (MMDrawerController *)_controller +{ + return [(DkNappDrawerDrawer *)[self view] controller]; } --(TiUIView*)newView { - return [[DkNappDrawerDrawer alloc] init]; +- (TiUIView *)newView +{ + return [[DkNappDrawerDrawer alloc] init]; } -# pragma API +#pragma API --(void)toggleLeftWindow:(id)args { - TiThreadPerformOnMainThread(^{[(DkNappDrawerDrawer*)[self view] toggleLeftWindow:args];}, NO); +- (void)toggleLeftWindow:(id)args +{ + TiThreadPerformOnMainThread(^{ + [(DkNappDrawerDrawer *)[self view] toggleLeftWindow:args]; + }, + NO); } --(void)toggleRightWindow:(id)args { - TiThreadPerformOnMainThread(^{[(DkNappDrawerDrawer*)[self view] toggleRightWindow:args];}, NO); +- (void)toggleRightWindow:(id)args +{ + TiThreadPerformOnMainThread(^{ + [(DkNappDrawerDrawer *)[self view] toggleRightWindow:args]; + }, + NO); } --(void)bounceLeftWindow:(id)args { - TiThreadPerformOnMainThread(^{[(DkNappDrawerDrawer*)[self view] bounceLeftWindow:args];}, NO); +- (void)bounceLeftWindow:(id)args +{ + TiThreadPerformOnMainThread(^{ + [(DkNappDrawerDrawer *)[self view] bounceLeftWindow:args]; + }, + NO); } --(void)bounceRightWindow:(id)args { - TiThreadPerformOnMainThread(^{[(DkNappDrawerDrawer*)[self view] bounceRightWindow:args];}, NO); +- (void)bounceRightWindow:(id)args +{ + TiThreadPerformOnMainThread(^{ + [(DkNappDrawerDrawer *)[self view] bounceRightWindow:args]; + }, + NO); } --(NSNumber*)isAnyWindowOpen:(id)args { - return [(DkNappDrawerDrawer*)[self view] isAnyWindowOpen:args]; +- (NSNumber *)isAnyWindowOpen:(id)args +{ + return [(DkNappDrawerDrawer *)[self view] isAnyWindowOpen:args]; } --(NSNumber*)isLeftWindowOpen:(id)args { - return [(DkNappDrawerDrawer*)[self view] isLeftWindowOpen:args]; +- (NSNumber *)isLeftWindowOpen:(id)args +{ + return [(DkNappDrawerDrawer *)[self view] isLeftWindowOpen:args]; } --(NSNumber*)isRightWindowOpen:(id)args { - return [(DkNappDrawerDrawer*)[self view] isRightWindowOpen:args]; +- (NSNumber *)isRightWindowOpen:(id)args +{ + return [(DkNappDrawerDrawer *)[self view] isRightWindowOpen:args]; } - @end diff --git a/ios/Classes/DkNappDrawerModule.h b/ios/Classes/DkNappDrawerModule.h index 7155e6b..0f7d805 100644 --- a/ios/Classes/DkNappDrawerModule.h +++ b/ios/Classes/DkNappDrawerModule.h @@ -8,8 +8,7 @@ */ #import "TiModule.h" -@interface DkNappDrawerModule : TiModule -{ +@interface DkNappDrawerModule : TiModule { } @end diff --git a/ios/Classes/DkNappDrawerModule.m b/ios/Classes/DkNappDrawerModule.m index 9217b0d..5e378b9 100644 --- a/ios/Classes/DkNappDrawerModule.m +++ b/ios/Classes/DkNappDrawerModule.m @@ -15,151 +15,91 @@ @implementation DkNappDrawerModule -# pragma mark GestureModes +#pragma mark GestureModes -MAKE_SYSTEM_PROP(CLOSE_MODE_NONE, MMCloseDrawerGestureModeNone); -MAKE_SYSTEM_PROP(CLOSE_MODE_ALL, MMCloseDrawerGestureModeAll); -MAKE_SYSTEM_PROP(CLOSE_MODE_PANNING_NAVBAR, MMCloseDrawerGestureModePanningNavigationBar); -MAKE_SYSTEM_PROP(CLOSE_MODE_PANNING_CENTERWINDOW, MMCloseDrawerGestureModePanningCenterView); +MAKE_SYSTEM_PROP(CLOSE_MODE_NONE, MMCloseDrawerGestureModeNone); +MAKE_SYSTEM_PROP(CLOSE_MODE_ALL, MMCloseDrawerGestureModeAll); +MAKE_SYSTEM_PROP(CLOSE_MODE_PANNING_NAVBAR, MMCloseDrawerGestureModePanningNavigationBar); +MAKE_SYSTEM_PROP(CLOSE_MODE_PANNING_CENTERWINDOW, MMCloseDrawerGestureModePanningCenterView); MAKE_SYSTEM_PROP(CLOSE_MODE_BEZEL_PANNING_CENTERWINDOW, MMCloseDrawerGestureModeBezelPanningCenterView); -MAKE_SYSTEM_PROP(CLOSE_MODE_TAP_NAVBAR, MMCloseDrawerGestureModeTapNavigationBar); -MAKE_SYSTEM_PROP(CLOSE_MODE_TAP_CENTERWINDOW, MMCloseDrawerGestureModeTapCenterView); -MAKE_SYSTEM_PROP(CLOSE_MODE_PANNING_DRAWER, MMCloseDrawerGestureModePanningDrawerView); +MAKE_SYSTEM_PROP(CLOSE_MODE_TAP_NAVBAR, MMCloseDrawerGestureModeTapNavigationBar); +MAKE_SYSTEM_PROP(CLOSE_MODE_TAP_CENTERWINDOW, MMCloseDrawerGestureModeTapCenterView); +MAKE_SYSTEM_PROP(CLOSE_MODE_PANNING_DRAWER, MMCloseDrawerGestureModePanningDrawerView); -MAKE_SYSTEM_PROP(OPEN_MODE_NONE, MMOpenDrawerGestureModeNone); -MAKE_SYSTEM_PROP(OPEN_MODE_ALL, MMOpenDrawerGestureModeAll); -MAKE_SYSTEM_PROP(OPEN_MODE_PANNING_NAVBAR, MMOpenDrawerGestureModePanningNavigationBar); -MAKE_SYSTEM_PROP(OPEN_MODE_PANNING_CENTERWINDOW, MMOpenDrawerGestureModePanningCenterView); -MAKE_SYSTEM_PROP(OPEN_MODE_BEZEL_PANNING_CENTERWINDOW, MMOpenDrawerGestureModeBezelPanningCenterView); +MAKE_SYSTEM_PROP(OPEN_MODE_NONE, MMOpenDrawerGestureModeNone); +MAKE_SYSTEM_PROP(OPEN_MODE_ALL, MMOpenDrawerGestureModeAll); +MAKE_SYSTEM_PROP(OPEN_MODE_PANNING_NAVBAR, MMOpenDrawerGestureModePanningNavigationBar); +MAKE_SYSTEM_PROP(OPEN_MODE_PANNING_CENTERWINDOW, MMOpenDrawerGestureModePanningCenterView); +MAKE_SYSTEM_PROP(OPEN_MODE_BEZEL_PANNING_CENTERWINDOW, MMOpenDrawerGestureModeBezelPanningCenterView); -MAKE_SYSTEM_PROP(OPEN_CENTER_MODE_NONE, MMDrawerOpenCenterInteractionModeNone); -MAKE_SYSTEM_PROP(OPEN_CENTER_MODE_FULL, MMDrawerOpenCenterInteractionModeFull); -MAKE_SYSTEM_PROP(OPEN_CENTER_MODE_NAVBAR, MMDrawerOpenCenterInteractionModeNavigationBarOnly); +MAKE_SYSTEM_PROP(OPEN_CENTER_MODE_NONE, MMDrawerOpenCenterInteractionModeNone); +MAKE_SYSTEM_PROP(OPEN_CENTER_MODE_FULL, MMDrawerOpenCenterInteractionModeFull); +MAKE_SYSTEM_PROP(OPEN_CENTER_MODE_NAVBAR, MMDrawerOpenCenterInteractionModeNavigationBarOnly); +#pragma mark AnimationModes -# pragma mark AnimationModes - -MAKE_SYSTEM_PROP(ANIMATION_SLIDE_SCALE, 1); -MAKE_SYSTEM_PROP(ANIMATION_SLIDE, 2); +MAKE_SYSTEM_PROP(ANIMATION_SLIDE_SCALE, 1); +MAKE_SYSTEM_PROP(ANIMATION_SLIDE, 2); //MAKE_SYSTEM_PROP(ANIMATION_SWINGING_DOOR, 3); -MAKE_SYSTEM_PROP(ANIMATION_PARALLAX_FACTOR_3, 4); -MAKE_SYSTEM_PROP(ANIMATION_PARALLAX_FACTOR_5, 5); -MAKE_SYSTEM_PROP(ANIMATION_PARALLAX_FACTOR_7, 6); -MAKE_SYSTEM_PROP(ANIMATION_FADE, 7); -MAKE_SYSTEM_PROP(ANIMATION_NONE, 100); - +MAKE_SYSTEM_PROP(ANIMATION_PARALLAX_FACTOR_3, 4); +MAKE_SYSTEM_PROP(ANIMATION_PARALLAX_FACTOR_5, 5); +MAKE_SYSTEM_PROP(ANIMATION_PARALLAX_FACTOR_7, 6); +MAKE_SYSTEM_PROP(ANIMATION_FADE, 7); +MAKE_SYSTEM_PROP(ANIMATION_NONE, 100); -# pragma mark StatusBar +#pragma mark StatusBar -MAKE_SYSTEM_PROP(STATUSBAR_BLACK,0); -MAKE_SYSTEM_PROP(STATUSBAR_WHITE,1); - -MAKE_SYSTEM_PROP(STATUSBAR_ANIMATION_NONE,0); -MAKE_SYSTEM_PROP(STATUSBAR_ANIMATION_FADE,1); -MAKE_SYSTEM_PROP(STATUSBAR_ANIMATION_SLIDE,2); +MAKE_SYSTEM_PROP(STATUSBAR_BLACK, UIStatusBarStyleDefault); +MAKE_SYSTEM_PROP(STATUSBAR_WHITE, UIStatusBarStyleLightContent); +MAKE_SYSTEM_PROP(STATUSBAR_ANIMATION_NONE, 0); +MAKE_SYSTEM_PROP(STATUSBAR_ANIMATION_FADE, 1); +MAKE_SYSTEM_PROP(STATUSBAR_ANIMATION_SLIDE, 2); #pragma mark Internal -// this is generated for your module, please do not change it --(id)moduleGUID +- (id)moduleGUID { - return @"2a446559-1d59-4808-aefc-7d02d3130ebb"; + return @"2a446559-1d59-4808-aefc-7d02d3130ebb"; } -// this is generated for your module, please do not change it --(NSString*)moduleId +- (NSString *)moduleId { - return @"dk.napp.drawer"; + return @"dk.napp.drawer"; } #pragma mark Lifecycle --(void)startup // module class startup method -{ - // this method is called when the module is first loaded - // you *must* call the superclass - [super startup]; - NSLog(@"[INFO] %@ loaded",self); -} - --(void)shutdown:(id)sender -{ - // this method is called when the module is being unloaded - // typically this is during shutdown. make sure you don't do too - // much processing here or the app will be quit forceably - - // you *must* call the superclass - [super shutdown:sender]; -} - -#pragma mark Cleanup - --(void)dealloc -{ - // release any resources that have been retained by the module - [super dealloc]; -} - -#pragma mark Internal Memory Management - --(void)didReceiveMemoryWarning:(NSNotification*)notification +- (void)startup { - // optionally release any resources that can be dynamically - // reloaded once memory is available - such as caches - [super didReceiveMemoryWarning:notification]; + [super startup]; + NSLog(@"[DEBUG] %@ loaded", self); } -#pragma mark Listener Notifications +#pragma Public APIs --(void)_listenerAdded:(NSString *)type count:(int)count +- (void)hideStatusBar:(id)args { - if (count == 1 && [type isEqualToString:@"my_event"]) - { - // the first (of potentially many) listener is being added - // for event named 'my_event' - } -} + ENSURE_SINGLE_ARG_OR_NIL(args, NSDictionary); + ENSURE_UI_THREAD(hideStatusBar, args); --(void)_listenerRemoved:(NSString *)type count:(int)count -{ - if (count == 0 && [type isEqualToString:@"my_event"]) - { - // the last listener called for event named 'my_event' has - // been removed, we can optionally clean up any resources - // since no body is listening at this point for that event - } + int style = [TiUtils intValue:@"animationStyle" properties:args def:UIStatusBarAnimationSlide]; + [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:style]; } - - -#pragma Public APIs - - --(void)hideStatusBar:(id)args +- (void)showStatusBar:(id)args { - ENSURE_SINGLE_ARG_OR_NIL(args,NSDictionary); - ENSURE_UI_THREAD(hideStatusBar,args); - - int style = [TiUtils intValue:@"animationStyle" properties:args def:UIStatusBarAnimationSlide]; - [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:style]; -} + ENSURE_SINGLE_ARG_OR_NIL(args, NSDictionary); + ENSURE_UI_THREAD(showStatusBar, args); - --(void)showStatusBar:(id)args -{ - ENSURE_SINGLE_ARG_OR_NIL(args,NSDictionary); - ENSURE_UI_THREAD(showStatusBar,args); - - int style = [TiUtils intValue:@"animationStyle" properties:args def:UIStatusBarAnimationSlide]; - [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:style]; + int style = [TiUtils intValue:@"animationStyle" properties:args def:UIStatusBarAnimationSlide]; + [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:style]; } - --(void)setStatusBarStyle:(NSNumber *)style +- (void)setStatusBarStyle:(NSNumber *)style { - ENSURE_UI_THREAD(setStatusBarStyle,style); - [[UIApplication sharedApplication] setStatusBarStyle:[style intValue]]; + ENSURE_UI_THREAD(setStatusBarStyle, style); + [[UIApplication sharedApplication] setStatusBarStyle:[style intValue]]; } @end diff --git a/ios/Classes/DkNappDrawerModuleAssets.h b/ios/Classes/DkNappDrawerModuleAssets.h index 23b9578..c277db4 100644 --- a/ios/Classes/DkNappDrawerModuleAssets.h +++ b/ios/Classes/DkNappDrawerModuleAssets.h @@ -6,10 +6,9 @@ * Appcelerator Titanium is Copyright (c) 2009-2010 by Appcelerator, Inc. * and licensed under the Apache Public License (version 2) */ -@interface DkNappDrawerModuleAssets : NSObject -{ +@interface DkNappDrawerModuleAssets : NSObject { } -- (NSData*) moduleAsset; -- (NSData*) resolveModuleAsset:(NSString*)path; +- (NSData *)moduleAsset; +- (NSData *)resolveModuleAsset:(NSString *)path; @end diff --git a/ios/Classes/DkNappDrawerModuleAssets.m b/ios/Classes/DkNappDrawerModuleAssets.m index 385288c..71f65e5 100644 --- a/ios/Classes/DkNappDrawerModuleAssets.m +++ b/ios/Classes/DkNappDrawerModuleAssets.m @@ -1,10 +1,5 @@ /** - * Module developed by Napp ApS - * www.napp.dk - * Mads Møller - * - * Appcelerator Titanium is Copyright (c) 2009-2010 by Appcelerator, Inc. - * and licensed under the Apache Public License (version 2) + * This is a generated file. Do not edit or your changes will be lost */ #import "DkNappDrawerModuleAssets.h" @@ -12,20 +7,18 @@ @implementation DkNappDrawerModuleAssets -- (NSData*) moduleAsset +- (NSData *)moduleAsset { - //##TI_AUTOGEN_BEGIN asset - //Compiler generates code for asset here - return nil; // DEFAULT BEHAVIOR - //##TI_AUTOGEN_END asset + + + return nil; } -- (NSData*) resolveModuleAsset:(NSString*)path +- (NSData *)resolveModuleAsset:(NSString *)path { - //##TI_AUTOGEN_BEGIN resolve_asset - //Compiler generates code for asset resolution here - return nil; // DEFAULT BEHAVIOR - //##TI_AUTOGEN_END resolve_asset + + + return nil; } @end diff --git a/ios/Classes/MMDrawerController/.gitignore b/ios/Classes/MMDrawerController/.gitignore new file mode 100644 index 0000000..31e6fd9 --- /dev/null +++ b/ios/Classes/MMDrawerController/.gitignore @@ -0,0 +1,17 @@ +# Xcode +.DS_Store +*/build/* +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +profile +*.moved-aside +DerivedData +.idea/ +*.hmap diff --git a/ios/Classes/MMDrawerController/.travis.yml b/ios/Classes/MMDrawerController/.travis.yml new file mode 100644 index 0000000..ec14b54 --- /dev/null +++ b/ios/Classes/MMDrawerController/.travis.yml @@ -0,0 +1,2 @@ +language: objective-c +script: xcodebuild -project KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/ -scheme MMDrawerControllerKitchenSink -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO \ No newline at end of file diff --git a/ios/Classes/MMDrawerController/CHANGELOG.md b/ios/Classes/MMDrawerController/CHANGELOG.md new file mode 100644 index 0000000..366be1f --- /dev/null +++ b/ios/Classes/MMDrawerController/CHANGELOG.md @@ -0,0 +1,114 @@ +#MMDrawerController Changelog +##[0.5.7](https://github.com/mutualmobile/MMDrawerController/issues?q=milestone%3A0.5.7+is%3Aclosed)(Monday, August 25th, 2014) +###Fixed +* **FIXED** an issue ([#271](https://github.com/mutualmobile/MMDrawerController/pull/271)) where state restoration would cause multiple calls to viewDidAppear. (pronebird) +* **FIXED** an issue ([#269](https://github.com/mutualmobile/MMDrawerController/pull/269)) where an internal method name was misnamed. (shoecart) + +##[0.5.6](https://github.com/mutualmobile/MMDrawerController/issues?milestone=14&page=1&state=closed)(Monday, June 9th, 2014) +###Fixed +* **FIXED** an issue ([#259](https://github.com/mutualmobile/MMDrawerController/pull/259)) where the side would rarely show up hidden when opening. (Eric Miller, Lars Anderson, Kevin Harwood) +* **FIXED** an issue ([#251](https://github.com/mutualmobile/MMDrawerController/pull/251)) where the completion block would not be called if you set the new center view controller with a full close animation while the drawer was closed. (ThuggishNuggets) +* **FIXED** an issue ([#246](https://github.com/mutualmobile/MMDrawerController/pull/246)) where user could interact with content while an animation completed. (jgallagher, Kevin Harwood) +* **FIXED** an issue ([#232](https://github.com/mutualmobile/MMDrawerController/pull/232)) where the drawer controller was not properly calling willMoveToParentViewController:nil when removing children from the drawer container view controller. (Josh Berlin, Kevin Harwood) +* **FIXED** an issue ([#222](https://github.com/mutualmobile/MMDrawerController/pull/222)) where a user interacting with during rotation would cause UI glitches. (Kevin Harwood, vkormushkin) +* **FIXED** an ([#220](https://github.com/mutualmobile/MMDrawerController/pull/220)) where we were setting the background color on the wrong view, which prevented setting a custom background color for the entire view. (Kevin Harwood, David Dulak, trawor) + +##[0.5.5](https://github.com/mutualmobile/MMDrawerController/releases/tag/0.5.5) (Wednesday, April 30, 2014) +###Fixed +* **FIXED** an issue ([#244](https://github.com/mutualmobile/MMDrawerController/pull/244)) where a user could continue to interact with the view while a pan gesture animation was ongoing. (Kevin Harwood, Patrick Hernandez) + +##[0.5.4](https://github.com/mutualmobile/MMDrawerController/releases/tag/0.5.4) (Tuesday, April 15, 2014) +###Fixed +* **FIXED** an issue ([#240](https://github.com/mutualmobile/MMDrawerController/pull/240)) where the center container view controller would be init'ed twice. (Lars Anderson) +* **FIXED** an issue ([#226](https://github.com/mutualmobile/MMDrawerController/pull/226)) where the side drawer would not be refreshed on a viewWill/DidAppear call. (kk-achu) +* **FIXED** an issue ([#224](https://github.com/mutualmobile/MMDrawerController/pull/224)) where we had some unreachable code. (tewha) + + +##[0.5.3](https://github.com/mutualmobile/MMDrawerController/releases/tag/0.5.3) (Tuesday, February 18, 2014) +###Fixed +* **FIXED** an issue ([#219](https://github.com/mutualmobile/MMDrawerController/pull/219)) where you would get an unbalanced appearance method call if you set the center view controller to the same center view controller. + +##[0.5.2](https://github.com/mutualmobile/MMDrawerController/releases/tag/0.5.2) (Friday, January 31, 2014) +###New +* **Added Highlighting for iOS 7 Drawer Button Item** - Now supporting button highlighting. Also stream lined code path for iOS 6 menu button. ([#199](https://github.com/mutualmobile/MMDrawerController/pull/119)) (TomSwift) + +###Fixed +* **FIXED** a Clang Analyzer issue ([#120](https://github.com/mutualmobile/MMDrawerController/pull/120)) found in Xcode 5. (klundberg) +* **FIXED** an issue ([#124](https://github.com/mutualmobile/MMDrawerController/pull/124)) where the navigation bar gestures would not work if a toolbar was displayed in the center view controller. (tbveralrud) +* **FIXED** an issue ([#152](https://github.com/mutualmobile/MMDrawerController/pull/152)) where two childControllerContainers view could be init'ed and added to the view hierarchy. (Kevin Harwood, JonasGessner) +* **FIXED** an issue ([#163](https://github.com/mutualmobile/MMDrawerController/pull/163)) where the navigation bar touch areas were smaller than they were supposed to be. (antonholmquist) +* **FIXED** an issue ([#177](https://github.com/mutualmobile/MMDrawerController/pull/177)) where disabling the shadow caused a performance issue in iOS 7. (Lars Anderson) +* **FIXED** an issue ([#211](https://github.com/mutualmobile/MMDrawerController/pull/211)) where the side drawer may become hidden if you try to interact with it during an animation. (Kevin Harwood, antonholmquist) +* **FIXED** an issue ([#212](https://github.com/mutualmobile/MMDrawerController/pull/212)) where the view controller appearance methods were not correctly send to the center view controller if you exchanged it while neither drawer was open. (Kevin Harwood, Club15CC) + +##[0.5.1](https://github.com/mutualmobile/MMDrawerController/releases/tag/0.5.1) (Wednesday, September 18, 2013) +###Fixed +* **FIXED** an issue ([#110](https://github.com/mutualmobile/MMDrawerController/pull/110)) where you could not compile for iOS 6 using Xcode 4.6.3. + +##[0.5.0](https://github.com/mutualmobile/MMDrawerController/releases/tag/0.5.0) (Tuesday, September 17, 2013) +###New +* **iOS 7 Support** - Compiled to work with iOS 7 +* **iOS 7 Status Bar Support** - Now includes a feature to drawer an iOS 6 style status bar, allowing your drawer animations to not impact the status bar area. Consult the README or the documentation for further information. +* **MMDrawerBarButtonItem Design** - Now designed to fit in with the iOS 7 aesthetic. +* **MMDrawerBarButtonItem TintColor** - Now uses tintColor in iOS 7. +* Example project now runs in both iOS 6 and iOS 7 with two different visual designs. + +###Known Issues +* iOS 7 animations transforms are a bit choppy. This issue requires further investigation, and is being tracked [here](https://github.com/mutualmobile/MMDrawerController/issues/101). + +##[0.4.0](https://github.com/mutualmobile/MMDrawerController/issues?milestone=8&page=1&state=closed) (Monday, August 19, 2013) +###New +* **State Restoration Support** - `MMDrawerController` now supports state restoration, and will save the state of the open side as well. Consult the [documentation](https://github.com/mutualmobile/MMDrawerController#state-restoration) for more information. ([#69](https://github.com/mutualmobile/MMDrawerController/pull/69)). (Kevin Harwood, djibouti33) +* **Better Subclass Support** - `MMDrawerController` now contains an additional Subclass header file, to allow subclasses to access protected methods of the framework. Please consult the [documentation](https://github.com/mutualmobile/MMDrawerController#subclassing) for additional details on how to properly subclass `MMDrawerController`. ([#37](https://github.com/mutualmobile/MMDrawerController/pull/37)). (Lars Anderson) +* **initWithCoder: Support** - `MMDrawerController` now implements `initWithCoder:`, making it easier to integrate with a storyboard. Looks for an official extension from @TomSwift providing storyboard integration. ([#81](https://github.com/mutualmobile/MMDrawerController/pull/81)). (Tom Swift) +* **Improved parent drawer controller detection** - `mm_drawerController` will now walk up the entire view controller stack looking for the parent, making it easier to access the drawer controller from any child view controller in the hierarchy. ([#70](https://github.com/mutualmobile/MMDrawerController/pull/70)). (messi) + +###Fixed +* **FIXED** an issue ([#66](https://github.com/mutualmobile/MMDrawerController/pull/66)) where you would get unbalanced begin/end appearance transitions when using a non-animated `setCenterViewController:...` method. (Kevin Harwood, jsankey) +* **FIXED** an issue ([#63](https://github.com/mutualmobile/MMDrawerController/pull/63)) where the visual state block received invalid transform values. (Kevin Harwood) +* **FIXED** an issue ([#71](https://github.com/mutualmobile/MMDrawerController/pull/71)) where the side drawer could become blank if you called the `closeDrawerAnimated:...` while the drawer was closing. (Kevin Harwood, Bryan Wang) +* **FIXED** an issue ([#80](https://github.com/mutualmobile/MMDrawerController/pull/80)) where the block parameters were not named appropriately. (Kevin Harwood, Joao Nunes) + +##[0.3.0](https://github.com/mutualmobile/MMDrawerController/issues?milestone=6&page=1&state=closed) (Monday, July 22nd, 2013) +###New +* Added a block to determine if a gesture should be recognized, giving the implementer a chance to define where a gesture should be recognized within their views. Please consult the [README](https://github.com/mutualmobile/mmdrawercontroller#custom-gesture-recognizer-support) for additional details. ([#25](https://github.com/mutualmobile/MMDrawerController/pull/25)). (Kevin Harwood) + +###Fixed +* **FIXED** an issue ([#56](https://github.com/mutualmobile/MMDrawerController/pull/56)) where the bezel gesture would be detected even if there was no drawer controller on that side. (Kevin Harwood) +* **FIXED** an issue ([#50](https://github.com/mutualmobile/MMDrawerController/pull/50)) where a subclass could get stuck in an infinite loop in the `init` method. (Tuan Cao) + +##[0.2.1](https://github.com/mutualmobile/MMDrawerController/issues?milestone=7&state=closed) (Friday, June 21st, 2013) +###Fixed +* **FIXED** an issue([#42](https://github.com/mutualmobile/MMDrawerController/issues/42)) where the gesture completion block was not being called if the gesture action closed the drawer completely. (Kevin Harwood) + +##[0.2.0](https://github.com/mutualmobile/MMDrawerController/issues?milestone=5&state=closed) (Tuesday, June 4th, 2013) +###New +* Added support for using the panning velocity to complete the animation. It now looks *much* better ([#18](https://github.com/mutualmobile/MMDrawerController/issues/18)). (Kevin Harwood) +* Added a new callback block to get notified when a gesture animation has completed ([#20](https://github.com/mutualmobile/MMDrawerController/issues/20)). (Kevin Harwood) + +###Fixed +* **FIXED** an issue([#23](https://github.com/mutualmobile/MMDrawerController/issues/23)) where the drawer could bounce, even if a drawer was open. (Kevin Harwood) +* **FIXED** an issue([#38](https://github.com/mutualmobile/MMDrawerController/issues/38)) the designator initializer for `UIViewController` was not properly setting default values. (poteryaysya) +* **FIXED** an issue([#24](https://github.com/mutualmobile/MMDrawerController/issues/24)) where some documentation was incorrect. (Kevin Harwood) + +##[0.1.0](https://github.com/mutualmobile/MMDrawerController/issues?milestone=3&page=1&state=closed) (Wednesday, May 15th, 2013) +###New +* `MMDrawerController` now properly supports full view controller containment. The drawer view controllers will properly receive their view appearance methods at the correct time now, including every time they are about to become visible. Please note that `mm_drawerWillApear` has now been deprecated. More notes below. (Kevin Harwood, Lars Anderson) + +###Fixed +* **FIXED** an issue([#9](https://github.com/mutualmobile/MMDrawerController/issues/9)) where the drawer could bounce, even if no drawer was set. (Kevin Harwood) +* **FIXED** an issue([#14](https://github.com/mutualmobile/MMDrawerController/issues/14)) where open center interaction state could be incorrectly applied if a new view controller is pushed onto a center view controller when a drawer is open. (Kevin Harwood) + +###Deprecated +* Support for the `mm_drawerWillAppear` method in the `UIViewController+MMDrawerController` category is no longer available. Please move any logic contained within this method to `viewWillAppear:` in your drawer view controllers. This method will no longer be called going forward. + +##[0.0.2](https://github.com/mutualmobile/MMDrawerController/issues?milestone=2&state=closed) (Thursday, May 9th, 2013) +###New +* Improved the example to allow you to disable the left or right side drawer controller. (Kevin Harwood) + +###Fixed +* **FIXED** an issue([#6](https://github.com/mutualmobile/MMDrawerController/issues/1)) where hidden side drawer controllers received touches if the center view controller was set to userInteraction NO. (Kevin Harwood) +* **FIXED** an issue([#1](https://github.com/mutualmobile/MMDrawerController/issues/1)) where `shouldStretchDrawer` caused drawer controllers with only one side drawer to stretch in the wrong direction (Lars Anderson, Kevin Harwood) + +##0.0.1 (Wednesday, May 8th, 2013) + * Initial Library Release diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/Default-568h@2x.png b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/Default-568h@2x.png new file mode 100644 index 0000000..0891b7a Binary files /dev/null and b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/Default-568h@2x.png differ diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/Default.png b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/Default.png new file mode 100644 index 0000000..4c8ca6f Binary files /dev/null and b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/Default.png differ diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/Default@2x.png b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/Default@2x.png new file mode 100644 index 0000000..35b84cf Binary files /dev/null and b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/Default@2x.png differ diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMAppDelegate.h b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMAppDelegate.h new file mode 100644 index 0000000..7983b50 --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMAppDelegate.h @@ -0,0 +1,28 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import + +@interface MMAppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMAppDelegate.m b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMAppDelegate.m new file mode 100644 index 0000000..a5a4eb5 --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMAppDelegate.m @@ -0,0 +1,147 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import "MMAppDelegate.h" +#import "MMDrawerController.h" +#import "MMExampleCenterTableViewController.h" +#import "MMExampleLeftSideDrawerViewController.h" +#import "MMExampleRightSideDrawerViewController.h" +#import "MMDrawerVisualState.h" +#import "MMExampleDrawerVisualStateManager.h" +#import "MMNavigationController.h" + +#import + +@interface MMAppDelegate () +@property (nonatomic,strong) MMDrawerController * drawerController; + +@end + +@implementation MMAppDelegate +-(BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ + + UIViewController * leftSideDrawerViewController = [[MMExampleLeftSideDrawerViewController alloc] init]; + + UIViewController * centerViewController = [[MMExampleCenterTableViewController alloc] init]; + + UIViewController * rightSideDrawerViewController = [[MMExampleRightSideDrawerViewController alloc] init]; + + UINavigationController * navigationController = [[MMNavigationController alloc] initWithRootViewController:centerViewController]; + [navigationController setRestorationIdentifier:@"MMExampleCenterNavigationControllerRestorationKey"]; + if(OSVersionIsAtLeastiOS7()){ + UINavigationController * rightSideNavController = [[MMNavigationController alloc] initWithRootViewController:rightSideDrawerViewController]; + [rightSideNavController setRestorationIdentifier:@"MMExampleRightNavigationControllerRestorationKey"]; + UINavigationController * leftSideNavController = [[MMNavigationController alloc] initWithRootViewController:leftSideDrawerViewController]; + [leftSideNavController setRestorationIdentifier:@"MMExampleLeftNavigationControllerRestorationKey"]; + self.drawerController = [[MMDrawerController alloc] + initWithCenterViewController:navigationController + leftDrawerViewController:leftSideNavController + rightDrawerViewController:rightSideNavController]; + [self.drawerController setShowsShadow:NO]; + } + else{ + self.drawerController = [[MMDrawerController alloc] + initWithCenterViewController:navigationController + leftDrawerViewController:leftSideDrawerViewController + rightDrawerViewController:rightSideDrawerViewController]; + } + [self.drawerController setRestorationIdentifier:@"MMDrawer"]; + [self.drawerController setMaximumRightDrawerWidth:200.0]; + [self.drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll]; + [self.drawerController setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll]; + + [self.drawerController + setDrawerVisualStateBlock:^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) { + MMDrawerControllerDrawerVisualStateBlock block; + block = [[MMExampleDrawerVisualStateManager sharedManager] + drawerVisualStateBlockForDrawerSide:drawerSide]; + if(block){ + block(drawerController, drawerSide, percentVisible); + } + }]; + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + if(OSVersionIsAtLeastiOS7()){ + UIColor * tintColor = [UIColor colorWithRed:29.0/255.0 + green:173.0/255.0 + blue:234.0/255.0 + alpha:1.0]; + [self.window setTintColor:tintColor]; + } + [self.window setRootViewController:self.drawerController]; + + return YES; +} + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + self.window.backgroundColor = [UIColor whiteColor]; + [self.window makeKeyAndVisible]; + + return YES; +} + +- (BOOL)application:(UIApplication *)application shouldSaveApplicationState:(NSCoder *)coder{ + return YES; +} + +- (BOOL)application:(UIApplication *)application shouldRestoreApplicationState:(NSCoder *)coder{ + return YES; +} + +- (UIViewController *)application:(UIApplication *)application viewControllerWithRestorationIdentifierPath:(NSArray *)identifierComponents coder:(NSCoder *)coder +{ + NSString * key = [identifierComponents lastObject]; + if([key isEqualToString:@"MMDrawer"]){ + return self.window.rootViewController; + } + else if ([key isEqualToString:@"MMExampleCenterNavigationControllerRestorationKey"]) { + return ((MMDrawerController *)self.window.rootViewController).centerViewController; + } + else if ([key isEqualToString:@"MMExampleRightNavigationControllerRestorationKey"]) { + return ((MMDrawerController *)self.window.rootViewController).rightDrawerViewController; + } + else if ([key isEqualToString:@"MMExampleLeftNavigationControllerRestorationKey"]) { + return ((MMDrawerController *)self.window.rootViewController).leftDrawerViewController; + } + else if ([key isEqualToString:@"MMExampleLeftSideDrawerController"]){ + UIViewController * leftVC = ((MMDrawerController *)self.window.rootViewController).leftDrawerViewController; + if([leftVC isKindOfClass:[UINavigationController class]]){ + return [(UINavigationController*)leftVC topViewController]; + } + else { + return leftVC; + } + + } + else if ([key isEqualToString:@"MMExampleRightSideDrawerController"]){ + UIViewController * rightVC = ((MMDrawerController *)self.window.rootViewController).rightDrawerViewController; + if([rightVC isKindOfClass:[UINavigationController class]]){ + return [(UINavigationController*)rightVC topViewController]; + } + else { + return rightVC; + } + } + return nil; +} + +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMCenterTableViewCell.h b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMCenterTableViewCell.h new file mode 100644 index 0000000..97c2183 --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMCenterTableViewCell.h @@ -0,0 +1,26 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import "MMTableViewCell.h" + +@interface MMCenterTableViewCell : MMTableViewCell + +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMCenterTableViewCell.m b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMCenterTableViewCell.m new file mode 100644 index 0000000..0d11206 --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMCenterTableViewCell.m @@ -0,0 +1,43 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import "MMCenterTableViewCell.h" + +@implementation MMCenterTableViewCell + +- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier +{ + self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; + if (self) { + [self setAccessoryCheckmarkColor:[UIColor colorWithRed:13.0/255.0 + green:88.0/255.0 + blue:161.0/255.0 + alpha:1.0]]; + } + return self; +} + +-(void)updateContentForNewContentSize{ + if([[UIFont class] respondsToSelector:@selector(preferredFontForTextStyle:)]){ + [self.textLabel setFont:[UIFont preferredFontForTextStyle:UIFontTextStyleBody]]; + } +} +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMDrawerControllerKitchenSink-Prefix.pch b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMDrawerControllerKitchenSink-Prefix.pch new file mode 100644 index 0000000..a5bafa3 --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMDrawerControllerKitchenSink-Prefix.pch @@ -0,0 +1,19 @@ +// +// Prefix header for all source files of the 'MMDrawerController' target in the 'MMDrawerController' project +// + +#import + +#ifndef __IPHONE_3_0 +#warning "This project uses features only available in iOS SDK 3.0 and later." +#endif + +#ifdef __OBJC__ + #import + #import +#endif + + +static BOOL OSVersionIsAtLeastiOS7() { + return (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1); +} \ No newline at end of file diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleCenterTableViewController.h b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleCenterTableViewController.h new file mode 100644 index 0000000..6bdd4d5 --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleCenterTableViewController.h @@ -0,0 +1,28 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import +#import "MMExampleViewController.h" + +@interface MMExampleCenterTableViewController : MMExampleViewController +@property (nonatomic,strong) UITableView * tableView; + +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleCenterTableViewController.m b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleCenterTableViewController.m new file mode 100644 index 0000000..287df67 --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleCenterTableViewController.m @@ -0,0 +1,365 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import "MMExampleCenterTableViewController.h" +#import "MMExampleDrawerVisualStateManager.h" +#import "UIViewController+MMDrawerController.h" +#import "MMDrawerBarButtonItem.h" +#import "MMLogoView.h" +#import "MMCenterTableViewCell.h" +#import "MMExampleLeftSideDrawerViewController.h" +#import "MMExampleRightSideDrawerViewController.h" +#import "MMNavigationController.h" + +#import + +typedef NS_ENUM(NSInteger, MMCenterViewControllerSection){ + MMCenterViewControllerSectionLeftViewState, + MMCenterViewControllerSectionLeftDrawerAnimation, + MMCenterViewControllerSectionRightViewState, + MMCenterViewControllerSectionRightDrawerAnimation, +}; + +@interface MMExampleCenterTableViewController () + +@end + +@implementation MMExampleCenterTableViewController + +- (id)init +{ + self = [super init]; + if (self) { + [self setRestorationIdentifier:@"MMExampleCenterControllerRestorationKey"]; + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + + _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped]; + [self.tableView setDelegate:self]; + [self.tableView setDataSource:self]; + [self.view addSubview:self.tableView]; + [self.tableView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight]; + + UITapGestureRecognizer * doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTap:)]; + [doubleTap setNumberOfTapsRequired:2]; + [self.view addGestureRecognizer:doubleTap]; + + UITapGestureRecognizer * twoFingerDoubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(twoFingerDoubleTap:)]; + [twoFingerDoubleTap setNumberOfTapsRequired:2]; + [twoFingerDoubleTap setNumberOfTouchesRequired:2]; + [self.view addGestureRecognizer:twoFingerDoubleTap]; + + + [self setupLeftMenuButton]; + [self setupRightMenuButton]; + + if(OSVersionIsAtLeastiOS7()){ + UIColor * barColor = [UIColor + colorWithRed:247.0/255.0 + green:249.0/255.0 + blue:250.0/255.0 + alpha:1.0]; + [self.navigationController.navigationBar setBarTintColor:barColor]; + } + else { + UIColor * barColor = [UIColor + colorWithRed:78.0/255.0 + green:156.0/255.0 + blue:206.0/255.0 + alpha:1.0]; + [self.navigationController.navigationBar setTintColor:barColor]; + } + + + MMLogoView * logo = [[MMLogoView alloc] initWithFrame:CGRectMake(0, 0, 29, 31)]; + [self.navigationItem setTitleView:logo]; + [self.navigationController.view.layer setCornerRadius:10.0f]; + + + UIView *backView = [[UIView alloc] init]; + [backView setBackgroundColor:[UIColor colorWithRed:208.0/255.0 + green:208.0/255.0 + blue:208.0/255.0 + alpha:1.0]]; + [self.tableView setBackgroundView:backView]; +} + +-(void)viewWillAppear:(BOOL)animated{ + [super viewWillAppear:animated]; + NSLog(@"Center will appear"); +} + +-(void)viewDidAppear:(BOOL)animated{ + [super viewDidAppear:animated]; + NSLog(@"Center did appear"); +} + +-(void)viewWillDisappear:(BOOL)animated{ + [super viewWillDisappear:animated]; + NSLog(@"Center will disappear"); +} + +-(void)viewDidDisappear:(BOOL)animated{ + [super viewDidDisappear:animated]; + NSLog(@"Center did disappear"); +} + +-(void)setupLeftMenuButton{ + MMDrawerBarButtonItem * leftDrawerButton = [[MMDrawerBarButtonItem alloc] initWithTarget:self action:@selector(leftDrawerButtonPress:)]; + [self.navigationItem setLeftBarButtonItem:leftDrawerButton animated:YES]; +} + +-(void)setupRightMenuButton{ + MMDrawerBarButtonItem * rightDrawerButton = [[MMDrawerBarButtonItem alloc] initWithTarget:self action:@selector(rightDrawerButtonPress:)]; + [self.navigationItem setRightBarButtonItem:rightDrawerButton animated:YES]; +} + +-(void)contentSizeDidChange:(NSString *)size{ + [self.tableView reloadData]; +} + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return 4; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + // Return the number of rows in the section. + switch (section) { + case MMCenterViewControllerSectionLeftDrawerAnimation: + case MMCenterViewControllerSectionRightDrawerAnimation: + return 5; + case MMCenterViewControllerSectionLeftViewState: + case MMCenterViewControllerSectionRightViewState: + return 1; + default: + return 0; + } +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + static NSString *CellIdentifier = @"Cell"; + + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; + if (cell == nil) { + + cell = [[MMCenterTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; + [cell setSelectionStyle:UITableViewCellSelectionStyleGray]; + } + + UIColor * selectedColor = [UIColor + colorWithRed:1.0/255.0 + green:15.0/255.0 + blue:25.0/255.0 + alpha:1.0]; + UIColor * unselectedColor = [UIColor + colorWithRed:79.0/255.0 + green:93.0/255.0 + blue:102.0/255.0 + alpha:1.0]; + + switch (indexPath.section) { + case MMCenterViewControllerSectionLeftDrawerAnimation: + case MMCenterViewControllerSectionRightDrawerAnimation:{ + MMDrawerAnimationType animationTypeForSection; + if(indexPath.section == MMCenterViewControllerSectionLeftDrawerAnimation){ + animationTypeForSection = [[MMExampleDrawerVisualStateManager sharedManager] leftDrawerAnimationType]; + } + else { + animationTypeForSection = [[MMExampleDrawerVisualStateManager sharedManager] rightDrawerAnimationType]; + } + + if(animationTypeForSection == indexPath.row){ + [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; + [cell.textLabel setTextColor:selectedColor]; + } + else { + [cell setAccessoryType:UITableViewCellAccessoryNone]; + [cell.textLabel setTextColor:unselectedColor]; + } + switch (indexPath.row) { + case MMDrawerAnimationTypeNone: + [cell.textLabel setText:@"None"]; + break; + case MMDrawerAnimationTypeSlide: + [cell.textLabel setText:@"Slide"]; + break; + case MMDrawerAnimationTypeSlideAndScale: + [cell.textLabel setText:@"Slide and Scale"]; + break; + case MMDrawerAnimationTypeSwingingDoor: + [cell.textLabel setText:@"Swinging Door"]; + break; + case MMDrawerAnimationTypeParallax: + [cell.textLabel setText:@"Parallax"]; + break; + default: + break; + } + break; + } + case MMCenterViewControllerSectionLeftViewState:{ + [cell.textLabel setText:@"Enabled"]; + if(self.mm_drawerController.leftDrawerViewController){ + [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; + [cell.textLabel setTextColor:selectedColor]; + } + else{ + [cell setAccessoryType:UITableViewCellAccessoryNone]; + [cell.textLabel setTextColor:unselectedColor]; + } + break; + } + case MMCenterViewControllerSectionRightViewState:{ + [cell.textLabel setText:@"Enabled"]; + if(self.mm_drawerController.rightDrawerViewController){ + [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; + [cell.textLabel setTextColor:selectedColor]; + } + else{ + [cell setAccessoryType:UITableViewCellAccessoryNone]; + [cell.textLabel setTextColor:unselectedColor]; + } + break; + } + default: + break; + } + + return cell; +} + +-(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{ + switch (section) { + case MMCenterViewControllerSectionLeftDrawerAnimation: + return @"Left Drawer Animation"; + case MMCenterViewControllerSectionRightDrawerAnimation: + return @"Right Drawer Animation"; + case MMCenterViewControllerSectionLeftViewState: + return @"Left Drawer"; + case MMCenterViewControllerSectionRightViewState: + return @"Right Drawer"; + default: + return nil; + } +} +#pragma mark - Table view delegate + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath +{ + switch (indexPath.section) { + case MMCenterViewControllerSectionLeftDrawerAnimation: + case MMCenterViewControllerSectionRightDrawerAnimation:{ + if(indexPath.section == MMCenterViewControllerSectionLeftDrawerAnimation){ + [[MMExampleDrawerVisualStateManager sharedManager] setLeftDrawerAnimationType:indexPath.row]; + } + else { + [[MMExampleDrawerVisualStateManager sharedManager] setRightDrawerAnimationType:indexPath.row]; + } + [tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone]; + [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; + [tableView deselectRowAtIndexPath:indexPath animated:YES]; + break; + } + case MMCenterViewControllerSectionLeftViewState: + case MMCenterViewControllerSectionRightViewState:{ + UIViewController * sideDrawerViewController; + MMDrawerSide drawerSide = MMDrawerSideNone; + if(indexPath.section == MMCenterViewControllerSectionLeftViewState){ + sideDrawerViewController = self.mm_drawerController.leftDrawerViewController; + drawerSide = MMDrawerSideLeft; + } + else if(indexPath.section == MMCenterViewControllerSectionRightViewState){ + sideDrawerViewController = self.mm_drawerController.rightDrawerViewController; + drawerSide = MMDrawerSideRight; + } + + if(sideDrawerViewController){ + [self.mm_drawerController + closeDrawerAnimated:YES + completion:^(BOOL finished) { + if(drawerSide == MMDrawerSideLeft){ + [self.mm_drawerController setLeftDrawerViewController:nil]; + [self.navigationItem setLeftBarButtonItems:nil animated:YES]; + } + else if(drawerSide == MMDrawerSideRight){ + [self.mm_drawerController setRightDrawerViewController:nil]; + [self.navigationItem setRightBarButtonItem:nil animated:YES]; + } + [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; + [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; + [tableView deselectRowAtIndexPath:indexPath animated:YES]; + }]; + + } + else { + if(drawerSide == MMDrawerSideLeft){ + UIViewController * vc = [[MMExampleLeftSideDrawerViewController alloc] init]; + UINavigationController * navC = [[MMNavigationController alloc] initWithRootViewController:vc]; + [self.mm_drawerController setLeftDrawerViewController:navC]; + [self setupLeftMenuButton]; + + } + else if(drawerSide == MMDrawerSideRight){ + UIViewController * vc = [[MMExampleRightSideDrawerViewController alloc] init]; + UINavigationController * navC = [[MMNavigationController alloc] initWithRootViewController:vc]; + [self.mm_drawerController setRightDrawerViewController:navC]; + [self setupRightMenuButton]; + } + [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; + [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; + [tableView deselectRowAtIndexPath:indexPath animated:YES]; + } + + break; + } + default: + break; + } +} + +#pragma mark - Button Handlers +-(void)leftDrawerButtonPress:(id)sender{ + [self.mm_drawerController toggleDrawerSide:MMDrawerSideLeft animated:YES completion:nil]; +} + +-(void)rightDrawerButtonPress:(id)sender{ + [self.mm_drawerController toggleDrawerSide:MMDrawerSideRight animated:YES completion:nil]; +} + +-(void)doubleTap:(UITapGestureRecognizer*)gesture{ + [self.mm_drawerController bouncePreviewForDrawerSide:MMDrawerSideLeft completion:nil]; +} + +-(void)twoFingerDoubleTap:(UITapGestureRecognizer*)gesture{ + [self.mm_drawerController bouncePreviewForDrawerSide:MMDrawerSideRight completion:nil]; +} + +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleDrawerVisualStateManager.h b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleDrawerVisualStateManager.h new file mode 100644 index 0000000..050fbbf --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleDrawerVisualStateManager.h @@ -0,0 +1,42 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import +#import "MMDrawerVisualState.h" + +typedef NS_ENUM(NSInteger, MMDrawerAnimationType){ + MMDrawerAnimationTypeNone, + MMDrawerAnimationTypeSlide, + MMDrawerAnimationTypeSlideAndScale, + MMDrawerAnimationTypeSwingingDoor, + MMDrawerAnimationTypeParallax, +}; + +@interface MMExampleDrawerVisualStateManager : NSObject + +@property (nonatomic,assign) MMDrawerAnimationType leftDrawerAnimationType; +@property (nonatomic,assign) MMDrawerAnimationType rightDrawerAnimationType; + ++ (MMExampleDrawerVisualStateManager *)sharedManager; + +-(MMDrawerControllerDrawerVisualStateBlock)drawerVisualStateBlockForDrawerSide:(MMDrawerSide)drawerSide; + +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleDrawerVisualStateManager.m b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleDrawerVisualStateManager.m new file mode 100644 index 0000000..45a170e --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleDrawerVisualStateManager.m @@ -0,0 +1,97 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import "MMExampleDrawerVisualStateManager.h" + +#import + +@implementation MMExampleDrawerVisualStateManager + ++ (MMExampleDrawerVisualStateManager *)sharedManager { + static MMExampleDrawerVisualStateManager *_sharedManager = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _sharedManager = [[MMExampleDrawerVisualStateManager alloc] init]; + [_sharedManager setLeftDrawerAnimationType:MMDrawerAnimationTypeParallax]; + [_sharedManager setRightDrawerAnimationType:MMDrawerAnimationTypeParallax]; + }); + + return _sharedManager; +} + +-(MMDrawerControllerDrawerVisualStateBlock)drawerVisualStateBlockForDrawerSide:(MMDrawerSide)drawerSide{ + MMDrawerAnimationType animationType; + if(drawerSide == MMDrawerSideLeft){ + animationType = self.leftDrawerAnimationType; + } + else { + animationType = self.rightDrawerAnimationType; + } + + MMDrawerControllerDrawerVisualStateBlock visualStateBlock = nil; + switch (animationType) { + case MMDrawerAnimationTypeSlide: + visualStateBlock = [MMDrawerVisualState slideVisualStateBlock]; + break; + case MMDrawerAnimationTypeSlideAndScale: + visualStateBlock = [MMDrawerVisualState slideAndScaleVisualStateBlock]; + break; + case MMDrawerAnimationTypeParallax: + visualStateBlock = [MMDrawerVisualState parallaxVisualStateBlockWithParallaxFactor:2.0]; + break; + case MMDrawerAnimationTypeSwingingDoor: + visualStateBlock = [MMDrawerVisualState swingingDoorVisualStateBlock]; + break; + default: + visualStateBlock = ^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){ + + UIViewController * sideDrawerViewController; + CATransform3D transform; + CGFloat maxDrawerWidth; + + if(drawerSide == MMDrawerSideLeft){ + sideDrawerViewController = drawerController.leftDrawerViewController; + maxDrawerWidth = drawerController.maximumLeftDrawerWidth; + } + else if(drawerSide == MMDrawerSideRight){ + sideDrawerViewController = drawerController.rightDrawerViewController; + maxDrawerWidth = drawerController.maximumRightDrawerWidth; + } + + if(percentVisible > 1.0){ + transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); + + if(drawerSide == MMDrawerSideLeft){ + transform = CATransform3DTranslate(transform, maxDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f); + }else if(drawerSide == MMDrawerSideRight){ + transform = CATransform3DTranslate(transform, -maxDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f); + } + } + else { + transform = CATransform3DIdentity; + } + [sideDrawerViewController.view.layer setTransform:transform]; + }; + break; + } + return visualStateBlock; +} +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleLeftSideDrawerViewController.h b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleLeftSideDrawerViewController.h new file mode 100644 index 0000000..0e8b9d5 --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleLeftSideDrawerViewController.h @@ -0,0 +1,26 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import "MMExampleSideDrawerViewController.h" + +@interface MMExampleLeftSideDrawerViewController : MMExampleSideDrawerViewController + +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleLeftSideDrawerViewController.m b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleLeftSideDrawerViewController.m new file mode 100644 index 0000000..2e097e1 --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleLeftSideDrawerViewController.m @@ -0,0 +1,106 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import "MMExampleLeftSideDrawerViewController.h" +#import "MMTableViewCell.h" + +@interface MMExampleLeftSideDrawerViewController () + +@end + +@implementation MMExampleLeftSideDrawerViewController + +-(id)init{ + self = [super init]; + if(self){ + [self setRestorationIdentifier:@"MMExampleLeftSideDrawerController"]; + } + return self; +} + +-(void)viewWillAppear:(BOOL)animated{ + [super viewWillAppear:animated]; + NSLog(@"Left will appear"); +} + +-(void)viewDidAppear:(BOOL)animated{ + [super viewDidAppear:animated]; + NSLog(@"Left did appear"); +} + +-(void)viewWillDisappear:(BOOL)animated{ + [super viewWillDisappear:animated]; + NSLog(@"Left will disappear"); +} + +-(void)viewDidDisappear:(BOOL)animated{ + [super viewDidDisappear:animated]; + NSLog(@"Left did disappear"); +} + +-(void)viewDidLoad{ + [super viewDidLoad]; + [self setTitle:@"Left Drawer"]; +} + +-(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{ + + if(section == MMDrawerSectionDrawerWidth) + return @"Left Drawer Width"; + else + return [super tableView:tableView titleForHeaderInSection:section]; +} + +-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ + UITableViewCell * cell = [super tableView:tableView cellForRowAtIndexPath:indexPath]; + if(indexPath.section == MMDrawerSectionDrawerWidth){ + + CGFloat width = [self.drawerWidths[indexPath.row] intValue]; + CGFloat drawerWidth = self.mm_drawerController.maximumLeftDrawerWidth; + if(drawerWidth == width){ + [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; + } + else{ + [cell setAccessoryType:UITableViewCellAccessoryNone]; + } + [cell.textLabel setText:[NSString stringWithFormat:@"Width %d",[self.drawerWidths[indexPath.row] intValue]]]; + } + return cell; +} + +-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ + if(indexPath.section == MMDrawerSectionDrawerWidth){ + [self.mm_drawerController + setMaximumLeftDrawerWidth:[self.drawerWidths[indexPath.row] floatValue] + animated:YES + completion:^(BOOL finished) { + [tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone]; + [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; + [tableView deselectRowAtIndexPath:indexPath animated:YES]; + }]; + + } + else { + [super tableView:tableView didSelectRowAtIndexPath:indexPath]; + } +} + +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleRightSideDrawerViewController.h b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleRightSideDrawerViewController.h new file mode 100644 index 0000000..6013f48 --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleRightSideDrawerViewController.h @@ -0,0 +1,25 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "MMExampleSideDrawerViewController.h" + +@interface MMExampleRightSideDrawerViewController : MMExampleSideDrawerViewController + +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleRightSideDrawerViewController.m b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleRightSideDrawerViewController.m new file mode 100644 index 0000000..232a95c --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleRightSideDrawerViewController.m @@ -0,0 +1,101 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import "MMExampleRightSideDrawerViewController.h" + +@interface MMExampleRightSideDrawerViewController () + +@end + +@implementation MMExampleRightSideDrawerViewController +-(id)init{ + self = [super init]; + if(self){ + [self setRestorationIdentifier:@"MMExampleRightSideDrawerController"]; + } + return self; +} + +-(void)viewWillAppear:(BOOL)animated{ + [super viewWillAppear:animated]; + NSLog(@"Right will appear"); +} + +-(void)viewDidAppear:(BOOL)animated{ + [super viewDidAppear:animated]; + NSLog(@"Right did appear"); +} + +-(void)viewWillDisappear:(BOOL)animated{ + [super viewWillDisappear:animated]; + NSLog(@"Right will disappear"); +} + +-(void)viewDidDisappear:(BOOL)animated{ + [super viewDidDisappear:animated]; + NSLog(@"Right did disappear"); +} + +-(void)viewDidLoad{ + [super viewDidLoad]; + [self setTitle:@"Right Drawer"]; +} + +-(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{ + + if(section == MMDrawerSectionDrawerWidth) + return @"Right Drawer Width"; + else + return [super tableView:tableView titleForHeaderInSection:section]; +} + +-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ + UITableViewCell * cell = [super tableView:tableView cellForRowAtIndexPath:indexPath]; + if(indexPath.section == MMDrawerSectionDrawerWidth){ + CGFloat width = [self.drawerWidths[indexPath.row] intValue]; + CGFloat drawerWidth = self.mm_drawerController.maximumRightDrawerWidth; + if(drawerWidth == width) + [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; + else + [cell setAccessoryType:UITableViewCellAccessoryNone]; + [cell.textLabel setText:[NSString stringWithFormat:@"Width %d",[self.drawerWidths[indexPath.row] intValue]]]; + } + + return cell; +} + +-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ + if(indexPath.section == MMDrawerSectionDrawerWidth){ + [self.mm_drawerController + setMaximumRightDrawerWidth:[self.drawerWidths[indexPath.row] floatValue] + animated:YES + completion:^(BOOL finished) { + [tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone]; + [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; + [tableView deselectRowAtIndexPath:indexPath animated:YES]; + }]; + } + else { + [super tableView:tableView didSelectRowAtIndexPath:indexPath]; + } +} + +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleSideDrawerViewController.h b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleSideDrawerViewController.h new file mode 100644 index 0000000..dbc3733 --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleSideDrawerViewController.h @@ -0,0 +1,40 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import +#import "UIViewController+MMDrawerController.h" +#import "MMExampleViewController.h" + +typedef NS_ENUM(NSInteger, MMDrawerSection){ + MMDrawerSectionViewSelection, + MMDrawerSectionDrawerWidth, + MMDrawerSectionShadowToggle, + MMDrawerSectionOpenDrawerGestures, + MMDrawerSectionCloseDrawerGestures, + MMDrawerSectionCenterHiddenInteraction, + MMDrawerSectionStretchDrawer, +}; + +@interface MMExampleSideDrawerViewController : MMExampleViewController +@property (nonatomic, strong) UITableView * tableView; +@property (nonatomic,strong) NSArray * drawerWidths; + +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleSideDrawerViewController.m b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleSideDrawerViewController.m new file mode 100644 index 0000000..21c3e8e --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleSideDrawerViewController.m @@ -0,0 +1,447 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import "MMExampleSideDrawerViewController.h" +#import "MMExampleCenterTableViewController.h" +#import "MMSideDrawerTableViewCell.h" +#import "MMSideDrawerSectionHeaderView.h" +#import "MMLogoView.h" +#import "MMNavigationController.h" + +@implementation MMExampleSideDrawerViewController + +- (void)viewDidLoad +{ + [super viewDidLoad]; + + if(OSVersionIsAtLeastiOS7()){ + _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped]; + } + else { + _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain]; + } + + [self.tableView setDelegate:self]; + [self.tableView setDataSource:self]; + [self.view addSubview:self.tableView]; + [self.tableView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight]; + + UIColor * tableViewBackgroundColor; + if(OSVersionIsAtLeastiOS7()){ + tableViewBackgroundColor = [UIColor colorWithRed:110.0/255.0 + green:113.0/255.0 + blue:115.0/255.0 + alpha:1.0]; + } + else { + tableViewBackgroundColor = [UIColor colorWithRed:77.0/255.0 + green:79.0/255.0 + blue:80.0/255.0 + alpha:1.0]; + } + [self.tableView setBackgroundColor:tableViewBackgroundColor]; + + [self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone]; + + [self.view setBackgroundColor:[UIColor colorWithRed:66.0/255.0 + green:69.0/255.0 + blue:71.0/255.0 + alpha:1.0]]; + + UIColor * barColor = [UIColor colorWithRed:161.0/255.0 + green:164.0/255.0 + blue:166.0/255.0 + alpha:1.0]; + if([self.navigationController.navigationBar respondsToSelector:@selector(setBarTintColor:)]){ + [self.navigationController.navigationBar setBarTintColor:barColor]; + } + else { + [self.navigationController.navigationBar setTintColor:barColor]; + } + + + NSDictionary *navBarTitleDict; + UIColor * titleColor = [UIColor colorWithRed:55.0/255.0 + green:70.0/255.0 + blue:77.0/255.0 + alpha:1.0]; + navBarTitleDict = @{NSForegroundColorAttributeName:titleColor}; + [self.navigationController.navigationBar setTitleTextAttributes:navBarTitleDict]; + + self.drawerWidths = @[@(160),@(200),@(240),@(280),@(320)]; + + CGSize logoSize = CGSizeMake(58, 62); + MMLogoView * logo = [[MMLogoView alloc] initWithFrame:CGRectMake(CGRectGetMidX(self.tableView.bounds)-logoSize.width/2.0, + -logoSize.height-logoSize.height/4.0, + logoSize.width, + logoSize.height)]; + [logo setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin]; + [self.tableView addSubview:logo]; + [self.view setBackgroundColor:[UIColor clearColor]]; +} + +-(void)viewWillAppear:(BOOL)animated{ + [super viewWillAppear:animated]; + [self.tableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, self.tableView.numberOfSections-1)] withRowAnimation:UITableViewRowAnimationNone]; +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +-(void)contentSizeDidChange:(NSString *)size{ + [self.tableView reloadData]; +} + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + // Return the number of sections. + return 7; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + // Return the number of rows in the section. + switch (section) { + case MMDrawerSectionViewSelection: + return 2; + case MMDrawerSectionDrawerWidth: + return self.drawerWidths.count; + case MMDrawerSectionShadowToggle: + return 1; + case MMDrawerSectionOpenDrawerGestures: + return 3; + case MMDrawerSectionCloseDrawerGestures: + return 6; + case MMDrawerSectionCenterHiddenInteraction: + return 3; + case MMDrawerSectionStretchDrawer: + return 1; + default: + return 0; + } +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + static NSString *CellIdentifier = @"Cell"; + + UITableViewCell *cell = (UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; + if (cell == nil) { + + cell = [[MMSideDrawerTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; + [cell setSelectionStyle:UITableViewCellSelectionStyleBlue]; + } + + switch (indexPath.section) { + case MMDrawerSectionViewSelection: + if(indexPath.row == 0){ + [cell.textLabel setText:@"Quick View Change"]; + } + else { + [cell.textLabel setText:@"Full View Change"]; + } + [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator]; + break; + case MMDrawerSectionDrawerWidth:{ + //Implement in Subclass + break; + } + case MMDrawerSectionShadowToggle:{ + [cell.textLabel setText:@"Show Shadow"]; + if(self.mm_drawerController.showsShadow) + [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; + else + [cell setAccessoryType:UITableViewCellAccessoryNone]; + break; + } + case MMDrawerSectionOpenDrawerGestures:{ + switch (indexPath.row) { + case 0: + [cell.textLabel setText:@"Pan Nav Bar"]; + if((self.mm_drawerController.openDrawerGestureModeMask&MMOpenDrawerGestureModePanningNavigationBar)>0) + [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; + else + [cell setAccessoryType:UITableViewCellAccessoryNone]; + break; + case 1: + [cell.textLabel setText:@"Pan Center View"]; + if((self.mm_drawerController.openDrawerGestureModeMask&MMOpenDrawerGestureModePanningCenterView)>0) + [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; + else + [cell setAccessoryType:UITableViewCellAccessoryNone]; + break; + case 2: + [cell.textLabel setText:@"Bezel Pan Center View"]; + if((self.mm_drawerController.openDrawerGestureModeMask&MMOpenDrawerGestureModeBezelPanningCenterView)>0) + [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; + else + [cell setAccessoryType:UITableViewCellAccessoryNone]; + break; + default: + break; + } + break; + } + case MMDrawerSectionCloseDrawerGestures:{ + switch (indexPath.row) { + case 0: + [cell.textLabel setText:@"Pan Nav Bar"]; + if((self.mm_drawerController.closeDrawerGestureModeMask&MMCloseDrawerGestureModePanningNavigationBar)>0) + [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; + else + [cell setAccessoryType:UITableViewCellAccessoryNone]; + break; + case 1: + [cell.textLabel setText:@"Pan Center View"]; + if((self.mm_drawerController.closeDrawerGestureModeMask&MMCloseDrawerGestureModePanningCenterView)>0) + [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; + else + [cell setAccessoryType:UITableViewCellAccessoryNone]; + break; + case 2: + [cell.textLabel setText:@"Bezel Pan Center View"]; + if((self.mm_drawerController.closeDrawerGestureModeMask&MMCloseDrawerGestureModeBezelPanningCenterView)>0) + [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; + else + [cell setAccessoryType:UITableViewCellAccessoryNone]; + break; + case 3: + [cell.textLabel setText:@"Tap Nav Bar"]; + if((self.mm_drawerController.closeDrawerGestureModeMask&MMCloseDrawerGestureModeTapNavigationBar)>0) + [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; + else + [cell setAccessoryType:UITableViewCellAccessoryNone]; + break; + case 4: + [cell.textLabel setText:@"Tap Center View"]; + if((self.mm_drawerController.closeDrawerGestureModeMask&MMCloseDrawerGestureModeTapCenterView)>0) + [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; + else + [cell setAccessoryType:UITableViewCellAccessoryNone]; + break; + case 5: + [cell.textLabel setText:@"Pan Drawer View"]; + if((self.mm_drawerController.closeDrawerGestureModeMask&MMCloseDrawerGestureModePanningDrawerView)>0) + [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; + else + [cell setAccessoryType:UITableViewCellAccessoryNone]; + break; + default: + break; + } + break; + } + case MMDrawerSectionCenterHiddenInteraction:{ + [cell setSelectionStyle:UITableViewCellSelectionStyleBlue]; + switch (indexPath.row) { + case 0: + [cell.textLabel setText:@"None"]; + if(self.mm_drawerController.centerHiddenInteractionMode == MMDrawerOpenCenterInteractionModeNone) + [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; + else + [cell setAccessoryType:UITableViewCellAccessoryNone]; + break; + case 1: + [cell.textLabel setText:@"Full"]; + if(self.mm_drawerController.centerHiddenInteractionMode == MMDrawerOpenCenterInteractionModeFull) + [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; + else + [cell setAccessoryType:UITableViewCellAccessoryNone]; + break; + case 2: + [cell.textLabel setText:@"Nav Bar Only"]; + if(self.mm_drawerController.centerHiddenInteractionMode == MMDrawerOpenCenterInteractionModeNavigationBarOnly) + [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; + else + [cell setAccessoryType:UITableViewCellAccessoryNone]; + break; + + default: + break; + } + break; + } + case MMDrawerSectionStretchDrawer:{ + [cell.textLabel setText:@"Stretch Drawer"]; + if(self.mm_drawerController.shouldStretchDrawer) + [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; + else + [cell setAccessoryType:UITableViewCellAccessoryNone]; + break; + } + default: + break; + } + + return cell; +} + +-(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{ + switch (section) { + case MMDrawerSectionViewSelection: + return @"New Center View"; + case MMDrawerSectionDrawerWidth: + return @"Drawer Width"; + case MMDrawerSectionShadowToggle: + return @"Shadow"; + case MMDrawerSectionOpenDrawerGestures: + return @"Drawer Open Gestures"; + case MMDrawerSectionCloseDrawerGestures: + return @"Drawer Close Gestures"; + case MMDrawerSectionCenterHiddenInteraction: + return @"Open Center Interaction Mode"; + case MMDrawerSectionStretchDrawer: + return @"Strech Drawer"; + default: + return nil; + } +} + +-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ + MMSideDrawerSectionHeaderView * headerView; + if(OSVersionIsAtLeastiOS7()){ + headerView = [[MMSideDrawerSectionHeaderView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(tableView.bounds), 56.0)]; + } + else { + headerView = [[MMSideDrawerSectionHeaderView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(tableView.bounds), 23.0)]; + } + [headerView setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth]; + [headerView setTitle:[tableView.dataSource tableView:tableView titleForHeaderInSection:section]]; + return headerView; +} + +-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ + if(OSVersionIsAtLeastiOS7()){ + return 56.0; + } + else { + return 23.0; + } +} + +-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ + return 40.0; +} + +-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ + return 0.0; +} + +#pragma mark - Table view delegate + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath +{ + switch (indexPath.section) { + case MMDrawerSectionViewSelection:{ + MMExampleCenterTableViewController * center = [[MMExampleCenterTableViewController alloc] init]; + + UINavigationController * nav = [[MMNavigationController alloc] initWithRootViewController:center]; + + if(indexPath.row%2==0){ + [self.mm_drawerController + setCenterViewController:nav + withCloseAnimation:YES + completion:nil]; + } + else { + [self.mm_drawerController + setCenterViewController:nav + withFullCloseAnimation:YES + completion:nil]; + } + break; + } + + case MMDrawerSectionDrawerWidth:{ + //Implement in Subclass + break; + } + case MMDrawerSectionShadowToggle:{ + [self.mm_drawerController setShowsShadow:!self.mm_drawerController.showsShadow]; + [tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone]; + break; + } + case MMDrawerSectionOpenDrawerGestures:{ + switch (indexPath.row) { + case 0: + self.mm_drawerController.openDrawerGestureModeMask ^= MMOpenDrawerGestureModePanningNavigationBar; + break; + case 1: + self.mm_drawerController.openDrawerGestureModeMask ^= MMOpenDrawerGestureModePanningCenterView; + break; + case 2: + self.mm_drawerController.openDrawerGestureModeMask ^= MMOpenDrawerGestureModeBezelPanningCenterView; + break; + default: + break; + } + [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; + break; + } + case MMDrawerSectionCloseDrawerGestures:{ + switch (indexPath.row) { + case 0: + self.mm_drawerController.closeDrawerGestureModeMask ^= MMCloseDrawerGestureModePanningNavigationBar; + break; + case 1: + self.mm_drawerController.closeDrawerGestureModeMask ^= MMCloseDrawerGestureModePanningCenterView; + break; + case 2: + self.mm_drawerController.closeDrawerGestureModeMask ^= MMCloseDrawerGestureModeBezelPanningCenterView; + break; + case 3: + self.mm_drawerController.closeDrawerGestureModeMask ^= MMCloseDrawerGestureModeTapNavigationBar; + break; + case 4: + self.mm_drawerController.closeDrawerGestureModeMask ^= MMCloseDrawerGestureModeTapCenterView; + break; + case 5: + self.mm_drawerController.closeDrawerGestureModeMask ^= MMCloseDrawerGestureModePanningDrawerView; + break; + default: + break; + } + [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; + break; + } + case MMDrawerSectionCenterHiddenInteraction:{ + self.mm_drawerController.centerHiddenInteractionMode = indexPath.row; + [tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationNone]; + break; + } + case MMDrawerSectionStretchDrawer:{ + self.mm_drawerController.shouldStretchDrawer = !self.mm_drawerController.shouldStretchDrawer; + [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; + break; + } + default: + break; + } + [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; + [tableView deselectRowAtIndexPath:indexPath animated:YES]; +} + +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleViewController.h b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleViewController.h new file mode 100644 index 0000000..1b5f94f --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleViewController.h @@ -0,0 +1,27 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +@interface MMExampleViewController : UIViewController + +-(void)contentSizeDidChange:(NSString*)size; + +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleViewController.m b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleViewController.m new file mode 100644 index 0000000..3ae1031 --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMExampleViewController.m @@ -0,0 +1,63 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "MMExampleViewController.h" + +@interface MMExampleViewController () + +@end + +@implementation MMExampleViewController + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Custom initialization + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + if(OSVersionIsAtLeastiOS7()){ + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(contentSizeDidChangeNotification:) + name:UIContentSizeCategoryDidChangeNotification + object:nil]; + } +} + +- (void)dealloc{ + [[NSNotificationCenter defaultCenter] + removeObserver:self]; +} + +-(void)contentSizeDidChangeNotification:(NSNotification*)notification{ + [self contentSizeDidChange:notification.userInfo[UIContentSizeCategoryNewValueKey]]; +} + +-(void)contentSizeDidChange:(NSString *)size{ + //Implement in subclass +} + +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMLogoView.h b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMLogoView.h new file mode 100644 index 0000000..d094705 --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMLogoView.h @@ -0,0 +1,26 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import + +@interface MMLogoView : UIView + +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMLogoView.m b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMLogoView.m new file mode 100644 index 0000000..5495e39 --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMLogoView.m @@ -0,0 +1,160 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import "MMLogoView.h" + +@implementation MMLogoView + +-(id)initWithFrame:(CGRect)frame{ + self = [super initWithFrame:frame]; + if(self) { + [self setBackgroundColor:[UIColor clearColor]]; + } + return self; +} + +-(void)drawRect:(CGRect)rect{ + //// General Declarations + CGContextRef context = UIGraphicsGetCurrentContext(); + + //// Color Declarations + UIColor* mmFill = [UIColor colorWithRed: 0 green: 0 blue: 0 alpha: 0.196]; + UIColor* shape1DropShadowColor = [UIColor colorWithRed: 1 green: 1 blue: 1 alpha: 0.4]; + UIColor* shape1InnerShadowColor = [UIColor colorWithRed: 0 green: 0 blue: 0 alpha: 0.392]; + + //// Shadow Declarations + UIColor* mmDropShadow = shape1DropShadowColor; + CGSize mmDropShadowOffset = CGSizeMake(0.1, 1.1); + CGFloat mmDropShadowBlurRadius = 0; + UIColor* mmInnerShadow = shape1InnerShadowColor; + CGSize mmInnerShadowOffset = CGSizeMake(0.1, 1.1); + CGFloat mmInnerShadowBlurRadius = 0; + + //// Frames + CGRect frame = self.bounds; + + + //// mmGroup + { + //// mmShape Drawing + UIBezierPath* mmShapePath = [UIBezierPath bezierPath]; + [mmShapePath moveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.51759 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.96761 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.37558 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.91398 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.46395 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.96761 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.41351 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.94854 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.31759 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.76824 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.33346 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.87556 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.31234 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.82249 * CGRectGetHeight(frame))]; + [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.31904 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.75325 * CGRectGetHeight(frame))]; + [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.30262 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.75459 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.28470 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.75535 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.29666 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.75510 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.29065 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.75535 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.14274 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.70173 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.23106 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.75535 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.18067 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.73625 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.14274 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.44291 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.06451 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.63038 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.06451 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.51425 * CGRectGetHeight(frame))]; + [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.45528 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.15799 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.48085 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.14832 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.46207 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.15176 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.47120 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.14832 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.50639 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.15799 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.49051 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.14832 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.49957 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.15176 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.50639 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.20462 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.52050 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.17087 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.52050 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.19177 * CGRectGetHeight(frame))]; + [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.19390 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.48951 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.19386 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.65510 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.14397 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.53518 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.14397 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.60942 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.28476 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.68936 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.21821 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.67720 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.25047 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.68936 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.37557 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.65514 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.31904 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.68936 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.35128 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.67720 * CGRectGetHeight(frame))]; + [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.68812 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.37025 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.71365 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.36056 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.69491 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.36401 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.70403 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.36056 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.73923 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.37025 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.72332 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.36056 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.73241 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.36401 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.73923 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.41681 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.75333 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.38310 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.75333 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.40399 * CGRectGetHeight(frame))]; + [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.42673 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.70173 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.42670 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.86737 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.37681 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.74744 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.37681 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.82172 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.51759 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.90159 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.45104 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.88944 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.48328 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.90159 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.60840 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.86743 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.55183 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.90159 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.58413 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.88944 * CGRectGetHeight(frame))]; + [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.92092 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.58246 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.94646 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.57284 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.92773 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.57623 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.93682 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.57284 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.97208 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.58246 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.95617 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.57284 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.96523 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.57623 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.97208 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.62912 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.98615 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.59535 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.98615 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.61626 * CGRectGetHeight(frame))]; + [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.65956 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.91398 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.51759 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.96761 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.62160 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.94854 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.57117 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.96761 * CGRectGetHeight(frame))]; + [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.51759 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.96761 * CGRectGetHeight(frame))]; + [mmShapePath closePath]; + [mmShapePath moveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.51965 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.81940 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.49408 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.80982 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.50999 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.81940 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.50091 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.81600 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.49408 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.76313 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.48000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.79686 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.48000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.77600 * CGRectGetHeight(frame))]; + [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.80659 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.47824 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.80662 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.31264 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.85650 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.43259 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.85650 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.35831 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.71574 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.27840 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.78226 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.29053 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.75001 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.27840 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.62493 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.31260 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.68146 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.27840 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.64921 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.29053 * CGRectGetHeight(frame))]; + [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.31239 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.59752 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.28684 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.60718 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.30556 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.60378 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.29644 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.60718 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.26125 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.59752 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.27718 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.60718 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.26808 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.60378 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.26125 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.55093 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.24715 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.58467 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.24715 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.56377 * CGRectGetHeight(frame))]; + [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.57377 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.26601 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.57380 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.10041 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.62368 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.22029 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.62368 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.14606 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.48291 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.06617 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.54946 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.07832 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.51721 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.06617 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.39208 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.10040 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.44863 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.06617 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.41637 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.07832 * CGRectGetHeight(frame))]; + [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.07956 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.38530 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.05400 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.39496 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.07274 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.39149 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.06365 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.39496 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.02841 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.38530 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.04434 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.39496 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.03525 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.39149 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.02841 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.33867 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.01434 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.37241 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.01434 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.35151 * CGRectGetHeight(frame))]; + [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.34095 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.05378 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.48291 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.00013 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.37888 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.01919 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.42931 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.00013 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.62491 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.05378 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.53657 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.00013 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.58700 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.01919 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.68292 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.19950 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.66705 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.09219 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.68815 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.14529 * CGRectGetHeight(frame))]; + [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.68143 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.21454 * CGRectGetHeight(frame))]; + [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.69786 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.21318 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.71580 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.21244 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.70379 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.21269 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.70984 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.21244 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.85774 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.26604 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.76941 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.21244 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.81981 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.23147 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.85774 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.52485 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.93599 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.33738 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.93599 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.45349 * CGRectGetHeight(frame))]; + [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.54521 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.80977 * CGRectGetHeight(frame))]; + [mmShapePath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.51965 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.81940 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.53840 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.81600 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.52930 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.81940 * CGRectGetHeight(frame))]; + [mmShapePath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.51965 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.81940 * CGRectGetHeight(frame))]; + [mmShapePath closePath]; + CGContextSaveGState(context); + CGContextSetShadowWithColor(context, mmDropShadowOffset, mmDropShadowBlurRadius, mmDropShadow.CGColor); + + CGContextSetBlendMode(context, kCGBlendModeOverlay); + [mmFill setFill]; + [mmShapePath fill]; + + ////// mmShape Inner Shadow + CGRect mmShapeBorderRect = CGRectInset([mmShapePath bounds], -mmInnerShadowBlurRadius, -mmInnerShadowBlurRadius); + mmShapeBorderRect = CGRectOffset(mmShapeBorderRect, -mmInnerShadowOffset.width, -mmInnerShadowOffset.height); + mmShapeBorderRect = CGRectInset(CGRectUnion(mmShapeBorderRect, [mmShapePath bounds]), -1, -1); + + UIBezierPath* mmShapeNegativePath = [UIBezierPath bezierPathWithRect: mmShapeBorderRect]; + [mmShapeNegativePath appendPath: mmShapePath]; + mmShapeNegativePath.usesEvenOddFillRule = YES; + + CGContextSaveGState(context); + { + CGFloat xOffset = mmInnerShadowOffset.width + round(mmShapeBorderRect.size.width); + CGFloat yOffset = mmInnerShadowOffset.height; + CGContextSetShadowWithColor(context, + CGSizeMake(xOffset + copysign(0.1, xOffset), yOffset + copysign(0.1, yOffset)), + mmInnerShadowBlurRadius, + mmInnerShadow.CGColor); + + [mmShapePath addClip]; + CGAffineTransform transform = CGAffineTransformMakeTranslation(-round(mmShapeBorderRect.size.width), 0); + [mmShapeNegativePath applyTransform: transform]; + [[UIColor grayColor] setFill]; + [mmShapeNegativePath fill]; + } + CGContextRestoreGState(context); + + CGContextRestoreGState(context); + } +} + +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMNavigationController.h b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMNavigationController.h new file mode 100644 index 0000000..e6bea9a --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMNavigationController.h @@ -0,0 +1,25 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +@interface MMNavigationController : UINavigationController + +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMNavigationController.m b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMNavigationController.m new file mode 100644 index 0000000..f17037b --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMNavigationController.m @@ -0,0 +1,38 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +#import "MMNavigationController.h" +#import "UIViewController+MMDrawerController.h" + +@interface MMNavigationController () + +@end + +@implementation MMNavigationController + +-(UIStatusBarStyle)preferredStatusBarStyle{ + if(self.mm_drawerController.showsStatusBarBackgroundView){ + return UIStatusBarStyleLightContent; + } + else { + return UIStatusBarStyleDefault; + } +} + +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMSideDrawerSectionHeaderView.h b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMSideDrawerSectionHeaderView.h new file mode 100644 index 0000000..6fd3efc --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMSideDrawerSectionHeaderView.h @@ -0,0 +1,28 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import + +@interface MMSideDrawerSectionHeaderView : UIView + +@property (nonatomic, copy) NSString * title; + +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMSideDrawerSectionHeaderView.m b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMSideDrawerSectionHeaderView.m new file mode 100644 index 0000000..2da6eb6 --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMSideDrawerSectionHeaderView.m @@ -0,0 +1,162 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "MMSideDrawerSectionHeaderView.h" +#import + +@interface MMSideDrawerSectionHeaderView () +@property (nonatomic, strong) UILabel * label; +@end + +@implementation MMSideDrawerSectionHeaderView + +- (id)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + // Initialization code + + if(OSVersionIsAtLeastiOS7()){ + [self setBackgroundColor:[UIColor colorWithRed:110./255.0 + green:113.0/255.0 + blue:115.0/255.0 + alpha:1.0]]; + } + else { + [self setBackgroundColor:[UIColor colorWithRed:77.0/255.0 + green:79.0/255.0 + blue:80.0/255.0 + alpha:1.0]]; + } + + if(OSVersionIsAtLeastiOS7()){ + _label = [[UILabel alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(self.bounds)-28,CGRectGetWidth(self.bounds)-30, 22)]; + } + else { + _label = [[UILabel alloc] initWithFrame:CGRectInset(self.bounds, 10.0, 2.0)]; + } + + + if([[UIFont class] respondsToSelector:@selector(preferredFontForTextStyle:)]){ + [self.label setFont:[UIFont preferredFontForTextStyle:UIFontTextStyleCaption1]]; + } + else { + [self.label setFont:[UIFont boldSystemFontOfSize:12.0]]; + } + + [self.label setBackgroundColor:[UIColor clearColor]]; + [self.label setTextColor:[UIColor colorWithRed:203.0/255.0 + green:206.0/255.0 + blue:209.0/255.0 + alpha:1.0]]; + if(OSVersionIsAtLeastiOS7() == NO){ + [self.label setShadowOffset:CGSizeMake(0, 1)]; + [self.label setShadowColor:[[UIColor blackColor] colorWithAlphaComponent:.5]]; + } + [self.label setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleTopMargin]; + [self addSubview:self.label]; + [self setClipsToBounds:NO]; + } + return self; +} + +-(void)setTitle:(NSString *)title{ + _title = title; + [self.label setText:[self.title uppercaseString]]; +} + +-(void)drawRect:(CGRect)rect{ + //// General Declarations + if(OSVersionIsAtLeastiOS7()== NO){ + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + CGContextRef context = UIGraphicsGetCurrentContext(); + + //// Color Declarations + UIColor* color = [UIColor colorWithRed: 0.373 green: 0.388 blue: 0.404 alpha: 1]; + UIColor* color2 = [UIColor colorWithRed: 0.216 green: 0.231 blue: 0.243 alpha: 1]; + UIColor* color3 = [UIColor colorWithRed: 0.451 green: 0.463 blue: 0.475 alpha: 1]; + UIColor* color4 = [UIColor colorWithRed: 0.184 green: 0.2 blue: 0.212 alpha: 1]; + UIColor* fillColor2 = [UIColor colorWithRed: 0.373 green: 0.388 blue: 0.404 alpha: 0]; + + //// Gradient Declarations + NSArray* gradient2Colors = [NSArray arrayWithObjects: + (id)color.CGColor, + (id)fillColor2.CGColor, nil]; + CGFloat gradient2Locations[] = {0, 1}; + CGGradientRef gradient2 = CGGradientCreateWithColors(colorSpace, (__bridge CFArrayRef)gradient2Colors, gradient2Locations); + + //// Frames + CGRect frame = CGRectMake(0, -1, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds)+1); + + + //// Fill Drawing + CGRect fillRect = CGRectMake(CGRectGetMinX(frame), CGRectGetMinY(frame), CGRectGetWidth(frame), CGRectGetHeight(frame) - 1); + UIBezierPath* fillPath = [UIBezierPath bezierPathWithRect: fillRect]; + CGContextSaveGState(context); + [fillPath addClip]; + CGContextDrawLinearGradient(context, gradient2, + CGPointMake(CGRectGetMidX(fillRect), CGRectGetMinY(fillRect)), + CGPointMake(CGRectGetMidX(fillRect), CGRectGetMaxY(fillRect)), + 0); + CGContextRestoreGState(context); + + + //// TopStroke Drawing + UIBezierPath* topStrokePath = [UIBezierPath bezierPathWithRect: CGRectMake(CGRectGetMinX(frame), CGRectGetMinY(frame), CGRectGetWidth(frame), 1)]; + [color4 setFill]; + [topStrokePath fill]; + + + //// Highlight Drawing + UIBezierPath* highlightPath = [UIBezierPath bezierPathWithRect: CGRectMake(CGRectGetMinX(frame), CGRectGetMinY(frame) + 1, CGRectGetWidth(frame), 1)]; + [color3 setFill]; + [highlightPath fill]; + + + //// BottomStroke Drawing + UIBezierPath* bottomStrokePath = [UIBezierPath bezierPathWithRect: CGRectMake(CGRectGetMinX(frame), CGRectGetMinY(frame) + CGRectGetHeight(frame) - 1, CGRectGetWidth(frame), 1)]; + [color2 setFill]; + [bottomStrokePath fill]; + + + //// Cleanup + CGGradientRelease(gradient2); + CGColorSpaceRelease(colorSpace); + + } + else { + CGContextRef context = UIGraphicsGetCurrentContext(); + UIColor * lineColor = [UIColor colorWithRed:94.0/255.0 + green:97.0/255.0 + blue:99.0/255.0 + alpha:1.0]; + CGContextSetStrokeColorWithColor(context, lineColor.CGColor); + + CGContextSetLineWidth(context, 1.0); + + CGContextMoveToPoint(context, CGRectGetMinX(self.bounds), CGRectGetMaxY(self.bounds)-.5); //start at this point + + CGContextAddLineToPoint(context, CGRectGetMaxX(self.bounds), CGRectGetMaxY(self.bounds)-.5); //draw to this point + + CGContextStrokePath(context); + } +} + +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMSideDrawerTableViewCell.h b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMSideDrawerTableViewCell.h new file mode 100644 index 0000000..60d322d --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMSideDrawerTableViewCell.h @@ -0,0 +1,26 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import "MMTableViewCell.h" + +@interface MMSideDrawerTableViewCell : MMTableViewCell + +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMSideDrawerTableViewCell.m b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMSideDrawerTableViewCell.m new file mode 100644 index 0000000..845fb44 --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMSideDrawerTableViewCell.m @@ -0,0 +1,74 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import "MMSideDrawerTableViewCell.h" + +@implementation MMSideDrawerTableViewCell + +- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier +{ + self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; + if (self) { + [self setAccessoryCheckmarkColor:[UIColor whiteColor]]; + + UIView * backgroundView = [[UIView alloc] initWithFrame:self.bounds]; + [backgroundView setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth]; + UIColor * backgroundColor; + if(OSVersionIsAtLeastiOS7()){ + backgroundColor = [UIColor colorWithRed:122.0/255.0 + green:126.0/255.0 + blue:128.0/255.0 + alpha:1.0]; + } + else { + backgroundColor = [UIColor colorWithRed:77.0/255.0 + green:79.0/255.0 + blue:80.0/255.0 + alpha:1.0]; + } + [backgroundView setBackgroundColor:backgroundColor]; + + [self setBackgroundView:backgroundView]; + + [self.textLabel setBackgroundColor:[UIColor clearColor]]; + [self.textLabel setTextColor:[UIColor + colorWithRed:230.0/255.0 + green:236.0/255.0 + blue:242.0/255.0 + alpha:1.0]]; + if(OSVersionIsAtLeastiOS7()== NO){ + [self.textLabel setShadowColor:[[UIColor blackColor] colorWithAlphaComponent:.5]]; + [self.textLabel setShadowOffset:CGSizeMake(0, 1)]; + } + } + return self; +} + +-(void)updateContentForNewContentSize{ + if([[UIFont class] respondsToSelector:@selector(preferredFontForTextStyle:)]){ + [self.textLabel setFont:[UIFont preferredFontForTextStyle:UIFontTextStyleBody]]; + } + else { + [self.textLabel setFont:[UIFont boldSystemFontOfSize:16.0]]; + } +} + +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMTableViewCell.h b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMTableViewCell.h new file mode 100644 index 0000000..d6f50e6 --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMTableViewCell.h @@ -0,0 +1,31 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import + +@interface MMTableViewCell : UITableViewCell + +@property (nonatomic, strong) UIColor * accessoryCheckmarkColor; +@property (nonatomic, strong) UIColor * disclosureIndicatorColor; + +-(void)updateContentForNewContentSize; + +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMTableViewCell.m b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMTableViewCell.m new file mode 100644 index 0000000..8ebbfa6 --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/MMTableViewCell.m @@ -0,0 +1,190 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import "MMTableViewCell.h" + +@interface MMDisclosureIndicator : UIView +@property (nonatomic, strong) UIColor * color; +@end + +@implementation MMDisclosureIndicator +-(id)initWithFrame:(CGRect)frame{ + self = [super initWithFrame:frame]; + if(self){ + [self setBackgroundColor:[UIColor clearColor]]; + [self setColor:[UIColor whiteColor]]; + } + return self; +} + +-(void)drawRect:(CGRect)rect{ + //// General Declarations + CGContextRef context = UIGraphicsGetCurrentContext(); + + //// Color Declarations + UIColor* shadow; + if(OSVersionIsAtLeastiOS7()){ + shadow = [UIColor clearColor]; + } + else { + shadow = [UIColor colorWithRed: 0 green: 0 blue: 0 alpha: 0.46]; + } + UIColor* chevronColor = self.color; + + //// Shadow Declarations + CGSize shadowOffset = CGSizeMake(0.1, 1.1); + CGFloat shadowBlurRadius = 0; + + //// Frames + CGRect frame = self.bounds; + + + //// chevron Drawing + UIBezierPath* chevronPath = [UIBezierPath bezierPath]; + [chevronPath moveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.22000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.01667 * CGRectGetHeight(frame))]; + [chevronPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.98000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.48333 * CGRectGetHeight(frame))]; + [chevronPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.22000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.98333 * CGRectGetHeight(frame))]; + [chevronPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.02000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.81667 * CGRectGetHeight(frame))]; + [chevronPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.54000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.48333 * CGRectGetHeight(frame))]; + [chevronPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.02000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.15000 * CGRectGetHeight(frame))]; + [chevronPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.22000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.01667 * CGRectGetHeight(frame))]; + [chevronPath closePath]; + CGContextSaveGState(context); + CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor); + [chevronColor setFill]; + [chevronPath fill]; + CGContextRestoreGState(context); +} +@end + +@interface MMCustomCheckmark : UIControl +@property (nonatomic, strong) UIColor * color; +@end + +@implementation MMCustomCheckmark + +-(id)initWithFrame:(CGRect)frame{ + self = [super initWithFrame:frame]; + if(self) { + [self setBackgroundColor:[UIColor clearColor]]; + [self setUserInteractionEnabled:NO]; + } + return self; +} + +-(void)drawRect:(CGRect)rect{ + //// Color Declarations + UIColor* checkMarkColor = self.color; + + //// Frames + CGRect frame = self.bounds; + + + //// checkMark Drawing + UIBezierPath* checkMarkPath = [UIBezierPath bezierPath]; + [checkMarkPath moveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.07087 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.48855 * CGRectGetHeight(frame))]; + [checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.12500 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.45284 * CGRectGetHeight(frame))]; + [checkMarkPath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.21038 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.47898 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.15489 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.43312 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.19312 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.44482 * CGRectGetHeight(frame))]; + [checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.51450 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.79528 * CGRectGetHeight(frame))]; + [checkMarkPath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.49163 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.89286 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.53176 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.82945 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.52152 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.87313 * CGRectGetHeight(frame))]; + [checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.38337 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.96429 * CGRectGetHeight(frame))]; + [checkMarkPath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.29800 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.93814 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.35348 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.98401 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.31526 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.97230 * CGRectGetHeight(frame))]; + [checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.04800 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.58613 * CGRectGetHeight(frame))]; + [checkMarkPath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.07087 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.48855 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.03074 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.55196 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.04098 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.50828 * CGRectGetHeight(frame))]; + [checkMarkPath closePath]; + [checkMarkPath moveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.92048 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.00641 * CGRectGetHeight(frame))]; + [checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.93750 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.02427 * CGRectGetHeight(frame))]; + [checkMarkPath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.96038 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.12184 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.96739 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.04399 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.97764 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.08768 * CGRectGetHeight(frame))]; + [checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.51450 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.93814 * CGRectGetHeight(frame))]; + [checkMarkPath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.42913 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.96429 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.49724 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.97230 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.45902 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.98401 * CGRectGetHeight(frame))]; + [checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.32087 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.89286 * CGRectGetHeight(frame))]; + [checkMarkPath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.29800 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.79528 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.29098 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.87313 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.28074 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.82945 * CGRectGetHeight(frame))]; + [checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.83511 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.03255 * CGRectGetHeight(frame))]; + [checkMarkPath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.92048 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.00641 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.85237 * CGRectGetWidth(frame), CGRectGetMinY(frame) + -0.00161 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.89059 * CGRectGetWidth(frame), CGRectGetMinY(frame) + -0.01331 * CGRectGetHeight(frame))]; + [checkMarkPath closePath]; + [checkMarkPath moveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.37500 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.78572 * CGRectGetHeight(frame))]; + [checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.43750 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.78572 * CGRectGetHeight(frame))]; + [checkMarkPath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.50000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.85714 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.47202 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.78572 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.50000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.81769 * CGRectGetHeight(frame))]; + [checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.50000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.92857 * CGRectGetHeight(frame))]; + [checkMarkPath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.43750 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 1.00000 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.50000 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.96802 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.47202 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 1.00000 * CGRectGetHeight(frame))]; + [checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.37500 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 1.00000 * CGRectGetHeight(frame))]; + [checkMarkPath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.31250 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.92857 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.34048 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 1.00000 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.31250 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.96802 * CGRectGetHeight(frame))]; + [checkMarkPath addLineToPoint: CGPointMake(CGRectGetMinX(frame) + 0.31250 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.85714 * CGRectGetHeight(frame))]; + [checkMarkPath addCurveToPoint: CGPointMake(CGRectGetMinX(frame) + 0.37500 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.78572 * CGRectGetHeight(frame)) controlPoint1: CGPointMake(CGRectGetMinX(frame) + 0.31250 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.81769 * CGRectGetHeight(frame)) controlPoint2: CGPointMake(CGRectGetMinX(frame) + 0.34048 * CGRectGetWidth(frame), CGRectGetMinY(frame) + 0.78572 * CGRectGetHeight(frame))]; + [checkMarkPath closePath]; + [checkMarkColor setFill]; + [checkMarkPath fill]; +} + +-(void)setSelected:(BOOL)selected{ + [super setSelected:selected]; + [self setNeedsDisplay]; +} + +@end + +@implementation MMTableViewCell + +- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier +{ + self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; + if (self) { + [self setAccessoryCheckmarkColor:[UIColor whiteColor]]; + [self setDisclosureIndicatorColor:[UIColor whiteColor]]; + [self updateContentForNewContentSize]; + } + return self; +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated +{ + [super setSelected:selected animated:animated]; + + // Configure the view for the selected state +} + +- (void)setAccessoryType:(UITableViewCellAccessoryType)accessoryType{ + [super setAccessoryType:accessoryType]; + if(accessoryType == UITableViewCellAccessoryCheckmark){ + MMCustomCheckmark * customCheckmark = [[MMCustomCheckmark alloc] initWithFrame:CGRectMake(0, 0, 15, 15)]; + [customCheckmark setColor:self.accessoryCheckmarkColor]; + [self setAccessoryView:customCheckmark]; + } + else if(accessoryType == UITableViewCellAccessoryDisclosureIndicator){ + MMDisclosureIndicator * di = [[MMDisclosureIndicator alloc] initWithFrame:CGRectMake(0, 0, 10, 14)]; + [di setColor:self.disclosureIndicatorColor]; + [self setAccessoryView:di]; + } + else { + [self setAccessoryView:nil]; + } +} + +-(void)prepareForReuse{ + [super prepareForReuse]; + [self updateContentForNewContentSize]; +} + +-(void)updateContentForNewContentSize{ + +} + +@end diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/en.lproj/InfoPlist.strings b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/en.lproj/InfoPlist.strings new file mode 100644 index 0000000..477b28f --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/main.m b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/main.m new file mode 100644 index 0000000..8c674a0 --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/ExampleFiles/main.m @@ -0,0 +1,31 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import + +#import "MMAppDelegate.h" + +int main(int argc, char *argv[]) +{ + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([MMAppDelegate class])); + } +} diff --git a/ios/Classes/MMDrawerController/KitchenSink/Icons/Icon-72.png b/ios/Classes/MMDrawerController/KitchenSink/Icons/Icon-72.png new file mode 100644 index 0000000..5865706 Binary files /dev/null and b/ios/Classes/MMDrawerController/KitchenSink/Icons/Icon-72.png differ diff --git a/ios/Classes/MMDrawerController/KitchenSink/Icons/Icon-72@2x.png b/ios/Classes/MMDrawerController/KitchenSink/Icons/Icon-72@2x.png new file mode 100644 index 0000000..f481fcf Binary files /dev/null and b/ios/Classes/MMDrawerController/KitchenSink/Icons/Icon-72@2x.png differ diff --git a/ios/Classes/MMDrawerController/KitchenSink/Icons/Icon.png b/ios/Classes/MMDrawerController/KitchenSink/Icons/Icon.png new file mode 100644 index 0000000..2458d27 Binary files /dev/null and b/ios/Classes/MMDrawerController/KitchenSink/Icons/Icon.png differ diff --git a/ios/Classes/MMDrawerController/KitchenSink/Icons/Icon@2x.png b/ios/Classes/MMDrawerController/KitchenSink/Icons/Icon@2x.png new file mode 100644 index 0000000..b31d044 Binary files /dev/null and b/ios/Classes/MMDrawerController/KitchenSink/Icons/Icon@2x.png differ diff --git a/ios/Classes/MMDrawerController/KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.pbxproj b/ios/Classes/MMDrawerController/KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.pbxproj new file mode 100644 index 0000000..c4d5df3 --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.pbxproj @@ -0,0 +1,462 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 294A1D1117199537005BF6B1 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 294A1D1017199537005BF6B1 /* UIKit.framework */; }; + 294A1D1317199537005BF6B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 294A1D1217199537005BF6B1 /* Foundation.framework */; }; + 294A1D1517199537005BF6B1 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 294A1D1417199537005BF6B1 /* CoreGraphics.framework */; }; + 294A1D1B17199537005BF6B1 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 294A1D1917199537005BF6B1 /* InfoPlist.strings */; }; + 294A1D1D17199537005BF6B1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 294A1D1C17199537005BF6B1 /* main.m */; }; + 294A1D2117199537005BF6B1 /* MMAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 294A1D2017199537005BF6B1 /* MMAppDelegate.m */; }; + 294A1D2317199537005BF6B1 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 294A1D2217199537005BF6B1 /* Default.png */; }; + 294A1D2517199537005BF6B1 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 294A1D2417199537005BF6B1 /* Default@2x.png */; }; + 294A1D2717199537005BF6B1 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 294A1D2617199537005BF6B1 /* Default-568h@2x.png */; }; + 294A1D301719982B005BF6B1 /* MMDrawerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 294A1D2F1719982B005BF6B1 /* MMDrawerController.m */; }; + 294A1D3317199844005BF6B1 /* UIViewController+MMDrawerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 294A1D3217199844005BF6B1 /* UIViewController+MMDrawerController.m */; }; + 2961190717383AFC00CD4063 /* MMLogoView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2961190617383AFC00CD4063 /* MMLogoView.m */; }; + 2961190A1738416400CD4063 /* MMCenterTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 296119091738416400CD4063 /* MMCenterTableViewCell.m */; }; + 2969636C1738141500281B9A /* MMSideDrawerTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 2969636B1738141500281B9A /* MMSideDrawerTableViewCell.m */; }; + 297EA0051738112A00472DF4 /* MMTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 297EA0041738112A00472DF4 /* MMTableViewCell.m */; }; + 29848B5F173015D3006D8502 /* MMExampleLeftSideDrawerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 29848B5E173015D3006D8502 /* MMExampleLeftSideDrawerViewController.m */; }; + 29848B6517301793006D8502 /* MMExampleRightSideDrawerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 29848B6417301793006D8502 /* MMExampleRightSideDrawerViewController.m */; }; + 299E0ADD1738173B009FAA3C /* MMSideDrawerSectionHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 299E0ADC1738173B009FAA3C /* MMSideDrawerSectionHeaderView.m */; }; + 29C28481172AD77D0089E872 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29C28480172AD77D0089E872 /* QuartzCore.framework */; }; + 29C28487172B07C10089E872 /* MMExampleCenterTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 29C28486172B07C10089E872 /* MMExampleCenterTableViewController.m */; }; + 29C2848D172EB1710089E872 /* MMExampleSideDrawerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 29C2848C172EB1710089E872 /* MMExampleSideDrawerViewController.m */; }; + 29CFD5EC173192D100E1FABB /* MMDrawerVisualState.m in Sources */ = {isa = PBXBuildFile; fileRef = 29CFD5EB173192D100E1FABB /* MMDrawerVisualState.m */; }; + 29CFD5EF1731C7DB00E1FABB /* MMExampleDrawerVisualStateManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 29CFD5EE1731C7DB00E1FABB /* MMExampleDrawerVisualStateManager.m */; }; + 29E2C6181738A10F00606309 /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = 29E2C6141738A10F00606309 /* Icon-72.png */; }; + 29E2C6191738A10F00606309 /* Icon-72@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 29E2C6151738A10F00606309 /* Icon-72@2x.png */; }; + 29E2C61A1738A10F00606309 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 29E2C6161738A10F00606309 /* Icon.png */; }; + 29E2C61B1738A10F00606309 /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 29E2C6171738A10F00606309 /* Icon@2x.png */; }; + 29EEA51B17998320006D68B7 /* MMNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 29EEA51A17998320006D68B7 /* MMNavigationController.m */; }; + 29EEA51E1799923E006D68B7 /* MMExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 29EEA51D1799923E006D68B7 /* MMExampleViewController.m */; }; + 29F6163B172AC22A00B31282 /* MMDrawerBarButtonItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 29F6163A172AC22A00B31282 /* MMDrawerBarButtonItem.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 294A1D0D17199537005BF6B1 /* MMDrawerControllerKitchenSink.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MMDrawerControllerKitchenSink.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 294A1D1017199537005BF6B1 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + 294A1D1217199537005BF6B1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 294A1D1417199537005BF6B1 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + 294A1D1817199537005BF6B1 /* MMDrawerControllerKitchenSink-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "MMDrawerControllerKitchenSink-Info.plist"; sourceTree = ""; }; + 294A1D1A17199537005BF6B1 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + 294A1D1C17199537005BF6B1 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 294A1D1E17199537005BF6B1 /* MMDrawerControllerKitchenSink-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MMDrawerControllerKitchenSink-Prefix.pch"; sourceTree = ""; }; + 294A1D1F17199537005BF6B1 /* MMAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MMAppDelegate.h; sourceTree = ""; }; + 294A1D2017199537005BF6B1 /* MMAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MMAppDelegate.m; sourceTree = ""; }; + 294A1D2217199537005BF6B1 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; + 294A1D2417199537005BF6B1 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; + 294A1D2617199537005BF6B1 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; + 294A1D2E1719982B005BF6B1 /* MMDrawerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMDrawerController.h; sourceTree = ""; }; + 294A1D2F1719982B005BF6B1 /* MMDrawerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMDrawerController.m; sourceTree = ""; }; + 294A1D3117199844005BF6B1 /* UIViewController+MMDrawerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+MMDrawerController.h"; sourceTree = ""; }; + 294A1D3217199844005BF6B1 /* UIViewController+MMDrawerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+MMDrawerController.m"; sourceTree = ""; }; + 2961190517383AFC00CD4063 /* MMLogoView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMLogoView.h; sourceTree = ""; }; + 2961190617383AFC00CD4063 /* MMLogoView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMLogoView.m; sourceTree = ""; }; + 296119081738416400CD4063 /* MMCenterTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMCenterTableViewCell.h; sourceTree = ""; }; + 296119091738416400CD4063 /* MMCenterTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMCenterTableViewCell.m; sourceTree = ""; }; + 2969636A1738141500281B9A /* MMSideDrawerTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMSideDrawerTableViewCell.h; sourceTree = ""; }; + 2969636B1738141500281B9A /* MMSideDrawerTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMSideDrawerTableViewCell.m; sourceTree = ""; }; + 297EA0031738112A00472DF4 /* MMTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMTableViewCell.h; sourceTree = ""; }; + 297EA0041738112A00472DF4 /* MMTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMTableViewCell.m; sourceTree = ""; }; + 29848B5D173015D3006D8502 /* MMExampleLeftSideDrawerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMExampleLeftSideDrawerViewController.h; sourceTree = ""; }; + 29848B5E173015D3006D8502 /* MMExampleLeftSideDrawerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMExampleLeftSideDrawerViewController.m; sourceTree = ""; }; + 29848B6317301793006D8502 /* MMExampleRightSideDrawerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMExampleRightSideDrawerViewController.h; sourceTree = ""; }; + 29848B6417301793006D8502 /* MMExampleRightSideDrawerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMExampleRightSideDrawerViewController.m; sourceTree = ""; }; + 299E0ADB1738173B009FAA3C /* MMSideDrawerSectionHeaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMSideDrawerSectionHeaderView.h; sourceTree = ""; }; + 299E0ADC1738173B009FAA3C /* MMSideDrawerSectionHeaderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMSideDrawerSectionHeaderView.m; sourceTree = ""; }; + 29C28480172AD77D0089E872 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; + 29C28485172B07C10089E872 /* MMExampleCenterTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMExampleCenterTableViewController.h; sourceTree = ""; }; + 29C28486172B07C10089E872 /* MMExampleCenterTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMExampleCenterTableViewController.m; sourceTree = ""; }; + 29C2848B172EB1710089E872 /* MMExampleSideDrawerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMExampleSideDrawerViewController.h; sourceTree = ""; }; + 29C2848C172EB1710089E872 /* MMExampleSideDrawerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMExampleSideDrawerViewController.m; sourceTree = ""; }; + 29CFD5EA173192D100E1FABB /* MMDrawerVisualState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMDrawerVisualState.h; sourceTree = ""; }; + 29CFD5EB173192D100E1FABB /* MMDrawerVisualState.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMDrawerVisualState.m; sourceTree = ""; }; + 29CFD5ED1731C7DB00E1FABB /* MMExampleDrawerVisualStateManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMExampleDrawerVisualStateManager.h; sourceTree = ""; }; + 29CFD5EE1731C7DB00E1FABB /* MMExampleDrawerVisualStateManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMExampleDrawerVisualStateManager.m; sourceTree = ""; }; + 29E2C6141738A10F00606309 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = ""; }; + 29E2C6151738A10F00606309 /* Icon-72@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72@2x.png"; sourceTree = ""; }; + 29E2C6161738A10F00606309 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = ""; }; + 29E2C6171738A10F00606309 /* Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon@2x.png"; sourceTree = ""; }; + 29EEA51917998320006D68B7 /* MMNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMNavigationController.h; sourceTree = ""; }; + 29EEA51A17998320006D68B7 /* MMNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMNavigationController.m; sourceTree = ""; }; + 29EEA51C1799923E006D68B7 /* MMExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMExampleViewController.h; sourceTree = ""; }; + 29EEA51D1799923E006D68B7 /* MMExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMExampleViewController.m; sourceTree = ""; }; + 29F61639172AC22A00B31282 /* MMDrawerBarButtonItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMDrawerBarButtonItem.h; sourceTree = ""; }; + 29F6163A172AC22A00B31282 /* MMDrawerBarButtonItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMDrawerBarButtonItem.m; sourceTree = ""; }; + 462C592D1757C16B006C1D6F /* MMDrawerController+Subclass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MMDrawerController+Subclass.h"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 294A1D0A17199537005BF6B1 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 29C28481172AD77D0089E872 /* QuartzCore.framework in Frameworks */, + 294A1D1117199537005BF6B1 /* UIKit.framework in Frameworks */, + 294A1D1317199537005BF6B1 /* Foundation.framework in Frameworks */, + 294A1D1517199537005BF6B1 /* CoreGraphics.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 294A1D0417199537005BF6B1 = { + isa = PBXGroup; + children = ( + 294A1D2D17199819005BF6B1 /* MMDrawerController */, + 294A1D1617199537005BF6B1 /* ExampleFiles */, + 294A1D0F17199537005BF6B1 /* Frameworks */, + 294A1D0E17199537005BF6B1 /* Products */, + ); + sourceTree = ""; + }; + 294A1D0E17199537005BF6B1 /* Products */ = { + isa = PBXGroup; + children = ( + 294A1D0D17199537005BF6B1 /* MMDrawerControllerKitchenSink.app */, + ); + name = Products; + sourceTree = ""; + }; + 294A1D0F17199537005BF6B1 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 29C28480172AD77D0089E872 /* QuartzCore.framework */, + 294A1D1017199537005BF6B1 /* UIKit.framework */, + 294A1D1217199537005BF6B1 /* Foundation.framework */, + 294A1D1417199537005BF6B1 /* CoreGraphics.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 294A1D1617199537005BF6B1 /* ExampleFiles */ = { + isa = PBXGroup; + children = ( + 294A1D1F17199537005BF6B1 /* MMAppDelegate.h */, + 294A1D2017199537005BF6B1 /* MMAppDelegate.m */, + 2961190E173845FD00CD4063 /* VisualStateManager */, + 2961190D173845EF00CD4063 /* CustomViews */, + 2961190C173845E000CD4063 /* ViewControllers */, + 2961190B173845D100CD4063 /* TableViewHelpers */, + 294A1D1717199537005BF6B1 /* Supporting Files */, + ); + path = ExampleFiles; + sourceTree = ""; + }; + 294A1D1717199537005BF6B1 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 29E2C6131738A10F00606309 /* Icons */, + 294A1D1817199537005BF6B1 /* MMDrawerControllerKitchenSink-Info.plist */, + 294A1D1917199537005BF6B1 /* InfoPlist.strings */, + 294A1D1C17199537005BF6B1 /* main.m */, + 294A1D1E17199537005BF6B1 /* MMDrawerControllerKitchenSink-Prefix.pch */, + 294A1D2217199537005BF6B1 /* Default.png */, + 294A1D2417199537005BF6B1 /* Default@2x.png */, + 294A1D2617199537005BF6B1 /* Default-568h@2x.png */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 294A1D2D17199819005BF6B1 /* MMDrawerController */ = { + isa = PBXGroup; + children = ( + 294A1D2E1719982B005BF6B1 /* MMDrawerController.h */, + 294A1D2F1719982B005BF6B1 /* MMDrawerController.m */, + 462C592D1757C16B006C1D6F /* MMDrawerController+Subclass.h */, + 294A1D3117199844005BF6B1 /* UIViewController+MMDrawerController.h */, + 294A1D3217199844005BF6B1 /* UIViewController+MMDrawerController.m */, + 29F61639172AC22A00B31282 /* MMDrawerBarButtonItem.h */, + 29F6163A172AC22A00B31282 /* MMDrawerBarButtonItem.m */, + 29CFD5EA173192D100E1FABB /* MMDrawerVisualState.h */, + 29CFD5EB173192D100E1FABB /* MMDrawerVisualState.m */, + ); + name = MMDrawerController; + path = ../MMDrawerController; + sourceTree = ""; + }; + 2961190B173845D100CD4063 /* TableViewHelpers */ = { + isa = PBXGroup; + children = ( + 297EA0031738112A00472DF4 /* MMTableViewCell.h */, + 297EA0041738112A00472DF4 /* MMTableViewCell.m */, + 2969636A1738141500281B9A /* MMSideDrawerTableViewCell.h */, + 2969636B1738141500281B9A /* MMSideDrawerTableViewCell.m */, + 296119081738416400CD4063 /* MMCenterTableViewCell.h */, + 296119091738416400CD4063 /* MMCenterTableViewCell.m */, + 299E0ADB1738173B009FAA3C /* MMSideDrawerSectionHeaderView.h */, + 299E0ADC1738173B009FAA3C /* MMSideDrawerSectionHeaderView.m */, + ); + name = TableViewHelpers; + sourceTree = ""; + }; + 2961190C173845E000CD4063 /* ViewControllers */ = { + isa = PBXGroup; + children = ( + 29C28485172B07C10089E872 /* MMExampleCenterTableViewController.h */, + 29C28486172B07C10089E872 /* MMExampleCenterTableViewController.m */, + 29C2848B172EB1710089E872 /* MMExampleSideDrawerViewController.h */, + 29C2848C172EB1710089E872 /* MMExampleSideDrawerViewController.m */, + 29848B5D173015D3006D8502 /* MMExampleLeftSideDrawerViewController.h */, + 29848B5E173015D3006D8502 /* MMExampleLeftSideDrawerViewController.m */, + 29848B6317301793006D8502 /* MMExampleRightSideDrawerViewController.h */, + 29848B6417301793006D8502 /* MMExampleRightSideDrawerViewController.m */, + 29EEA51C1799923E006D68B7 /* MMExampleViewController.h */, + 29EEA51D1799923E006D68B7 /* MMExampleViewController.m */, + 29EEA51917998320006D68B7 /* MMNavigationController.h */, + 29EEA51A17998320006D68B7 /* MMNavigationController.m */, + ); + name = ViewControllers; + sourceTree = ""; + }; + 2961190D173845EF00CD4063 /* CustomViews */ = { + isa = PBXGroup; + children = ( + 2961190517383AFC00CD4063 /* MMLogoView.h */, + 2961190617383AFC00CD4063 /* MMLogoView.m */, + ); + name = CustomViews; + sourceTree = ""; + }; + 2961190E173845FD00CD4063 /* VisualStateManager */ = { + isa = PBXGroup; + children = ( + 29CFD5ED1731C7DB00E1FABB /* MMExampleDrawerVisualStateManager.h */, + 29CFD5EE1731C7DB00E1FABB /* MMExampleDrawerVisualStateManager.m */, + ); + name = VisualStateManager; + sourceTree = ""; + }; + 29E2C6131738A10F00606309 /* Icons */ = { + isa = PBXGroup; + children = ( + 29E2C6141738A10F00606309 /* Icon-72.png */, + 29E2C6151738A10F00606309 /* Icon-72@2x.png */, + 29E2C6161738A10F00606309 /* Icon.png */, + 29E2C6171738A10F00606309 /* Icon@2x.png */, + ); + path = Icons; + sourceTree = SOURCE_ROOT; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 294A1D0C17199537005BF6B1 /* MMDrawerControllerKitchenSink */ = { + isa = PBXNativeTarget; + buildConfigurationList = 294A1D2A17199537005BF6B1 /* Build configuration list for PBXNativeTarget "MMDrawerControllerKitchenSink" */; + buildPhases = ( + 294A1D0917199537005BF6B1 /* Sources */, + 294A1D0A17199537005BF6B1 /* Frameworks */, + 294A1D0B17199537005BF6B1 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = MMDrawerControllerKitchenSink; + productName = MMSideDrawerContainerViewController; + productReference = 294A1D0D17199537005BF6B1 /* MMDrawerControllerKitchenSink.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 294A1D0517199537005BF6B1 /* Project object */ = { + isa = PBXProject; + attributes = { + CLASSPREFIX = MM; + LastUpgradeCheck = 0460; + ORGANIZATIONNAME = "Mutual Mobile"; + }; + buildConfigurationList = 294A1D0817199537005BF6B1 /* Build configuration list for PBXProject "MMDrawerControllerKitchenSink" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 294A1D0417199537005BF6B1; + productRefGroup = 294A1D0E17199537005BF6B1 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 294A1D0C17199537005BF6B1 /* MMDrawerControllerKitchenSink */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 294A1D0B17199537005BF6B1 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 294A1D1B17199537005BF6B1 /* InfoPlist.strings in Resources */, + 294A1D2317199537005BF6B1 /* Default.png in Resources */, + 294A1D2517199537005BF6B1 /* Default@2x.png in Resources */, + 294A1D2717199537005BF6B1 /* Default-568h@2x.png in Resources */, + 29E2C6181738A10F00606309 /* Icon-72.png in Resources */, + 29E2C6191738A10F00606309 /* Icon-72@2x.png in Resources */, + 29E2C61A1738A10F00606309 /* Icon.png in Resources */, + 29E2C61B1738A10F00606309 /* Icon@2x.png in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 294A1D0917199537005BF6B1 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 294A1D1D17199537005BF6B1 /* main.m in Sources */, + 294A1D2117199537005BF6B1 /* MMAppDelegate.m in Sources */, + 294A1D301719982B005BF6B1 /* MMDrawerController.m in Sources */, + 294A1D3317199844005BF6B1 /* UIViewController+MMDrawerController.m in Sources */, + 29F6163B172AC22A00B31282 /* MMDrawerBarButtonItem.m in Sources */, + 29C28487172B07C10089E872 /* MMExampleCenterTableViewController.m in Sources */, + 29C2848D172EB1710089E872 /* MMExampleSideDrawerViewController.m in Sources */, + 29848B5F173015D3006D8502 /* MMExampleLeftSideDrawerViewController.m in Sources */, + 29EEA51E1799923E006D68B7 /* MMExampleViewController.m in Sources */, + 29848B6517301793006D8502 /* MMExampleRightSideDrawerViewController.m in Sources */, + 29CFD5EC173192D100E1FABB /* MMDrawerVisualState.m in Sources */, + 29EEA51B17998320006D68B7 /* MMNavigationController.m in Sources */, + 29CFD5EF1731C7DB00E1FABB /* MMExampleDrawerVisualStateManager.m in Sources */, + 297EA0051738112A00472DF4 /* MMTableViewCell.m in Sources */, + 2969636C1738141500281B9A /* MMSideDrawerTableViewCell.m in Sources */, + 299E0ADD1738173B009FAA3C /* MMSideDrawerSectionHeaderView.m in Sources */, + 2961190717383AFC00CD4063 /* MMLogoView.m in Sources */, + 2961190A1738416400CD4063 /* MMCenterTableViewCell.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 294A1D1917199537005BF6B1 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 294A1D1A17199537005BF6B1 /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 294A1D2817199537005BF6B1 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 6.1; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 294A1D2917199537005BF6B1 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 6.1; + OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 294A1D2B17199537005BF6B1 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "ExampleFiles/MMDrawerControllerKitchenSink-Prefix.pch"; + INFOPLIST_FILE = "ExampleFiles/MMDrawerControllerKitchenSink-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; + PRODUCT_NAME = MMDrawerControllerKitchenSink; + WARNING_CFLAGS = "-Wdocumentation"; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + 294A1D2C17199537005BF6B1 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "ExampleFiles/MMDrawerControllerKitchenSink-Prefix.pch"; + INFOPLIST_FILE = "ExampleFiles/MMDrawerControllerKitchenSink-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; + PRODUCT_NAME = MMDrawerControllerKitchenSink; + WARNING_CFLAGS = "-Wdocumentation"; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 294A1D0817199537005BF6B1 /* Build configuration list for PBXProject "MMDrawerControllerKitchenSink" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 294A1D2817199537005BF6B1 /* Debug */, + 294A1D2917199537005BF6B1 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 294A1D2A17199537005BF6B1 /* Build configuration list for PBXNativeTarget "MMDrawerControllerKitchenSink" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 294A1D2B17199537005BF6B1 /* Debug */, + 294A1D2C17199537005BF6B1 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 294A1D0517199537005BF6B1 /* Project object */; +} diff --git a/ios/Classes/MMDrawerController/KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ios/Classes/MMDrawerController/KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..72fe7c2 --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/ios/Classes/MMDrawerController/KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.xcworkspace/xcshareddata/MMDrawerControllerKitchenSink.xccheckout b/ios/Classes/MMDrawerController/KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.xcworkspace/xcshareddata/MMDrawerControllerKitchenSink.xccheckout new file mode 100644 index 0000000..2bf4fcb --- /dev/null +++ b/ios/Classes/MMDrawerController/KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.xcworkspace/xcshareddata/MMDrawerControllerKitchenSink.xccheckout @@ -0,0 +1,41 @@ + + + + + IDESourceControlProjectFavoriteDictionaryKey + + IDESourceControlProjectIdentifier + 88813EDE-C4BC-4EAD-BA3F-F5FC71109468 + IDESourceControlProjectName + MMDrawerControllerKitchenSink + IDESourceControlProjectOriginsDictionary + + C486FB0C-7803-4607-BCA9-799E743ECFBA + https://github.com/mutualmobile/MMDrawerController.git + + IDESourceControlProjectPath + KitchenSink/MMDrawerControllerKitchenSink.xcodeproj/project.xcworkspace + IDESourceControlProjectRelativeInstallPathDictionary + + C486FB0C-7803-4607-BCA9-799E743ECFBA + ../../.. + + IDESourceControlProjectURL + https://github.com/mutualmobile/MMDrawerController.git + IDESourceControlProjectVersion + 110 + IDESourceControlProjectWCCIdentifier + C486FB0C-7803-4607-BCA9-799E743ECFBA + IDESourceControlProjectWCConfigurations + + + IDESourceControlRepositoryExtensionIdentifierKey + public.vcs.git + IDESourceControlWCCIdentifierKey + C486FB0C-7803-4607-BCA9-799E743ECFBA + IDESourceControlWCCName + MMDrawerController-GitHub + + + + diff --git a/ios/Classes/MMDrawerController/LICENSE b/ios/Classes/MMDrawerController/LICENSE new file mode 100644 index 0000000..5cda9d9 --- /dev/null +++ b/ios/Classes/MMDrawerController/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) + +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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/ios/Classes/MMDrawerController/MMDrawerController.podspec b/ios/Classes/MMDrawerController/MMDrawerController.podspec new file mode 100644 index 0000000..3b81644 --- /dev/null +++ b/ios/Classes/MMDrawerController/MMDrawerController.podspec @@ -0,0 +1,33 @@ +Pod::Spec.new do |s| + s.name = "MMDrawerController" + s.version = "0.5.7" + s.summary = "A lightweight, easy-to-use side drawer navigation controller." + s.homepage = "https://github.com/mutualmobile/MMDrawerController" + s.license = { :type => 'MIT', :file => 'LICENSE' } + s.author = { "Kevin Harwood" => "kevin.harwood@mutualmobile.com" } + s.source = { :git => "https://github.com/mutualmobile/MMDrawerController.git", :tag => "0.5.7" } + s.platform = :ios, '5.0' + s.requires_arc = true + s.screenshots = [ "http://mutualmobile.github.io/MMDrawerController/ExampleImages/example1.png", + "http://mutualmobile.github.io/MMDrawerController/ExampleImages/example2.png" ] + + s.subspec 'Core' do |ss| + ss.source_files = 'MMDrawerController/MMDrawerController*', 'MMDrawerController/UIViewController+MMDrawerController*' + ss.framework = 'QuartzCore' + end + + s.subspec 'MMDrawerBarButtonItem' do |ss| + ss.source_files = 'MMDrawerController/MMDrawerBarButtonItem.{h,m}' + ss.dependency 'MMDrawerController/Core' + end + + s.subspec 'MMDrawerVisualStates' do |ss| + ss.source_files = 'MMDrawerController/MMDrawerVisualState.{h,m}' + ss.dependency 'MMDrawerController/Core' + end + + s.subspec 'Subclass' do |ss| + ss.source_files = 'MMDrawerController/MMDrawerController+Subclass.h' + ss.dependency 'MMDrawerController/Core' + end +end diff --git a/ios/Classes/MMDrawerController/MMDrawerController/MMDrawerBarButtonItem.h b/ios/Classes/MMDrawerController/MMDrawerController/MMDrawerBarButtonItem.h new file mode 100644 index 0000000..e765424 --- /dev/null +++ b/ios/Classes/MMDrawerController/MMDrawerController/MMDrawerBarButtonItem.h @@ -0,0 +1,77 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +/** + `MMDrawerBarButtonItem` provides convenience methods to create `UIBarButtonItems` with a default hamburger-menu asset. + */ + +@interface MMDrawerBarButtonItem : UIBarButtonItem + +///--------------------------------------- +/// @name Initializing a `MMDrawerBarButtonItem` +///--------------------------------------- + +/** + Creates and initializes an `MMDrawerBarButtonItem` without a border. + + @param target The target to forward the `action` to when the button is pressed. + @param action The action to call when the button is pressed. + + @return The newly-initialized bar button item. + */ +-(id)initWithTarget:(id)target action:(SEL)action; + +/** + Returns the current color of the menu button for the state requested. This property is deprecated in iOS 7.0. Use `tintColor` instead. + + @param state The UIControl state that the color is being requested for. + + @return The menu button color for the requested state. + */ +-(UIColor *)menuButtonColorForState:(UIControlState)state __attribute__((deprecated("Use tintColor instead"))); + +/** + Sets the color of the menu button for the specified state. For this control, only set colors for `UIControlStateNormal` and `UIControlStateHighlighted`. This property is deprecated in iOS 7.0. Use `tintColor` instead. + + @param color The color to set. + @param state The state to set the color for. + */ +-(void)setMenuButtonColor:(UIColor *)color forState:(UIControlState)state __attribute__((deprecated("Use tintColor instead"))); + +/** + Returns the current color of the shadow for the state requested. This property is deprecated in iOS 7.0. The menu button no longer supports a shadow. + + @param state The UIControl state that the color is being requested for. + + @return The menu button color for the requested state. + */ +-(UIColor *)shadowColorForState:(UIControlState)state __attribute__((deprecated("Shadow is no longer supported"))); + +/** + Sets the color of the shadow for the specified state. For this control, only set colors for `UIControlStateNormal` and `UIControlStateHighlighted`. This property is deprecated in iOS 7.0. The menu button no longer supports a shadow. + + @param color The color to set. + @param state The state to set the color for. + */ +-(void)setShadowColor:(UIColor *)color forState:(UIControlState)state __attribute__((deprecated("Shadow is no longer supported"))); + +@end diff --git a/ios/Classes/MMDrawerController/MMDrawerController/MMDrawerBarButtonItem.m b/ios/Classes/MMDrawerController/MMDrawerController/MMDrawerBarButtonItem.m new file mode 100644 index 0000000..2fc9997 --- /dev/null +++ b/ios/Classes/MMDrawerController/MMDrawerController/MMDrawerBarButtonItem.m @@ -0,0 +1,302 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import "MMDrawerBarButtonItem.h" + +@interface MMDrawerMenuButtonView : UIButton +@property (nonatomic,strong) UIColor * menuButtonNormalColor; +@property (nonatomic,strong) UIColor * menuButtonHighlightedColor; + +@property (nonatomic,strong) UIColor * shadowNormalColor; +@property (nonatomic,strong) UIColor * shadowHighlightedColor; + +-(UIColor *)menuButtonColorForState:(UIControlState)state; +-(void)setMenuButtonColor:(UIColor *)color forState:(UIControlState)state; + +-(UIColor *)shadowColorForState:(UIControlState)state; +-(void)setShadowColor:(UIColor *)color forState:(UIControlState)state; + +@end + +@implementation MMDrawerMenuButtonView + +-(id)initWithFrame:(CGRect)frame{ + self = [super initWithFrame:frame]; + if(self){ + [self setMenuButtonNormalColor:[[UIColor whiteColor] colorWithAlphaComponent:0.9f]]; + [self setMenuButtonHighlightedColor:[UIColor colorWithRed:139.0/255.0 + green:135.0/255.0 + blue:136.0/255.0 + alpha:0.9f]]; + + [self setShadowNormalColor:[[UIColor blackColor] colorWithAlphaComponent:0.5f]]; + [self setShadowHighlightedColor:[[UIColor blackColor] colorWithAlphaComponent:0.2f]]; + } + return self; +} + +-(UIColor *)menuButtonColorForState:(UIControlState)state{ + UIColor * color; + switch (state) { + case UIControlStateNormal: + color = self.menuButtonNormalColor; + break; + case UIControlStateHighlighted: + color = self.menuButtonHighlightedColor; + break; + default: + break; + } + return color; +} + +-(void)setMenuButtonColor:(UIColor *)color forState:(UIControlState)state{ + switch (state) { + case UIControlStateNormal: + [self setMenuButtonNormalColor:color]; + break; + case UIControlStateHighlighted: + [self setMenuButtonHighlightedColor:color]; + break; + default: + break; + } + [self setNeedsDisplay]; +} + +-(UIColor *)shadowColorForState:(UIControlState)state{ + UIColor * color; + switch (state) { + case UIControlStateNormal: + color = self.shadowNormalColor; + break; + case UIControlStateHighlighted: + color = self.shadowHighlightedColor; + break; + default: + break; + } + return color; +} + +-(void)setShadowColor:(UIColor *)color forState:(UIControlState)state{ + switch (state) { + case UIControlStateNormal: + [self setShadowNormalColor:color]; + break; + case UIControlStateHighlighted: + [self setShadowHighlightedColor:color]; + break; + default: + break; + } + [self setNeedsDisplay]; +} + +-(void)drawRect:(CGRect)rect{ + //// General Declarations + CGContextRef context = UIGraphicsGetCurrentContext(); + + //Sizes + CGFloat buttonWidth = CGRectGetWidth(self.bounds)*.80; + CGFloat buttonHeight = CGRectGetHeight(self.bounds)*.16; + CGFloat xOffset = CGRectGetWidth(self.bounds)*.10; + CGFloat yOffset = CGRectGetHeight(self.bounds)*.12; + CGFloat cornerRadius = 1.0; + + //// Color Declarations + UIColor* buttonColor = [self menuButtonColorForState:self.state]; + UIColor* shadowColor = [self shadowColorForState:self.state]; + + + //// Shadow Declarations + UIColor* shadow = shadowColor; + CGSize shadowOffset = CGSizeMake(0.0, 1.0); + CGFloat shadowBlurRadius = 0; + + //// Top Bun Drawing + UIBezierPath* topBunPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(xOffset, yOffset, buttonWidth, buttonHeight) cornerRadius:cornerRadius]; + CGContextSaveGState(context); + CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor); + [buttonColor setFill]; + [topBunPath fill]; + CGContextRestoreGState(context); + + //// Meat Drawing + UIBezierPath* meatPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(xOffset, yOffset*2 + buttonHeight, buttonWidth, buttonHeight) cornerRadius:cornerRadius]; + CGContextSaveGState(context); + CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor); + [buttonColor setFill]; + [meatPath fill]; + CGContextRestoreGState(context); + + //// Bottom Bun Drawing + UIBezierPath* bottomBunPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(xOffset, yOffset*3 + buttonHeight*2, buttonWidth, buttonHeight) cornerRadius:cornerRadius]; + CGContextSaveGState(context); + CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor); + [buttonColor setFill]; + [bottomBunPath fill]; + CGContextRestoreGState(context); +} + +-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ + [super touchesBegan:touches withEvent:event]; + [self setNeedsDisplay]; +} + +-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ + [super touchesEnded:touches withEvent:event]; + [self setNeedsDisplay]; +} + +-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{ + [super touchesCancelled:touches withEvent:event]; + [self setNeedsDisplay]; +} + +-(void)setSelected:(BOOL)selected{ + [super setSelected:selected]; + [self setNeedsDisplay]; +} + +-(void)setHighlighted:(BOOL)highlighted{ + [super setHighlighted:highlighted]; + [self setNeedsDisplay]; +} + +-(void)setTintColor:(UIColor *)tintColor{ + if([super respondsToSelector:@selector(setTintColor:)]){ + [super setTintColor:tintColor]; + } +} + +-(void)tintColorDidChange{ + [self setNeedsDisplay]; +} + +@end + +@interface MMDrawerBarButtonItem () +@property (nonatomic,strong) MMDrawerMenuButtonView * buttonView; + +@end + +@implementation MMDrawerBarButtonItem + ++(UIImage*)drawerButtonItemImage{ + + static UIImage *drawerButtonImage = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + + UIGraphicsBeginImageContextWithOptions( CGSizeMake(26, 26), NO, 0 ); + + //// Color Declarations + UIColor* fillColor = [UIColor whiteColor]; + + //// Frames + CGRect frame = CGRectMake(0, 0, 26, 26); + + //// Bottom Bar Drawing + UIBezierPath* bottomBarPath = [UIBezierPath bezierPathWithRect: CGRectMake(CGRectGetMinX(frame) + floor((CGRectGetWidth(frame) - 16) * 0.50000 + 0.5), CGRectGetMinY(frame) + floor((CGRectGetHeight(frame) - 1) * 0.72000 + 0.5), 16, 1)]; + [fillColor setFill]; + [bottomBarPath fill]; + + + //// Middle Bar Drawing + UIBezierPath* middleBarPath = [UIBezierPath bezierPathWithRect: CGRectMake(CGRectGetMinX(frame) + floor((CGRectGetWidth(frame) - 16) * 0.50000 + 0.5), CGRectGetMinY(frame) + floor((CGRectGetHeight(frame) - 1) * 0.48000 + 0.5), 16, 1)]; + [fillColor setFill]; + [middleBarPath fill]; + + + //// Top Bar Drawing + UIBezierPath* topBarPath = [UIBezierPath bezierPathWithRect: CGRectMake(CGRectGetMinX(frame) + floor((CGRectGetWidth(frame) - 16) * 0.50000 + 0.5), CGRectGetMinY(frame) + floor((CGRectGetHeight(frame) - 1) * 0.24000 + 0.5), 16, 1)]; + [fillColor setFill]; + [topBarPath fill]; + + drawerButtonImage = UIGraphicsGetImageFromCurrentImageContext(); + }); + + return drawerButtonImage; +} + +-(id)initWithTarget:(id)target action:(SEL)action{ + + if((floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1)){ + return [self initWithImage:[self.class drawerButtonItemImage] + style:UIBarButtonItemStylePlain + target:target + action:action]; + } + else { + MMDrawerMenuButtonView * buttonView = [[MMDrawerMenuButtonView alloc] initWithFrame:CGRectMake(0, 0, 26, 26)]; + [buttonView addTarget:self action:@selector(touchUpInside:) forControlEvents:UIControlEventTouchUpInside]; + self = [self initWithCustomView:buttonView]; + if(self){ + [self setButtonView:buttonView]; + } + self.action = action; + self.target = target; + return self; + } +} + +-(id)initWithCoder:(NSCoder *)aDecoder{ + // non-ideal way to get the target/action, but it works + UIBarButtonItem* barButtonItem = [[UIBarButtonItem alloc] initWithCoder: aDecoder]; + return [self initWithTarget:barButtonItem.target action:barButtonItem.action]; +} + +-(void)touchUpInside:(id)sender{ + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warc-performSelector-leaks" + [self.target performSelector:self.action withObject:sender]; +#pragma clang diagnostic pop; + +} + +-(UIColor *)menuButtonColorForState:(UIControlState)state{ + return [self.buttonView menuButtonColorForState:state]; +} + +-(void)setMenuButtonColor:(UIColor *)color forState:(UIControlState)state{ + [self.buttonView setMenuButtonColor:color forState:state]; +} + +-(UIColor *)shadowColorForState:(UIControlState)state{ + return [self.buttonView shadowColorForState:state]; +} + +-(void)setShadowColor:(UIColor *)color forState:(UIControlState)state{ + [self.buttonView setShadowColor:color forState:state]; +} + +-(void)setTintColor:(UIColor *)tintColor{ + if([super respondsToSelector:@selector(setTintColor:)]){ + [super setTintColor:tintColor]; + } + if([self.buttonView respondsToSelector:@selector(setTintColor:)]){ + [self.buttonView setTintColor:tintColor]; + } +} + +@end diff --git a/ios/Classes/MMDrawerController/MMDrawerController/MMDrawerController+Subclass.h b/ios/Classes/MMDrawerController/MMDrawerController/MMDrawerController+Subclass.h new file mode 100644 index 0000000..419ff68 --- /dev/null +++ b/ios/Classes/MMDrawerController/MMDrawerController/MMDrawerController+Subclass.h @@ -0,0 +1,111 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "MMDrawerController.h" + +/** + This class extension is designed for use by subclasses of `MMDrawerController` to customize the functionality to support a specific use-case by a developer. When importing this file, there is no need to also call `#import MMDrawerController.h`. + + None of these methods are meant to be called by non-subclasses of `MMDrawerController`. + */ + +@interface MMDrawerController (Subclass) +///--------------------------------------- +/// @name Gesture Interaction +///--------------------------------------- +/** + `MMDrawerController`'s single-tap gesture recognizer callback. This method is called every time the `UITapGestureRecognizer` is triggered. + + @param tapGesture The single-tap gesture recognizer instance that triggered the callback + */ +-(void)tapGestureCallback:(UITapGestureRecognizer *)tapGesture __attribute((objc_requires_super)); + +/** + `MMDrawerController`'s pan gesture recognizer callback. This method is called every time the `UIPanGestureRecognizer` is updated. + + @warning This method do the minimal amount of work to keep the pan gesture responsive. + + @param panGesture The pan gesture recognizer instance that triggered the callback + */ +-(void)panGestureCallback:(UIPanGestureRecognizer *)panGesture __attribute((objc_requires_super)); + +/** + A `UIGestureRecognizerDelegate` method that is queried by `MMDrawerController`'s gestures to determine if it should receive the touch. + + @param gestureRecognizer The gesture recognizer that is asking if it should recieve a touch + @param touch The touch in question in gestureRecognizer.view's coordinate space + */ +-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch __attribute((objc_requires_super)); + +///--------------------------------------- +/// @name Drawer Presentation +///--------------------------------------- +/** + Sets the initial conditions for `MMDrawerController` and its child view controllers to prepare the drawer for a transition. If a drawer is open and the opposite drawer is being presented, it prepares that drawer to be hidden and vice-versa for the closing drawer. + + @param drawer The drawer side that will be presented + @param animated A boolean that indicates whether the presentation is being animated or not + */ +-(void)prepareToPresentDrawer:(MMDrawerSide)drawer animated:(BOOL)animated __attribute((objc_requires_super)); + +///--------------------------------------- +/// @name Opening/Closing Drawer +///--------------------------------------- +/** + The method that handles closing the drawer. You can subclass this method to get a callback every time the drawer is about to be closed. You can inspect the current open side to determine what side is about to be closed. + + @param animated A boolean that indicates whether the drawer should close with animation + @param velocity A float indicating how fast the drawer should close + @param animationOptions A mask defining the animation options of the animation + @param completion A completion block to be called when the drawer is finished closing + */ +-(void)closeDrawerAnimated:(BOOL)animated velocity:(CGFloat)velocity animationOptions:(UIViewAnimationOptions)options completion:(void (^)(BOOL))completion __attribute((objc_requires_super)); + +/** + The method that handles opening the drawer. You can subclass this method to get a callback every time the drawer is about to be opened. + + @param drawerSide The drawer side that will be opened + @param animated A boolean that indicates whether the drawer should open with animation + @param velocity A float indicating how fast the drawer should open + @param animationOptions A mask defining the animation options of the animation + @param completion A completion block to be called when the drawer is finished opening + */ +-(void)openDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated velocity:(CGFloat)velocity animationOptions:(UIViewAnimationOptions)options completion:(void (^)(BOOL))completion __attribute((objc_requires_super)); + +///--------------------------------------- +/// @name `UIViewController` Subclass Methods +///--------------------------------------- +/** + Included here to ensure subclasses call `super`. + + @param toInterfaceOrientation The interface orientation that the interface is moving to + @param duration The duration of the interface orientation animation + */ +-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration __attribute((objc_requires_super)); + +/** + Included here to ensure subclasses call `super`. + + @param toInterfaceOrientation The interface orientation that the interface is moving to + @param duration The duration of the interface orientation animation + */ +-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration __attribute((objc_requires_super)); + +@end diff --git a/ios/Classes/MMDrawerController/MMDrawerController/MMDrawerController.h b/ios/Classes/MMDrawerController/MMDrawerController/MMDrawerController.h new file mode 100644 index 0000000..bf895cb --- /dev/null +++ b/ios/Classes/MMDrawerController/MMDrawerController/MMDrawerController.h @@ -0,0 +1,413 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import + +/** + `MMDrawerController` is a side drawer navigation container view controller designed to support the growing number of applications that leverage the side drawer paradigm. This library is designed to exclusively support side drawer navigation in light-weight, focused approach. + + ## Creating a MMDrawerController + `MMDrawerController` is a container view controller, similiar to `UINavigationController` or `UITabBarController`, with up to three child view controllers - Center, LeftDrawer, and RightDrawer. To create a `MMDrawerController`, you must first instantiate the drawer view controllers and the initial center controller, then call one of the init methods listed in this class. + + ## Handling a UINavigationController as the centerViewController + `MMDrawerController` automatically supports handling a `UINavigationController` as the `centerViewController`, and will correctly handle the proper gestures on each view (the navigation bar view as well as the content view for the visible view controller). Note that while this library does support other container view controllers, the open/close gestures are not customized to support them. + + ## Accessing MMDrawerController from the Child View Controller + You can leverage the category class (UIViewController+MMDrawerController) included with this library to access information about the parent `MMDrawerController`. Note that if you are contained within a UINavigationController, the `drawerContainerViewController` will still return the proper reference to the `drawerContainerViewController` parent, even though it is not the direct parent. Refer to the documentation included with the category for more information. + + ## How MMDrawerOpenCenterInteractionMode is handled + `MMDrawerOpenCenterInteractionMode` controls how the user should be able to interact with the center view controller when either drawer is open. By default, this is set to `MMDrawerOpenCenterInteractionModeNavigationBarOnly`, which allows the user to interact with UINavigationBarItems while either drawer is open (typicaly used to click the menu button to close). If you set the interaction mode to `MMDrawerOpenCenterInteractionModeNone`, no items within the center view will be able to be interacted with while a drawer is open. Note that this setting has no effect at all on the `MMCloseDrawerGestureMode`. + + ## How Open/Close Gestures are handled + Two gestures are added to every instance of a drawer controller, one for pan and one for touch. `MMDrawerController` is the delegate for each of the gesture recoginzers, and determines if a touch should be sent to the appropriate gesture when a touch is detected compared with the masks set for open and close gestures and the state of the drawer controller. + + ## Integrating with State Restoration + In order to opt in to state restoration for `MMDrawerController`, you must set the `restorationIdentifier` of your drawer controller. Instances of your centerViewController, leftDrawerViewController and rightDrawerViewController must also be configured with their own `restorationIdentifier` (and optionally a restorationClass) if you intend for those to be restored as well. If your MMDrawerController had an open drawer when your app was sent to the background, that state will also be restored. + + ## What this library doesn't do. + This library is not meant for: + - Top or bottom drawer views + - Displaying both drawers at one time + - Displaying a minimum drawer width + - Support container view controllers other than `UINavigationController` as the center view controller. + */ + +typedef NS_ENUM(NSInteger,MMDrawerSide){ + MMDrawerSideNone = 0, + MMDrawerSideLeft, + MMDrawerSideRight, +}; + +typedef NS_OPTIONS(NSInteger, MMOpenDrawerGestureMode) { + MMOpenDrawerGestureModeNone = 0, + MMOpenDrawerGestureModePanningNavigationBar = 1 << 1, + MMOpenDrawerGestureModePanningCenterView = 1 << 2, + MMOpenDrawerGestureModeBezelPanningCenterView = 1 << 3, + MMOpenDrawerGestureModeCustom = 1 << 4, + MMOpenDrawerGestureModeAll = MMOpenDrawerGestureModePanningNavigationBar | + MMOpenDrawerGestureModePanningCenterView | + MMOpenDrawerGestureModeBezelPanningCenterView | + MMOpenDrawerGestureModeCustom, +}; + +typedef NS_OPTIONS(NSInteger, MMCloseDrawerGestureMode) { + MMCloseDrawerGestureModeNone = 0, + MMCloseDrawerGestureModePanningNavigationBar = 1 << 1, + MMCloseDrawerGestureModePanningCenterView = 1 << 2, + MMCloseDrawerGestureModeBezelPanningCenterView = 1 << 3, + MMCloseDrawerGestureModeTapNavigationBar = 1 << 4, + MMCloseDrawerGestureModeTapCenterView = 1 << 5, + MMCloseDrawerGestureModePanningDrawerView = 1 << 6, + MMCloseDrawerGestureModeCustom = 1 << 7, + MMCloseDrawerGestureModeAll = MMCloseDrawerGestureModePanningNavigationBar | + MMCloseDrawerGestureModePanningCenterView | + MMCloseDrawerGestureModeBezelPanningCenterView | + MMCloseDrawerGestureModeTapNavigationBar | + MMCloseDrawerGestureModeTapCenterView | + MMCloseDrawerGestureModePanningDrawerView | + MMCloseDrawerGestureModeCustom, +}; + +typedef NS_ENUM(NSInteger, MMDrawerOpenCenterInteractionMode) { + MMDrawerOpenCenterInteractionModeNone, + MMDrawerOpenCenterInteractionModeFull, + MMDrawerOpenCenterInteractionModeNavigationBarOnly, +}; + +@class MMDrawerController; +typedef void (^MMDrawerControllerDrawerVisualStateBlock)(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible); + +@interface MMDrawerController : UIViewController + +///--------------------------------------- +/// @name Accessing Drawer Container View Controller Properties +///--------------------------------------- + +/** + The center view controller. + + This can only be set via the init methods, as well as the `setNewCenterViewController:...` methods. The size of this view controller will automatically be set to the size of the drawer container view controller, and it's position is modified from within this class. Do not modify the frame externally. + */ +@property (nonatomic, strong) UIViewController * centerViewController; + +/** + The left drawer view controller. + + The size of this view controller is managed within this class, and is automatically set to the appropriate size based on the `maximumLeftDrawerWidth`. Do not modify the frame externally. + */ +@property (nonatomic, strong) UIViewController * leftDrawerViewController; + +/** + The right drawer view controller. + + The size of this view controller is managed within this class, and is automatically set to the appropriate size based on the `maximumRightDrawerWidth`. Do not modify the frame externally. + */ +@property (nonatomic, strong) UIViewController * rightDrawerViewController; + +/** + The maximum width of the `leftDrawerViewController`. + + By default, this is set to 280. If the `leftDrawerViewController` is nil, this property will return 0.0; + */ +@property (nonatomic, assign) CGFloat maximumLeftDrawerWidth; + +/** + The maximum width of the `rightDrawerViewController`. + + By default, this is set to 280. If the `rightDrawerViewController` is nil, this property will return 0.0; + + */ +@property (nonatomic, assign) CGFloat maximumRightDrawerWidth; + +/** + The visible width of the `leftDrawerViewController`. + + Note this value can be greater than `maximumLeftDrawerWidth` during the full close animation when setting a new center view controller; + */ +@property (nonatomic, assign, readonly) CGFloat visibleLeftDrawerWidth; + +/** + The visible width of the `rightDrawerViewController`. + + Note this value can be greater than `maximumRightDrawerWidth` during the full close animation when setting a new center view controller; + */ +@property (nonatomic, assign, readonly) CGFloat visibleRightDrawerWidth; + +/** + The animation velocity of the open and close methods, measured in points per second. + + By default, this is set to 840 points per second (three times the default drawer width), meaning it takes 1/3 of a second for the `centerViewController` to open/close across the default drawer width. Note that there is a minimum .1 second duration for built in animations, to account for small distance animations. + */ +@property (nonatomic, assign) CGFloat animationVelocity; + +/** + A boolean that determines whether or not the panning gesture will "hard-stop" at the maximum width for a given drawer side. + + By default, this value is set to YES. Enabling `shouldStretchDrawer` will give the pan a gradual asymptotic stopping point much like `UIScrollView` behaves. Note that if this value is set to YES, the `drawerVisualStateBlock` can be passed a `percentVisible` greater than 1.0, so be sure to handle that case appropriately. + */ +@property (nonatomic, assign) BOOL shouldStretchDrawer; + +/** + The current open side of the drawer. + + Note this value will change as soon as a pan gesture opens a drawer, or when a open/close animation is finished. + */ +@property (nonatomic, assign, readonly) MMDrawerSide openSide; + +/** + How a user is allowed to open a drawer using gestures. + + By default, this is set to `MMOpenDrawerGestureModeNone`. Note these gestures may affect user interaction with the `centerViewController`, so be sure to use appropriately. + */ +@property (nonatomic, assign) MMOpenDrawerGestureMode openDrawerGestureModeMask; + +/** + How a user is allowed to close a drawer. + + By default, this is set to `MMCloseDrawerGestureModeNone`. Note these gestures may affect user interaction with the `centerViewController`, so be sure to use appropriately. + */ +@property (nonatomic, assign) MMCloseDrawerGestureMode closeDrawerGestureModeMask; + +/** + The value determining if the user can interact with the `centerViewController` when a side drawer is open. + + By default, it is `MMDrawerOpenCenterInteractionModeNavigationBarOnly`, meaning that the user can only interact with the buttons on the `UINavigationBar`, if the center view controller is a `UINavigationController`. Otherwise, the user cannot interact with any other center view controller elements. + */ +@property (nonatomic, assign) MMDrawerOpenCenterInteractionMode centerHiddenInteractionMode; + +/** + The flag determining if a shadow should be drawn off of `centerViewController` when a drawer is open. + + By default, this is set to YES. + */ +@property (nonatomic, assign) BOOL showsShadow; + +/** + The flag determining if a custom background view should appear beneath the status bar, forcing the child content to be drawn lower than the status bar. This property is only available for > iOS 7.0 to take into account for the new behavior of the status bar. + + By default, this is set to NO. If running on < iOS 7.0, it will always return NO. + */ +@property (nonatomic, assign) BOOL showsStatusBarBackgroundView; + +/** + The color of the status bar background view if `showsStatusBarBackgroundView` is set to YES. This value is ignored in < iOS 7.0. + + By default, this is set `[UIColor blackColor]`. + */ +@property (nonatomic, strong) UIColor * statusBarViewBackgroundColor; + +///--------------------------------------- +/// @name Initializing a `MMDrawerController` +///--------------------------------------- + +/** + Creates and initializes an `MMDrawerController` object with the specified center view controller, left drawer view controller, and right drawer view controller. + + @param centerViewController The center view controller. This argument must not be `nil`. + @param leftDrawerViewController The left drawer view controller. + @param rightDrawerViewController The right drawer controller. + + @return The newly-initialized drawer container view controller. + */ +-(id)initWithCenterViewController:(UIViewController *)centerViewController leftDrawerViewController:(UIViewController *)leftDrawerViewController rightDrawerViewController:(UIViewController *)rightDrawerViewController; + +/** + Creates and initializes an `MMDrawerController` object with the specified center view controller, left drawer view controller. + + @param centerViewController The center view controller. This argument must not be `nil`. + @param leftDrawerViewController The left drawer view controller. + + @return The newly-initialized drawer container view controller. + */ +-(id)initWithCenterViewController:(UIViewController *)centerViewController leftDrawerViewController:(UIViewController *)leftDrawerViewController; + +/** + Creates and initializes an `MMDrawerController` object with the specified center view controller, right drawer view controller. + + @param centerViewController The center view controller. This argument must not be `nil`. + @param rightDrawerViewController The right drawer controller. + + @return The newly-initialized drawer container view controller. + */ +-(id)initWithCenterViewController:(UIViewController *)centerViewController rightDrawerViewController:(UIViewController *)rightDrawerViewController; + +///--------------------------------------- +/// @name Opening and Closing a Drawer +///--------------------------------------- + +/** + Toggles the drawer open/closed based on the `drawer` passed in. + + Note that if you attempt to toggle a drawer closed while the other is open, nothing will happen. For example, if you pass in MMDrawerSideLeft, but the right drawer is open, nothing will happen. In addition, the completion block will be called with the finished flag set to NO. + + @param drawerSide The `MMDrawerSide` to toggle. This value cannot be `MMDrawerSideNone`. + @param animated Determines whether the `drawer` should be toggle animated. + @param completion The block that is called when the toggle is complete, or if no toggle took place at all. + + */ +-(void)toggleDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated completion:(void(^)(BOOL finished))completion; + +/** + Closes the open drawer. + + @param animated Determines whether the drawer side should be closed animated + @param completion The block that is called when the close is complete + + */ +-(void)closeDrawerAnimated:(BOOL)animated completion:(void(^)(BOOL finished))completion; + +/** + Opens the `drawer` passed in. + + @param drawerSide The `MMDrawerSide` to open. This value cannot be `MMDrawerSideNone`. + @param animated Determines whether the `drawer` should be open animated. + @param completion The block that is called when the toggle is open. + + */ +-(void)openDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated completion:(void(^)(BOOL finished))completion; + +///--------------------------------------- +/// @name Setting a new Center View Controller +///--------------------------------------- + +/** + Sets the new `centerViewController`. + + This sets the view controller and will automatically adjust the frame based on the current state of the drawer controller. If `closeAnimated` is YES, it will immediately change the center view controller, and close the drawer from its current position. + + @param centerViewController The new `centerViewController`. + @param closeAnimated Determines whether the drawer should be closed with an animation. + @param completion The block called when the animation is finsihed. + + */ +-(void)setCenterViewController:(UIViewController *)centerViewController withCloseAnimation:(BOOL)closeAnimated completion:(void(^)(BOOL finished))completion; + +/** + Sets the new `centerViewController`. + + This sets the view controller and will automatically adjust the frame based on the current state of the drawer controller. If `closeFullAnimated` is YES, the current center view controller will animate off the screen, the new center view controller will then be set, followed by the drawer closing across the full width of the screen. + + @param newCenterViewController The new `centerViewController`. + @param fullCloseAnimated Determines whether the drawer should be closed with an animation. + @param completion The block called when the animation is finsihed. + + */ +-(void)setCenterViewController:(UIViewController *)newCenterViewController withFullCloseAnimation:(BOOL)fullCloseAnimated completion:(void(^)(BOOL finished))completion; + +///--------------------------------------- +/// @name Animating the Width of a Drawer +///--------------------------------------- + +/** + Sets the maximum width of the left drawer view controller. + + If the drawer is open, and `animated` is YES, it will animate the drawer frame as well as adjust the center view controller. If the drawer is not open, this change will take place immediately. + + @param width The new width of left drawer view controller. This must be greater than zero. + @param animated Determines whether the drawer should be adjusted with an animation. + @param completion The block called when the animation is finished. + + */ +-(void)setMaximumLeftDrawerWidth:(CGFloat)width animated:(BOOL)animated completion:(void(^)(BOOL finished))completion; + +/** + Sets the maximum width of the right drawer view controller. + + If the drawer is open, and `animated` is YES, it will animate the drawer frame as well as adjust the center view controller. If the drawer is not open, this change will take place immediately. + + @param width The new width of right drawer view controller. This must be greater than zero. + @param animated Determines whether the drawer should be adjusted with an animation. + @param completion The block called when the animation is finished. + + */ +-(void)setMaximumRightDrawerWidth:(CGFloat)width animated:(BOOL)animated completion:(void(^)(BOOL finished))completion; + +///--------------------------------------- +/// @name Previewing a Drawer +///--------------------------------------- + +/** + Bounce preview for the specified `drawerSide` a distance of 40 points. + + @param drawerSide The drawer to preview. This value cannot be `MMDrawerSideNone`. + @param completion The block called when the animation is finsihed. + + */ +-(void)bouncePreviewForDrawerSide:(MMDrawerSide)drawerSide completion:(void(^)(BOOL finished))completion; + +/** + Bounce preview for the specified `drawerSide`. + + @param drawerSide The drawer side to preview. This value cannot be `MMDrawerSideNone`. + @param distance The distance to bounce. + @param completion The block called when the animation is finsihed. + + */ +-(void)bouncePreviewForDrawerSide:(MMDrawerSide)drawerSide distance:(CGFloat)distance completion:(void(^)(BOOL finished))completion; + +///--------------------------------------- +/// @name Custom Drawer Animations +///--------------------------------------- + +/** + Sets a callback to be called when a drawer visual state needs to be updated. + + This block is responsible for updating the drawer's view state, and the drawer controller will handle animating to that state from the current state. This block will be called when the drawer is opened or closed, as well when the user is panning the drawer. This block is not responsible for doing animations directly, but instead just updating the state of the properies (such as alpha, anchor point, transform, etc). Note that if `shouldStretchDrawer` is set to YES, it is possible for `percentVisible` to be greater than 1.0. If `shouldStretchDrawer` is set to NO, `percentVisible` will never be greater than 1.0. + + Note that when the drawer is finished opening or closing, the side drawer controller view will be reset with the following properies: + + - alpha: 1.0 + - transform: CATransform3DIdentity + - anchorPoint: (0.5,0.5) + + @param drawerVisualStateBlock A block object to be called that allows the implementer to update visual state properties on the drawer. `percentVisible` represents the amount of the drawer space that is current visible, with drawer space being defined as the edge of the screen to the maxmimum drawer width. Note that you do have access to the drawerController, which will allow you to update things like the anchor point of the side drawer layer. + */ +-(void)setDrawerVisualStateBlock:(void(^)(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible))drawerVisualStateBlock; + +///--------------------------------------- +/// @name Gesture Completion Handling +///--------------------------------------- + +/** + Sets a callback to be called when a gesture has been completed. + + This block is called when a gesture action has been completed. You can query the `openSide` of the `drawerController` to determine what the new state of the drawer is. + + @param gestureCompletionBlock A block object to be called that allows the implementer be notified when a gesture action has been completed. + */ +-(void)setGestureCompletionBlock:(void(^)(MMDrawerController * drawerController, UIGestureRecognizer * gesture))gestureCompletionBlock; + +///--------------------------------------- +/// @name Custom Gesture Handler +///--------------------------------------- + +/** + Sets a callback to be called to determine if a UIGestureRecognizer should recieve the given UITouch. + + This block provides a way to allow a gesture to be recognized with custom logic. For example, you may have a certain part of your view that should accept a pan gesture recognizer to open the drawer, but not another a part. If you return YES, the gesture is recognized and the appropriate action is taken. This provides similar support to how Facebook allows you to pan on the background view of the main table view, but not the content itself. You can inspect the `openSide` property of the `drawerController` to determine the current state of the drawer, and apply the appropriate logic within your block. + + Note that either `openDrawerGestureModeMask` must contain `MMOpenDrawerGestureModeCustom`, or `closeDrawerGestureModeMask` must contain `MMCloseDrawerGestureModeCustom` for this block to be consulted. + + @param gestureShouldRecognizeTouchBlock A block object to be called to determine if the given `touch` should be recognized by the given gesture. + */ +-(void)setGestureShouldRecognizeTouchBlock:(BOOL(^)(MMDrawerController * drawerController, UIGestureRecognizer * gesture, UITouch * touch))gestureShouldRecognizeTouchBlock; + +@end diff --git a/ios/Classes/MMDrawerController/MMDrawerController/MMDrawerController.m b/ios/Classes/MMDrawerController/MMDrawerController/MMDrawerController.m new file mode 100644 index 0000000..577ebab --- /dev/null +++ b/ios/Classes/MMDrawerController/MMDrawerController/MMDrawerController.m @@ -0,0 +1,1417 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import "MMDrawerController.h" +#import "UIViewController+MMDrawerController.h" + +#import + +CGFloat const MMDrawerDefaultWidth = 280.0f; +CGFloat const MMDrawerDefaultAnimationVelocity = 840.0f; + +NSTimeInterval const MMDrawerDefaultFullAnimationDelay = 0.10f; + +CGFloat const MMDrawerDefaultBounceDistance = 50.0f; + +NSTimeInterval const MMDrawerDefaultBounceAnimationDuration = 0.2f; +CGFloat const MMDrawerDefaultSecondBounceDistancePercentage = .25f; + +CGFloat const MMDrawerDefaultShadowRadius = 10.0f; +CGFloat const MMDrawerDefaultShadowOpacity = 0.8; + +NSTimeInterval const MMDrawerMinimumAnimationDuration = 0.15f; + +CGFloat const MMDrawerBezelRange = 20.0f; + +CGFloat const MMDrawerPanVelocityXAnimationThreshold = 200.0f; + +/** The amount of overshoot that is panned linearly. The remaining percentage nonlinearly asymptotes to the max percentage. */ +CGFloat const MMDrawerOvershootLinearRangePercentage = 0.75f; + +/** The percent of the possible overshoot width to use as the actual overshoot percentage. */ +CGFloat const MMDrawerOvershootPercentage = 0.1f; + +typedef BOOL (^MMDrawerGestureShouldRecognizeTouchBlock)(MMDrawerController * drawerController, UIGestureRecognizer * gesture, UITouch * touch); +typedef void (^MMDrawerGestureCompletionBlock)(MMDrawerController * drawerController, UIGestureRecognizer * gesture); + +static CAKeyframeAnimation * bounceKeyFrameAnimationForDistanceOnView(CGFloat distance, UIView * view) { + CGFloat factors[32] = {0, 32, 60, 83, 100, 114, 124, 128, 128, 124, 114, 100, 83, 60, 32, + 0, 24, 42, 54, 62, 64, 62, 54, 42, 24, 0, 18, 28, 32, 28, 18, 0}; + + NSMutableArray *values = [NSMutableArray array]; + + for (int i=0; i<32; i++) + { + CGFloat positionOffset = factors[i]/128.0f * distance + CGRectGetMidX(view.bounds); + [values addObject:@(positionOffset)]; + } + + CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position.x"]; + animation.repeatCount = 1; + animation.duration = .8; + animation.fillMode = kCAFillModeForwards; + animation.values = values; + animation.removedOnCompletion = YES; + animation.autoreverses = NO; + + return animation; +} + +static NSString *MMDrawerLeftDrawerKey = @"MMDrawerLeftDrawer"; +static NSString *MMDrawerRightDrawerKey = @"MMDrawerRightDrawer"; +static NSString *MMDrawerCenterKey = @"MMDrawerCenter"; +static NSString *MMDrawerOpenSideKey = @"MMDrawerOpenSide"; + +@interface MMDrawerCenterContainerView : UIView +@property (nonatomic,assign) MMDrawerOpenCenterInteractionMode centerInteractionMode; +@property (nonatomic,assign) MMDrawerSide openSide; +@end + +@implementation MMDrawerCenterContainerView + +-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{ + UIView *hitView = [super hitTest:point withEvent:event]; + if(hitView && + self.openSide != MMDrawerSideNone){ + UINavigationBar * navBar = [self navigationBarContainedWithinSubviewsOfView:self]; + CGRect navBarFrame = [navBar convertRect:navBar.bounds toView:self]; + if((self.centerInteractionMode == MMDrawerOpenCenterInteractionModeNavigationBarOnly && + CGRectContainsPoint(navBarFrame, point) == NO) || + self.centerInteractionMode == MMDrawerOpenCenterInteractionModeNone){ + hitView = nil; + } + } + return hitView; +} + +-(UINavigationBar*)navigationBarContainedWithinSubviewsOfView:(UIView*)view{ + UINavigationBar * navBar = nil; + for(UIView * subview in [view subviews]){ + if([view isKindOfClass:[UINavigationBar class]]){ + navBar = (UINavigationBar*)view; + break; + } + else { + navBar = [self navigationBarContainedWithinSubviewsOfView:subview]; + if (navBar != nil) { + break; + } + } + } + return navBar; +} +@end + +@interface MMDrawerController () { + CGFloat _maximumRightDrawerWidth; + CGFloat _maximumLeftDrawerWidth; + UIColor * _statusBarViewBackgroundColor; +} + +@property (nonatomic, assign, readwrite) MMDrawerSide openSide; + +@property (nonatomic, strong) UIView * childControllerContainerView; +@property (nonatomic, strong) MMDrawerCenterContainerView * centerContainerView; +@property (nonatomic, strong) UIView * dummyStatusBarView; + +@property (nonatomic, assign) CGRect startingPanRect; +@property (nonatomic, copy) MMDrawerControllerDrawerVisualStateBlock drawerVisualState; +@property (nonatomic, copy) MMDrawerGestureShouldRecognizeTouchBlock gestureShouldRecognizeTouch; +@property (nonatomic, copy) MMDrawerGestureCompletionBlock gestureCompletion; +@property (nonatomic, assign, getter = isAnimatingDrawer) BOOL animatingDrawer; + +@end + +@implementation MMDrawerController + +#pragma mark - Init + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + [self commonSetup]; + } + return self; +} + +- (id)initWithCoder:(NSCoder *)aDecoder{ + self = [super initWithCoder:aDecoder]; + if (self) { + [self commonSetup]; + } + return self; +} + +-(id)initWithCenterViewController:(UIViewController *)centerViewController leftDrawerViewController:(UIViewController *)leftDrawerViewController rightDrawerViewController:(UIViewController *)rightDrawerViewController{ + NSParameterAssert(centerViewController); + self = [super init]; + if(self){ + [self setCenterViewController:centerViewController]; + [self setLeftDrawerViewController:leftDrawerViewController]; + [self setRightDrawerViewController:rightDrawerViewController]; + } + return self; +} + +-(id)initWithCenterViewController:(UIViewController *)centerViewController leftDrawerViewController:(UIViewController *)leftDrawerViewController{ + return [self initWithCenterViewController:centerViewController leftDrawerViewController:leftDrawerViewController rightDrawerViewController:nil]; +} + +-(id)initWithCenterViewController:(UIViewController *)centerViewController rightDrawerViewController:(UIViewController *)rightDrawerViewController{ + return [self initWithCenterViewController:centerViewController leftDrawerViewController:nil rightDrawerViewController:rightDrawerViewController]; +} + +-(void)commonSetup{ + [self setMaximumLeftDrawerWidth:MMDrawerDefaultWidth]; + [self setMaximumRightDrawerWidth:MMDrawerDefaultWidth]; + + [self setAnimationVelocity:MMDrawerDefaultAnimationVelocity]; + + [self setShowsShadow:YES]; + [self setShouldStretchDrawer:YES]; + + [self setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeNone]; + [self setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeNone]; + [self setCenterHiddenInteractionMode:MMDrawerOpenCenterInteractionModeNavigationBarOnly]; +} + +#pragma mark - State Restoration +- (void)encodeRestorableStateWithCoder:(NSCoder *)coder{ + [super encodeRestorableStateWithCoder:coder]; + if (self.leftDrawerViewController){ + [coder encodeObject:self.leftDrawerViewController forKey:MMDrawerLeftDrawerKey]; + } + + if (self.rightDrawerViewController){ + [coder encodeObject:self.rightDrawerViewController forKey:MMDrawerRightDrawerKey]; + } + + if (self.centerViewController){ + [coder encodeObject:self.centerViewController forKey:MMDrawerCenterKey]; + } + + [coder encodeInteger:self.openSide forKey:MMDrawerOpenSideKey]; +} + +- (void)decodeRestorableStateWithCoder:(NSCoder *)coder{ + UIViewController *controller; + MMDrawerSide openside; + + [super decodeRestorableStateWithCoder:coder]; + + if ((controller = [coder decodeObjectForKey:MMDrawerLeftDrawerKey])){ + self.leftDrawerViewController = controller; + } + + if ((controller = [coder decodeObjectForKey:MMDrawerRightDrawerKey])){ + self.rightDrawerViewController = controller; + } + + if ((controller = [coder decodeObjectForKey:MMDrawerCenterKey])){ + self.centerViewController = controller; + } + + if ((openside = [coder decodeIntegerForKey:MMDrawerOpenSideKey])){ + [self openDrawerSide:openside animated:NO completion:nil]; + } +} +#pragma mark - Open/Close methods +-(void)toggleDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated completion:(void (^)(BOOL finished))completion{ + NSParameterAssert(drawerSide!=MMDrawerSideNone); + if(self.openSide == MMDrawerSideNone){ + [self openDrawerSide:drawerSide animated:animated completion:completion]; + } + else { + if((drawerSide == MMDrawerSideLeft && + self.openSide == MMDrawerSideLeft) || + (drawerSide == MMDrawerSideRight && + self.openSide == MMDrawerSideRight)){ + [self closeDrawerAnimated:animated completion:completion]; + } + else if(completion){ + completion(NO); + } + } +} + +-(void)closeDrawerAnimated:(BOOL)animated completion:(void (^)(BOOL finished))completion{ + [self closeDrawerAnimated:animated velocity:self.animationVelocity animationOptions:UIViewAnimationOptionCurveEaseInOut completion:completion]; +} + +-(void)closeDrawerAnimated:(BOOL)animated velocity:(CGFloat)velocity animationOptions:(UIViewAnimationOptions)options completion:(void (^)(BOOL finished))completion{ + if(self.isAnimatingDrawer){ + if(completion){ + completion(NO); + } + } + else { + [self setAnimatingDrawer:animated]; + CGRect newFrame = self.childControllerContainerView.bounds; + + CGFloat distance = ABS(CGRectGetMinX(self.centerContainerView.frame)); + NSTimeInterval duration = MAX(distance/ABS(velocity),MMDrawerMinimumAnimationDuration); + + BOOL leftDrawerVisible = CGRectGetMinX(self.centerContainerView.frame) > 0; + BOOL rightDrawerVisible = CGRectGetMinX(self.centerContainerView.frame) < 0; + + MMDrawerSide visibleSide = MMDrawerSideNone; + CGFloat percentVisble = 0.0; + + if(leftDrawerVisible){ + CGFloat visibleDrawerPoints = CGRectGetMinX(self.centerContainerView.frame); + percentVisble = MAX(0.0,visibleDrawerPoints/self.maximumLeftDrawerWidth); + visibleSide = MMDrawerSideLeft; + } + else if(rightDrawerVisible){ + CGFloat visibleDrawerPoints = CGRectGetWidth(self.centerContainerView.frame)-CGRectGetMaxX(self.centerContainerView.frame); + percentVisble = MAX(0.0,visibleDrawerPoints/self.maximumRightDrawerWidth); + visibleSide = MMDrawerSideRight; + } + + UIViewController * sideDrawerViewController = [self sideDrawerViewControllerForSide:visibleSide]; + + [self updateDrawerVisualStateForDrawerSide:visibleSide percentVisible:percentVisble]; + + [sideDrawerViewController beginAppearanceTransition:NO animated:animated]; + + [UIView + animateWithDuration:(animated?duration:0.0) + delay:0.0 + options:options + animations:^{ + [self setNeedsStatusBarAppearanceUpdateIfSupported]; + [self.centerContainerView setFrame:newFrame]; + [self updateDrawerVisualStateForDrawerSide:visibleSide percentVisible:0.0]; + } + completion:^(BOOL finished) { + [sideDrawerViewController endAppearanceTransition]; + [self setOpenSide:MMDrawerSideNone]; + [self resetDrawerVisualStateForDrawerSide:visibleSide]; + [self setAnimatingDrawer:NO]; + if(completion){ + completion(finished); + } + }]; + } +} + +-(void)openDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated completion:(void (^)(BOOL finished))completion{ + NSParameterAssert(drawerSide != MMDrawerSideNone); + + [self openDrawerSide:drawerSide animated:animated velocity:self.animationVelocity animationOptions:UIViewAnimationOptionCurveEaseInOut completion:completion]; +} + +-(void)openDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated velocity:(CGFloat)velocity animationOptions:(UIViewAnimationOptions)options completion:(void (^)(BOOL finished))completion{ + NSParameterAssert(drawerSide != MMDrawerSideNone); + if (self.isAnimatingDrawer) { + if(completion){ + completion(NO); + } + } + else { + [self setAnimatingDrawer:animated]; + UIViewController * sideDrawerViewController = [self sideDrawerViewControllerForSide:drawerSide]; + if (self.openSide != drawerSide) { + [self prepareToPresentDrawer:drawerSide animated:animated]; + } + + if(sideDrawerViewController){ + CGRect newFrame; + CGRect oldFrame = self.centerContainerView.frame; + if(drawerSide == MMDrawerSideLeft){ + newFrame = self.centerContainerView.frame; + newFrame.origin.x = self.maximumLeftDrawerWidth; + } + else { + newFrame = self.centerContainerView.frame; + newFrame.origin.x = 0-self.maximumRightDrawerWidth; + } + + CGFloat distance = ABS(CGRectGetMinX(oldFrame)-newFrame.origin.x); + NSTimeInterval duration = MAX(distance/ABS(velocity),MMDrawerMinimumAnimationDuration); + + [UIView + animateWithDuration:(animated?duration:0.0) + delay:0.0 + options:options + animations:^{ + [self setNeedsStatusBarAppearanceUpdateIfSupported]; + [self.centerContainerView setFrame:newFrame]; + [self updateDrawerVisualStateForDrawerSide:drawerSide percentVisible:1.0]; + } + completion:^(BOOL finished) { + //End the appearance transition if it already wasn't open. + if(drawerSide != self.openSide){ + [sideDrawerViewController endAppearanceTransition]; + } + [self setOpenSide:drawerSide]; + + [self resetDrawerVisualStateForDrawerSide:drawerSide]; + [self setAnimatingDrawer:NO]; + if(completion){ + completion(finished); + } + }]; + } + } +} + +#pragma mark - Updating the Center View Controller +//If animated is NO, then we need to handle all the appearance calls within this method. Otherwise, +//let the method calling this one handle proper appearance methods since they will have more context +-(void)setCenterViewController:(UIViewController *)centerViewController animated:(BOOL)animated{ + if ([self.centerViewController isEqual:centerViewController]) { + return; + } + + if (_centerContainerView == nil) { + //This is related to Issue #152 (https://github.com/mutualmobile/MMDrawerController/issues/152) + // also fixed below in the getter for `childControllerContainerView`. Turns out we have + // two center container views getting added to the view during init, + // because the first request self.centerContainerView.bounds was kicking off a + // viewDidLoad, which caused us to be able to fall through this check twice. + // + //The fix is to grab the bounds, and then check again that the child container view has + //not been created. + + CGRect centerFrame = self.childControllerContainerView.bounds; + if(_centerContainerView == nil){ + _centerContainerView = [[MMDrawerCenterContainerView alloc] initWithFrame:centerFrame]; + [self.centerContainerView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight]; + [self.centerContainerView setBackgroundColor:[UIColor clearColor]]; + [self.centerContainerView setOpenSide:self.openSide]; + [self.centerContainerView setCenterInteractionMode:self.centerHiddenInteractionMode]; + [self.childControllerContainerView addSubview:self.centerContainerView]; + } + } + + UIViewController * oldCenterViewController = self.centerViewController; + if(oldCenterViewController){ + [oldCenterViewController willMoveToParentViewController:nil]; + if(animated == NO){ + [oldCenterViewController beginAppearanceTransition:NO animated:NO]; + } + [oldCenterViewController removeFromParentViewController]; + [oldCenterViewController.view removeFromSuperview]; + if(animated == NO){ + [oldCenterViewController endAppearanceTransition]; + } + } + + _centerViewController = centerViewController; + + [self addChildViewController:self.centerViewController]; + [self.centerViewController.view setFrame:self.childControllerContainerView.bounds]; + [self.centerContainerView addSubview:self.centerViewController.view]; + [self.childControllerContainerView bringSubviewToFront:self.centerContainerView]; + [self.centerViewController.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight]; + [self updateShadowForCenterView]; + + if(animated == NO){ + // If drawer is offscreen, then viewWillAppear: will take care of this + if(self.view.window) { + [self.centerViewController beginAppearanceTransition:YES animated:NO]; + [self.centerViewController endAppearanceTransition]; + } + [self.centerViewController didMoveToParentViewController:self]; + } +} + +-(void)setCenterViewController:(UIViewController *)newCenterViewController withCloseAnimation:(BOOL)animated completion:(void(^)(BOOL finished))completion{ + + if(self.openSide == MMDrawerSideNone){ + //If a side drawer isn't open, there is nothing to animate... + animated = NO; + } + + BOOL forwardAppearanceMethodsToCenterViewController = ([self.centerViewController isEqual:newCenterViewController] == NO); + [self setCenterViewController:newCenterViewController animated:animated]; + + if(animated){ + [self updateDrawerVisualStateForDrawerSide:self.openSide percentVisible:1.0]; + if (forwardAppearanceMethodsToCenterViewController) { + [self.centerViewController beginAppearanceTransition:YES animated:animated]; + } + [self + closeDrawerAnimated:animated + completion:^(BOOL finished) { + if (forwardAppearanceMethodsToCenterViewController) { + [self.centerViewController endAppearanceTransition]; + [self.centerViewController didMoveToParentViewController:self]; + } + if(completion){ + completion(finished); + } + }]; + } + else { + if(completion) { + completion(YES); + } + } +} + +-(void)setCenterViewController:(UIViewController *)newCenterViewController withFullCloseAnimation:(BOOL)animated completion:(void(^)(BOOL finished))completion{ + if(self.openSide != MMDrawerSideNone && + animated){ + + BOOL forwardAppearanceMethodsToCenterViewController = ([self.centerViewController isEqual:newCenterViewController] == NO); + + UIViewController * sideDrawerViewController = [self sideDrawerViewControllerForSide:self.openSide]; + + CGFloat targetClosePoint = 0.0f; + if(self.openSide == MMDrawerSideRight){ + targetClosePoint = -CGRectGetWidth(self.childControllerContainerView.bounds); + } + else if(self.openSide == MMDrawerSideLeft) { + targetClosePoint = CGRectGetWidth(self.childControllerContainerView.bounds); + } + + CGFloat distance = ABS(self.centerContainerView.frame.origin.x-targetClosePoint); + NSTimeInterval firstDuration = [self animationDurationForAnimationDistance:distance]; + + CGRect newCenterRect = self.centerContainerView.frame; + + [self setAnimatingDrawer:animated]; + + UIViewController * oldCenterViewController = self.centerViewController; + if(forwardAppearanceMethodsToCenterViewController ){ + [oldCenterViewController beginAppearanceTransition:NO animated:animated]; + } + newCenterRect.origin.x = targetClosePoint; + [UIView + animateWithDuration:firstDuration + delay:0.0 + options:UIViewAnimationOptionCurveEaseInOut + animations:^{ + [self.centerContainerView setFrame:newCenterRect]; + [sideDrawerViewController.view setFrame:self.childControllerContainerView.bounds]; + } + completion:^(BOOL finished) { + + CGRect oldCenterRect = self.centerContainerView.frame; + [self setCenterViewController:newCenterViewController animated:animated]; + [self.centerContainerView setFrame:oldCenterRect]; + [self updateDrawerVisualStateForDrawerSide:self.openSide percentVisible:1.0]; + if(forwardAppearanceMethodsToCenterViewController) { + [oldCenterViewController endAppearanceTransition]; + [self.centerViewController beginAppearanceTransition:YES animated:animated]; + } + [sideDrawerViewController beginAppearanceTransition:NO animated:animated]; + [UIView + animateWithDuration:[self animationDurationForAnimationDistance:CGRectGetWidth(self.childControllerContainerView.bounds)] + delay:MMDrawerDefaultFullAnimationDelay + options:UIViewAnimationOptionCurveEaseInOut + animations:^{ + [self.centerContainerView setFrame:self.childControllerContainerView.bounds]; + [self updateDrawerVisualStateForDrawerSide:self.openSide percentVisible:0.0]; + } + completion:^(BOOL finished) { + if (forwardAppearanceMethodsToCenterViewController) { + [self.centerViewController endAppearanceTransition]; + [self.centerViewController didMoveToParentViewController:self]; + } + [sideDrawerViewController endAppearanceTransition]; + [self resetDrawerVisualStateForDrawerSide:self.openSide]; + + [sideDrawerViewController.view setFrame:sideDrawerViewController.mm_visibleDrawerFrame]; + + [self setOpenSide:MMDrawerSideNone]; + [self setAnimatingDrawer:NO]; + if(completion){ + completion(finished); + } + }]; + }]; + } + else { + [self setCenterViewController:newCenterViewController animated:animated]; + if(self.openSide != MMDrawerSideNone){ + [self closeDrawerAnimated:animated completion:completion]; + } + else if(completion){ + completion(YES); + } + } +} + +#pragma mark - Size Methods +-(void)setMaximumLeftDrawerWidth:(CGFloat)width animated:(BOOL)animated completion:(void(^)(BOOL finished))completion{ + [self setMaximumDrawerWidth:width forSide:MMDrawerSideLeft animated:animated completion:completion]; +} + +-(void)setMaximumRightDrawerWidth:(CGFloat)width animated:(BOOL)animated completion:(void(^)(BOOL finished))completion{ + [self setMaximumDrawerWidth:width forSide:MMDrawerSideRight animated:animated completion:completion]; +} + +- (void)setMaximumDrawerWidth:(CGFloat)width forSide:(MMDrawerSide)drawerSide animated:(BOOL)animated completion:(void(^)(BOOL finished))completion{ + NSParameterAssert(width > 0); + NSParameterAssert(drawerSide != MMDrawerSideNone); + + UIViewController *sideDrawerViewController = [self sideDrawerViewControllerForSide:drawerSide]; + CGFloat oldWidth = 0.f; + NSInteger drawerSideOriginCorrection = 1; + if (drawerSide == MMDrawerSideLeft) { + oldWidth = _maximumLeftDrawerWidth; + _maximumLeftDrawerWidth = width; + } + else if(drawerSide == MMDrawerSideRight){ + oldWidth = _maximumRightDrawerWidth; + _maximumRightDrawerWidth = width; + drawerSideOriginCorrection = -1; + } + + CGFloat distance = ABS(width-oldWidth); + NSTimeInterval duration = [self animationDurationForAnimationDistance:distance]; + + if(self.openSide == drawerSide){ + CGRect newCenterRect = self.centerContainerView.frame; + newCenterRect.origin.x = drawerSideOriginCorrection*width; + [UIView + animateWithDuration:(animated?duration:0) + delay:0.0 + options:UIViewAnimationOptionCurveEaseInOut + animations:^{ + [self.centerContainerView setFrame:newCenterRect]; + [sideDrawerViewController.view setFrame:sideDrawerViewController.mm_visibleDrawerFrame]; + } + completion:^(BOOL finished) { + if(completion != nil){ + completion(finished); + } + }]; + } + else{ + [sideDrawerViewController.view setFrame:sideDrawerViewController.mm_visibleDrawerFrame]; + if(completion != nil){ + completion(YES); + } + } +} + +#pragma mark - Bounce Methods +-(void)bouncePreviewForDrawerSide:(MMDrawerSide)drawerSide completion:(void(^)(BOOL finished))completion{ + NSParameterAssert(drawerSide!=MMDrawerSideNone); + [self bouncePreviewForDrawerSide:drawerSide distance:MMDrawerDefaultBounceDistance completion:nil]; +} + +-(void)bouncePreviewForDrawerSide:(MMDrawerSide)drawerSide distance:(CGFloat)distance completion:(void(^)(BOOL finished))completion{ + NSParameterAssert(drawerSide!=MMDrawerSideNone); + + UIViewController * sideDrawerViewController = [self sideDrawerViewControllerForSide:drawerSide]; + + if(sideDrawerViewController == nil || + self.openSide != MMDrawerSideNone){ + if(completion){ + completion(NO); + } + return; + } + else { + [self prepareToPresentDrawer:drawerSide animated:YES]; + + [self updateDrawerVisualStateForDrawerSide:drawerSide percentVisible:1.0]; + + [CATransaction begin]; + [CATransaction + setCompletionBlock:^{ + [sideDrawerViewController endAppearanceTransition]; + [sideDrawerViewController beginAppearanceTransition:NO animated:NO]; + [sideDrawerViewController endAppearanceTransition]; + if(completion){ + completion(YES); + } + }]; + + CGFloat modifier = ((drawerSide == MMDrawerSideLeft)?1.0:-1.0); + CAKeyframeAnimation *animation = bounceKeyFrameAnimationForDistanceOnView(distance*modifier,self.centerContainerView); + [self.centerContainerView.layer addAnimation:animation forKey:@"bouncing"]; + + [CATransaction commit]; + } +} + +#pragma mark - Setting Drawer Visual State +-(void)setDrawerVisualStateBlock:(void (^)(MMDrawerController *, MMDrawerSide, CGFloat))drawerVisualStateBlock{ + [self setDrawerVisualState:drawerVisualStateBlock]; +} + +#pragma mark - Setting Custom Gesture Handler Block +-(void)setGestureShouldRecognizeTouchBlock:(BOOL (^)(MMDrawerController *, UIGestureRecognizer *, UITouch *))gestureShouldRecognizeTouchBlock{ + [self setGestureShouldRecognizeTouch:gestureShouldRecognizeTouchBlock]; +} + +#pragma mark - Setting the Gesture Completion Block +-(void)setGestureCompletionBlock:(void (^)(MMDrawerController *, UIGestureRecognizer *))gestureCompletionBlock{ + [self setGestureCompletion:gestureCompletionBlock]; +} + +#pragma mark - Subclass Methods +-(BOOL)shouldAutomaticallyForwardAppearanceMethods{ + return NO; +} + +-(BOOL)shouldAutomaticallyForwardRotationMethods{ + return NO; +} + +-(BOOL)automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers{ + return NO; +} + +#pragma mark - View Lifecycle + +- (void)viewDidLoad { + [super viewDidLoad]; + + [self.view setBackgroundColor:[UIColor blackColor]]; + + [self setupGestureRecognizers]; +} + +-(void)viewWillAppear:(BOOL)animated{ + [super viewWillAppear:animated]; + [self.centerViewController beginAppearanceTransition:YES animated:animated]; + + if(self.openSide == MMDrawerSideLeft) { + [self.leftDrawerViewController beginAppearanceTransition:YES animated:animated]; + } + else if(self.openSide == MMDrawerSideRight) { + [self.rightDrawerViewController beginAppearanceTransition:YES animated:animated]; + } +} + +-(void)viewDidAppear:(BOOL)animated{ + [super viewDidAppear:animated]; + [self updateShadowForCenterView]; + [self.centerViewController endAppearanceTransition]; + + if(self.openSide == MMDrawerSideLeft) { + [self.leftDrawerViewController endAppearanceTransition]; + } + else if(self.openSide == MMDrawerSideRight) { + [self.rightDrawerViewController endAppearanceTransition]; + } +} + +-(void)viewWillDisappear:(BOOL)animated{ + [super viewWillDisappear:animated]; + [self.centerViewController beginAppearanceTransition:NO animated:animated]; + if(self.openSide == MMDrawerSideLeft) { + [self.leftDrawerViewController beginAppearanceTransition:NO animated:animated]; + } + else if (self.openSide == MMDrawerSideRight) { + [self.rightDrawerViewController beginAppearanceTransition:NO animated:animated]; + } +} + +-(void)viewDidDisappear:(BOOL)animated{ + [super viewDidDisappear:animated]; + [self.centerViewController endAppearanceTransition]; + if(self.openSide == MMDrawerSideLeft) { + [self.leftDrawerViewController endAppearanceTransition]; + } + else if (self.openSide == MMDrawerSideRight) { + [self.rightDrawerViewController endAppearanceTransition]; + } +} + +#pragma mark Rotation + +-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{ + [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration]; + //If a rotation begins, we are going to cancel the current gesture and reset transform and anchor points so everything works correctly + BOOL gestureInProgress = NO; + for(UIGestureRecognizer * gesture in self.view.gestureRecognizers){ + if(gesture.state == UIGestureRecognizerStateChanged){ + [gesture setEnabled:NO]; + [gesture setEnabled:YES]; + gestureInProgress = YES; + } + if (gestureInProgress) { + [self resetDrawerVisualStateForDrawerSide:self.openSide]; + } + } + for(UIViewController * childViewController in self.childViewControllers){ + [childViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration]; + } +} +-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{ + [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration]; + //We need to support the shadow path rotation animation + //Inspired from here: http://blog.radi.ws/post/8348898129/calayers-shadowpath-and-uiview-autoresizing + if(self.showsShadow){ + CGPathRef oldShadowPath = self.centerContainerView.layer.shadowPath; + if(oldShadowPath){ + CFRetain(oldShadowPath); + } + + [self updateShadowForCenterView]; + + if (oldShadowPath) { + [self.centerContainerView.layer addAnimation:((^ { + CABasicAnimation *transition = [CABasicAnimation animationWithKeyPath:@"shadowPath"]; + transition.fromValue = (__bridge id)oldShadowPath; + transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; + transition.duration = duration; + return transition; + })()) forKey:@"transition"]; + CFRelease(oldShadowPath); + } + } + for(UIViewController * childViewController in self.childViewControllers){ + [childViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration]; + } +} + +-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{ + return YES; +} + +-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{ + [super didRotateFromInterfaceOrientation:fromInterfaceOrientation]; + for(UIViewController * childViewController in self.childViewControllers){ + [childViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation]; + } +} + +#pragma mark - Setters +-(void)setRightDrawerViewController:(UIViewController *)rightDrawerViewController{ + [self setDrawerViewController:rightDrawerViewController forSide:MMDrawerSideRight]; +} + +-(void)setLeftDrawerViewController:(UIViewController *)leftDrawerViewController{ + [self setDrawerViewController:leftDrawerViewController forSide:MMDrawerSideLeft]; +} + +- (void)setDrawerViewController:(UIViewController *)viewController forSide:(MMDrawerSide)drawerSide{ + NSParameterAssert(drawerSide != MMDrawerSideNone); + + UIViewController *currentSideViewController = [self sideDrawerViewControllerForSide:drawerSide]; + + if (currentSideViewController == viewController) { + return; + } + + if (currentSideViewController != nil) { + [currentSideViewController beginAppearanceTransition:NO animated:NO]; + [currentSideViewController.view removeFromSuperview]; + [currentSideViewController endAppearanceTransition]; + [currentSideViewController willMoveToParentViewController:nil]; + [currentSideViewController removeFromParentViewController]; + } + + UIViewAutoresizing autoResizingMask = 0; + if (drawerSide == MMDrawerSideLeft) { + _leftDrawerViewController = viewController; + autoResizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight; + + } + else if(drawerSide == MMDrawerSideRight){ + _rightDrawerViewController = viewController; + autoResizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight; + } + + if(viewController){ + [self addChildViewController:viewController]; + + if((self.openSide == drawerSide) && + [self.childControllerContainerView.subviews containsObject:self.centerContainerView]){ + [self.childControllerContainerView insertSubview:viewController.view belowSubview:self.centerContainerView]; + [viewController beginAppearanceTransition:YES animated:NO]; + [viewController endAppearanceTransition]; + } + else{ + [self.childControllerContainerView addSubview:viewController.view]; + [self.childControllerContainerView sendSubviewToBack:viewController.view]; + [viewController.view setHidden:YES]; + } + [viewController didMoveToParentViewController:self]; + [viewController.view setAutoresizingMask:autoResizingMask]; + [viewController.view setFrame:viewController.mm_visibleDrawerFrame]; + } +} + +-(void)setCenterViewController:(UIViewController *)centerViewController{ + [self setCenterViewController:centerViewController animated:NO]; +} + +-(void)setShowsShadow:(BOOL)showsShadow{ + _showsShadow = showsShadow; + [self updateShadowForCenterView]; +} + +-(void)setOpenSide:(MMDrawerSide)openSide{ + if(_openSide != openSide){ + _openSide = openSide; + [self.centerContainerView setOpenSide:openSide]; + if(openSide == MMDrawerSideNone){ + [self.leftDrawerViewController.view setHidden:YES]; + [self.rightDrawerViewController.view setHidden:YES]; + } + [self setNeedsStatusBarAppearanceUpdateIfSupported]; + } +} + +-(void)setCenterHiddenInteractionMode:(MMDrawerOpenCenterInteractionMode)centerHiddenInteractionMode{ + if(_centerHiddenInteractionMode!=centerHiddenInteractionMode){ + _centerHiddenInteractionMode = centerHiddenInteractionMode; + [self.centerContainerView setCenterInteractionMode:centerHiddenInteractionMode]; + } +} + +-(void)setMaximumLeftDrawerWidth:(CGFloat)maximumLeftDrawerWidth{ + [self setMaximumLeftDrawerWidth:maximumLeftDrawerWidth animated:NO completion:nil]; +} + +-(void)setMaximumRightDrawerWidth:(CGFloat)maximumRightDrawerWidth{ + [self setMaximumRightDrawerWidth:maximumRightDrawerWidth animated:NO completion:nil]; +} + +-(void)setShowsStatusBarBackgroundView:(BOOL)showsDummyStatusBar{ + NSArray *sysVersion = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."]; + float majorVersion = [[sysVersion objectAtIndex:0] floatValue]; + if (majorVersion >= 7){ + if(showsDummyStatusBar!=_showsStatusBarBackgroundView){ + _showsStatusBarBackgroundView = showsDummyStatusBar; + CGRect frame = self.childControllerContainerView.frame; + if(_showsStatusBarBackgroundView){ + frame.origin.y = [UIApplication sharedApplication].statusBarFrame.size.height; + frame.size.height = CGRectGetHeight(self.view.bounds) - [UIApplication sharedApplication].statusBarFrame.size.height;; + } + else { + frame.origin.y = 0; + frame.size.height = CGRectGetHeight(self.view.bounds); + } + [self.childControllerContainerView setFrame:frame]; + [self.dummyStatusBarView setHidden:!showsDummyStatusBar]; + } + } + else { + _showsStatusBarBackgroundView = NO; + } +} + +-(void)setStatusBarViewBackgroundColor:(UIColor *)dummyStatusBarColor{ + _statusBarViewBackgroundColor = dummyStatusBarColor; + [self.dummyStatusBarView setBackgroundColor:_statusBarViewBackgroundColor]; +} + +-(void)setAnimatingDrawer:(BOOL)animatingDrawer{ + _animatingDrawer = animatingDrawer; + [self.view setUserInteractionEnabled:!animatingDrawer]; +} + +#pragma mark - Getters +-(CGFloat)maximumLeftDrawerWidth{ + if(self.leftDrawerViewController){ + return _maximumLeftDrawerWidth; + } + else{ + return 0; + } +} + +-(CGFloat)maximumRightDrawerWidth{ + if(self.rightDrawerViewController){ + return _maximumRightDrawerWidth; + } + else { + return 0; + } +} + +-(CGFloat)visibleLeftDrawerWidth{ + return MAX(0.0,CGRectGetMinX(self.centerContainerView.frame)); +} + +-(CGFloat)visibleRightDrawerWidth{ + if(CGRectGetMinX(self.centerContainerView.frame)<0){ + return CGRectGetWidth(self.childControllerContainerView.bounds)-CGRectGetMaxX(self.centerContainerView.frame); + } + else { + return 0.0f; + } +} + +-(UIView*)childControllerContainerView{ + if(_childControllerContainerView == nil){ + //Issue #152 (https://github.com/mutualmobile/MMDrawerController/issues/152) + //Turns out we have two child container views getting added to the view during init, + //because the first request self.view.bounds was kicking off a viewDidLoad, which + //caused us to be able to fall through this check twice. + // + //The fix is to grab the bounds, and then check again that the child container view has + //not been created. + CGRect childContainerViewFrame = self.view.bounds; + if(_childControllerContainerView == nil){ + _childControllerContainerView = [[UIView alloc] initWithFrame:childContainerViewFrame]; + [_childControllerContainerView setBackgroundColor:[UIColor clearColor]]; + [_childControllerContainerView setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth]; + [self.view addSubview:_childControllerContainerView]; + } + + } + return _childControllerContainerView; +} + +-(UIView*)dummyStatusBarView{ + if(_dummyStatusBarView==nil){ + _dummyStatusBarView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), [UIApplication sharedApplication].statusBarFrame.size.height)]; + [_dummyStatusBarView setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; + [_dummyStatusBarView setBackgroundColor:self.statusBarViewBackgroundColor]; + [_dummyStatusBarView setHidden:!_showsStatusBarBackgroundView]; + [self.view addSubview:_dummyStatusBarView]; + } + return _dummyStatusBarView; +} + +-(UIColor*)statusBarViewBackgroundColor{ + if(_statusBarViewBackgroundColor == nil){ + _statusBarViewBackgroundColor = [UIColor blackColor]; + } + return _statusBarViewBackgroundColor; +} + +#pragma mark - Gesture Handlers + +-(void)tapGestureCallback:(UITapGestureRecognizer *)tapGesture{ + if(self.openSide != MMDrawerSideNone && + self.isAnimatingDrawer == NO){ + [self closeDrawerAnimated:YES completion:^(BOOL finished) { + if(self.gestureCompletion){ + self.gestureCompletion(self, tapGesture); + } + }]; + } +} + +-(void)panGestureCallback:(UIPanGestureRecognizer *)panGesture{ + switch (panGesture.state) { + case UIGestureRecognizerStateBegan:{ + if(self.animatingDrawer){ + [panGesture setEnabled:NO]; + break; + } + else { + self.startingPanRect = self.centerContainerView.frame; + } + } + case UIGestureRecognizerStateChanged:{ + self.view.userInteractionEnabled = NO; + CGRect newFrame = self.startingPanRect; + CGPoint translatedPoint = [panGesture translationInView:self.centerContainerView]; + newFrame.origin.x = [self roundedOriginXForDrawerConstriants:CGRectGetMinX(self.startingPanRect)+translatedPoint.x]; + newFrame = CGRectIntegral(newFrame); + CGFloat xOffset = newFrame.origin.x; + + MMDrawerSide visibleSide = MMDrawerSideNone; + CGFloat percentVisible = 0.0; + if(xOffset > 0){ + visibleSide = MMDrawerSideLeft; + percentVisible = xOffset/self.maximumLeftDrawerWidth; + } + else if(xOffset < 0){ + visibleSide = MMDrawerSideRight; + percentVisible = ABS(xOffset)/self.maximumRightDrawerWidth; + } + UIViewController * visibleSideDrawerViewController = [self sideDrawerViewControllerForSide:visibleSide]; + + if(self.openSide != visibleSide){ + //Handle disappearing the visible drawer + UIViewController * sideDrawerViewController = [self sideDrawerViewControllerForSide:self.openSide]; + [sideDrawerViewController beginAppearanceTransition:NO animated:NO]; + [sideDrawerViewController endAppearanceTransition]; + + //Drawer is about to become visible + [self prepareToPresentDrawer:visibleSide animated:NO]; + [visibleSideDrawerViewController endAppearanceTransition]; + [self setOpenSide:visibleSide]; + } + else if(visibleSide == MMDrawerSideNone){ + [self setOpenSide:MMDrawerSideNone]; + } + + [self updateDrawerVisualStateForDrawerSide:visibleSide percentVisible:percentVisible]; + + [self.centerContainerView setCenter:CGPointMake(CGRectGetMidX(newFrame), CGRectGetMidY(newFrame))]; + break; + } + case UIGestureRecognizerStateEnded: + case UIGestureRecognizerStateCancelled: { + self.startingPanRect = CGRectNull; + CGPoint velocity = [panGesture velocityInView:self.childControllerContainerView]; + [self finishAnimationForPanGestureWithXVelocity:velocity.x completion:^(BOOL finished) { + if(self.gestureCompletion){ + self.gestureCompletion(self, panGesture); + } + }]; + self.view.userInteractionEnabled = YES; + break; + } + default: + break; + } +} + +#pragma mark - iOS 7 Status Bar Helpers +-(UIViewController*)childViewControllerForStatusBarStyle{ + return [self childViewControllerForSide:self.openSide]; +} + +-(UIViewController*)childViewControllerForStatusBarHidden{ + return [self childViewControllerForSide:self.openSide]; +} + +-(void)setNeedsStatusBarAppearanceUpdateIfSupported{ + if([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]){ + [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)]; + } +} + +#pragma mark - Animation helpers +-(void)finishAnimationForPanGestureWithXVelocity:(CGFloat)xVelocity completion:(void(^)(BOOL finished))completion{ + CGFloat currentOriginX = CGRectGetMinX(self.centerContainerView.frame); + + CGFloat animationVelocity = MAX(ABS(xVelocity),MMDrawerPanVelocityXAnimationThreshold*2); + + if(self.openSide == MMDrawerSideLeft) { + CGFloat midPoint = self.maximumLeftDrawerWidth / 2.0; + if(xVelocity > MMDrawerPanVelocityXAnimationThreshold){ + [self openDrawerSide:MMDrawerSideLeft animated:YES velocity:animationVelocity animationOptions:UIViewAnimationOptionCurveEaseOut completion:completion]; + } + else if(xVelocity < -MMDrawerPanVelocityXAnimationThreshold){ + [self closeDrawerAnimated:YES velocity:animationVelocity animationOptions:UIViewAnimationOptionCurveEaseOut completion:completion]; + } + else if(currentOriginX < midPoint){ + [self closeDrawerAnimated:YES completion:completion]; + } + else { + [self openDrawerSide:MMDrawerSideLeft animated:YES completion:completion]; + } + } + else if(self.openSide == MMDrawerSideRight){ + currentOriginX = CGRectGetMaxX(self.centerContainerView.frame); + CGFloat midPoint = (CGRectGetWidth(self.childControllerContainerView.bounds)-self.maximumRightDrawerWidth) + (self.maximumRightDrawerWidth / 2.0); + if(xVelocity > MMDrawerPanVelocityXAnimationThreshold){ + [self closeDrawerAnimated:YES velocity:animationVelocity animationOptions:UIViewAnimationOptionCurveEaseOut completion:completion]; + } + else if (xVelocity < -MMDrawerPanVelocityXAnimationThreshold){ + [self openDrawerSide:MMDrawerSideRight animated:YES velocity:animationVelocity animationOptions:UIViewAnimationOptionCurveEaseOut completion:completion]; + } + else if(currentOriginX > midPoint){ + [self closeDrawerAnimated:YES completion:completion]; + } + else { + [self openDrawerSide:MMDrawerSideRight animated:YES completion:completion]; + } + } + else { + if(completion){ + completion(NO); + } + } +} + +-(void)updateDrawerVisualStateForDrawerSide:(MMDrawerSide)drawerSide percentVisible:(CGFloat)percentVisible{ + if(self.drawerVisualState){ + self.drawerVisualState(self,drawerSide,percentVisible); + } + else if(self.shouldStretchDrawer){ + [self applyOvershootScaleTransformForDrawerSide:drawerSide percentVisible:percentVisible]; + } +} + +- (void)applyOvershootScaleTransformForDrawerSide:(MMDrawerSide)drawerSide percentVisible:(CGFloat)percentVisible{ + + if (percentVisible >= 1.f) { + CATransform3D transform = CATransform3DIdentity; + UIViewController * sideDrawerViewController = [self sideDrawerViewControllerForSide:drawerSide]; + if(drawerSide == MMDrawerSideLeft) { + transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); + transform = CATransform3DTranslate(transform, self.maximumLeftDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f); + } + else if(drawerSide == MMDrawerSideRight){ + transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); + transform = CATransform3DTranslate(transform, -self.maximumRightDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f); + } + sideDrawerViewController.view.layer.transform = transform; + } +} + +-(void)resetDrawerVisualStateForDrawerSide:(MMDrawerSide)drawerSide{ + UIViewController * sideDrawerViewController = [self sideDrawerViewControllerForSide:drawerSide]; + + [sideDrawerViewController.view.layer setAnchorPoint:CGPointMake(0.5f, 0.5f)]; + [sideDrawerViewController.view.layer setTransform:CATransform3DIdentity]; + [sideDrawerViewController.view setAlpha:1.0]; +} + +-(CGFloat)roundedOriginXForDrawerConstriants:(CGFloat)originX{ + + if (originX < -self.maximumRightDrawerWidth) { + if (self.shouldStretchDrawer && + self.rightDrawerViewController) { + CGFloat maxOvershoot = (CGRectGetWidth(self.centerContainerView.frame)-self.maximumRightDrawerWidth)*MMDrawerOvershootPercentage; + return originXForDrawerOriginAndTargetOriginOffset(originX, -self.maximumRightDrawerWidth, maxOvershoot); + } + else{ + return -self.maximumRightDrawerWidth; + } + } + else if(originX > self.maximumLeftDrawerWidth){ + if (self.shouldStretchDrawer && + self.leftDrawerViewController) { + CGFloat maxOvershoot = (CGRectGetWidth(self.centerContainerView.frame)-self.maximumLeftDrawerWidth)*MMDrawerOvershootPercentage; + return originXForDrawerOriginAndTargetOriginOffset(originX, self.maximumLeftDrawerWidth, maxOvershoot); + } + else{ + return self.maximumLeftDrawerWidth; + } + } + + return originX; +} + +static inline CGFloat originXForDrawerOriginAndTargetOriginOffset(CGFloat originX, CGFloat targetOffset, CGFloat maxOvershoot){ + CGFloat delta = ABS(originX - targetOffset); + CGFloat maxLinearPercentage = MMDrawerOvershootLinearRangePercentage; + CGFloat nonLinearRange = maxOvershoot * maxLinearPercentage; + CGFloat nonLinearScalingDelta = (delta - nonLinearRange); + CGFloat overshoot = nonLinearRange + nonLinearScalingDelta * nonLinearRange/sqrt(pow(nonLinearScalingDelta,2.f) + 15000); + + if (delta < nonLinearRange) { + return originX; + } + else if (targetOffset < 0) { + return targetOffset - round(overshoot); + } + else{ + return targetOffset + round(overshoot); + } +} + +#pragma mark - Helpers +-(void)setupGestureRecognizers{ + UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureCallback:)]; + [pan setDelegate:self]; + [self.view addGestureRecognizer:pan]; + + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureCallback:)]; + [tap setDelegate:self]; + [self.view addGestureRecognizer:tap]; +} + +-(void)prepareToPresentDrawer:(MMDrawerSide)drawer animated:(BOOL)animated{ + MMDrawerSide drawerToHide = MMDrawerSideNone; + if(drawer == MMDrawerSideLeft){ + drawerToHide = MMDrawerSideRight; + } + else if(drawer == MMDrawerSideRight){ + drawerToHide = MMDrawerSideLeft; + } + + UIViewController * sideDrawerViewControllerToPresent = [self sideDrawerViewControllerForSide:drawer]; + UIViewController * sideDrawerViewControllerToHide = [self sideDrawerViewControllerForSide:drawerToHide]; + + [self.childControllerContainerView sendSubviewToBack:sideDrawerViewControllerToHide.view]; + [sideDrawerViewControllerToHide.view setHidden:YES]; + [sideDrawerViewControllerToPresent.view setHidden:NO]; + [self resetDrawerVisualStateForDrawerSide:drawer]; + [sideDrawerViewControllerToPresent.view setFrame:sideDrawerViewControllerToPresent.mm_visibleDrawerFrame]; + [self updateDrawerVisualStateForDrawerSide:drawer percentVisible:0.0]; + [sideDrawerViewControllerToPresent beginAppearanceTransition:YES animated:animated]; +} + +-(void)updateShadowForCenterView{ + UIView * centerView = self.centerContainerView; + if(self.showsShadow){ + centerView.layer.masksToBounds = NO; + centerView.layer.shadowRadius = MMDrawerDefaultShadowRadius; + centerView.layer.shadowOpacity = MMDrawerDefaultShadowOpacity; + + /** In the event this gets called a lot, we won't update the shadowPath + unless it needs to be updated (like during rotation) */ + if (centerView.layer.shadowPath == NULL) { + centerView.layer.shadowPath = [[UIBezierPath bezierPathWithRect:self.centerContainerView.bounds] CGPath]; + } + else{ + CGRect currentPath = CGPathGetPathBoundingBox(centerView.layer.shadowPath); + if (CGRectEqualToRect(currentPath, centerView.bounds) == NO){ + centerView.layer.shadowPath = [[UIBezierPath bezierPathWithRect:self.centerContainerView.bounds] CGPath]; + } + } + } + else if (centerView.layer.shadowPath != NULL) { + centerView.layer.shadowRadius = 0.f; + centerView.layer.shadowOpacity = 0.f; + centerView.layer.shadowPath = NULL; + centerView.layer.masksToBounds = YES; + } +} + +-(NSTimeInterval)animationDurationForAnimationDistance:(CGFloat)distance{ + NSTimeInterval duration = MAX(distance/self.animationVelocity,MMDrawerMinimumAnimationDuration); + return duration; +} + +-(UIViewController*)sideDrawerViewControllerForSide:(MMDrawerSide)drawerSide{ + UIViewController * sideDrawerViewController = nil; + if(drawerSide != MMDrawerSideNone){ + sideDrawerViewController = [self childViewControllerForSide:drawerSide]; + } + return sideDrawerViewController; +} + +-(UIViewController*)childViewControllerForSide:(MMDrawerSide)drawerSide{ + UIViewController * childViewController = nil; + switch (drawerSide) { + case MMDrawerSideLeft: + childViewController = self.leftDrawerViewController; + break; + case MMDrawerSideRight: + childViewController = self.rightDrawerViewController; + break; + case MMDrawerSideNone: + childViewController = self.centerViewController; + break; + } + return childViewController; +} + +#pragma mark - UIGestureRecognizerDelegate +-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{ + + if(self.openSide == MMDrawerSideNone){ + MMOpenDrawerGestureMode possibleOpenGestureModes = [self possibleOpenGestureModesForGestureRecognizer:gestureRecognizer + withTouch:touch]; + return ((self.openDrawerGestureModeMask & possibleOpenGestureModes)>0); + } + else{ + MMCloseDrawerGestureMode possibleCloseGestureModes = [self possibleCloseGestureModesForGestureRecognizer:gestureRecognizer + withTouch:touch]; + return ((self.closeDrawerGestureModeMask & possibleCloseGestureModes)>0); + } +} + +#pragma mark Gesture Recogizner Delegate Helpers +-(MMCloseDrawerGestureMode)possibleCloseGestureModesForGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer withTouch:(UITouch*)touch{ + CGPoint point = [touch locationInView:self.childControllerContainerView]; + MMCloseDrawerGestureMode possibleCloseGestureModes = MMCloseDrawerGestureModeNone; + if([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]){ + if([self isPointContainedWithinNavigationRect:point]){ + possibleCloseGestureModes |= MMCloseDrawerGestureModeTapNavigationBar; + } + if([self isPointContainedWithinCenterViewContentRect:point]){ + possibleCloseGestureModes |= MMCloseDrawerGestureModeTapCenterView; + } + } + else if([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]){ + if([self isPointContainedWithinNavigationRect:point]){ + possibleCloseGestureModes |= MMCloseDrawerGestureModePanningNavigationBar; + } + if([self isPointContainedWithinCenterViewContentRect:point]){ + possibleCloseGestureModes |= MMCloseDrawerGestureModePanningCenterView; + } + if([self isPointContainedWithinRightBezelRect:point] && + self.openSide == MMDrawerSideLeft){ + possibleCloseGestureModes |= MMCloseDrawerGestureModeBezelPanningCenterView; + } + if([self isPointContainedWithinLeftBezelRect:point] && + self.openSide == MMDrawerSideRight){ + possibleCloseGestureModes |= MMCloseDrawerGestureModeBezelPanningCenterView; + } + if([self isPointContainedWithinCenterViewContentRect:point] == NO && + [self isPointContainedWithinNavigationRect:point] == NO){ + possibleCloseGestureModes |= MMCloseDrawerGestureModePanningDrawerView; + } + } + if((self.closeDrawerGestureModeMask & MMCloseDrawerGestureModeCustom) > 0 && + self.gestureShouldRecognizeTouch){ + if(self.gestureShouldRecognizeTouch(self,gestureRecognizer,touch)){ + possibleCloseGestureModes |= MMCloseDrawerGestureModeCustom; + } + } + return possibleCloseGestureModes; +} + +-(MMOpenDrawerGestureMode)possibleOpenGestureModesForGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer withTouch:(UITouch*)touch{ + CGPoint point = [touch locationInView:self.childControllerContainerView]; + MMOpenDrawerGestureMode possibleOpenGestureModes = MMOpenDrawerGestureModeNone; + if([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]){ + if([self isPointContainedWithinNavigationRect:point]){ + possibleOpenGestureModes |= MMOpenDrawerGestureModePanningNavigationBar; + } + if([self isPointContainedWithinCenterViewContentRect:point]){ + possibleOpenGestureModes |= MMOpenDrawerGestureModePanningCenterView; + } + if([self isPointContainedWithinLeftBezelRect:point] && + self.leftDrawerViewController){ + possibleOpenGestureModes |= MMOpenDrawerGestureModeBezelPanningCenterView; + } + if([self isPointContainedWithinRightBezelRect:point] && + self.rightDrawerViewController){ + possibleOpenGestureModes |= MMOpenDrawerGestureModeBezelPanningCenterView; + } + } + if((self.openDrawerGestureModeMask & MMOpenDrawerGestureModeCustom) > 0 && + self.gestureShouldRecognizeTouch){ + if(self.gestureShouldRecognizeTouch(self,gestureRecognizer,touch)){ + possibleOpenGestureModes |= MMOpenDrawerGestureModeCustom; + } + } + return possibleOpenGestureModes; +} + +-(BOOL)isPointContainedWithinNavigationRect:(CGPoint)point{ + CGRect navigationBarRect = CGRectNull; + if([self.centerViewController isKindOfClass:[UINavigationController class]]){ + UINavigationBar * navBar = [(UINavigationController*)self.centerViewController navigationBar]; + navigationBarRect = [navBar convertRect:navBar.bounds toView:self.childControllerContainerView]; + navigationBarRect = CGRectIntersection(navigationBarRect,self.childControllerContainerView.bounds); + } + return CGRectContainsPoint(navigationBarRect,point); +} + +-(BOOL)isPointContainedWithinCenterViewContentRect:(CGPoint)point{ + CGRect centerViewContentRect = self.centerContainerView.frame; + centerViewContentRect = CGRectIntersection(centerViewContentRect,self.childControllerContainerView.bounds); + return (CGRectContainsPoint(centerViewContentRect, point) && + [self isPointContainedWithinNavigationRect:point] == NO); +} + +-(BOOL)isPointContainedWithinLeftBezelRect:(CGPoint)point{ + CGRect leftBezelRect = CGRectNull; + CGRect tempRect; + CGRectDivide(self.childControllerContainerView.bounds, &leftBezelRect, &tempRect, MMDrawerBezelRange, CGRectMinXEdge); + return (CGRectContainsPoint(leftBezelRect, point) && + [self isPointContainedWithinCenterViewContentRect:point]); +} + +-(BOOL)isPointContainedWithinRightBezelRect:(CGPoint)point{ + CGRect rightBezelRect = CGRectNull; + CGRect tempRect; + CGRectDivide(self.childControllerContainerView.bounds, &rightBezelRect, &tempRect, MMDrawerBezelRange, CGRectMaxXEdge); + + return (CGRectContainsPoint(rightBezelRect, point) && + [self isPointContainedWithinCenterViewContentRect:point]); +} +@end diff --git a/ios/Classes/MMDrawerController/MMDrawerController/MMDrawerVisualState.h b/ios/Classes/MMDrawerController/MMDrawerController/MMDrawerVisualState.h new file mode 100644 index 0000000..7cb8fff --- /dev/null +++ b/ios/Classes/MMDrawerController/MMDrawerController/MMDrawerVisualState.h @@ -0,0 +1,61 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import +#import "MMDrawerController.h" + +/** + `MMDrawerVisualState` provides prebuilt visual state update blocks that can be used in the callback block of `MMDrawerController` for drawer animation. + */ + +@interface MMDrawerVisualState : NSObject + +/** + Creates a slide and scale visual state block that gives an experience similar to Mailbox.app. It scales from 90% to 100%, and translates 50 pixels in the x direction. In addition, it also sets alpha from 0.0 to 1.0. + + @return The visual state block. + */ ++(MMDrawerControllerDrawerVisualStateBlock)slideAndScaleVisualStateBlock; + +/** + Creates a slide visual state block that gives the user an experience that slides at the same speed of the center view controller during animation. This is equal to calling `parallaxVisualStateBlockWithParallaxFactor:` with a parallax factor of 1.0. + + @return The visual state block. + */ ++(MMDrawerControllerDrawerVisualStateBlock)slideVisualStateBlock; + +/** + Creates a swinging door visual state block that gives the user an experience that animates the drawer in along the hinge. + + @return The visual state block. + */ ++(MMDrawerControllerDrawerVisualStateBlock)swingingDoorVisualStateBlock; + +/** + Creates a parallax experience that slides the side drawer view controller at a different rate than the center view controller during animation. For every parallaxFactor of points moved by the center view controller, the side drawer view controller will move 1 point. Passing in 1.0 is the equivalent of a applying a sliding animation, while passing in MAX_FLOAT is the equivalent of having no animation at all. + + @param parallaxFactor The amount of parallax applied to the side drawer conroller. This value must be greater than 1.0. The closer the value is to 1.0, the faster the side drawer view controller will be parallaxing. + + @return The visual state block. + */ ++(MMDrawerControllerDrawerVisualStateBlock)parallaxVisualStateBlockWithParallaxFactor:(CGFloat)parallaxFactor; + +@end diff --git a/ios/Classes/MMDrawerController/MMDrawerController/MMDrawerVisualState.m b/ios/Classes/MMDrawerController/MMDrawerController/MMDrawerVisualState.m new file mode 100644 index 0000000..013d019 --- /dev/null +++ b/ios/Classes/MMDrawerController/MMDrawerController/MMDrawerVisualState.m @@ -0,0 +1,150 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import "MMDrawerVisualState.h" +#import + +@implementation MMDrawerVisualState ++(MMDrawerControllerDrawerVisualStateBlock)slideAndScaleVisualStateBlock{ + MMDrawerControllerDrawerVisualStateBlock visualStateBlock = + ^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){ + CGFloat minScale = .90; + CGFloat scale = minScale + (percentVisible*(1.0-minScale)); + CATransform3D scaleTransform = CATransform3DMakeScale(scale, scale, scale); + + CGFloat maxDistance = 50; + CGFloat distance = maxDistance * percentVisible; + CATransform3D translateTransform = CATransform3DIdentity; + UIViewController * sideDrawerViewController; + if(drawerSide == MMDrawerSideLeft) { + sideDrawerViewController = drawerController.leftDrawerViewController; + translateTransform = CATransform3DMakeTranslation((maxDistance-distance), 0.0, 0.0); + } + else if(drawerSide == MMDrawerSideRight){ + sideDrawerViewController = drawerController.rightDrawerViewController; + translateTransform = CATransform3DMakeTranslation(-(maxDistance-distance), 0.0, 0.0); + } + + [sideDrawerViewController.view.layer setTransform:CATransform3DConcat(scaleTransform, translateTransform)]; + [sideDrawerViewController.view setAlpha:percentVisible]; + }; + return visualStateBlock; +} + ++(MMDrawerControllerDrawerVisualStateBlock)slideVisualStateBlock{ + return [self parallaxVisualStateBlockWithParallaxFactor:1.0]; +} + + ++(MMDrawerControllerDrawerVisualStateBlock)swingingDoorVisualStateBlock{ + MMDrawerControllerDrawerVisualStateBlock visualStateBlock = + ^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){ + UIViewController * sideDrawerViewController; + CGPoint anchorPoint; + CGFloat maxDrawerWidth = 0.0; + CGFloat xOffset; + CGFloat angle = 0.0; + + if(drawerSide==MMDrawerSideLeft){ + + sideDrawerViewController = drawerController.leftDrawerViewController; + anchorPoint = CGPointMake(1.0, .5); + maxDrawerWidth = MAX(drawerController.maximumLeftDrawerWidth,drawerController.visibleLeftDrawerWidth); + xOffset = -(maxDrawerWidth/2.0) + (maxDrawerWidth)*percentVisible; + angle = -M_PI_2+(percentVisible*M_PI_2); + } + else { + sideDrawerViewController = drawerController.rightDrawerViewController; + anchorPoint = CGPointMake(0.0, .5); + maxDrawerWidth = MAX(drawerController.maximumRightDrawerWidth,drawerController.visibleRightDrawerWidth); + xOffset = (maxDrawerWidth/2.0) - (maxDrawerWidth)*percentVisible; + angle = M_PI_2-(percentVisible*M_PI_2); + } + + [sideDrawerViewController.view.layer setAnchorPoint:anchorPoint]; + [sideDrawerViewController.view.layer setShouldRasterize:YES]; + [sideDrawerViewController.view.layer setRasterizationScale:[[UIScreen mainScreen] scale]]; + + CATransform3D swingingDoorTransform = CATransform3DIdentity; + if (percentVisible <= 1.f) { + + CATransform3D identity = CATransform3DIdentity; + identity.m34 = -1.0/1000.0; + CATransform3D rotateTransform = CATransform3DRotate(identity, angle, 0.0, 1.0, 0.0); + + CATransform3D translateTransform = CATransform3DMakeTranslation(xOffset, 0.0, 0.0); + + CATransform3D concatTransform = CATransform3DConcat(rotateTransform, translateTransform); + + swingingDoorTransform = concatTransform; + } + else{ + CATransform3D overshootTransform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); + + NSInteger scalingModifier = 1.f; + if (drawerSide == MMDrawerSideRight) { + scalingModifier = -1.f; + } + + overshootTransform = CATransform3DTranslate(overshootTransform, scalingModifier*maxDrawerWidth/2, 0.f, 0.f); + swingingDoorTransform = overshootTransform; + } + + [sideDrawerViewController.view.layer setTransform:swingingDoorTransform]; + }; + return visualStateBlock; +} + ++(MMDrawerControllerDrawerVisualStateBlock)parallaxVisualStateBlockWithParallaxFactor:(CGFloat)parallaxFactor{ + MMDrawerControllerDrawerVisualStateBlock visualStateBlock = + ^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){ + NSParameterAssert(parallaxFactor >= 1.0); + CATransform3D transform = CATransform3DIdentity; + UIViewController * sideDrawerViewController; + if(drawerSide == MMDrawerSideLeft) { + sideDrawerViewController = drawerController.leftDrawerViewController; + CGFloat distance = MAX(drawerController.maximumLeftDrawerWidth,drawerController.visibleLeftDrawerWidth); + if (percentVisible <= 1.f) { + transform = CATransform3DMakeTranslation((-distance)/parallaxFactor+(distance*percentVisible/parallaxFactor), 0.0, 0.0); + } + else{ + transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); + transform = CATransform3DTranslate(transform, drawerController.maximumLeftDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f); + } + } + else if(drawerSide == MMDrawerSideRight){ + sideDrawerViewController = drawerController.rightDrawerViewController; + CGFloat distance = MAX(drawerController.maximumRightDrawerWidth,drawerController.visibleRightDrawerWidth); + if(percentVisible <= 1.f){ + transform = CATransform3DMakeTranslation((distance)/parallaxFactor-(distance*percentVisible)/parallaxFactor, 0.0, 0.0); + } + else{ + transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); + transform = CATransform3DTranslate(transform, -drawerController.maximumRightDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f); + } + } + + [sideDrawerViewController.view.layer setTransform:transform]; + }; + return visualStateBlock; +} + +@end diff --git a/ios/Classes/MMDrawerController/MMDrawerController/UIViewController+MMDrawerController.h b/ios/Classes/MMDrawerController/MMDrawerController/UIViewController+MMDrawerController.h new file mode 100644 index 0000000..1bf05ef --- /dev/null +++ b/ios/Classes/MMDrawerController/MMDrawerController/UIViewController+MMDrawerController.h @@ -0,0 +1,45 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import "MMDrawerController.h" + +/** + A helper category on `UIViewController` that exposes the parent drawer controller, the visible side drawer frame, and a `mm_drawerWillAppear` method that is called when the drawer is about to appear. + */ + +@interface UIViewController (MMDrawerController) + +///--------------------------------------- +/// @name Accessing Drawer View Controller Properties +///--------------------------------------- + +/** + The `MMDrawerController` that the view controller is contained within. If the view controller is not contained within a `MMDrawerController`, this property is nil. Note that if the view controller is contained within a `UINavigationController`, that navigation controller is contained within a `MMDrawerController`, this property will return a refernce to the `MMDrawerController`, despite the fact that it is not the direct parent of the view controller. + */ +@property(nonatomic, strong, readonly) MMDrawerController *mm_drawerController; + +/** + The visible rect of the side drawer view controller in the drawer controller coordinate space. If the view controller is not a drawer in a `MMDrawerController`, then this property returns `CGRectNull` + */ +@property(nonatomic, assign, readonly) CGRect mm_visibleDrawerFrame; + +@end diff --git a/ios/Classes/MMDrawerController/MMDrawerController/UIViewController+MMDrawerController.m b/ios/Classes/MMDrawerController/MMDrawerController/UIViewController+MMDrawerController.m new file mode 100644 index 0000000..d2ffe3b --- /dev/null +++ b/ios/Classes/MMDrawerController/MMDrawerController/UIViewController+MMDrawerController.m @@ -0,0 +1,58 @@ +// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) +// +// 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 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import "UIViewController+MMDrawerController.h" + +@implementation UIViewController (MMDrawerController) + + +-(MMDrawerController*)mm_drawerController{ + UIViewController *parentViewController = self.parentViewController; + while (parentViewController != nil) { + if([parentViewController isKindOfClass:[MMDrawerController class]]){ + return (MMDrawerController *)parentViewController; + } + parentViewController = parentViewController.parentViewController; + } + return nil; +} + +-(CGRect)mm_visibleDrawerFrame{ + if([self isEqual:self.mm_drawerController.leftDrawerViewController] || + [self.navigationController isEqual:self.mm_drawerController.leftDrawerViewController]){ + CGRect rect = self.mm_drawerController.view.bounds; + rect.size.width = self.mm_drawerController.maximumLeftDrawerWidth; + return rect; + + } + else if([self isEqual:self.mm_drawerController.rightDrawerViewController] || + [self.navigationController isEqual:self.mm_drawerController.rightDrawerViewController]){ + CGRect rect = self.mm_drawerController.view.bounds; + rect.size.width = self.mm_drawerController.maximumRightDrawerWidth; + rect.origin.x = CGRectGetWidth(self.mm_drawerController.view.bounds)-rect.size.width; + return rect; + } + else { + return CGRectNull; + } +} + +@end diff --git a/ios/Classes/MMDrawerController/README.md b/ios/Classes/MMDrawerController/README.md new file mode 100644 index 0000000..b138547 --- /dev/null +++ b/ios/Classes/MMDrawerController/README.md @@ -0,0 +1,213 @@ +#Mutual Mobile Drawer Controller +`MMDrawerController` is a side drawer navigation container view controller designed to support the growing number of applications that leverage the side drawer paradigm. This library is designed to exclusively support side drawer navigation in a light-weight, focused approach while exposing the ability to provide custom animations for presenting and dismissing the drawer. + +

+ + +

+ +--- +##Documentation +Official appledoc documentation can be found at [CocoaDocs](http://cocoadocs.org/docsets/MMDrawerController/). + +--- +##Installing MMDrawerController +
+You can install MMDrawerController in your project by using [CocoaPods](https://github.com/cocoapods/cocoapods): + +```Ruby +pod 'MMDrawerController', '~> 0.5.7' +``` + +--- +##Creating a Drawer Controller +Creating a `MMDrawerController` is as easy as creating a center view controller and the drawer view controllers, and init'ing the drawer. + +```Objective-C +UIViewController * leftDrawer = [[UIViewController alloc] init]; +UIViewController * center = [[UIViewController alloc] init]; +UIViewController * rightDrawer = [[UIViewController alloc] init]; + +MMDrawerController * drawerController = [[MMDrawerController alloc] + initWithCenterViewController:center + leftDrawerViewController:leftDrawer + rightDrawerViewController:rightDrawer]; +``` + +--- +##Features + +###UINavigationController Support +`MMDrawerController` seamlessly accepts a `UINavigationController` as the `centerViewController`, and will update all of the gesture support automatically. In addition, any child view controller contained within the `UINavigationController` will have access to the parent drawer controller using the category explained [below](#accessing-the-drawer-controller-from-a-child-view-controller). + +###UIGestureRecognizer Support +`MMDrawerController` exposes gesture support for opening and closing the drawer through two masks, one for opening and one for closing. The options are as follows: + +* **MMOpenDrawerGestureMode** + * **MMOpenDrawerGestureModePanningNavigationBar**: The user can open the drawer by panning anywhere on the navigation bar. + * **MMOpenDrawerGestureModePanningCenterView**: The user can open the drawer by panning anywhere on the center view. + * **MMOpenDrawerGestureModeBezelPanningCenterView**: The user can open the drawer by starting a pan anywhere within 20 points of the bezel. + * **MMOpenDrawerGestureModeCustom**: The developer can provide a callback block to determine if the gesture should be recognized. More information below. + +* **MMCloseDrawerGestureMode** + * **MMCloseDrawerGestureModePanningNavigationBar**: The user can close the drawer by panning anywhere on the navigation bar. + * **MMCloseDrawerGestureModePanningCenterView**: The user can close the drawer by panning anywhere on the center view. + * **MMCloseDrawerGestureModeBezelPanningCenterView**: The user can close the drawer by starting a pan anywhere within the bezel of the center view. + * **MMCloseDrawerGestureModeTapNavigationBar**: The user can close the drawer by tapping the navigation bar. + * **MMCloseDrawerGestureModeTapCenterView**: The user can close the drawer by tapping the center view. + * **MMCloseDrawerGestureModePanningDrawerView**: The user can close the drawer by panning anywhere on the drawer view. + * **MMCloseDrawerGestureModeCustom**: The developer can provide a callback block to determine if the gesture should be recognized. More information below. + +You are free to set whatever combination you want for opening and closing. Note that these gestures may impact touches sent to the child view controllers, so be sure to use these appropriately for your application. For example, you wouldn't want `MMOpenDrawerGestureModePanningCenterView` set if a `MKMapView` is your center view controller, since it would intercept the pan meant for moving around the map. + +####Custom Gesture Recognizer Support +Starting with version 0.3.0, you can now provide a callback block to determine if a gesture should be recognized using the `setGestureShouldRecognizeTouchBlock:` method. This method provides three parameters - the drawer controller, the gesture, and the touch. As a developer, you are responsible for inspecting those elements and determining if the gesture should be recognized or not. Note the block is only consulted if you have set `MMOpenDrawerGestureModeCustom`/`MMCloseDrawerGestureModeCustom` on the appropriate mask. + +For example, lets say you have a center view controller that contains a few elements, and you only want the pan gesture to be recognized to open the drawer when the touch begins within a certain subview. You would make sure that the `openDrawerGestureModeMask` contains `MMOpenDrawerGestureModeCustom`, and you could set a block below as so: + +```Objective-C +[myDrawerController + setGestureShouldRecognizeTouchBlock:^BOOL(MMDrawerController *drawerController, UIGestureRecognizer *gesture, UITouch *touch) { + BOOL shouldRecognizeTouch = NO; + if(drawerController.openSide == MMDrawerSideNone && + [gesture isKindOfClass:[UIPanGestureRecognizer class]]){ + UIView * customView = [drawerController.centerViewController myCustomSubview]; + CGPoint location = [touch locationInView:customView]; + shouldRecognizeTouch = (CGRectContainsPoint(customView.bounds, location)); + } + return shouldRecognizeTouch; + }]; + ``` + Note that you would not want the `openDrawerGestureModeMask` to contain `MMOpenDrawerGestureModePanningCenterView`, since that would take over and be applied automatically regardless of where the touch begins within the center view. + +###Custom Drawer Open/Close Animations +`MMDrawerController` provides a callback block that allows you to implement your own custom state for the drawer controller when an open/close or pan gesture event happens. Within the block, you are responsible for updating the visual state of the drawer controller, and the drawer controller will handle animating to that state. + +For example, to set the alpha of the side drawer controller from 0 to 1 during an animation, you would do the following: + +```Objective-C +[drawerController + setDrawerVisualStateBlock:^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) { + UIViewController * sideDrawerViewController; + if(drawerSide == MMDrawerSideLeft){ + sideDrawerViewController = drawerController.leftDrawerViewController; + } + else if(drawerSide == MMDrawerSideRight){ + sideDrawerViewController = drawerController.rightDrawerViewController; + } + [sideDrawerViewController.view setAlpha:percentVisible]; + }]; +``` + +In addition, `MMDrawerController` ships with several prebuilt animations to let you go crazy right out of the box. These are included as a subspec for the project, and more information can be found [below](#prebuilt-example-animations). + +###Center View Controller Interaction Mode +When a drawer is open, you can control how a user can interact with the center view controller. + +* **MMDrawerOpenCenterInteractionModeNone**: The user can not interact with any content in the center view. +* **MMDrawerOpenCenterInteractionModeFull**: The user can interact with all content in the center view. +* **MMDrawerOpenCenterInteractionModeNavigationBarOnly**: The user can interact with only content on the navigation bar. The setting allows the menu button to still respond, allowing you to toggle the drawer closed when it is open. This is the default setting. + +###Accessing the Drawer Controller from a Child View Controller +You can use the `UIViewController+MMDrawerController` category in order to query the drawerController directly from child view controllers. + +###State Restoration +Beginning with 0.4.0, `MMDrawerController` supports iOS state restoration. In order to opt in to state restoration for `MMDrawerController`, you must set the `restorationIdentifier` of your drawer controller. Instances of your `centerViewController`, `leftDrawerViewController` and `rightDrawerViewController` must also be configured with their own `restorationIdentifier` (and optionally a restorationClass) if you intend for those to be restored as well. If your MMDrawerController had an open drawer when your app was sent to the background, that state will also be restored. + +##iOS 7 Status Bar Support +###Child View Controller Support +Beginning with iOS 7, the child view controllers will by default determine the state of the status bar, including its' style and whether or not it is hidden. This value will also be updated anytime the open side changes state, meaning that a side drawer can provide a different value than the center view controller. + +If you do not want the drawer controller to consult the child view controllers for this state, you should subclass `MMDrawerController`, override `childViewControllerForStatusBarStyle` and `childViewControllerForStatusBarHidden`, and return nil for both. + +###Custom Status Bar Background View +If you have a contrasting colors between your center view controller and your drawer controllers, the new iOS 7 status bar handling could cause your application to look less than ideal. Starting with iOS 7, `MMDrawerController` supports drawing a custom status bar area at the top of the screen, to give you an area to display the status bar with a constant color, while allowing you to draw custom content below the status bar without worrying about the color of your navigation bars or the top of your content running up underneath the status bar. Using the feature essentially mimics <= iOS 6.X behavior. + +To enable a custom status bar, simple set `showsStatusBarBackgroundView` to `YES`. By default, this will draw a black a view underneath the status bar, and adjust your to content to be laid out lower than the status bar. If you would like a custom status background color, you can set `statusBarViewBackgroundColor` to whatever color you desire. + +--- +##Subclassing +If you plan to subclass `MMDrawerController`, import `MMDrawerController+Subclass.h` into your subclass to access protected methods for `MMDrawerController.` Note that several methods assume and require you to call super, so be sure to follow that convention. + +If there is specific functionality you need that is not supported by these methods, please open a Github issue explaining your needs and we can try and find a way to open up methods that can help you out. + +--- +##Bells and Whistles +A few extras to make your life easier... + +###MMDrawerBarButtonItem +Using Paint Code, we created a standard Menu Button that you can use in any `UINavigationBar`, and make it whatever color you want. It's included as a subspec to this library. Enjoy. + +Starting with iOS 7, the drawer button is now drawn in a much thinner stroke. In addition, the color methods have been deprecated, and the color will now be determined by the `tintColor.` Also note that the shadow has been deprecated to be more in line with the design themes of the OS. + +###Prebuilt Example Animations +In order to make it as easy as possible for you to use this library, we built some of the common animations we see out there today. Simply include the `MMDrawerVisualStates` subspec, and use any of the prebuilt visual states. + +For example, if you wanted to use a slide and scale animation, you would do the following: + +```Objective-C +[drawerController setDrawerVisualStateBlock:[MMDrawerVisualState slideAndScaleVisualStateBlock]]; +``` + +And that's it... + +Here's a quick list of the built in animations: + +* **Slide**: The drawer slides at the same rate as the center view controller. +* **Slide and Scale**: The drawer slides and scales up at the same time, while also alpha'ing from 0.0 to 1.0. +* **Swinging Door**: The drawer swings in along a hinge on the center view controller. +* **Parallax**: The drawer slides in at a slower rate than the center view controller, giving a parallax effect. + +###Stretchy Drawer +By default, the side drawer will stretch if the user pans past the maximum drawer width. This gives a playful stretch effect. You can disable this by setting `shouldStretchDrawer` to NO, or you can make your own overshoot animation by creating a custom visual state block and setting up custom transforms for when percentVisible is greater than 1.0 + +###Bounce Preview +To make your side drawer more discoverable, it may be helpful to bounce the drawer the first time your user launches the app. You can use the `bouncePreviewForDrawerSide:completion:` method to easily do this. + +If you would like to bounce a custom distance, you can use `bouncePreviewForDrawerSide:distance:completion:`. + +###Nifty Example +We decided to spruce up the example a bit using graphics generated from PaintCode. Hope you like it. + +The example shows off all the features of the library. Give it a whirl. + +--- +##What this Library Doesn't Do +In order to keep this library light-weight, we had to make some design trade off decisions. Specifically, we decided this library would NOT DO the following: + +* Top or bottom drawer views +* Displaying both drawers at one time +* Displaying a minimum drawer width +* Support container view controllers other than `UINavigationController` (such as `UITabBarController` or `UISplitViewController`) as the center view controller. +* Support presenting the drawer above the center view controller (like the Google+ app). + +We're sure this list will grow over time. But that's the cost of keeping something maintainable :) + +--- +##Workarounds/FAQs +####How do I support editing/dragging cells in a tableview in the center view controller? +The best way to support this is to set the open/close mask to `MMOpenDrawerGestureModeNone` / `MMCloseDrawerGestureModeNone` while editing is enabled, and restore the mask when editing is finished. This will allow the proper gestures/touches to be passed all the way to the table view. ([#184](https://github.com/mutualmobile/MMDrawerController/issues/184)) + + +--- +##Credit +Designed and Developed by these fine folks at [Mutual Mobile](http://mutualmobile.com): + +###Development + +* [Kevin Harwood](http://twitter.com/kevinharwood) +* [Lars Anderson](http://twitter.com/theonlylars) +* [Rene Cacheaux](http://twitter.com/rcachatx) +* [Conrad Stoll](http://twitter.com/conradstoll) + +###Design + +* [Matt McDaniel](http://twitter.com/supermattzor) + +--- +##Feedback +We'd love to hear feedback on the library. Create Github issues, or hit us up on Twitter. + +--- +##License +`MMDrawerController` is available under the MIT license. See the LICENSE file for more info. diff --git a/ios/Classes/NappDrawerVisualState.h b/ios/Classes/NappDrawerVisualState.h index 1620df3..5af6d7a 100644 --- a/ios/Classes/NappDrawerVisualState.h +++ b/ios/Classes/NappDrawerVisualState.h @@ -7,29 +7,26 @@ * and licensed under the Apache Public License (version 2) */ - -#import #import "MMDrawerController.h" +#import @interface NappDrawerVisualState : NSObject ++ (MMDrawerControllerDrawerVisualStateBlock)slideAndScaleVisualStateBlock; -+(MMDrawerControllerDrawerVisualStateBlock)slideAndScaleVisualStateBlock; ++ (MMDrawerControllerDrawerVisualStateBlock)slideVisualStateBlock; -+(MMDrawerControllerDrawerVisualStateBlock)slideVisualStateBlock; - -+(MMDrawerControllerDrawerVisualStateBlock)swingingDoorVisualStateBlock; ++ (MMDrawerControllerDrawerVisualStateBlock)swingingDoorVisualStateBlock; // parallax -+(MMDrawerControllerDrawerVisualStateBlock)parallax3VisualStateBlock; -+(MMDrawerControllerDrawerVisualStateBlock)parallax5VisualStateBlock; -+(MMDrawerControllerDrawerVisualStateBlock)parallax7VisualStateBlock; ++ (MMDrawerControllerDrawerVisualStateBlock)parallax3VisualStateBlock; ++ (MMDrawerControllerDrawerVisualStateBlock)parallax5VisualStateBlock; ++ (MMDrawerControllerDrawerVisualStateBlock)parallax7VisualStateBlock; // fade -+(MMDrawerControllerDrawerVisualStateBlock)fadeVisualStateBlock; ++ (MMDrawerControllerDrawerVisualStateBlock)fadeVisualStateBlock; // node -+(MMDrawerControllerDrawerVisualStateBlock)noneVisualStateBlock; - ++ (MMDrawerControllerDrawerVisualStateBlock)noneVisualStateBlock; @end diff --git a/ios/Classes/NappDrawerVisualState.m b/ios/Classes/NappDrawerVisualState.m index a266083..1f90f1d 100644 --- a/ios/Classes/NappDrawerVisualState.m +++ b/ios/Classes/NappDrawerVisualState.m @@ -12,288 +12,288 @@ @implementation NappDrawerVisualState -+(MMDrawerControllerDrawerVisualStateBlock)slideAndScaleVisualStateBlock{ - MMDrawerControllerDrawerVisualStateBlock visualStateBlock = - ^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){ - - if(drawerSide == MMDrawerSideNone){ - return; - } - - CGFloat minScale = .90; - CGFloat scale = minScale + (percentVisible*(1.0-minScale)); - CATransform3D scaleTransform = CATransform3DMakeScale(scale, scale, scale); - - CGFloat maxDistance = 50; - CGFloat distance = maxDistance * percentVisible; - CATransform3D translateTransform; - UIViewController * sideDrawerViewController; - if(drawerSide == MMDrawerSideLeft) { - sideDrawerViewController = drawerController.leftDrawerViewController; - translateTransform = CATransform3DMakeTranslation((maxDistance-distance), 0.0, 0.0); - } - else if(drawerSide == MMDrawerSideRight){ - sideDrawerViewController = drawerController.rightDrawerViewController; - translateTransform = CATransform3DMakeTranslation(-(maxDistance-distance), 0.0, 0.0); - } - - [sideDrawerViewController.view.layer setTransform:CATransform3DConcat(scaleTransform, translateTransform)]; - [sideDrawerViewController.view setAlpha:percentVisible]; - }; - return visualStateBlock; ++ (MMDrawerControllerDrawerVisualStateBlock)slideAndScaleVisualStateBlock +{ + MMDrawerControllerDrawerVisualStateBlock visualStateBlock = ^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) { + + if (drawerSide == MMDrawerSideNone) { + return; + } + + CGFloat minScale = .90; + CGFloat scale = minScale + (percentVisible * (1.0 - minScale)); + CATransform3D scaleTransform = CATransform3DMakeScale(scale, scale, scale); + + CGFloat maxDistance = 50; + CGFloat distance = maxDistance * percentVisible; + CATransform3D translateTransform = CATransform3DIdentity; + UIViewController *sideDrawerViewController = nil; + + if (drawerSide == MMDrawerSideLeft) { + sideDrawerViewController = drawerController.leftDrawerViewController; + translateTransform = CATransform3DMakeTranslation((maxDistance - distance), 0.0, 0.0); + } else if (drawerSide == MMDrawerSideRight) { + sideDrawerViewController = drawerController.rightDrawerViewController; + translateTransform = CATransform3DMakeTranslation(-(maxDistance - distance), 0.0, 0.0); + } + + if (sideDrawerViewController != nil && !CATransform3DIsIdentity(translateTransform)) { + [sideDrawerViewController.view.layer setTransform:CATransform3DConcat(scaleTransform, translateTransform)]; + [sideDrawerViewController.view setAlpha:percentVisible]; + } + }; + return visualStateBlock; } -+(MMDrawerControllerDrawerVisualStateBlock)swingingDoorVisualStateBlock{ - MMDrawerControllerDrawerVisualStateBlock visualStateBlock = - ^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){ - - if(drawerSide == MMDrawerSideNone){ - return; - } - - UIViewController * sideDrawerViewController; - CGPoint anchorPoint = CGPointMake(0.5, 0.5); - CGFloat maxDrawerWidth = 0.0; - CGFloat xOffset; - CGFloat angle = 0.0; - - if(drawerSide==MMDrawerSideLeft){ - - sideDrawerViewController = drawerController.leftDrawerViewController; - anchorPoint = CGPointMake(1.0, .5); - maxDrawerWidth = MAX(drawerController.maximumLeftDrawerWidth,drawerController.visibleLeftDrawerWidth); - xOffset = -(maxDrawerWidth/2.0) + (maxDrawerWidth)*percentVisible; - angle = -M_PI_2+(percentVisible*M_PI_2); - } - else { - sideDrawerViewController = drawerController.rightDrawerViewController; - anchorPoint = CGPointMake(0.0, .5); - maxDrawerWidth = MAX(drawerController.maximumRightDrawerWidth,drawerController.visibleRightDrawerWidth); - xOffset = (maxDrawerWidth/2.0) - (maxDrawerWidth)*percentVisible; - angle = M_PI_2-(percentVisible*M_PI_2); - } - - [sideDrawerViewController.view.layer setAnchorPoint:anchorPoint]; - [sideDrawerViewController.view.layer setShouldRasterize:YES]; - [sideDrawerViewController.view.layer setRasterizationScale:[[UIScreen mainScreen] scale]]; - - CATransform3D swingingDoorTransform = CATransform3DIdentity; - if (percentVisible <= 1.f) { - - CATransform3D identity = CATransform3DIdentity; - identity.m34 = -1.0/1000.0; - CATransform3D rotateTransform = CATransform3DRotate(identity, angle, 0.0, 1.0, 0.0); - - CATransform3D translateTransform = CATransform3DMakeTranslation(xOffset, 0.0, 0.0); - - CATransform3D concatTransform = CATransform3DConcat(rotateTransform, translateTransform); - - swingingDoorTransform = concatTransform; - } - else{ - CATransform3D overshootTransform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); - - NSInteger scalingModifier = 1.f; - if (drawerSide == MMDrawerSideRight) { - scalingModifier = -1.f; - } - - overshootTransform = CATransform3DTranslate(overshootTransform, scalingModifier*maxDrawerWidth/2, 0.f, 0.f); - swingingDoorTransform = overshootTransform; - } - - [sideDrawerViewController.view.layer setTransform:swingingDoorTransform]; - }; - return visualStateBlock; ++ (MMDrawerControllerDrawerVisualStateBlock)swingingDoorVisualStateBlock +{ + MMDrawerControllerDrawerVisualStateBlock visualStateBlock = ^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) { + + if (drawerSide == MMDrawerSideNone) { + return; + } + + UIViewController *sideDrawerViewController; + CGPoint anchorPoint = CGPointZero; + CGFloat maxDrawerWidth = 0.0; + CGFloat xOffset; + CGFloat angle = 0.0; + + if (drawerSide == MMDrawerSideLeft) { + + sideDrawerViewController = drawerController.leftDrawerViewController; + anchorPoint = CGPointMake(1.0, .5); + maxDrawerWidth = MAX(drawerController.maximumLeftDrawerWidth, drawerController.visibleLeftDrawerWidth); + xOffset = -(maxDrawerWidth / 2.0) + (maxDrawerWidth)*percentVisible; + angle = -M_PI_2 + (percentVisible * M_PI_2); + } else { + sideDrawerViewController = drawerController.rightDrawerViewController; + anchorPoint = CGPointMake(0.0, .5); + maxDrawerWidth = MAX(drawerController.maximumRightDrawerWidth, drawerController.visibleRightDrawerWidth); + xOffset = (maxDrawerWidth / 2.0) - (maxDrawerWidth)*percentVisible; + angle = M_PI_2 - (percentVisible * M_PI_2); + } + + [sideDrawerViewController.view.layer setAnchorPoint:anchorPoint]; + [sideDrawerViewController.view.layer setShouldRasterize:YES]; + [sideDrawerViewController.view.layer setRasterizationScale:[[UIScreen mainScreen] scale]]; + + CATransform3D swingingDoorTransform = CATransform3DIdentity; + if (percentVisible <= 1.f) { + + CATransform3D identity = CATransform3DIdentity; + identity.m34 = -1.0 / 1000.0; + CATransform3D rotateTransform = CATransform3DRotate(identity, angle, 0.0, 1.0, 0.0); + + CATransform3D translateTransform = CATransform3DMakeTranslation(xOffset, 0.0, 0.0); + + CATransform3D concatTransform = CATransform3DConcat(rotateTransform, translateTransform); + + swingingDoorTransform = concatTransform; + } else { + CATransform3D overshootTransform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); + + NSInteger scalingModifier = 1.f; + if (drawerSide == MMDrawerSideRight) { + scalingModifier = -1.f; + } + + overshootTransform = CATransform3DTranslate(overshootTransform, scalingModifier * maxDrawerWidth / 2, 0.f, 0.f); + swingingDoorTransform = overshootTransform; + } + + [sideDrawerViewController.view.layer setTransform:swingingDoorTransform]; + }; + return visualStateBlock; } -+(MMDrawerControllerDrawerVisualStateBlock)fadeVisualStateBlock{ - MMDrawerControllerDrawerVisualStateBlock visualStateBlock = - ^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){ - - if(drawerSide == MMDrawerSideNone){ - return; - } - - UIViewController * sideDrawerViewController; - if(drawerSide==MMDrawerSideLeft){ - sideDrawerViewController = drawerController.leftDrawerViewController; - } else { - sideDrawerViewController = drawerController.rightDrawerViewController; - } - [sideDrawerViewController.view setAlpha:percentVisible]; - }; - return visualStateBlock; ++ (MMDrawerControllerDrawerVisualStateBlock)fadeVisualStateBlock +{ + MMDrawerControllerDrawerVisualStateBlock visualStateBlock = ^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) { + + if (drawerSide == MMDrawerSideNone) { + return; + } + + UIViewController *sideDrawerViewController; + if (drawerSide == MMDrawerSideLeft) { + sideDrawerViewController = drawerController.leftDrawerViewController; + } else { + sideDrawerViewController = drawerController.rightDrawerViewController; + } + [sideDrawerViewController.view setAlpha:percentVisible]; + }; + return visualStateBlock; } -+(MMDrawerControllerDrawerVisualStateBlock)noneVisualStateBlock{ - MMDrawerControllerDrawerVisualStateBlock visualStateBlock = - ^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){ - }; - return visualStateBlock; ++ (MMDrawerControllerDrawerVisualStateBlock)noneVisualStateBlock +{ + MMDrawerControllerDrawerVisualStateBlock visualStateBlock = ^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) { + }; + return visualStateBlock; } -+(MMDrawerControllerDrawerVisualStateBlock)slideVisualStateBlock{ - MMDrawerControllerDrawerVisualStateBlock visualStateBlock = - ^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){ - - if(drawerSide == MMDrawerSideNone){ - return; - } - - //SETTING - CGFloat parallaxFactor = 1.0; - - UIViewController * sideDrawerViewController; - CATransform3D transform; - if(drawerSide == MMDrawerSideLeft) { - sideDrawerViewController = drawerController.leftDrawerViewController; - CGFloat distance = MAX(drawerController.maximumLeftDrawerWidth,drawerController.visibleLeftDrawerWidth); - if (percentVisible <= 1.f) { - transform = CATransform3DMakeTranslation((-distance)/parallaxFactor+(distance*percentVisible/parallaxFactor), 0.0, 0.0); - } - else{ - transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); - transform = CATransform3DTranslate(transform, drawerController.maximumLeftDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f); - } - } - else if(drawerSide == MMDrawerSideRight){ - sideDrawerViewController = drawerController.rightDrawerViewController; - CGFloat distance = MAX(drawerController.maximumRightDrawerWidth,drawerController.visibleRightDrawerWidth); - if(percentVisible <= 1.f){ - transform = CATransform3DMakeTranslation((distance)/parallaxFactor-(distance*percentVisible)/parallaxFactor, 0.0, 0.0); - } - else{ - transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); - transform = CATransform3DTranslate(transform, -drawerController.maximumRightDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f); - } - } - [sideDrawerViewController.view.layer setTransform:transform]; - }; - return visualStateBlock; ++ (MMDrawerControllerDrawerVisualStateBlock)slideVisualStateBlock +{ + MMDrawerControllerDrawerVisualStateBlock visualStateBlock = ^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) { + + if (drawerSide == MMDrawerSideNone) { + return; + } + + //SETTING + CGFloat parallaxFactor = 1.0; + + UIViewController *sideDrawerViewController = nil; + CATransform3D transform = CATransform3DIdentity; + + if (drawerSide == MMDrawerSideLeft) { + sideDrawerViewController = drawerController.leftDrawerViewController; + CGFloat distance = MAX(drawerController.maximumLeftDrawerWidth, drawerController.visibleLeftDrawerWidth); + if (percentVisible <= 1.f) { + transform = CATransform3DMakeTranslation((-distance) / parallaxFactor + (distance * percentVisible / parallaxFactor), 0.0, 0.0); + } else { + transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); + transform = CATransform3DTranslate(transform, drawerController.maximumLeftDrawerWidth * (percentVisible - 1.f) / 2, 0.f, 0.f); + } + } else if (drawerSide == MMDrawerSideRight) { + sideDrawerViewController = drawerController.rightDrawerViewController; + CGFloat distance = MAX(drawerController.maximumRightDrawerWidth, drawerController.visibleRightDrawerWidth); + if (percentVisible <= 1.f) { + transform = CATransform3DMakeTranslation((distance) / parallaxFactor - (distance * percentVisible) / parallaxFactor, 0.0, 0.0); + } else { + transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); + transform = CATransform3DTranslate(transform, -drawerController.maximumRightDrawerWidth * (percentVisible - 1.f) / 2, 0.f, 0.f); + } + } + + if (sideDrawerViewController != nil && !CATransform3DIsIdentity(transform)) { + [sideDrawerViewController.view.layer setTransform:transform]; + } + }; + return visualStateBlock; } ++ (MMDrawerControllerDrawerVisualStateBlock)parallax3VisualStateBlock +{ + MMDrawerControllerDrawerVisualStateBlock visualStateBlock = ^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) { + + if (drawerSide == MMDrawerSideNone) { + return; + } + + //SETTING + CGFloat parallaxFactor = 3.0; -+(MMDrawerControllerDrawerVisualStateBlock)parallax3VisualStateBlock{ - MMDrawerControllerDrawerVisualStateBlock visualStateBlock = - ^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){ - - if(drawerSide == MMDrawerSideNone){ - return; - } - - //SETTING - CGFloat parallaxFactor = 3.0; - - UIViewController * sideDrawerViewController; - CATransform3D transform; - if(drawerSide == MMDrawerSideLeft) { - sideDrawerViewController = drawerController.leftDrawerViewController; - CGFloat distance = MAX(drawerController.maximumLeftDrawerWidth,drawerController.visibleLeftDrawerWidth); - if (percentVisible <= 1.f) { - transform = CATransform3DMakeTranslation((-distance)/parallaxFactor+(distance*percentVisible/parallaxFactor), 0.0, 0.0); - } - else{ - transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); - transform = CATransform3DTranslate(transform, drawerController.maximumLeftDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f); - } - } - else if(drawerSide == MMDrawerSideRight){ - sideDrawerViewController = drawerController.rightDrawerViewController; - CGFloat distance = MAX(drawerController.maximumRightDrawerWidth,drawerController.visibleRightDrawerWidth); - if(percentVisible <= 1.f){ - transform = CATransform3DMakeTranslation((distance)/parallaxFactor-(distance*percentVisible)/parallaxFactor, 0.0, 0.0); - } - else{ - transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); - transform = CATransform3DTranslate(transform, -drawerController.maximumRightDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f); - } - } - [sideDrawerViewController.view.layer setTransform:transform]; - }; - return visualStateBlock; + UIViewController *sideDrawerViewController = nil; + CATransform3D transform = CATransform3DIdentity; + + if (drawerSide == MMDrawerSideLeft) { + sideDrawerViewController = drawerController.leftDrawerViewController; + CGFloat distance = MAX(drawerController.maximumLeftDrawerWidth, drawerController.visibleLeftDrawerWidth); + if (percentVisible <= 1.f) { + transform = CATransform3DMakeTranslation((-distance) / parallaxFactor + (distance * percentVisible / parallaxFactor), 0.0, 0.0); + } else { + transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); + transform = CATransform3DTranslate(transform, drawerController.maximumLeftDrawerWidth * (percentVisible - 1.f) / 2, 0.f, 0.f); + } + } else if (drawerSide == MMDrawerSideRight) { + sideDrawerViewController = drawerController.rightDrawerViewController; + CGFloat distance = MAX(drawerController.maximumRightDrawerWidth, drawerController.visibleRightDrawerWidth); + if (percentVisible <= 1.f) { + transform = CATransform3DMakeTranslation((distance) / parallaxFactor - (distance * percentVisible) / parallaxFactor, 0.0, 0.0); + } else { + transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); + transform = CATransform3DTranslate(transform, -drawerController.maximumRightDrawerWidth * (percentVisible - 1.f) / 2, 0.f, 0.f); + } + } + if (sideDrawerViewController != nil && !CATransform3DIsIdentity(transform)) { + [sideDrawerViewController.view.layer setTransform:transform]; + } + }; + return visualStateBlock; } ++ (MMDrawerControllerDrawerVisualStateBlock)parallax5VisualStateBlock +{ + MMDrawerControllerDrawerVisualStateBlock visualStateBlock = ^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) { + + if (drawerSide == MMDrawerSideNone) { + return; + } + + //SETTING + CGFloat parallaxFactor = 5.0; + + UIViewController *sideDrawerViewController = nil; + CATransform3D transform = CATransform3DIdentity; + + if (drawerSide == MMDrawerSideLeft) { + sideDrawerViewController = drawerController.leftDrawerViewController; + CGFloat distance = MAX(drawerController.maximumLeftDrawerWidth, drawerController.visibleLeftDrawerWidth); + if (percentVisible <= 1.f) { + transform = CATransform3DMakeTranslation((-distance) / parallaxFactor + (distance * percentVisible / parallaxFactor), 0.0, 0.0); + } else { + transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); + transform = CATransform3DTranslate(transform, drawerController.maximumLeftDrawerWidth * (percentVisible - 1.f) / 2, 0.f, 0.f); + } + } else if (drawerSide == MMDrawerSideRight) { + sideDrawerViewController = drawerController.rightDrawerViewController; + CGFloat distance = MAX(drawerController.maximumRightDrawerWidth, drawerController.visibleRightDrawerWidth); + if (percentVisible <= 1.f) { + transform = CATransform3DMakeTranslation((distance) / parallaxFactor - (distance * percentVisible) / parallaxFactor, 0.0, 0.0); + } else { + transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); + transform = CATransform3DTranslate(transform, -drawerController.maximumRightDrawerWidth * (percentVisible - 1.f) / 2, 0.f, 0.f); + } + } -+(MMDrawerControllerDrawerVisualStateBlock)parallax5VisualStateBlock{ - MMDrawerControllerDrawerVisualStateBlock visualStateBlock = - ^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){ - - if(drawerSide == MMDrawerSideNone){ - return; - } - - //SETTING - CGFloat parallaxFactor = 5.0; - - UIViewController * sideDrawerViewController; - CATransform3D transform; - if(drawerSide == MMDrawerSideLeft) { - sideDrawerViewController = drawerController.leftDrawerViewController; - CGFloat distance = MAX(drawerController.maximumLeftDrawerWidth,drawerController.visibleLeftDrawerWidth); - if (percentVisible <= 1.f) { - transform = CATransform3DMakeTranslation((-distance)/parallaxFactor+(distance*percentVisible/parallaxFactor), 0.0, 0.0); - } - else{ - transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); - transform = CATransform3DTranslate(transform, drawerController.maximumLeftDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f); - } - } - else if(drawerSide == MMDrawerSideRight){ - sideDrawerViewController = drawerController.rightDrawerViewController; - CGFloat distance = MAX(drawerController.maximumRightDrawerWidth,drawerController.visibleRightDrawerWidth); - if(percentVisible <= 1.f){ - transform = CATransform3DMakeTranslation((distance)/parallaxFactor-(distance*percentVisible)/parallaxFactor, 0.0, 0.0); - } - else{ - transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); - transform = CATransform3DTranslate(transform, -drawerController.maximumRightDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f); - } - } - [sideDrawerViewController.view.layer setTransform:transform]; - }; - return visualStateBlock; + if (sideDrawerViewController != nil && !CATransform3DIsIdentity(transform)) { + [sideDrawerViewController.view.layer setTransform:transform]; + } + }; + return visualStateBlock; } ++ (MMDrawerControllerDrawerVisualStateBlock)parallax7VisualStateBlock +{ + MMDrawerControllerDrawerVisualStateBlock visualStateBlock = ^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) { + + if (drawerSide == MMDrawerSideNone) { + return; + } + + //SETTING + CGFloat parallaxFactor = 7.0; + + UIViewController *sideDrawerViewController = nil; + CATransform3D transform = CATransform3DIdentity; + + if (drawerSide == MMDrawerSideLeft) { + sideDrawerViewController = drawerController.leftDrawerViewController; + CGFloat distance = MAX(drawerController.maximumLeftDrawerWidth, drawerController.visibleLeftDrawerWidth); + if (percentVisible <= 1.f) { + transform = CATransform3DMakeTranslation((-distance) / parallaxFactor + (distance * percentVisible / parallaxFactor), 0.0, 0.0); + } else { + transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); + transform = CATransform3DTranslate(transform, drawerController.maximumLeftDrawerWidth * (percentVisible - 1.f) / 2, 0.f, 0.f); + } + } else if (drawerSide == MMDrawerSideRight) { + sideDrawerViewController = drawerController.rightDrawerViewController; + CGFloat distance = MAX(drawerController.maximumRightDrawerWidth, drawerController.visibleRightDrawerWidth); + if (percentVisible <= 1.f) { + transform = CATransform3DMakeTranslation((distance) / parallaxFactor - (distance * percentVisible) / parallaxFactor, 0.0, 0.0); + } else { + transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); + transform = CATransform3DTranslate(transform, -drawerController.maximumRightDrawerWidth * (percentVisible - 1.f) / 2, 0.f, 0.f); + } + } -+(MMDrawerControllerDrawerVisualStateBlock)parallax7VisualStateBlock{ - MMDrawerControllerDrawerVisualStateBlock visualStateBlock = - ^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){ - - if(drawerSide == MMDrawerSideNone){ - return; - } - - //SETTING - CGFloat parallaxFactor = 7.0; - - UIViewController * sideDrawerViewController; - CATransform3D transform; - if(drawerSide == MMDrawerSideLeft) { - sideDrawerViewController = drawerController.leftDrawerViewController; - CGFloat distance = MAX(drawerController.maximumLeftDrawerWidth,drawerController.visibleLeftDrawerWidth); - if (percentVisible <= 1.f) { - transform = CATransform3DMakeTranslation((-distance)/parallaxFactor+(distance*percentVisible/parallaxFactor), 0.0, 0.0); - } - else{ - transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); - transform = CATransform3DTranslate(transform, drawerController.maximumLeftDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f); - } - } - else if(drawerSide == MMDrawerSideRight){ - sideDrawerViewController = drawerController.rightDrawerViewController; - CGFloat distance = MAX(drawerController.maximumRightDrawerWidth,drawerController.visibleRightDrawerWidth); - if(percentVisible <= 1.f){ - transform = CATransform3DMakeTranslation((distance)/parallaxFactor-(distance*percentVisible)/parallaxFactor, 0.0, 0.0); - } - else{ - transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); - transform = CATransform3DTranslate(transform, -drawerController.maximumRightDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f); - } - } - [sideDrawerViewController.view.layer setTransform:transform]; - }; - return visualStateBlock; + if (sideDrawerViewController != nil && !CATransform3DIsIdentity(transform)) { + [sideDrawerViewController.view.layer setTransform:transform]; + } + }; + return visualStateBlock; } @end diff --git a/ios/LICENSE b/ios/LICENSE deleted file mode 100644 index 6ae867d..0000000 --- a/ios/LICENSE +++ /dev/null @@ -1 +0,0 @@ -TODO: place your license here and we'll include it in the module distribution diff --git a/ios/LICENSE.txt b/ios/LICENSE.txt deleted file mode 100644 index 4124b1d..0000000 --- a/ios/LICENSE.txt +++ /dev/null @@ -1 +0,0 @@ -Place your license text here. This file will be incorporated with your app at package time. \ No newline at end of file diff --git a/ios/MMDrawerController b/ios/MMDrawerController deleted file mode 160000 index 6555e2d..0000000 --- a/ios/MMDrawerController +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6555e2d66d3b4f5c838bb55f640ae521f7a18c99 diff --git a/ios/NappDrawer.xcodeproj/project.pbxproj b/ios/NappDrawer.xcodeproj/project.pbxproj index 651ebcd..aa26e09 100644 --- a/ios/NappDrawer.xcodeproj/project.pbxproj +++ b/ios/NappDrawer.xcodeproj/project.pbxproj @@ -23,29 +23,29 @@ /* Begin PBXBuildFile section */ 24DD6CF91134B3F500162E58 /* DkNappDrawerModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 24DD6CF71134B3F500162E58 /* DkNappDrawerModule.h */; }; - 24DD6CFA1134B3F500162E58 /* DkNappDrawerModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 24DD6CF81134B3F500162E58 /* DkNappDrawerModule.m */; }; + 24DD6CFA1134B3F500162E58 /* DkNappDrawerModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 24DD6CF81134B3F500162E58 /* DkNappDrawerModule.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; 24DE9E1111C5FE74003F90F6 /* DkNappDrawerModuleAssets.h in Headers */ = {isa = PBXBuildFile; fileRef = 24DE9E0F11C5FE74003F90F6 /* DkNappDrawerModuleAssets.h */; }; - 24DE9E1211C5FE74003F90F6 /* DkNappDrawerModuleAssets.m in Sources */ = {isa = PBXBuildFile; fileRef = 24DE9E1011C5FE74003F90F6 /* DkNappDrawerModuleAssets.m */; }; + 24DE9E1211C5FE74003F90F6 /* DkNappDrawerModuleAssets.m in Sources */ = {isa = PBXBuildFile; fileRef = 24DE9E1011C5FE74003F90F6 /* DkNappDrawerModuleAssets.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; AA747D9F0F9514B9006C5449 /* DkNappDrawer_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = AA747D9E0F9514B9006C5449 /* DkNappDrawer_Prefix.pch */; }; AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; }; B6579363178CA9BF00F89C92 /* NappDrawerVisualState.h in Headers */ = {isa = PBXBuildFile; fileRef = B6579361178CA9BF00F89C92 /* NappDrawerVisualState.h */; }; - B6579364178CA9BF00F89C92 /* NappDrawerVisualState.m in Sources */ = {isa = PBXBuildFile; fileRef = B6579362178CA9BF00F89C92 /* NappDrawerVisualState.m */; }; + B6579364178CA9BF00F89C92 /* NappDrawerVisualState.m in Sources */ = {isa = PBXBuildFile; fileRef = B6579362178CA9BF00F89C92 /* NappDrawerVisualState.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; B67C6EA7188837D2009C03BC /* CustomMMDrawerController.h in Headers */ = {isa = PBXBuildFile; fileRef = B67C6EA5188837D2009C03BC /* CustomMMDrawerController.h */; }; - B67C6EA8188837D2009C03BC /* CustomMMDrawerController.m in Sources */ = {isa = PBXBuildFile; fileRef = B67C6EA6188837D2009C03BC /* CustomMMDrawerController.m */; }; + B67C6EA8188837D2009C03BC /* CustomMMDrawerController.m in Sources */ = {isa = PBXBuildFile; fileRef = B67C6EA6188837D2009C03BC /* CustomMMDrawerController.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; B67E52EA1780B77B001348B3 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B67E52E91780B77B001348B3 /* QuartzCore.framework */; }; B67E52ED1780B7D2001348B3 /* DkNappDrawerDrawerProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = B67E52EB1780B7D2001348B3 /* DkNappDrawerDrawerProxy.h */; }; - B67E52EE1780B7D2001348B3 /* DkNappDrawerDrawerProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = B67E52EC1780B7D2001348B3 /* DkNappDrawerDrawerProxy.m */; }; + B67E52EE1780B7D2001348B3 /* DkNappDrawerDrawerProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = B67E52EC1780B7D2001348B3 /* DkNappDrawerDrawerProxy.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; B67E52F11780B7E8001348B3 /* DkNappDrawerDrawer.h in Headers */ = {isa = PBXBuildFile; fileRef = B67E52EF1780B7E8001348B3 /* DkNappDrawerDrawer.h */; }; - B67E52F21780B7E8001348B3 /* DkNappDrawerDrawer.m in Sources */ = {isa = PBXBuildFile; fileRef = B67E52F01780B7E8001348B3 /* DkNappDrawerDrawer.m */; }; - D914F3A919B403DC00E3C518 /* MMDrawerBarButtonItem.h in Headers */ = {isa = PBXBuildFile; fileRef = D914F3A019B403DC00E3C518 /* MMDrawerBarButtonItem.h */; }; - D914F3AA19B403DC00E3C518 /* MMDrawerBarButtonItem.m in Sources */ = {isa = PBXBuildFile; fileRef = D914F3A119B403DC00E3C518 /* MMDrawerBarButtonItem.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; - D914F3AB19B403DC00E3C518 /* MMDrawerController+Subclass.h in Headers */ = {isa = PBXBuildFile; fileRef = D914F3A219B403DC00E3C518 /* MMDrawerController+Subclass.h */; }; - D914F3AC19B403DC00E3C518 /* MMDrawerController.h in Headers */ = {isa = PBXBuildFile; fileRef = D914F3A319B403DC00E3C518 /* MMDrawerController.h */; }; - D914F3AD19B403DC00E3C518 /* MMDrawerController.m in Sources */ = {isa = PBXBuildFile; fileRef = D914F3A419B403DC00E3C518 /* MMDrawerController.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; - D914F3AE19B403DC00E3C518 /* MMDrawerVisualState.h in Headers */ = {isa = PBXBuildFile; fileRef = D914F3A519B403DC00E3C518 /* MMDrawerVisualState.h */; }; - D914F3AF19B403DC00E3C518 /* MMDrawerVisualState.m in Sources */ = {isa = PBXBuildFile; fileRef = D914F3A619B403DC00E3C518 /* MMDrawerVisualState.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; - D914F3B019B403DC00E3C518 /* UIViewController+MMDrawerController.h in Headers */ = {isa = PBXBuildFile; fileRef = D914F3A719B403DC00E3C518 /* UIViewController+MMDrawerController.h */; }; - D914F3B119B403DC00E3C518 /* UIViewController+MMDrawerController.m in Sources */ = {isa = PBXBuildFile; fileRef = D914F3A819B403DC00E3C518 /* UIViewController+MMDrawerController.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; + B67E52F21780B7E8001348B3 /* DkNappDrawerDrawer.m in Sources */ = {isa = PBXBuildFile; fileRef = B67E52F01780B7E8001348B3 /* DkNappDrawerDrawer.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; + DBDF0587200CE7D300A84135 /* MMDrawerBarButtonItem.m in Sources */ = {isa = PBXBuildFile; fileRef = DBDF057E200CE7D300A84135 /* MMDrawerBarButtonItem.m */; }; + DBDF0588200CE7D300A84135 /* UIViewController+MMDrawerController.m in Sources */ = {isa = PBXBuildFile; fileRef = DBDF057F200CE7D300A84135 /* UIViewController+MMDrawerController.m */; }; + DBDF0589200CE7D300A84135 /* MMDrawerController.m in Sources */ = {isa = PBXBuildFile; fileRef = DBDF0580200CE7D300A84135 /* MMDrawerController.m */; }; + DBDF058A200CE7D300A84135 /* MMDrawerController+Subclass.h in Headers */ = {isa = PBXBuildFile; fileRef = DBDF0581200CE7D300A84135 /* MMDrawerController+Subclass.h */; }; + DBDF058B200CE7D300A84135 /* MMDrawerVisualState.h in Headers */ = {isa = PBXBuildFile; fileRef = DBDF0582200CE7D300A84135 /* MMDrawerVisualState.h */; }; + DBDF058C200CE7D300A84135 /* MMDrawerBarButtonItem.h in Headers */ = {isa = PBXBuildFile; fileRef = DBDF0583200CE7D300A84135 /* MMDrawerBarButtonItem.h */; }; + DBDF058D200CE7D300A84135 /* UIViewController+MMDrawerController.h in Headers */ = {isa = PBXBuildFile; fileRef = DBDF0584200CE7D300A84135 /* UIViewController+MMDrawerController.h */; }; + DBDF058E200CE7D300A84135 /* MMDrawerVisualState.m in Sources */ = {isa = PBXBuildFile; fileRef = DBDF0585200CE7D300A84135 /* MMDrawerVisualState.m */; }; + DBDF058F200CE7D300A84135 /* MMDrawerController.h in Headers */ = {isa = PBXBuildFile; fileRef = DBDF0586200CE7D300A84135 /* MMDrawerController.h */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -76,15 +76,15 @@ B67E52EF1780B7E8001348B3 /* DkNappDrawerDrawer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DkNappDrawerDrawer.h; path = Classes/DkNappDrawerDrawer.h; sourceTree = ""; }; B67E52F01780B7E8001348B3 /* DkNappDrawerDrawer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DkNappDrawerDrawer.m; path = Classes/DkNappDrawerDrawer.m; sourceTree = ""; }; D2AAC07E0554694100DB518D /* libDkNappDrawer.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libDkNappDrawer.a; sourceTree = BUILT_PRODUCTS_DIR; }; - D914F3A019B403DC00E3C518 /* MMDrawerBarButtonItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMDrawerBarButtonItem.h; sourceTree = ""; }; - D914F3A119B403DC00E3C518 /* MMDrawerBarButtonItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMDrawerBarButtonItem.m; sourceTree = ""; }; - D914F3A219B403DC00E3C518 /* MMDrawerController+Subclass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MMDrawerController+Subclass.h"; sourceTree = ""; }; - D914F3A319B403DC00E3C518 /* MMDrawerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMDrawerController.h; sourceTree = ""; }; - D914F3A419B403DC00E3C518 /* MMDrawerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMDrawerController.m; sourceTree = ""; }; - D914F3A519B403DC00E3C518 /* MMDrawerVisualState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMDrawerVisualState.h; sourceTree = ""; }; - D914F3A619B403DC00E3C518 /* MMDrawerVisualState.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMDrawerVisualState.m; sourceTree = ""; }; - D914F3A719B403DC00E3C518 /* UIViewController+MMDrawerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+MMDrawerController.h"; sourceTree = ""; }; - D914F3A819B403DC00E3C518 /* UIViewController+MMDrawerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+MMDrawerController.m"; sourceTree = ""; }; + DBDF057E200CE7D300A84135 /* MMDrawerBarButtonItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMDrawerBarButtonItem.m; sourceTree = ""; }; + DBDF057F200CE7D300A84135 /* UIViewController+MMDrawerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+MMDrawerController.m"; sourceTree = ""; }; + DBDF0580200CE7D300A84135 /* MMDrawerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMDrawerController.m; sourceTree = ""; }; + DBDF0581200CE7D300A84135 /* MMDrawerController+Subclass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MMDrawerController+Subclass.h"; sourceTree = ""; }; + DBDF0582200CE7D300A84135 /* MMDrawerVisualState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMDrawerVisualState.h; sourceTree = ""; }; + DBDF0583200CE7D300A84135 /* MMDrawerBarButtonItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMDrawerBarButtonItem.h; sourceTree = ""; }; + DBDF0584200CE7D300A84135 /* UIViewController+MMDrawerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+MMDrawerController.h"; sourceTree = ""; }; + DBDF0585200CE7D300A84135 /* MMDrawerVisualState.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMDrawerVisualState.m; sourceTree = ""; }; + DBDF0586200CE7D300A84135 /* MMDrawerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMDrawerController.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -131,7 +131,7 @@ 08FB77AEFE84172EC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( - D914F39F19B403DC00E3C518 /* MMDrawerController */, + DBDF057D200CE7D300A84135 /* MMDrawerController */, 24DE9E0F11C5FE74003F90F6 /* DkNappDrawerModuleAssets.h */, 24DE9E1011C5FE74003F90F6 /* DkNappDrawerModuleAssets.m */, 24DD6CF71134B3F500162E58 /* DkNappDrawerModule.h */, @@ -157,21 +157,21 @@ name = "Other Sources"; sourceTree = ""; }; - D914F39F19B403DC00E3C518 /* MMDrawerController */ = { + DBDF057D200CE7D300A84135 /* MMDrawerController */ = { isa = PBXGroup; children = ( - D914F3A019B403DC00E3C518 /* MMDrawerBarButtonItem.h */, - D914F3A119B403DC00E3C518 /* MMDrawerBarButtonItem.m */, - D914F3A219B403DC00E3C518 /* MMDrawerController+Subclass.h */, - D914F3A319B403DC00E3C518 /* MMDrawerController.h */, - D914F3A419B403DC00E3C518 /* MMDrawerController.m */, - D914F3A519B403DC00E3C518 /* MMDrawerVisualState.h */, - D914F3A619B403DC00E3C518 /* MMDrawerVisualState.m */, - D914F3A719B403DC00E3C518 /* UIViewController+MMDrawerController.h */, - D914F3A819B403DC00E3C518 /* UIViewController+MMDrawerController.m */, + DBDF0584200CE7D300A84135 /* UIViewController+MMDrawerController.h */, + DBDF057F200CE7D300A84135 /* UIViewController+MMDrawerController.m */, + DBDF0583200CE7D300A84135 /* MMDrawerBarButtonItem.h */, + DBDF057E200CE7D300A84135 /* MMDrawerBarButtonItem.m */, + DBDF0581200CE7D300A84135 /* MMDrawerController+Subclass.h */, + DBDF0586200CE7D300A84135 /* MMDrawerController.h */, + DBDF0580200CE7D300A84135 /* MMDrawerController.m */, + DBDF0582200CE7D300A84135 /* MMDrawerVisualState.h */, + DBDF0585200CE7D300A84135 /* MMDrawerVisualState.m */, ); name = MMDrawerController; - path = MMDrawerController/MMDrawerController; + path = Classes/MMDrawerController/MMDrawerController; sourceTree = ""; }; /* End PBXGroup section */ @@ -181,18 +181,18 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + B67C6EA7188837D2009C03BC /* CustomMMDrawerController.h in Headers */, AA747D9F0F9514B9006C5449 /* DkNappDrawer_Prefix.pch in Headers */, - D914F3AC19B403DC00E3C518 /* MMDrawerController.h in Headers */, 24DD6CF91134B3F500162E58 /* DkNappDrawerModule.h in Headers */, 24DE9E1111C5FE74003F90F6 /* DkNappDrawerModuleAssets.h in Headers */, - B67C6EA7188837D2009C03BC /* CustomMMDrawerController.h in Headers */, - D914F3A919B403DC00E3C518 /* MMDrawerBarButtonItem.h in Headers */, - D914F3B019B403DC00E3C518 /* UIViewController+MMDrawerController.h in Headers */, - D914F3AB19B403DC00E3C518 /* MMDrawerController+Subclass.h in Headers */, B67E52ED1780B7D2001348B3 /* DkNappDrawerDrawerProxy.h in Headers */, B67E52F11780B7E8001348B3 /* DkNappDrawerDrawer.h in Headers */, - D914F3AE19B403DC00E3C518 /* MMDrawerVisualState.h in Headers */, B6579363178CA9BF00F89C92 /* NappDrawerVisualState.h in Headers */, + DBDF058D200CE7D300A84135 /* UIViewController+MMDrawerController.h in Headers */, + DBDF058A200CE7D300A84135 /* MMDrawerController+Subclass.h in Headers */, + DBDF058C200CE7D300A84135 /* MMDrawerBarButtonItem.h in Headers */, + DBDF058B200CE7D300A84135 /* MMDrawerVisualState.h in Headers */, + DBDF058F200CE7D300A84135 /* MMDrawerController.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -266,16 +266,16 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 24DD6CFA1134B3F500162E58 /* DkNappDrawerModule.m in Sources */, B67C6EA8188837D2009C03BC /* CustomMMDrawerController.m in Sources */, - D914F3AD19B403DC00E3C518 /* MMDrawerController.m in Sources */, - D914F3B119B403DC00E3C518 /* UIViewController+MMDrawerController.m in Sources */, - D914F3AF19B403DC00E3C518 /* MMDrawerVisualState.m in Sources */, + 24DD6CFA1134B3F500162E58 /* DkNappDrawerModule.m in Sources */, 24DE9E1211C5FE74003F90F6 /* DkNappDrawerModuleAssets.m in Sources */, B67E52EE1780B7D2001348B3 /* DkNappDrawerDrawerProxy.m in Sources */, B67E52F21780B7E8001348B3 /* DkNappDrawerDrawer.m in Sources */, B6579364178CA9BF00F89C92 /* NappDrawerVisualState.m in Sources */, - D914F3AA19B403DC00E3C518 /* MMDrawerBarButtonItem.m in Sources */, + DBDF0588200CE7D300A84135 /* UIViewController+MMDrawerController.m in Sources */, + DBDF058E200CE7D300A84135 /* MMDrawerVisualState.m in Sources */, + DBDF0589200CE7D300A84135 /* MMDrawerController.m in Sources */, + DBDF0587200CE7D300A84135 /* MMDrawerBarButtonItem.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -339,6 +339,7 @@ ALWAYS_SEARCH_USER_PATHS = NO; "ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD)"; "ARCHS[sdk=iphonesimulator*]" = "$(ARCHS_STANDARD)"; + DEPLOYMENT_POSTPROCESSING = YES; DSTROOT = /tmp/DkNappDrawer.dst; GCC_C_LANGUAGE_STANDARD = c99; GCC_MODEL_TUNING = G5; diff --git a/ios/README.md b/ios/README.md index 72ce56b..4dcfa8d 100644 --- a/ios/README.md +++ b/ios/README.md @@ -265,7 +265,30 @@ mainWindow.addEventListener("windowDidClose", function(e) { }); ``` +### centerWindowDidFocus + +When the drawer center window has been focussed. + +```javascript +mainWindow.addEventListener("centerWindowDidFocus", function(e) { + // Center window focussed +}); +``` + +### centerWindowDidBlur + +When the drawer center window has been blurred. + +```javascript +mainWindow.addEventListener("centerWindowDidBlur", function(e) { +// Center window blurred +}); +``` + ## Changelog +* v2.0.0 + * Major module refactoring (https://github.com/viezel/NappDrawer/pull/211) + * v1.2.3 * Fixed statusbare frame when rotating the device diff --git a/ios/dist/dk.napp.drawer-iphone-2.0.0.zip b/ios/dist/dk.napp.drawer-iphone-2.0.0.zip new file mode 100644 index 0000000..005b2e6 Binary files /dev/null and b/ios/dist/dk.napp.drawer-iphone-2.0.0.zip differ diff --git a/ios/example/app.js b/ios/example/app.js index cdf7d97..36240ae 100644 --- a/ios/example/app.js +++ b/ios/example/app.js @@ -1,236 +1,263 @@ var NappDrawerModule = require('dk.napp.drawer'); -function createAPIExampleWindow(){ - var win = Ti.UI.createWindow(); - - var data = [ - {title: "Toggle shadow"}, - {title: "Toggle stretch drawer"}, - {title: "Close Drawer"}, - {title: "New Window"}, - {title: "Default Window"}, - {title: "Remove right Drawer"} - ]; - - var tableView = Ti.UI.createTableView({ - data:data - }); - - tableView.addEventListener("click", function(e){ - Ti.API.info("isLeftWindowOpen: " + drawer.isLeftWindowOpen()); - switch(e.index){ - case 0: - drawer.setShowShadow(!drawer.showShadow); - break; - case 1: - drawer.setShouldStretchDrawer(!drawer.shouldStretchDrawer); - break; - case 2: - drawer.toggleLeftWindow(); - break; - case 3: - var newWin = openNewNavWindow(); - drawer.setCenterWindow(newWin); - drawer.toggleLeftWindow(); - break; - case 4: - drawer.setCenterWindow(createCenterNavWindow()); - drawer.toggleLeftWindow(); - break; - case 5: - drawer.setRightWindow(false); - drawer.toggleLeftWindow(); - break; - } - }); - - win.add(tableView); - return win; -} +function createAPIExampleWindow() { + var win = Ti.UI.createWindow(); + + var data = [{ + title: "Toggle shadow" + }, + { + title: "Toggle stretch drawer" + }, + { + title: "Close Drawer" + }, + { + title: "New Window" + }, + { + title: "Default Window" + }, + { + title: "Remove right Drawer" + } + ]; + + var tableView = Ti.UI.createTableView({ + data: data + }); + tableView.addEventListener("click", function(e) { + Ti.API.info("isLeftWindowOpen: " + drawer.isLeftWindowOpen()); + switch (e.index) { + case 0: + drawer.setShowShadow(!drawer.showShadow); + break; + case 1: + drawer.setShouldStretchDrawer(!drawer.shouldStretchDrawer); + break; + case 2: + drawer.toggleLeftWindow(); + break; + case 3: + var newWin = openNewNavWindow(); + drawer.setCenterWindow(newWin); + drawer.toggleLeftWindow(); + break; + case 4: + drawer.setCenterWindow(createCenterNavWindow()); + drawer.toggleLeftWindow(); + break; + case 5: + drawer.setRightWindow(false); + drawer.toggleLeftWindow(); + break; + } + }); -function openNewNavWindow(){ - var leftBtn = Ti.UI.createButton({title:"Left"}); - leftBtn.addEventListener("click", function(){ - drawer.toggleLeftWindow(); - }); - var win = Ti.UI.createWindow({ - backgroundColor:'#222', - translucent:true, - extendEdges:[Ti.UI.EXTEND_EDGE_TOP], - title:"New Nav Window", - barColor:"#FFA", - tintColor:"yellow", - leftNavButton:leftBtn - }); - - var scrollView = Ti.UI.createScrollView({ - layout:"vertical", - left:0, - right:0, - contentHeight:'auto', - contentWidth:"100%", - showVerticalScrollIndicator: true, - showHorizontalScrollIndicator: false - }); - - for(var i=0; i<20; i++){ - var label = Ti.UI.createLabel({ - top:30, - text:"iOS7 is the new black", - color:"#FFF", - font:{ - fontSize:20 - } - }); - scrollView.add(label); - } - win.add(scrollView); - var navController = Ti.UI.iOS.createNavigationWindow({ - window : win - }); - return navController; + win.add(tableView); + return win; } -function createCenterNavWindow(){ - var leftBtn = Ti.UI.createButton({title:"Left"}); - leftBtn.addEventListener("click", function(){ - drawer.toggleLeftWindow(); - }); - var rightBtn = Ti.UI.createButton({title:"Right"}); - rightBtn.addEventListener("click", function(){ - drawer.toggleRightWindow(); - }); - - var win = Ti.UI.createWindow({ - backgroundColor:'#eee', - translucent:false, - title:"NappDrawer", - barColor:"#F9A", - tintColor:"purple", - leftNavButton: leftBtn, - rightNavButton: rightBtn - }); - - var closeGestureMode = 1; - var closeGestureModeBtn = Ti.UI.createButton({ - title:"closeGestureMode: ALL", - width:300, - top:80 - }); - closeGestureModeBtn.addEventListener("click", function(e){ - if(closeGestureMode == 2){ - closeGestureMode = 0; - } else { - closeGestureMode++; - } - switch(closeGestureMode){ - case 0: - drawer.setCloseDrawerGestureMode(NappDrawerModule.CLOSE_MODE_TAP_CENTERWINDOW); - closeGestureModeBtn.setTitle("closeGesture: Tap Center"); - break; - case 1: - drawer.setCloseDrawerGestureMode(NappDrawerModule.CLOSE_MODE_ALL); - closeGestureModeBtn.setTitle("closeGesture: ALL"); - break; - case 2: - drawer.setCloseDrawerGestureMode(NappDrawerModule.CLOSE_MODE_PANNING_NAVBAR); - closeGestureModeBtn.setTitle("closeGesture: NAVBAR"); - break; - } - }); - win.add(closeGestureModeBtn); - - - var animationMode = 0; - var animationModeBtn = Ti.UI.createButton({ - title:"animation: NONE", - width:300, - top:140 - }); - animationModeBtn.addEventListener("click", function(e){ - if(animationMode == 5){ - animationMode = 0; - } else { - animationMode++; - } - switch(animationMode){ - case 0: - drawer.setAnimationMode(NappDrawerModule.ANIMATION_NONE); - animationModeBtn.setTitle("animation: None"); - break; - case 1: - drawer.setAnimationMode(NappDrawerModule.ANIMATION_PARALLAX_FACTOR_3); - animationModeBtn.setTitle("animation: Parallax factor 3"); - break; - case 2: - drawer.setAnimationMode(NappDrawerModule.ANIMATION_PARALLAX_FACTOR_7); - animationModeBtn.setTitle("animation: Parallax factor 7"); - break; - case 3: - drawer.setAnimationMode(NappDrawerModule.ANIMATION_FADE); - animationModeBtn.setTitle("animation: Fade"); - break; - case 4: - drawer.setAnimationMode(NappDrawerModule.ANIMATION_SLIDE); - animationModeBtn.setTitle("animation: Slide"); - break; - case 5: - drawer.setAnimationMode(NappDrawerModule.ANIMATION_SLIDE_SCALE); - animationModeBtn.setTitle("animation: Slide & Scale"); - break; - } - }); - win.add(animationModeBtn); - - - var slider = Ti.UI.createSlider({ - top: 280, - min: 50, - max: 280, - width: 280, - value: 200 - }); - var label = Ti.UI.createLabel({ - text: "Left Drawer Width: " + slider.value, - top: 250 +function openNewNavWindow() { + var leftBtn = Ti.UI.createButton({ + title: "Left" + }); + leftBtn.addEventListener("click", function() { + drawer.toggleLeftWindow(); + }); + var win = Ti.UI.createWindow({ + backgroundColor: '#222', + translucent: true, + extendEdges: [Ti.UI.EXTEND_EDGE_TOP], + title: "New Nav Window", + barColor: "#FFA", + tintColor: "yellow", + leftNavButton: leftBtn + }); + + var scrollView = Ti.UI.createScrollView({ + layout: "vertical", + left: 0, + right: 0, + contentHeight: 'auto', + contentWidth: "100%", + showVerticalScrollIndicator: true, + showHorizontalScrollIndicator: false + }); + + for (var i = 0; i < 20; i++) { + var label = Ti.UI.createLabel({ + top: 30, + text: "iOS7 is the new black", + color: "#FFF", + font: { + fontSize: 20 + } }); - slider.addEventListener('touchend', function(e) { - var value = Math.round(e.value); - label.setText("Left Drawer Width: " + value); - drawer.setLeftDrawerWidth(value); - }); - win.add(label); - win.add(slider); - - var navController = Ti.UI.iOS.createNavigationWindow({ - window : win - }); - return navController; + scrollView.add(label); + } + win.add(scrollView); + var navController = Ti.UI.iOS.createNavigationWindow({ + window: win + }); + return navController; +} + + +function createCenterNavWindow() { + var leftBtn = Ti.UI.createButton({ + title: "Left" + }); + leftBtn.addEventListener("click", function() { + drawer.toggleLeftWindow(); + }); + var rightBtn = Ti.UI.createButton({ + title: "Right" + }); + rightBtn.addEventListener("click", function() { + drawer.toggleRightWindow(); + }); + + var win = Ti.UI.createWindow({ + backgroundColor: '#eee', + translucent: false, + title: "NappDrawer", + barColor: "#F9A", + tintColor: "purple", + leftNavButton: leftBtn, + rightNavButton: rightBtn + }); + + var closeGestureMode = 1; + var closeGestureModeBtn = Ti.UI.createButton({ + title: "closeGestureMode: ALL", + width: 300, + top: 80 + }); + closeGestureModeBtn.addEventListener("click", function(e) { + if (closeGestureMode == 2) { + closeGestureMode = 0; + } else { + closeGestureMode++; + } + switch (closeGestureMode) { + case 0: + drawer.setCloseDrawerGestureMode(NappDrawerModule.CLOSE_MODE_TAP_CENTERWINDOW); + closeGestureModeBtn.setTitle("closeGesture: Tap Center"); + break; + case 1: + drawer.setCloseDrawerGestureMode(NappDrawerModule.CLOSE_MODE_ALL); + closeGestureModeBtn.setTitle("closeGesture: ALL"); + break; + case 2: + drawer.setCloseDrawerGestureMode(NappDrawerModule.CLOSE_MODE_PANNING_NAVBAR); + closeGestureModeBtn.setTitle("closeGesture: NAVBAR"); + break; + } + }); + win.add(closeGestureModeBtn); + + + var animationMode = 0; + var animationModeBtn = Ti.UI.createButton({ + title: "animation: NONE", + width: 300, + top: 140 + }); + animationModeBtn.addEventListener("click", function(e) { + if (animationMode == 5) { + animationMode = 0; + } else { + animationMode++; + } + switch (animationMode) { + case 0: + drawer.setAnimationMode(NappDrawerModule.ANIMATION_NONE); + animationModeBtn.setTitle("animation: None"); + break; + case 1: + drawer.setAnimationMode(NappDrawerModule.ANIMATION_PARALLAX_FACTOR_3); + animationModeBtn.setTitle("animation: Parallax factor 3"); + break; + case 2: + drawer.setAnimationMode(NappDrawerModule.ANIMATION_PARALLAX_FACTOR_7); + animationModeBtn.setTitle("animation: Parallax factor 7"); + break; + case 3: + drawer.setAnimationMode(NappDrawerModule.ANIMATION_FADE); + animationModeBtn.setTitle("animation: Fade"); + break; + case 4: + drawer.setAnimationMode(NappDrawerModule.ANIMATION_SLIDE); + animationModeBtn.setTitle("animation: Slide"); + break; + case 5: + drawer.setAnimationMode(NappDrawerModule.ANIMATION_SLIDE_SCALE); + animationModeBtn.setTitle("animation: Slide & Scale"); + break; + } + }); + win.add(animationModeBtn); + + + var slider = Ti.UI.createSlider({ + top: 280, + min: 50, + max: 280, + width: 280, + value: 200 + }); + var label = Ti.UI.createLabel({ + text: "Left Drawer Width: " + slider.value, + top: 250 + }); + slider.addEventListener('touchend', function(e) { + var value = Math.round(e.value); + label.setText("Left Drawer Width: " + value); + drawer.setLeftDrawerWidth(value); + }); + win.add(label); + win.add(slider); + + var navController = Ti.UI.iOS.createNavigationWindow({ + window: win + }); + return navController; } var mainWindow = createCenterNavWindow(); var drawer = NappDrawerModule.createDrawer({ - leftWindow: createAPIExampleWindow(), - centerWindow: mainWindow, - rightWindow: Ti.UI.createWindow({backgroundColor:"#FFF"}), - closeDrawerGestureMode: NappDrawerModule.CLOSE_MODE_ALL, - openDrawerGestureMode: NappDrawerModule.OPEN_MODE_ALL, - showShadow: false, //no shadow in iOS7 - leftDrawerWidth: 200, - rightDrawerWidth: 120, - statusBarStyle: NappDrawerModule.STATUSBAR_WHITE, // remember to set UIViewControllerBasedStatusBarAppearance to false in tiapp.xml - orientationModes: [Ti.UI.PORTRAIT, Ti.UI.UPSIDE_PORTRAIT] + leftWindow: createAPIExampleWindow(), + centerWindow: mainWindow, + rightWindow: Ti.UI.createWindow({ + backgroundColor: "#FFF" + }), + closeDrawerGestureMode: NappDrawerModule.CLOSE_MODE_ALL, + openDrawerGestureMode: NappDrawerModule.OPEN_MODE_ALL, + showShadow: false, //no shadow in iOS7 + leftDrawerWidth: 200, + rightDrawerWidth: 120, + statusBarStyle: NappDrawerModule.STATUSBAR_WHITE, // remember to set UIViewControllerBasedStatusBarAppearance to false in tiapp.xml + orientationModes: [Ti.UI.PORTRAIT, Ti.UI.UPSIDE_PORTRAIT] +}); + +drawer.addEventListener('centerWindowDidFocus', function() { + Ti.API.info('Center did focus!'); +}); + +drawer.addEventListener('centerWindowDidBlur', function() { + Ti.API.info('Center did blur!'); }); drawer.addEventListener('windowDidOpen', function(e) { - Ti.API.info("windowDidOpen"); + Ti.API.info("windowDidOpen"); }); drawer.addEventListener('windowDidClose', function(e) { - Ti.API.info("windowDidClose"); + Ti.API.info("windowDidClose"); }); drawer.open(); diff --git a/ios/hooks/README b/ios/hooks/README deleted file mode 100644 index 66b10a8..0000000 --- a/ios/hooks/README +++ /dev/null @@ -1 +0,0 @@ -These files are not yet supported as of 1.4.0 but will be in a near future release. diff --git a/ios/hooks/add.py b/ios/hooks/add.py deleted file mode 100644 index 04e1c1d..0000000 --- a/ios/hooks/add.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env python -# -# This is the module project add hook that will be -# called when your module is added to a project -# -import os, sys - -def dequote(s): - if s[0:1] == '"': - return s[1:-1] - return s - -def main(args,argc): - # You will get the following command line arguments - # in the following order: - # - # project_dir = the full path to the project root directory - # project_type = the type of project (desktop, mobile, ipad) - # project_name = the name of the project - # - project_dir = dequote(os.path.expanduser(args[1])) - project_type = dequote(args[2]) - project_name = dequote(args[3]) - - # TODO: write your add hook here (optional) - - - # exit - sys.exit(0) - - - -if __name__ == '__main__': - main(sys.argv,len(sys.argv)) - diff --git a/ios/hooks/install.py b/ios/hooks/install.py deleted file mode 100644 index b423fe9..0000000 --- a/ios/hooks/install.py +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env python -# -# This is the module install hook that will be -# called when your module is first installed -# -import os, sys - -def main(args,argc): - - # TODO: write your install hook here (optional) - - # exit - sys.exit(0) - - - -if __name__ == '__main__': - main(sys.argv,len(sys.argv)) - diff --git a/ios/hooks/remove.py b/ios/hooks/remove.py deleted file mode 100644 index f92a234..0000000 --- a/ios/hooks/remove.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python -# -# This is the module project remove hook that will be -# called when your module is remove from a project -# -import os, sys - -def dequote(s): - if s[0:1] == '"': - return s[1:-1] - return s - -def main(args,argc): - # You will get the following command line arguments - # in the following order: - # - # project_dir = the full path to the project root directory - # project_type = the type of project (desktop, mobile, ipad) - # project_name = the name of the project - # - project_dir = dequote(os.path.expanduser(args[1])) - project_type = dequote(args[2]) - project_name = dequote(args[3]) - - # TODO: write your remove hook here (optional) - - # exit - sys.exit(0) - - - -if __name__ == '__main__': - main(sys.argv,len(sys.argv)) - diff --git a/ios/hooks/uninstall.py b/ios/hooks/uninstall.py deleted file mode 100644 index a7ffd91..0000000 --- a/ios/hooks/uninstall.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env python -# -# This is the module uninstall hook that will be -# called when your module is uninstalled -# -import os, sys - -def main(args,argc): - - # TODO: write your uninstall hook here (optional) - - # exit - sys.exit(0) - - -if __name__ == '__main__': - main(sys.argv,len(sys.argv)) - diff --git a/ios/manifest b/ios/manifest index 2b9ddd9..a53376b 100644 --- a/ios/manifest +++ b/ios/manifest @@ -2,7 +2,7 @@ # this is your module manifest and used by Titanium # during compilation, packaging, distribution, etc. # -version: 1.2.4 +version: 2.0.0 apiversion: 2 architectures: armv7 i386 x86_64 arm64 description: Drawer controller @@ -10,10 +10,9 @@ author: Mads Møller license: MIT copyright: Napp ApS - # these should not be edited name: NappDrawer moduleid: dk.napp.drawer guid: 2a446559-1d59-4808-aefc-7d02d3130ebb platform: iphone -minsdk: 3.4.1.GA +minsdk: 5.5.0 diff --git a/ios/metadata.json b/ios/metadata.json new file mode 100644 index 0000000..43a62e5 --- /dev/null +++ b/ios/metadata.json @@ -0,0 +1 @@ +{"exports":[]} \ No newline at end of file diff --git a/ios/timodule.xml b/ios/timodule.xml index be2fe0e..7cfee16 100644 --- a/ios/timodule.xml +++ b/ios/timodule.xml @@ -4,11 +4,6 @@ Similar to tiapp.xml, but contains module/platform specific configuration in , , and sections --> - - 7.0 - - - - - + + diff --git a/ios/titanium.xcconfig b/ios/titanium.xcconfig index 4adf658..11e9ffb 100644 --- a/ios/titanium.xcconfig +++ b/ios/titanium.xcconfig @@ -4,7 +4,7 @@ // OF YOUR TITANIUM SDK YOU'RE BUILDING FOR // // -TITANIUM_SDK_VERSION = 3.5.0.GA +TITANIUM_SDK_VERSION = 7.0.1.GA // @@ -13,4 +13,4 @@ TITANIUM_SDK_VERSION = 3.5.0.GA TITANIUM_SDK = ~/Library/Application Support/Titanium/mobilesdk/osx/$(TITANIUM_SDK_VERSION) TITANIUM_BASE_SDK = "$(TITANIUM_SDK)/iphone/include" TITANIUM_BASE_SDK2 = "$(TITANIUM_SDK)/iphone/include/TiCore" -HEADER_SEARCH_PATHS= $(TITANIUM_BASE_SDK) $(TITANIUM_BASE_SDK2) \ No newline at end of file +HEADER_SEARCH_PATHS= $(TITANIUM_BASE_SDK) $(TITANIUM_BASE_SDK2) diff --git a/package.json b/package.json index 4b180c8..30c70b1 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "1.2.2", + "version": "2.0.0", "description": "A side drawer navigation container view controller for Appcelerator Titanium.", "author": "Mads Møller", "license": "MIT", @@ -10,14 +10,14 @@ "alloy": "/" }, "unzip": [ - "ios/dist/dk.napp.drawer-iphone-1.2.2.zip", - "android/dist/dk.napp.drawer-android-1.1.5.zip" + "ios/dist/dk.napp.drawer-iphone-2.0.0.zip", + "android/dist/dk.napp.drawer-android-2.0.2.zip" ] }, "files": [ "appc-npm", - "ios/dist/dk.napp.drawer-iphone-1.2.2.zip", - "android/dist/dk.napp.drawer-android-1.1.5.zip" + "ios/dist/dk.napp.drawer-iphone-2.0.0.zip", + "android/dist/dk.napp.drawer-android-2.0.2.zip" ], "scripts": { "postinstall": "node ./appc-npm"