Skip to content

Commit

Permalink
Merge pull request #15 from weiruiyang/master
Browse files Browse the repository at this point in the history
ios  更新支持弹框
  • Loading branch information
weiruiyang authored Mar 17, 2020
2 parents e8fa56c + 7e2aede commit 1a98cdc
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 3 deletions.
17 changes: 17 additions & 0 deletions doc/ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
|logoHeight|float|LOGO图片高度|
|logoOffsetY|float|LOGO图片偏移量|
|logoHidden|BOOL|LOGO图片隐藏|
|logoConstraints|[float,float,float,float]|LOGO图片布局对象(窗口相对屏幕中心的x轴偏移量,窗口相对屏幕中心的y轴偏移量,窗口宽度,窗口高度)|
|logoHorizontalConstraints|[float,float,float,float]|LOGO图片 横屏布局(窗口相对屏幕中心的x轴偏移量,窗口相对屏幕中心的y轴偏移量,窗口宽度,窗口高度),横屏时优先级高于logoConstraints|

+ 登录按钮

Expand All @@ -49,6 +51,8 @@
|logBtnOffsetY|float|登录按钮Y偏移量|
|logBtnTextColor|int|登录按钮文本颜色|
|logBtnImgs|String,String,String|登录按钮背景图片添加到数组(顺序如下) @[激活状态的图片,失效状态的图片,高亮状态的图片]|
|logBtnConstraints|[float,float,float,float]|登录按钮布局对象(窗口相对屏幕中心的x轴偏移量,窗口相对屏幕中心的y轴偏移量,窗口宽度,窗口高度)|
|logBtnHorizontalConstraints|[float,float,float,float]|登录按钮 横屏布局(窗口相对屏幕中心的x轴偏移量,窗口相对屏幕中心的y轴偏移量,窗口宽度,窗口高度),横屏时优先级高于logBtnConstraints|

+ 手机号码

Expand All @@ -57,6 +61,8 @@
|numberColor|int|手机号码字体颜色|
|numberSize|float|手机号码字体大小|
|numFieldOffsetY|float|号码栏Y偏移量|
|numberConstraints|[float,float,float,float]|号码栏布局对象(窗口相对屏幕中心的x轴偏移量,窗口相对屏幕中心的y轴偏移量,窗口宽度,窗口高度)|
|numberHorizontalConstraints|[float,float,float,float]|号码栏 横屏布局(窗口相对屏幕中心的x轴偏移量,窗口相对屏幕中心的y轴偏移量,窗口宽度,窗口高度),横屏时优先级高于numberConstraints|

+ checkBox

Expand All @@ -66,6 +72,8 @@
|checkedImg|String|checkBox选中时图片|
|checkViewHidden|BOOL|checkBox是否隐藏,默认不隐藏|
|privacyState|BOOL|隐私条款check框默认状态 默认:NO|
|checkViewConstraints|[float,float,float,float]|checkBox布局对象(窗口相对屏幕中心的x轴偏移量,窗口相对屏幕中心的y轴偏移量,窗口宽度,窗口高度)|
|checkViewHorizontalConstraints|[float,float,float,float]|checkBox横屏布局(窗口相对屏幕中心的x轴偏移量,窗口相对屏幕中心的y轴偏移量,窗口宽度,窗口高度),横屏优先级高于checkViewConstraints|

+ 隐私协议栏

Expand All @@ -79,6 +87,8 @@
|privacyComponents|String,String|隐私条款拼接文本数组|
|privacyShowBookSymbol|BOOL|隐私条款是否显示书名号,默认不显示|
|privacyLineSpacing|float|隐私条款行距,默认跟随系统|
|privacyConstraints|[float,float,float,float]|隐私条款布局对象(窗口相对屏幕中心的x轴偏移量,窗口相对屏幕中心的y轴偏移量,窗口宽度,窗口高度)|
|privacyHorizontalConstraints|[float,float,float,float]|隐私条款 横屏布局(窗口相对屏幕中心的x轴偏移量,窗口相对屏幕中心的y轴偏移量,窗口宽度,窗口高度),横屏下优先级高于privacyConstraints|


