Skip to content

Commit cde295d

Browse files
committed
iOS 支持checkbox未选中的状态。
1 parent fc85e28 commit cde295d

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export default class JVerification {
8282
}
8383

8484
/*
85-
* SDK获取号码认证token
85+
* SDK获取预取号token
8686
* @param time : int
8787
* @param callback = (result) => {"code":int,'content':String}
8888
*

ios/RCTJVerificationModule/RCTJVerificationModule.m

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111

1212
//事件
1313
#define LOGIN_EVENT @"LoginEvent"
14-
14+
#define UNCHECK_BOX_EVENT @"UncheckBoxCallBack"
1515
//自定义布局路径
1616
#define CUSTOM_VIEW_NAME @"customViewName"
1717
#define CUSTOM_VIEW_POINT @"customViewPoint"
18+
#define UNCHECK_BOX_CALLBACK @"unAgreePrivacyCallBack"
1819

1920
//资源文件夹
2021
#define JVERIFICATION_RESOURCE @"JVerificationResource"
@@ -119,7 +120,7 @@
119120
#define UIColorFromRGBValue(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
120121

121122
static double defaultTime = 5000;
122-
123+
bool debug = false;
123124
@implementation RCTJVerificationModule
124125

125126
RCT_EXPORT_MODULE(JVerificationModule);
@@ -132,6 +133,7 @@ + (BOOL)requiresMainQueueSetup
132133
RCT_EXPORT_METHOD(setDebug: (BOOL *)enable)
133134
{
134135
[JVERIFICATIONService setDebug: enable];
136+
debug = enable;
135137
}
136138

137139
RCT_EXPORT_METHOD(setupWithConfig: (NSDictionary *)params
@@ -152,6 +154,8 @@ + (BOOL)requiresMainQueueSetup
152154
}
153155
if(params[@"time"]){
154156
config.timeout = [params[@"time"] doubleValue];
157+
}else{
158+
config.timeout = defaultTime;
155159
}
156160
if(callback != nil){
157161
config.authBlock = ^(NSDictionary *result) {
@@ -306,7 +310,7 @@ + (BOOL)requiresMainQueueSetup
306310
//事件处理
307311
- (NSArray<NSString *> *)supportedEvents
308312
{
309-
return @[LOGIN_EVENT];
313+
return @[LOGIN_EVENT,UNCHECK_BOX_EVENT];
310314
}
311315

312316
- (void)sendLoginEvent:(NSDictionary *)responseData
@@ -316,7 +320,12 @@ - (void)sendLoginEvent:(NSDictionary *)responseData
316320
args:@[LOGIN_EVENT, responseData]
317321
completion:NULL];
318322
}
319-
323+
- (void)sendUncheckBoxEvent{
324+
[self.bridge enqueueJSCall:@"RCTDeviceEventEmitter"
325+
method:@"emit"
326+
args:@[UNCHECK_BOX_EVENT]
327+
completion:NULL];
328+
}
320329
//结果返回
321330
-(NSDictionary *)convertToResult:(BOOL)enable
322331
{
@@ -342,6 +351,10 @@ -(NSDictionary *)convertToResult:(NSNumber *)code
342351
-(JVUIConfig *)convertToCinfig: (NSDictionary *)configParams
343352
{
344353
JVUIConfig *config = [[JVUIConfig alloc] init];
354+
config.autoLayout = true;
355+
if (debug) {
356+
NSLog(@"configParams:%@",configParams);
357+
}
345358
//背景图
346359
if(configParams[BACK_GROUND_IMAGE]){
347360
config.authPageBackgroundImage = [self imageNamed:configParams[BACK_GROUND_IMAGE]];
@@ -550,6 +563,17 @@ -(JVUIConfig *)convertToCinfig: (NSDictionary *)configParams
550563
if(configParams[PRIVACY_UNCHECKED_IMAGE]){
551564
config.uncheckedImg = [self imageNamed:configParams[PRIVACY_UNCHECKED_IMAGE]];
552565
}
566+
//TODO:
567+
if ([configParams[UNCHECK_BOX_CALLBACK] isKindOfClass:[NSNumber class]]) {
568+
BOOL isNeedCallBack = [configParams[UNCHECK_BOX_CALLBACK] boolValue];
569+
if (isNeedCallBack) {
570+
config.customPrivacyAlertViewBlock = ^(UIViewController*vc){
571+
[self sendUncheckBoxEvent];
572+
};
573+
}
574+
}
575+
576+
553577
CGFloat privacyCheckboxW = config.uncheckedImg.size.width;
554578
CGFloat privacyCheckboxH = config.uncheckedImg.size.height;
555579
JVLayoutConstraint *constraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemPrivacy attribute:NSLayoutAttributeLeft multiplier:1 constant:-15];
-528 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)