Skip to content

Commit 9235f64

Browse files
author
sherry
committed
feature:add custom close
1 parent 31a41c4 commit 9235f64

File tree

7 files changed

+30
-7
lines changed

7 files changed

+30
-7
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# JVerification-React-Native
22

33
## ChangeLog
4+
### v 2.4.4
5+
- android增加弹窗自定义关闭按钮
46

57
### v 2.4.3
68
- iOS、android增加弹窗登录

android/src/main/java/cn/jiguang/plugins/verification/JVerificationModule.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import android.text.TextUtils;
44
import android.widget.ImageView;
55
import android.widget.RelativeLayout;
6+
import android.widget.ImageButton;
7+
import android.view.ViewGroup;
68

79
import com.facebook.react.ReactApplication;
810
import com.facebook.react.ReactRootView;
@@ -441,6 +443,22 @@ private void convertToConfig(ReadableMap readableMap){
441443
ReadableArray array = readableMap.getArray(JConstans.PRIVACY_DIALOG_THEME);
442444
builder.setDialogTheme(array.getInt(0), array.getInt(1),array.getInt(2), array.getInt(3), array.getBoolean(4));
443445
}
446+
// 弹窗是否需要关闭
447+
if (readableMap.hasKey(JConstans.PRIVACY_NEED_CLOSE) && readableMap.hasKey(JConstans.PRIVACY_CLOSE_THEME)) {
448+
boolean needClose = readableMap.getBoolean(JConstans.PRIVACY_NEED_CLOSE);
449+
if(needClose) {
450+
//自定义返回按钮示例
451+
ImageButton sampleReturnBtn = new ImageButton(reactContext);
452+
sampleReturnBtn.setImageResource(R.drawable.umcsdk_return_bg);
453+
RelativeLayout.LayoutParams returnLP = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
454+
// 返回按钮样式
455+
ReadableArray array = readableMap.hasKey(JConstans.PRIVACY_CLOSE_THEME) ? readableMap.getArray(JConstans.PRIVACY_CLOSE_THEME) : null;
456+
returnLP.setMargins(array.getInt(0), array.getInt(1),array.getInt(2), array.getInt(3));
457+
sampleReturnBtn.setLayoutParams(returnLP);
458+
builder.addCustomView(sampleReturnBtn,true,null);
459+
}
460+
}
461+
444462
}
445463

446464
private ReactRootView convertToView(ReadableMap readableMap){

android/src/main/java/cn/jiguang/plugins/verification/common/JConstans.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,9 @@ public class JConstans {
106106
public static final String PRIVACY_NEED_CLOSE_ANIM = "privacyNeedCloseAnim";
107107
// 授权页弹窗模式
108108
public static final String PRIVACY_DIALOG_THEME = "privacyDialogTheme";
109+
// 弹窗是否需要配置关闭按钮
110+
public static final String PRIVACY_NEED_CLOSE = "privacyNeedClose";
111+
// 弹窗关闭按钮模式
112+
public static final String PRIVACY_CLOSE_THEME = "privacyCloseTheme";
109113

110114
}

example/App.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,8 @@ const codeConfig = {
155155
};
156156
//安卓授权页弹窗模式
157157
const androidDialogConfig = {
158-
// navHidden: false, //导航栏是否隐藏
159-
// navColor: -16777216, //导航栏颜色
160-
// navReturnHidden: false, //导航栏返回按钮是否隐藏
161-
// navReturnImage: 'close', //导航栏左侧返回按钮图标
158+
privacyNeedClose:true, //弹窗是否需要关闭按钮
159+
privacyCloseTheme:[10, 60, 0, 0], //弹窗关闭按钮偏移量 privacyNeedClose为true时,必须设置它的偏移量
162160
privacyDialogTheme: [300, 400, 0, 0, false], //授权页弹窗模式
163161
privacyNeedStartAnim: true, //设置拉起授权页时是否需要显示默认动画 默认展示
164162
privacyNeedCloseAnim: true, //设置关闭授权页时是否需要显示默认动画 默认展示
@@ -258,6 +256,7 @@ export default class App extends React.Component {
258256

259257
<Button title='设置获取验证码时间间隔' onPress={() => JVerification.setCodeTime(1000)}/>
260258

259+
261260
</View>
262261
);
263262
}

example/android/settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ apply from: file("../node_modules/@react-native-community/cli-platform-android/n
33
include ':app'
44

55
include ':jverification-react-native'
6-
project(':jverification-react-native').projectDir = new File(rootProject.projectDir, '../../android')
6+
project(':jverification-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/jverification-react-native/android')
77
include ':jcore-react-native'
88
project(':jcore-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/jcore-react-native/android')

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"dependencies": {
1010
"jcore-react-native": "^1.7.0",
11-
"jverification-react-native": "2.4.3",
11+
"jverification-react-native": "2.4.4",
1212
"react": "16.8.6",
1313
"react-native": "0.60.5"
1414
},

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "index.js",
66
"license": "ISC",
77
"author": "wicked.tc130",
8-
"version": "2.4.3",
8+
"version": "2.4.4",
99
"repository": {
1010
"type": "git",
1111
"url": "https://github.com/jpush/jverification-react-native"

0 commit comments

Comments
 (0)