+ 隐私协议页面
Expand All @@ -98,6 +108,8 @@
|:-----:|:----:|:-----:|
|sloganOffsetY|float|slogan偏移量Y|
|sloganTextColor|int|slogan文字颜色|
|sloganConstraints|[float,float,float,float]|slogan布局对象(窗口相对屏幕中心的x轴偏移量,窗口相对屏幕中心的y轴偏移量,窗口宽度,窗口高度)|
|sloganHorizontalConstraints|[float,float,float,float]|slogan 横屏布局(窗口相对屏幕中心的x轴偏移量,窗口相对屏幕中心的y轴偏移量,窗口宽度,窗口高度),横屏下优先级高于sloganConstraints|


+ 弹窗
Expand All @@ -108,6 +120,11 @@
|windowBackgroundImage|String|弹框内部背景图片|
|windowBackgroundAlpha|float|弹窗外侧 透明度 0~1.0|
|windowCornerRadius|float|弹窗圆角数值|
|windowConstraints|[float,float,float,float]|弹窗布局对象(窗口相对屏幕中心的x轴偏移量,窗口相对屏幕中心的y轴偏移量,窗口宽度,窗口高度)|
|windowHorizontalConstraints|[float,float,float,float]|弹窗横屏布局(窗口相对屏幕中心的x轴偏移量,窗口相对屏幕中心的y轴偏移量,窗口宽度,窗口高度),横屏下优先级高于windowConstraints|
|windowCloseBtnImgs|[String,String]|弹窗close按钮图片 @[普通状态图片,高亮状态图片]
|windowCloseBtnConstraints|[float,float,float,float]|弹窗close按钮布局(窗口相对屏幕中心的x轴偏移量,窗口相对屏幕中心的y轴偏移量,窗口宽度,窗口高度)
|windowCloseBtnHorizontalConstraints|[float,float,float,float]|弹窗close按钮 横屏布局(窗口相对屏幕中心的x轴偏移量,窗口相对屏幕中心的y轴偏移量,窗口宽度,窗口高度),横屏下优先级高于windowCloseBtnConstraints|

![JVerification](https://docs.jiguang.cn/jverification/image/cutomeUI_description.png)

Expand Down
26 changes: 26 additions & 0 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,32 @@
appPrivacyColor:[0xff00f000,0xff000000]
}

// var json={//弹框
// navCustom:true,
// autoLayout:true,
// showWindow:true,
// windowConstraints:[0,0,300,300],
// windowBackgroundAlpha: 0.3,
// //logo
// logoImg:"AppIcon",
// logoConstraints:[0,-100,60,60],
// //number
// numberConstraints:[0,-42,200,14],
// //slogn
// sloganConstraints:[0,-20,200,14],
// //登录按钮
// logBtnConstraints:[0,20,220,40],
// logBtnText:"Demo loginAuth",
// logBtnTextColor:0x0000FF,
// windowCornerRadius:10,
// privacyConstraints:[0,100,200,40],
// checkViewConstraints:[-108,100,10,10],
// windowCloseBtnConstraints:[-135,-135,20,20],
// loadingConstraints:[0,0,20,20],
// windowCloseBtnImgs:["AppIcon","AppIcon"],
// windowBackgroundImage:"AppIcon"
// }

