Skip to content

Commit

Permalink
finally fixed crashing when drawer.close()
Browse files Browse the repository at this point in the history
finally fixed crashing when drawer.close()
also working in simulator with drawer.close() and with liveview
  • Loading branch information
mbender74 committed Aug 25, 2021
1 parent fade8fb commit 10b36fc
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 48 deletions.
21 changes: 20 additions & 1 deletion ios/Classes/CustomMMDrawerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ - (void)closeDrawerAnimated:(BOOL)animated completion:(void (^)(BOOL finished))c
- (void)setWindowAppearanceCallback:(void (^)(NSString *))callback
{
_callback = [callback copy];

__weak __typeof__(self) weakSelf = self;

// add callback for the gestures
Expand All @@ -52,4 +52,23 @@ - (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){
// self->_callback(@"close");
// } else {
// self->_callback(@"open");
// }
// }];
// }




@end
5 changes: 3 additions & 2 deletions ios/Classes/DkNappDrawerDrawer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
#import "TiBase.h"
#import "TiUIView.h"
#import "TiUINavigationWindowProxy.h"
#import "TiWindowProxy.h"
#import "TiUIWindowProxy.h"
#import "TiUIWindow.h"

#import <QuartzCore/QuartzCore.h>

Expand Down Expand Up @@ -44,6 +45,6 @@
- (NSNumber *)isAnyWindowOpen:(id)args;
- (NSNumber *)isLeftWindowOpen:(id)args;
- (NSNumber *)isRightWindowOpen:(id)args;
- (void)close:(id)args;
//- (KrollPromise *)close:(id)args;

@end
32 changes: 28 additions & 4 deletions ios/Classes/DkNappDrawerDrawer.m
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,15 @@ - (MMDrawerController *)controller
__typeof__(self) strongSelf = weakSelf;

if ([state isEqualToString:@"open"]) {

[[strongSelf proxy] fireEvent:@"windowDidOpen"];


} else if ([state isEqualToString:@"close"]) {
if ([TiUtils boolValue:[[strongSelf proxy] valueForUndefinedKey:@"autoCloseWindows"] def:YES]) {
[[strongSelf proxy] fireEvent:@"windowDidClose"];
}

}

[strongSelf _fireStateEventForCurrentState];
Expand Down Expand Up @@ -462,11 +466,31 @@ - (void)setAnimationMode_:(id)args
}
}



#pragma mark - API
-(void)close:(id)args {
[controller closeDrawerAnimated:NO completion:^(BOOL finished) {
}];
}


//-(KrollPromise *)close:(id)args {
//
// if ([self.proxy _hasListeners:@"close"]) {
// [self.proxy fireEvent:@"close"];
// }
//
//
//// [(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];
////
//// [controller closeDrawerAnimated:NO completion:^(BOOL finished) {
//// }];
//
//}

- (void)toggleLeftWindow:(id)args
{
Expand Down
8 changes: 3 additions & 5 deletions ios/Classes/DkNappDrawerDrawerProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
* Appcelerator Titanium is Copyright (c) 2009-2010 by Appcelerator, Inc.
* and licensed under the Apache Public License (version 2)
*/
#import "MMDrawerController.h"
#import "CustomMMDrawerController.h"
#import <TitaniumKit/TiBase.h>
#import <TitaniumKit/TiApp.h>
#import <TitaniumKit/TiUtils.h>
#import <TitaniumKit/TiWindowProxy.h>
@interface DkNappDrawerDrawerProxy : TiWindowProxy {
#import <TitaniumKit/TiUIWindowProxy.h>
@interface DkNappDrawerDrawerProxy : TiUIWindowProxy {
}

@end
66 changes: 38 additions & 28 deletions ios/Classes/DkNappDrawerDrawerProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
#import "DkNappDrawerDrawerProxy.h"
#import "DkNappDrawerDrawer.h"
#import "TiUtils.h"
#import "TiUINavigationWindowProxy.h"
#import "TiUtils.h"
#import "TiViewController.h"

@implementation DkNappDrawerDrawerProxy

Expand All @@ -24,14 +21,15 @@ - (void)windowDidOpen

- (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
Expand All @@ -42,11 +40,23 @@ - (void)windowDidClose
[leftWinProxy windowDidClose];
[rightWinProxy windowDidClose];
[centerWinProxy windowDidClose];
// [(DkNappDrawerDrawer *)[self view] removeFromSuperview];



[super windowDidClose];

TiThreadPerformOnMainThread(^{
[self close:nil];
if ([self _hasListeners:@"close"]) {
[self fireEvent:@"close"];
}
},
YES);
// [super windowDidClose];

}

- (MMDrawerController *)_controller
- (CustomMMDrawerController *)_controller
{
return [(DkNappDrawerDrawer *)[self view] controller];
}
Expand Down Expand Up @@ -127,27 +137,27 @@ - (NSNumber *)setBackGroundColor:(id)args
}



-(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);
}
//
//-(KrollPromise *)close:(id)args {
//
//
// [(DkNappDrawerDrawer*)[self view] close:args];
//
//
//
//
//
//
//
//
//}

//-(void)close:(id)args {
// TiThreadPerformOnMainThread(^{
// [(DkNappDrawerDrawer*)[self view] close:args];
// },
// NO);
//}
//

@end
2 changes: 1 addition & 1 deletion ios/Classes/DkNappDrawerModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#import "TiHost.h"
#import "TiUtils.h"

#import "MMDrawerController.h"
#import "CustomMMDrawerController.h"

@implementation DkNappDrawerModule

Expand Down
7 changes: 2 additions & 5 deletions ios/NappDrawer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,6 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */;
buildSettings = {
"ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD)";
"ARCHS[sdk=iphonesimulator*]" = "$(ARCHS_STANDARD)";
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
Expand Down Expand Up @@ -427,7 +425,7 @@
GCC_WARN_UNUSED_VARIABLE = NO;
INSTALL_PATH = /usr/local/lib;
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
ONLY_ACTIVE_ARCH = YES;
ONLY_ACTIVE_ARCH = "$(ARCHS_STANDARD)";
OTHER_CFLAGS = (
"-DDEBUG",
"-DTI_POST_1_2",
Expand All @@ -448,8 +446,6 @@
baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
"ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD)";
"ARCHS[sdk=iphonesimulator*]" = "$(ARCHS_STANDARD)";
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
Expand Down Expand Up @@ -494,6 +490,7 @@
GCC_WARN_UNUSED_VARIABLE = NO;
INSTALL_PATH = /usr/local/lib;
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
ONLY_ACTIVE_ARCH = "$(ARCHS_STANDARD)";
OTHER_CFLAGS = "-DTI_POST_1_2";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = DkNappDrawer;
Expand Down
Binary file modified ios/dist/dk.napp.drawer-iphone-2.2.6.zip
Binary file not shown.
Binary file added ios/dist/dk.napp.drawer-iphone-2.2.7.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.6
version: 2.2.7
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 = 10.1.1
TITANIUM_SDK_VERSION = 10.0.2.GA

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

0 comments on commit 10b36fc

Please sign in to comment.