@@ -74,43 +74,184 @@ jverify.getToken().then((map){
74
74
``` dart
75
75
///具体使用可以查看 example 样例
76
76
77
- Jverify jverify = new Jverify();
77
+ Jverify jverify = new Jverify();
78
+
79
+ final screenSize = MediaQuery.of(context).size;
80
+ final screenWidth = screenSize.width;
81
+ final screenHeight = screenSize.height;
82
+ bool isiOS = Platform.isIOS;
83
+
84
+ /// 自定义授权的 UI 界面,以下设置的图片必须添加到资源文件里,
85
+ /// android项目将图片存放至drawable文件夹下,可使用图片选择器的文件名,例如:btn_login.xml,入参为"btn_login"。
86
+ /// ios项目存放在 Assets.xcassets。
87
+ ///
88
+ JVUIConfig uiConfig = JVUIConfig();
89
+ //uiConfig.authBackgroundImage = ;
90
+
91
+ //uiConfig.navHidden = true;
92
+ uiConfig.navColor = Colors.red.value;
93
+ uiConfig.navText = "登录";
94
+ uiConfig.navTextColor = Colors.blue.value;
95
+ uiConfig.navReturnImgPath = "return_bg";//图片必须存在
96
+
97
+ uiConfig.logoWidth = 100;
98
+ uiConfig.logoHeight = 100;
99
+ //uiConfig.logoOffsetX = isiOS ? 0 : null;//(screenWidth/2 - uiConfig.logoWidth/2).toInt();
100
+ uiConfig.logoOffsetY = 10;
101
+ uiConfig.logoVerticalLayoutItem = JVIOSLayoutItem.ItemSuper;
102
+ uiConfig.logoHidden = false;
103
+ uiConfig.logoImgPath = "logo";
104
+
105
+ uiConfig.numberFieldWidth = 200;
106
+ uiConfig.numberFieldHeight = 40 ;
107
+ //uiConfig.numFieldOffsetX = isiOS ? 0 : null;//(screenWidth/2 - uiConfig.numberFieldWidth/2).toInt();
108
+ uiConfig.numFieldOffsetY = isiOS ? 20 : 120;
109
+ uiConfig.numberVerticalLayoutItem = JVIOSLayoutItem.ItemLogo;
110
+ uiConfig.numberColor = Colors.blue.value;
111
+ uiConfig.numberSize = 18;
112
+
113
+ uiConfig.sloganOffsetY = isiOS ? 20 : 160;
114
+ uiConfig.sloganVerticalLayoutItem = JVIOSLayoutItem.ItemNumber;
115
+ uiConfig.sloganTextColor = Colors.black.value;
116
+ uiConfig.sloganTextSize = 15;
117
+ //uiConfig.sloganHidden = 0;
118
+
119
+ uiConfig.logBtnWidth = 220;
120
+ uiConfig.logBtnHeight = 50;
121
+ //uiConfig.logBtnOffsetX = isiOS ? 0 : null;//(screenWidth/2 - uiConfig.logBtnWidth/2).toInt();
122
+ uiConfig.logBtnOffsetY = isiOS ? 20 : 230;
123
+ uiConfig.logBtnVerticalLayoutItem = JVIOSLayoutItem.ItemSlogan;
124
+ uiConfig.logBtnText = "登录按钮";
125
+ uiConfig.logBtnTextColor = Colors.brown.value;
126
+ uiConfig.logBtnTextSize = 16;
127
+ uiConfig.loginBtnNormalImage = "login_btn_normal";//图片必须存在
128
+ uiConfig.loginBtnPressedImage = "login_btn_press";//图片必须存在
129
+ uiConfig.loginBtnUnableImage = "login_btn_unable";//图片必须存在
130
+
131
+
132
+ uiConfig.privacyState = true;//设置默认勾选
133
+ uiConfig.privacyCheckboxSize = 20;
134
+ uiConfig.checkedImgPath = "check_image";//图片必须存在
135
+ uiConfig.uncheckedImgPath = "uncheck_image";//图片必须存在
136
+ uiConfig.privacyCheckboxInCenter = true;
137
+ //uiConfig.privacyCheckboxHidden = false;
138
+
139
+ //uiConfig.privacyOffsetX = isiOS ? (20 + uiConfig.privacyCheckboxSize) : null;
140
+ uiConfig.privacyOffsetY = 15;// 距离底部距离
141
+ uiConfig.privacyVerticalLayoutItem = JVIOSLayoutItem.ItemSuper;
142
+ uiConfig.clauseName = "协议1";
143
+ uiConfig.clauseUrl = "http://www.baidu.com";
144
+ uiConfig.clauseBaseColor = Colors.black.value;
145
+ uiConfig.clauseNameTwo = "协议二";
146
+ uiConfig.clauseUrlTwo = "http://www.hao123.com";
147
+ uiConfig.clauseColor = Colors.red.value;
148
+ uiConfig.privacyText = ["1极","2光","3认","4证"];
149
+ uiConfig.privacyTextSize = 13;
150
+ //uiConfig.privacyWithBookTitleMark = true;
151
+ //uiConfig.privacyTextCenterGravity = false;
152
+
153
+
154
+ uiConfig.privacyNavColor = Colors.red.value;;
155
+ uiConfig.privacyNavTitleTextColor = Colors.blue.value;
156
+ uiConfig.privacyNavTitleTextSize = 16;
157
+ uiConfig.privacyNavTitleTitle1 = "协议1 web页标题";
158
+ uiConfig.privacyNavTitleTitle2 = "协议2 web页标题";
159
+ uiConfig.privacyNavReturnBtnImage = "return_bg";//图片必须存在;
160
+
161
+ /// 添加自定义的 控件 到授权界面
162
+ List<JVCustomWidget>widgetList = [];
163
+
164
+ /*
165
+ final String text_widgetId = "jv_add_custom_text";// 标识控件 id
166
+ JVCustomWidget textWidget = JVCustomWidget(text_widgetId, JVCustomWidgetType.textView);
167
+ textWidget.title = "新加 text view 控件";
168
+ textWidget.left = 20;
169
+ textWidget.top = 360 ;
170
+ textWidget.width = 200;
171
+ textWidget.height = 40;
172
+ textWidget.backgroundColor = Colors.yellow.value;
173
+ textWidget.isShowUnderline = true;
174
+ textWidget.textAlignment = JVTextAlignmentType.center;
175
+ textWidget.isClickEnable = true;
176
+
177
+ // 添加点击事件监听
178
+ jverify.addClikWidgetEventListener(text_widgetId, (eventId) {
179
+ print("receive listener - click widget event :$eventId");
180
+ if (text_widgetId == eventId) {
181
+ print("receive listener - 点击【新加 text】");
182
+ }
183
+ });
184
+ widgetList.add(textWidget);
185
+
186
+ final String btn_widgetId = "jv_add_custom_button";// 标识控件 id
187
+ JVCustomWidget buttonWidget = JVCustomWidget(btn_widgetId, JVCustomWidgetType.button);
188
+ buttonWidget.title = "新加 button 控件";
189
+ buttonWidget.left = 100;
190
+ buttonWidget.top = 400;
191
+ buttonWidget.width = 150;
192
+ buttonWidget.height = 40;
193
+ buttonWidget.isShowUnderline = true;
194
+ buttonWidget.backgroundColor = Colors.brown.value;
195
+ //buttonWidget.btnNormalImageName = "";
196
+ //buttonWidget.btnPressedImageName = "";
197
+ //buttonWidget.textAlignment = JVTextAlignmentType.left;
198
+
199
+ // 添加点击事件监听
200
+ jverify.addClikWidgetEventListener(btn_widgetId, (eventId) {
201
+ print("receive listener - click widget event :$eventId");
202
+ if (btn_widgetId == eventId) {
203
+ print("receive listener - 点击【新加 button】");
204
+ }
205
+ });
206
+ widgetList.add(buttonWidget);
207
+ */
78
208
79
- /// 步骤 1:调用接口设置 UI
80
- jverify.setCustomAuthorizationView(true, uiConfig, landscapeConfig: uiConfig);
81
-
82
- /// 步骤 2:调用一键登录接口
83
-
84
- /// 方式一:使用同步接口 (如果想使用异步接口,则忽略此步骤,看方式二)
85
- /// 先,添加 loginAuthSyncApi 接口回调的监听
86
- jverify.addLoginAuthCallBackListener((event){
87
- setState(() {
88
- _loading = false;
89
- _result = "监听获取返回数据:[${event.code}] message = ${event.message}";
90
- });
91
- print("通过添加监听,获取到 loginAuthSyncApi 接口返回数据,code=${event.code},message = ${event.message},operator = ${event.operator}");
92
- });
93
- /// 再,执行同步的一键登录接口
94
- jverify.loginAuthSyncApi(autoDismiss: true);
95
-
96
- /*
97
- /// 方式二:使用异步接口 (如果想使用同步接口,则忽略此步骤,看方式一)
98
-
99
- /// 先,执行异步的一键登录接口
100
- jverify.loginAuth(true).then((map) {
101
-
102
- /// 再,在回调里获取 loginAuth 接口异步返回数据(如果是通过添加 JVLoginAuthCallBackListener 监听来获取返回数据,则忽略此步骤)
103
- int code = map[f_code_key];
104
- String content = map[f_msg_key];
105
- String operator = map[f_opr_key];
106
- setState(() {
107
- _loading = false;
108
- _result = "接口异步返回数据:[$code] message = $content";
109
- });
110
- print("通过接口异步返回,获取到 loginAuth 接口返回数据,code=$code,message = $content,operator = $operator");
111
- });
112
- */
113
-
209
+
210
+ /* 弹框模式
211
+ JVPopViewConfig popViewConfig = JVPopViewConfig();
212
+ popViewConfig.width = (screenWidth - 100.0).toInt();
213
+ popViewConfig.height = (screenHeight - 150.0).toInt();
214
+
215
+ uiConfig.popViewConfig = popViewConfig;
216
+ */
217
+
218
+
219
+ /// 步骤 1:调用接口设置 UI
220
+ jverify.setCustomAuthorizationView(true, uiConfig, landscapeConfig: uiConfig);
221
+
222
+ /// 步骤 2:调用一键登录接口
223
+
224
+ /// 方式一:使用同步接口 (如果想使用异步接口,则忽略此步骤,看方式二)
225
+ /// 先,添加 loginAuthSyncApi 接口回调的监听
226
+ jverify.addLoginAuthCallBackListener((event){
227
+ setState(() {
228
+ _loading = false;
229
+ _result = "监听获取返回数据:[${event.code}] message = ${event.message}";
230
+ });
231
+ print("通过添加监听,获取到 loginAuthSyncApi 接口返回数据,code=${event.code},message = ${event.message},operator = ${event.operator}");
232
+ });
233
+ /// 再,执行同步的一键登录接口
234
+ jverify.loginAuthSyncApi(autoDismiss: true);
235
+
236
+ /*
237
+
238
+ /// 方式二:使用异步接口 (如果想使用异步接口,则忽略此步骤,看方式二)
239
+
240
+ /// 先,执行异步的一键登录接口
241
+ jverify.loginAuth(true).then((map) {
242
+
243
+ /// 再,在回调里获取 loginAuth 接口异步返回数据(如果是通过添加 JVLoginAuthCallBackListener 监听来获取返回数据,则忽略此步骤)
244
+ int code = map[f_code_key];
245
+ String content = map[f_msg_key];
246
+ String operator = map[f_opr_key];
247
+ setState(() {
248
+ _loading = false;
249
+ _result = "接口异步返回数据:[$code] message = $content";
250
+ });
251
+ print("通过接口异步返回,获取到 loginAuth 接口返回数据,code=$code,message = $content,operator = $operator");
252
+ });
253
+
254
+ */
114
255
```
115
256
116
257
#### setCustomAuthorizationView
0 commit comments