json = JSON.stringify(json);
// alert(json);
JGJVerificationPlugin.setCustomUIWithConfig(json);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jg-jverification-cordova-plugin",
"version": "1.2.4",
"version": "1.2.5",
"description": "JVerification-cordova-plugin",
"cordova": {
"id": "jg-jverification-cordova-plugin",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='utf-8'?>
<plugin xmlns:android="http://schemas.android.com/apk/res/android"
id="jg-jverification-cordova-plugin" version="1.2.4"
id="jg-jverification-cordova-plugin" version="1.2.5"
xmlns="http://apache.org/cordova/ns/plugins/1.0">
<name>JVerification-cordova-plugin</name>

Expand Down
107 changes: 106 additions & 1 deletion src/ios/JVerificationPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -423,20 +423,28 @@ - (void)setCustomUIWithConfig:(CDVInvokedUrlCommand*)command
static NSString* logoHeight=@"logoHeight";
static NSString* logoOffsetY=@"logoOffsetY";
static NSString* logoHidden=@"logoHidden";
static NSString* logoConstraints=@"logoConstraints";
static NSString* logoHorizontalConstraints=@"logoHorizontalConstraints";
//登录按钮
static NSString* logBtnText=@"logBtnText";
static NSString* logBtnOffsetY=@"logBtnOffsetY";
static NSString* logBtnTextColor=@"logBtnTextColor";
static NSString* logBtnImgs=@"logBtnImgs";
static NSString* logBtnConstraints=@"logBtnConstraints";
static NSString* logBtnHorizontalConstraints=@"logBtnHorizontalConstraints";
//手机号码
static NSString* numberColor=@"numberColor";
static NSString* numberSize=@"numberSize";
static NSString* numFieldOffsetY=@"numFieldOffsetY";
static NSString* numberConstraints=@"numberConstraints";
static NSString* numberHorizontalConstraints=@"numberHorizontalConstraints";
//checkBox
static NSString* uncheckedImg=@"uncheckedImg";
static NSString* checkedImg=@"checkedImg";
static NSString* checkViewHidden=@"checkViewHidden";
static NSString* privacyState=@"privacyState";
static NSString* checkViewConstraints=@"checkViewConstraints";
static NSString* checkViewHorizontalConstraints=@"checkViewHorizontalConstraints";
//隐私协议栏
static NSString* appPrivacyOne=@"appPrivacyOne";
static NSString* appPrivacyTwo=@"appPrivacyTwo";
Expand All @@ -446,6 +454,8 @@ - (void)setCustomUIWithConfig:(CDVInvokedUrlCommand*)command
static NSString* privacyComponents=@"privacyComponents";
static NSString* privacyShowBookSymbol=@"privacyShowBookSymbol";
static NSString* privacyLineSpacing=@"privacyLineSpacing";
static NSString* privacyConstraints=@"privacyConstraints";
static NSString* privacyHorizontalConstraints=@"privacyHorizontalConstraints";
//隐私协议页面
static NSString* agreementNavBackgroundColor=@"agreementNavBackgroundColor";
static NSString* agreementNavText=@"agreementNavText";
Expand All @@ -454,15 +464,27 @@ - (void)setCustomUIWithConfig:(CDVInvokedUrlCommand*)command
static NSString* agreementNavReturnImage=@"agreementNavReturnImage";
//slogan
static NSString* sloganOffsetY=@"sloganOffsetY";
static NSString* sloganConstraints=@"sloganConstraints";
static NSString* sloganHorizontalConstraints=@"sloganHorizontalConstraints";
static NSString* sloganTextColor=@"sloganTextColor";
//弹窗
static NSString* showWindow=@"showWindow";
static NSString* windowBackgroundImage=@"windowBackgroundImage";
static NSString* windowBackgroundAlpha=@"windowBackgroundAlpha";
static NSString* windowCornerRadius=@"windowCornerRadius";
static NSString* windowConstraints=@"windowConstraints";
static NSString* windowHorizontalConstraints=@"windowHorizontalConstraints";
static NSString* windowCloseBtnImgs=@"windowCloseBtnImgs";
static NSString* windowCloseBtnConstraints=@"windowCloseBtnConstraints";
static NSString* windowCloseBtnHorizontalConstraints=@"windowCloseBtnHorizontalConstraints";

//loading
static NSString* loadingConstraints=@"loadingConstraints";
static NSString* loadingHorizontalConstraints=@"loadingHorizontalConstraints";

void setJVUIConfig(NSString* key ,NSDictionary *dict,
JVUIConfig *jvUIConfig){

//授权页面设置
if ([key containsString:authPageBackgroundImage]) {
jvUIConfig.authPageBackgroundImage = [UIImage imageNamed:dict[key]];
Expand Down Expand Up @@ -507,6 +529,12 @@ void setJVUIConfig(NSString* key ,NSDictionary *dict,
jvUIConfig.logoOffsetY =[dict[key] floatValue];//CGFloat;
}else if([key containsString:logoHidden]){
jvUIConfig.logoHidden =[dict[key] boolValue];//BOOL
}else if([key containsString:logoConstraints]){
NSArray* consWindow = dict[key];
jvUIConfig.logoConstraints = configConstraintWithAttributes(consWindow);
}else if([key containsString:logoHorizontalConstraints]){
NSArray* consWindow = dict[key];
jvUIConfig.logoHorizontalConstraints = configConstraintWithAttributes(consWindow);
}
// 登录按钮

Expand All @@ -524,6 +552,12 @@ void setJVUIConfig(NSString* key ,NSDictionary *dict,
[UIImage imageNamed:imgPaths[2]],
nil];
jvUIConfig.logBtnImgs = logBtnImgs;
}else if([key containsString:logBtnConstraints]){
NSArray* consWindow = dict[key];
jvUIConfig.logBtnConstraints = configConstraintWithAttributes(consWindow);
}else if([key containsString:logBtnHorizontalConstraints]){
NSArray* consWindow = dict[key];
jvUIConfig.logBtnHorizontalConstraints = configConstraintWithAttributes(consWindow);
}
// 手机号码
else if([key containsString:numberColor]){
Expand All @@ -532,6 +566,12 @@ void setJVUIConfig(NSString* key ,NSDictionary *dict,
jvUIConfig.numberSize = [dict[key] floatValue];
}else if([key containsString:numFieldOffsetY]){
jvUIConfig.numFieldOffsetY = [dict[key] floatValue];
}else if([key containsString:numberConstraints]){
NSArray* consWindow = dict[key];
jvUIConfig.numberConstraints = configConstraintWithAttributes(consWindow);
}else if([key containsString:numberHorizontalConstraints]){
NSArray* consWindow = dict[key];
jvUIConfig.numberHorizontalConstraints = configConstraintWithAttributes(consWindow);
}
// checkBox
else if([key containsString:uncheckedImg]){
Expand All @@ -542,6 +582,12 @@ void setJVUIConfig(NSString* key ,NSDictionary *dict,
jvUIConfig.checkViewHidden = [dict[key] boolValue];
}else if([key containsString:privacyState]){
jvUIConfig.privacyState = [dict[key] boolValue];
}else if([key containsString:checkViewConstraints]){
NSArray* consWindow = dict[key];
jvUIConfig.checkViewConstraints = configConstraintWithAttributes(consWindow);
}else if([key containsString:checkViewHorizontalConstraints]){
NSArray* consWindow = dict[key];
jvUIConfig.checkViewHorizontalConstraints = configConstraintWithAttributes(consWindow);
}
// 隐私协议栏

Expand All @@ -566,6 +612,12 @@ void setJVUIConfig(NSString* key ,NSDictionary *dict,
jvUIConfig.privacyShowBookSymbol = [dict[key] boolValue];
}else if([key containsString:privacyLineSpacing]){
jvUIConfig.privacyLineSpacing = [dict[key] floatValue];
}else if([key containsString:privacyConstraints]){
NSArray* consWindow = dict[key];
jvUIConfig.privacyConstraints = configConstraintWithAttributes(consWindow);
}else if([key containsString:privacyHorizontalConstraints]){
NSArray* consWindow = dict[key];
jvUIConfig.privacyHorizontalConstraints = configConstraintWithAttributes(consWindow);
}

// 隐私协议页面
Expand All @@ -586,18 +638,54 @@ void setJVUIConfig(NSString* key ,NSDictionary *dict,
// slogan
else if([key containsString:sloganOffsetY]){
jvUIConfig.sloganOffsetY = [dict[key] floatValue];
}else if([key containsString:sloganConstraints]){
NSArray* consWindow = dict[key];
jvUIConfig.sloganConstraints = configConstraintWithAttributes(consWindow);
}else if([key containsString:sloganHorizontalConstraints]){
NSArray* consWindow = dict[key];
jvUIConfig.sloganHorizontalConstraints = configConstraintWithAttributes(consWindow);
}else if([key containsString:sloganTextColor]){
jvUIConfig.sloganTextColor = UIColorFromRGBValue([dict[key] intValue]);
}
// 弹窗
else if([key containsString:sloganOffsetY]){
else if([key containsString:showWindow]){
jvUIConfig.showWindow = [dict[key] boolValue];
}else if([key containsString:windowBackgroundImage]){
jvUIConfig.windowBackgroundImage = [UIImage imageNamed:dict[key]];
}else if([key containsString:windowBackgroundAlpha]){
jvUIConfig.windowBackgroundAlpha = [dict[key] floatValue];
}else if([key containsString:windowCornerRadius]){
jvUIConfig.windowCornerRadius = [dict[key] floatValue];
}else if([key containsString:windowConstraints]){
NSArray* consWindow = dict[key];
jvUIConfig.windowConstraints = configConstraintWithAttributes(consWindow);
}else if([key containsString:windowHorizontalConstraints]){
NSArray* consWindow = dict[key];
jvUIConfig.windowHorizontalConstraints = configConstraintWithAttributes(consWindow);
}else if([key containsString:windowCloseBtnImgs]){
NSArray* imageNames = dict[key];
NSMutableArray *images = [NSMutableArray arrayWithCapacity:3];
for (int i = 0; i< imageNames.count; i++) {
UIImage *closeImage = [UIImage imageNamed:imageNames[i]];
if (closeImage) {
[images addObject:closeImage];
}
}
jvUIConfig.windowCloseBtnImgs = images;
}else if([key containsString:windowCloseBtnConstraints]){
NSArray* consWindow = dict[key];
jvUIConfig.windowCloseBtnConstraints = configConstraintWithAttributes(consWindow);
}else if([key containsString:windowCloseBtnHorizontalConstraints]){
NSArray* consWindow = dict[key];
jvUIConfig.windowCloseBtnHorizontalConstraints = configConstraintWithAttributes(consWindow);
}
//loading
else if([key containsString:loadingConstraints]){
NSArray* consWindow = dict[key];
jvUIConfig.loadingConstraints = configConstraintWithAttributes(consWindow);
}else if([key containsString:loadingHorizontalConstraints]){
NSArray* consWindow = dict[key];
jvUIConfig.loadingHorizontalConstraints = configConstraintWithAttributes(consWindow);
}

}
Expand Down Expand Up @@ -643,4 +731,21 @@ id APNativeJSONObject(NSData *data) {
return retId;
}



NSArray *configConstraintWithAttributes(NSArray* keys){
NSMutableArray *constraints = [NSMutableArray arrayWithCapacity:4];
NSArray* cons = keys;
CGFloat centerX = [cons[0] floatValue];
CGFloat centerY = [cons[1] floatValue];
CGFloat w = [cons[2] floatValue];
CGFloat h = [cons[3] floatValue];
JVLayoutConstraint *constraintX = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterX multiplier:1 constant:centerX];
JVLayoutConstraint *constraintY = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemSuper attribute:NSLayoutAttributeCenterY multiplier:1 constant:centerY];
JVLayoutConstraint *constraintW = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeWidth multiplier:1 constant:w];
JVLayoutConstraint *constraintH = [JVLayoutConstraint constraintWithAttribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:JVLayoutItemNone attribute:NSLayoutAttributeHeight multiplier:1 constant:h];
[constraints addObjectsFromArray:@[constraintX,constraintY,constraintW,constraintH]];
return constraints;
}

@end

0 comments on commit 1a98cdc

Please sign in to comment.