Commit 657e6553 authored by zooble's avatar zooble Committed by GitHub

Merge pull request #235 from rghorbani/master

add requires main queue setup
parents 43f485ea 6e583074
...@@ -22,16 +22,26 @@ ...@@ -22,16 +22,26 @@
@synthesize bridge = _bridge; @synthesize bridge = _bridge;
- (dispatch_queue_t)methodQueue
{
return dispatch_get_main_queue();
}
+ (BOOL)requiresMainQueueSetup
{
return YES;
}
RCT_EXPORT_MODULE(); RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(_init:(NSDictionary *)indic){ RCT_EXPORT_METHOD(_init:(NSDictionary *)indic){
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[[UIApplication sharedApplication].keyWindow endEditing:YES]; [[UIApplication sharedApplication].keyWindow endEditing:YES];
}); });
self.window = [UIApplication sharedApplication].keyWindow; self.window = [UIApplication sharedApplication].keyWindow;
NSString *pickerConfirmBtnText=indic[@"pickerConfirmBtnText"]; NSString *pickerConfirmBtnText=indic[@"pickerConfirmBtnText"];
NSString *pickerCancelBtnText=indic[@"pickerCancelBtnText"]; NSString *pickerCancelBtnText=indic[@"pickerCancelBtnText"];
NSString *pickerTitleText=indic[@"pickerTitleText"]; NSString *pickerTitleText=indic[@"pickerTitleText"];
...@@ -45,63 +55,63 @@ RCT_EXPORT_METHOD(_init:(NSDictionary *)indic){ ...@@ -45,63 +55,63 @@ RCT_EXPORT_METHOD(_init:(NSDictionary *)indic){
NSString *pickerToolBarFontSize=[NSString stringWithFormat:@"%@",indic[@"pickerToolBarFontSize"]]; NSString *pickerToolBarFontSize=[NSString stringWithFormat:@"%@",indic[@"pickerToolBarFontSize"]];
NSString *pickerFontSize=[NSString stringWithFormat:@"%@",indic[@"pickerFontSize"]]; NSString *pickerFontSize=[NSString stringWithFormat:@"%@",indic[@"pickerFontSize"]];
NSArray *pickerFontColor=indic[@"pickerFontColor"]; NSArray *pickerFontColor=indic[@"pickerFontColor"];
id pickerData=indic[@"pickerData"]; id pickerData=indic[@"pickerData"];
NSMutableDictionary *dataDic=[[NSMutableDictionary alloc]init]; NSMutableDictionary *dataDic=[[NSMutableDictionary alloc]init];
dataDic[@"pickerData"]=pickerData; dataDic[@"pickerData"]=pickerData;
[self.window.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { [self.window.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj isKindOfClass:[BzwPicker class]]) { if ([obj isKindOfClass:[BzwPicker class]]) {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[obj removeFromSuperview]; [obj removeFromSuperview];
}); });
} }
}]; }];
if ([[UIDevice currentDevice].systemVersion doubleValue] >= 9.0 ) { if ([[UIDevice currentDevice].systemVersion doubleValue] >= 9.0 ) {
self.height=250; self.height=250;
}else{ }else{
self.height=220; self.height=220;
} }
self.pick=[[BzwPicker alloc]initWithFrame:CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, self.height) dic:dataDic leftStr:pickerCancelBtnText centerStr:pickerTitleText rightStr:pickerConfirmBtnText topbgColor:pickerToolBarBg bottombgColor:pickerBg leftbtnbgColor:pickerCancelBtnColor rightbtnbgColor:pickerConfirmBtnColor centerbtnColor:pickerTitleColor selectValueArry:selectArry weightArry:weightArry pickerToolBarFontSize:pickerToolBarFontSize pickerFontSize:pickerFontSize pickerFontColor:pickerFontColor]; self.pick=[[BzwPicker alloc]initWithFrame:CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, self.height) dic:dataDic leftStr:pickerCancelBtnText centerStr:pickerTitleText rightStr:pickerConfirmBtnText topbgColor:pickerToolBarBg bottombgColor:pickerBg leftbtnbgColor:pickerCancelBtnColor rightbtnbgColor:pickerConfirmBtnColor centerbtnColor:pickerTitleColor selectValueArry:selectArry weightArry:weightArry pickerToolBarFontSize:pickerToolBarFontSize pickerFontSize:pickerFontSize pickerFontColor:pickerFontColor];
_pick.bolock=^(NSDictionary *backinfoArry){ _pick.bolock=^(NSDictionary *backinfoArry){
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[self.bridge.eventDispatcher sendAppEventWithName:@"pickerEvent" body:backinfoArry]; [self.bridge.eventDispatcher sendAppEventWithName:@"pickerEvent" body:backinfoArry];
}); });
}; };
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[self.window addSubview:_pick]; [self.window addSubview:_pick];
}); });
} }
RCT_EXPORT_METHOD(show){ RCT_EXPORT_METHOD(show){
if (self.pick) { if (self.pick) {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[UIView animateWithDuration:.3 animations:^{ [UIView animateWithDuration:.3 animations:^{
[_pick setFrame:CGRectMake(0, SCREEN_HEIGHT-self.height, SCREEN_WIDTH, self.height)]; [_pick setFrame:CGRectMake(0, SCREEN_HEIGHT-self.height, SCREEN_WIDTH, self.height)];
}]; }];
}); });
}return; }return;
} }
RCT_EXPORT_METHOD(hide){ RCT_EXPORT_METHOD(hide){
if (self.pick) { if (self.pick) {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[UIView animateWithDuration:.3 animations:^{ [UIView animateWithDuration:.3 animations:^{
...@@ -122,13 +132,13 @@ RCT_EXPORT_METHOD(select: (NSArray*)data){ ...@@ -122,13 +132,13 @@ RCT_EXPORT_METHOD(select: (NSArray*)data){
} }
RCT_EXPORT_METHOD(isPickerShow:(RCTResponseSenderBlock)getBack){ RCT_EXPORT_METHOD(isPickerShow:(RCTResponseSenderBlock)getBack){
if (self.pick) { if (self.pick) {
CGFloat pickY=_pick.frame.origin.y; CGFloat pickY=_pick.frame.origin.y;
if (pickY==SCREEN_HEIGHT) { if (pickY==SCREEN_HEIGHT) {
getBack(@[@YES]); getBack(@[@YES]);
}else }else
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment