diff --git a/ios/Classes/DkNappDrawerDrawer.m b/ios/Classes/DkNappDrawerDrawer.m index f5c3fc2..c90dcb6 100644 --- a/ios/Classes/DkNappDrawerDrawer.m +++ b/ios/Classes/DkNappDrawerDrawer.m @@ -36,6 +36,8 @@ @implementation DkNappDrawerDrawer +#pragma mark - Accessibility + - (id)accessibilityElement { return controllerView_; @@ -82,6 +84,8 @@ - (NSInteger)indexOfAccessibilityElement:(id)element return [[self accessibleElements] indexOfObject:element]; } +#pragma mark - Init + - (MMDrawerController *)controller { if (controller == nil) { @@ -100,23 +104,59 @@ - (MMDrawerController *)controller __weak __typeof__(self) weakSelf = self; if (leftWindow != nil) { + + //both left and right if (rightWindow != nil) { - //both left and right + + TiViewController *leftController = ControllerForViewProxy(leftWindow); + TiViewController *rightController = ControllerForViewProxy(rightWindow); + + TiUIiOSNavWindowProxy *centerProxy = [self.proxy valueForUndefinedKey:@"centerWindow"]; + + TiThreadPerformOnMainThread(^{ + [centerProxy windowWillOpen]; + [centerProxy windowDidOpen]; + }, + YES); + controller = [[CustomMMDrawerController alloc] initWithCenterViewController:centerWindow - leftDrawerViewController:ControllerForViewProxy(leftWindow) - rightDrawerViewController:ControllerForViewProxy(rightWindow)]; - } else { + leftDrawerViewController:leftController + rightDrawerViewController:rightController]; //left only + } else { + + TiViewController *leftController = ControllerForViewProxy(leftWindow); + + TiUIiOSNavWindowProxy *centerProxy = [self.proxy valueForUndefinedKey:@"centerWindow"]; + + TiThreadPerformOnMainThread(^{ + [centerProxy windowWillOpen]; + [centerProxy windowDidOpen]; + }, + YES); + controller = [[CustomMMDrawerController alloc] initWithCenterViewController:centerWindow - leftDrawerViewController:ControllerForViewProxy(leftWindow)]; + leftDrawerViewController:leftController]; } - } else if (rightWindow != nil) { //right only + } else if (rightWindow != nil) { + + TiViewController *rightController = ControllerForViewProxy(rightWindow); + + TiUIiOSNavWindowProxy *centerProxy = [self.proxy valueForUndefinedKey:@"centerWindow"]; + + TiThreadPerformOnMainThread(^{ + [centerProxy windowWillOpen]; + [centerProxy windowDidOpen]; + }, + YES); + controller = [[CustomMMDrawerController alloc] initWithCenterViewController:centerWindow - rightDrawerViewController:ControllerForViewProxy(rightWindow)]; - } else { + rightDrawerViewController:rightController]; + //error - NSLog(@"[ERROR] NappDrawer: No windows assigned"); + } else { + NSLog(@"[ERROR][DkNappDrawerDrawer] No windows assigned"); return nil; } @@ -174,7 +214,7 @@ - (MMDrawerController *)controller } else if ([state isEqualToString:@"close"]) { [[strongSelf proxy] fireEvent:@"windowDidClose"]; } - + [strongSelf _fireStateEventForCurrentState]; }]; @@ -213,7 +253,7 @@ - (void)frameSizeChanged:(CGRect)frame bounds:(CGRect)bounds [super frameSizeChanged:frame bounds:bounds]; } -// PROPERTIES +#pragma mark - Properties - (void)setCenterWindow_:(id)args { @@ -223,12 +263,21 @@ - (void)setCenterWindow_:(id)args useNavController = YES; } UIViewController *centerWindow = useNavController ? NavigationControllerForViewProxy([self.proxy valueForUndefinedKey:@"centerWindow"]) : ControllerForViewProxy([self.proxy valueForUndefinedKey:@"centerWindow"]); + if (useNavController) { + TiUIiOSNavWindowProxy *centerProxy = [self.proxy valueForUndefinedKey:@"centerWindow"]; + + if (controller != nil) { + [centerProxy windowWillOpen]; + [centerProxy windowDidOpen]; + } + } + [controller setCenterViewController:centerWindow]; // Cleanup if (useNavController) { if (navProxy != nil) { - NSLog(@"[DEBUG| Destroying old nav proxy"); + [navProxy windowWillClose]; [navProxy windowDidClose]; } // Save new proxy @@ -329,11 +378,12 @@ - (void)setShowsStatusBarBackgroundView_:(id)args - (UIStatusBarStyle)preferredStatusBarStyle { - if (self.controller.showsStatusBarBackgroundView) { - return UIStatusBarStyleLightContent; - } else { - return UIStatusBarStyleDefault; - } + return [controller preferredStatusBarStyle]; +} + +- (UIViewController *)childViewControllerForStatusBarStyle +{ + return nil; } - (void)setStatusBarStyle_:(NSNumber *)style @@ -354,7 +404,6 @@ - (void)setAnimationMode_:(id)args [controller setDrawerVisualStateBlock:[NappDrawerVisualState slideVisualStateBlock]]; break; case 3: - //[controller setDrawerVisualStateBlock:[NappDrawerVisualState swingingDoorVisualStateBlock]]; [controller setDrawerVisualStateBlock:[NappDrawerVisualState noneVisualStateBlock]]; break; case 4: @@ -377,7 +426,8 @@ - (void)setAnimationMode_:(id)args } } -// API +#pragma mark - API + - (void)toggleLeftWindow:(id)args { ENSURE_UI_THREAD(toggleLeftWindow, args); @@ -417,6 +467,8 @@ - (NSNumber *)isRightWindowOpen:(id)args return NUMBOOL(controller.openSide == MMDrawerSideRight); } +#pragma mark - Events + // Little hack to propagate focus/blur events - (void)_fireStateEventForCurrentState { diff --git a/ios/Classes/DkNappDrawerDrawerProxy.m b/ios/Classes/DkNappDrawerDrawerProxy.m index 9c98083..a7f6b15 100644 --- a/ios/Classes/DkNappDrawerDrawerProxy.m +++ b/ios/Classes/DkNappDrawerDrawerProxy.m @@ -53,6 +53,16 @@ - (TiUIView *)newView return [[DkNappDrawerDrawer alloc] init]; } +- (UIStatusBarStyle)preferredStatusBarStyle +{ + return [[self _controller] preferredStatusBarStyle]; +} + +- (UIViewController *)childViewControllerForStatusBarStyle +{ + return nil; +} + #pragma API - (void)toggleLeftWindow:(id)args diff --git a/ios/Classes/DkNappDrawerModule.m b/ios/Classes/DkNappDrawerModule.m index 5e378b9..4b33af8 100644 --- a/ios/Classes/DkNappDrawerModule.m +++ b/ios/Classes/DkNappDrawerModule.m @@ -73,7 +73,6 @@ - (NSString *)moduleId - (void)startup { [super startup]; - NSLog(@"[DEBUG] %@ loaded", self); } #pragma Public APIs diff --git a/ios/Classes/DkNappDrawerModuleAssets.m b/ios/Classes/DkNappDrawerModuleAssets.m index 71f65e5..cf28424 100644 --- a/ios/Classes/DkNappDrawerModuleAssets.m +++ b/ios/Classes/DkNappDrawerModuleAssets.m @@ -3,20 +3,18 @@ */ #import "DkNappDrawerModuleAssets.h" -extern NSData* filterDataInRange(NSData* thedata, NSRange range); +extern NSData *filterDataInRange(NSData *thedata, NSRange range); @implementation DkNappDrawerModuleAssets - (NSData *)moduleAsset { - return nil; } - (NSData *)resolveModuleAsset:(NSString *)path { - return nil; } diff --git a/ios/Classes/NappDrawerVisualState.m b/ios/Classes/NappDrawerVisualState.m index 1f90f1d..7bdcc44 100644 --- a/ios/Classes/NappDrawerVisualState.m +++ b/ios/Classes/NappDrawerVisualState.m @@ -15,7 +15,6 @@ @implementation NappDrawerVisualState + (MMDrawerControllerDrawerVisualStateBlock)slideAndScaleVisualStateBlock { MMDrawerControllerDrawerVisualStateBlock visualStateBlock = ^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) { - if (drawerSide == MMDrawerSideNone) { return; } @@ -48,7 +47,6 @@ + (MMDrawerControllerDrawerVisualStateBlock)slideAndScaleVisualStateBlock + (MMDrawerControllerDrawerVisualStateBlock)swingingDoorVisualStateBlock { MMDrawerControllerDrawerVisualStateBlock visualStateBlock = ^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) { - if (drawerSide == MMDrawerSideNone) { return; } @@ -110,7 +108,6 @@ + (MMDrawerControllerDrawerVisualStateBlock)swingingDoorVisualStateBlock + (MMDrawerControllerDrawerVisualStateBlock)fadeVisualStateBlock { MMDrawerControllerDrawerVisualStateBlock visualStateBlock = ^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) { - if (drawerSide == MMDrawerSideNone) { return; } @@ -136,7 +133,6 @@ + (MMDrawerControllerDrawerVisualStateBlock)noneVisualStateBlock + (MMDrawerControllerDrawerVisualStateBlock)slideVisualStateBlock { MMDrawerControllerDrawerVisualStateBlock visualStateBlock = ^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) { - if (drawerSide == MMDrawerSideNone) { return; } @@ -177,7 +173,6 @@ + (MMDrawerControllerDrawerVisualStateBlock)slideVisualStateBlock + (MMDrawerControllerDrawerVisualStateBlock)parallax3VisualStateBlock { MMDrawerControllerDrawerVisualStateBlock visualStateBlock = ^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) { - if (drawerSide == MMDrawerSideNone) { return; } @@ -217,7 +212,6 @@ + (MMDrawerControllerDrawerVisualStateBlock)parallax3VisualStateBlock + (MMDrawerControllerDrawerVisualStateBlock)parallax5VisualStateBlock { MMDrawerControllerDrawerVisualStateBlock visualStateBlock = ^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) { - if (drawerSide == MMDrawerSideNone) { return; } @@ -258,7 +252,6 @@ + (MMDrawerControllerDrawerVisualStateBlock)parallax5VisualStateBlock + (MMDrawerControllerDrawerVisualStateBlock)parallax7VisualStateBlock { MMDrawerControllerDrawerVisualStateBlock visualStateBlock = ^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) { - if (drawerSide == MMDrawerSideNone) { return; } diff --git a/ios/dist/dk.napp.drawer-iphone-2.1.1.zip b/ios/dist/dk.napp.drawer-iphone-2.1.1.zip new file mode 100644 index 0000000..e0de028 Binary files /dev/null and b/ios/dist/dk.napp.drawer-iphone-2.1.1.zip differ diff --git a/ios/manifest b/ios/manifest index 64b4535..e432d78 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: 2.1.0 +version: 2.1.1 apiversion: 2 architectures: armv7 i386 x86_64 arm64 description: Drawer controller