Skip to content

Commit

Permalink
Add drawer.close() EventListener
Browse files Browse the repository at this point in the history
drawer.close() now fires "close" event, also all subviews (leftWindow, rightWindow, centerWindow) also fires their "close" events
  • Loading branch information
mbender74 committed Aug 19, 2021
1 parent 4968e47 commit fade8fb
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 9 deletions.
23 changes: 16 additions & 7 deletions ios/Classes/DkNappDrawerDrawer.m
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ - (MMDrawerController *)controller
NSLog(@"[ERROR][DkNappDrawerDrawer] No windows assigned");
return nil;
}



// SET PROPERTIES at init
if ([self.proxy valueForUndefinedKey:@"openDrawerGestureMode"] != nil) {
[self setOpenDrawerGestureMode_:[self.proxy valueForUndefinedKey:@"openDrawerGestureMode"]];
Expand Down Expand Up @@ -239,7 +240,9 @@ - (MMDrawerController *)controller
if ([state isEqualToString:@"open"]) {
[[strongSelf proxy] fireEvent:@"windowDidOpen"];
} else if ([state isEqualToString:@"close"]) {
[[strongSelf proxy] fireEvent:@"windowDidClose"];
if ([TiUtils boolValue:[[strongSelf proxy] valueForUndefinedKey:@"autoCloseWindows"] def:YES]) {
[[strongSelf proxy] fireEvent:@"windowDidClose"];
}
}

[strongSelf _fireStateEventForCurrentState];
Expand Down Expand Up @@ -268,7 +271,7 @@ - (void)orientationDidChange:(NSNotification *)note
UINavigationController *navCon = (UINavigationController *)self.controller.centerViewController;
UINavigationBar *bar = navCon.navigationBar;

[[UIApplication sharedApplication] setStatusBarHidden:NO];
// [navCon prefersStatusBarHidden];

bar.frame = CGRectMake(0, 0, self.controller.view.bounds.size.width, 64);
}
Expand Down Expand Up @@ -304,8 +307,10 @@ - (void)setCenterWindow_:(id)args
// Cleanup
if (useNavController) {
if (navProxy != nil) {
[navProxy windowWillClose];
[navProxy windowDidClose];
if ([TiUtils boolValue:[[self proxy] valueForUndefinedKey:@"autoCloseWindows"] def:YES]) {
[navProxy windowWillClose];
[navProxy windowDidClose];
}
}
// Save new proxy
navProxy = [self.proxy valueForUndefinedKey:@"centerWindow"];
Expand Down Expand Up @@ -413,10 +418,14 @@ - (UIViewController *)childViewControllerForStatusBarStyle
return nil;
}


- (void)setStatusBarStyle_:(NSNumber *)style
{
ENSURE_UI_THREAD(setStatusBarStyle_, style);
[[UIApplication sharedApplication] setStatusBarStyle:[style intValue]];
ENSURE_UI_THREAD(setStatusBarStyle_, style);

controller.navigationController.navigationBar.barStyle = [style intValue];

// [[UIApplication sharedApplication] setStatusBarStyle:[style intValue]];
}

- (void)setAnimationMode_:(id)args
Expand Down
24 changes: 24 additions & 0 deletions ios/Classes/DkNappDrawerDrawerProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,37 @@ - (NSNumber *)isRightWindowOpen:(id)args
return [(DkNappDrawerDrawer *)[self view] isRightWindowOpen:args];
}

- (NSNumber *)setBackGroundColor:(id)args
{
[(DkNappDrawerDrawer *)[self view] setBackgroundColor:[[TiUtils colorValue:[self valueForUndefinedKey:@"backgroundColor"]] _color]];
//[[self _controller].view setBackgroundColor:[self view].backgroundColor];
// [self _controller].view.opaque = YES;
// [self _controller].view.layer.masksToBounds = true;
// self.view.opaque = YES;
// self.view.layer.masksToBounds = true;

}



-(void)close:(id)args {

TiThreadPerformOnMainThread(^{[(DkNappDrawerDrawer*)[self view] close:args];}, NO);
TiThreadPerformOnMainThread(
^{
[(DkNappDrawerDrawer *)[self view] removeFromSuperview];

TiViewProxy *leftWinProxy = [self valueForUndefinedKey:@"leftWindow"];
TiViewProxy *rightWinProxy = [self valueForUndefinedKey:@"rightWindow"];
TiViewProxy *centerWinProxy = [self valueForUndefinedKey:@"centerWindow"];
[leftWinProxy windowDidClose];
[rightWinProxy windowDidClose];
[centerWinProxy windowDidClose];

if ([self _hasListeners:@"close"]) {
[self fireEvent:@"close"];
}

},
NO);
}
Expand Down
Binary file modified ios/dist/dk.napp.drawer-iphone-2.2.5.zip
Binary file not shown.
Binary file added ios/dist/dk.napp.drawer-iphone-2.2.6.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion ios/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 2.2.5
version: 2.2.6
apiversion: 2
architectures: x86_64 arm64
description: Drawer controller
Expand Down
2 changes: 1 addition & 1 deletion ios/titanium.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// OF YOUR TITANIUM SDK YOU'RE BUILDING FOR
//
//
TITANIUM_SDK_VERSION = 9.3.2.GA
TITANIUM_SDK_VERSION = 10.1.1

//
// THESE SHOULD BE OK GENERALLY AS-IS
Expand Down

0 comments on commit fade8fb

Please sign in to comment.