Browse Source

更新协议显示

tags/0.0.2+8
Weller 4 years ago
parent
commit
7d25fda292
4 changed files with 111 additions and 74 deletions
  1. +1
    -1
      .dart_tool/package_config.json
  2. +45
    -25
      lib/dialog/global_dialog/policy_dialog/policy_confirm_dialog.dart
  3. +58
    -42
      lib/dialog/global_dialog/policy_dialog/policy_dialog.dart
  4. +7
    -6
      lib/pages/home_page/home_page.dart

+ 1
- 1
.dart_tool/package_config.json View File

@@ -650,7 +650,7 @@
"languageVersion": "2.8"
}
],
"generated": "2020-11-17T09:51:34.034604Z",
"generated": "2020-11-18T05:43:02.817433Z",
"generator": "pub",
"generatorVersion": "2.8.2"
}

+ 45
- 25
lib/dialog/global_dialog/policy_dialog/policy_confirm_dialog.dart View File

@@ -1,25 +1,12 @@
import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/dialog/global_dialog/policy_dialog/policy_dialog_model.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class PolicyConfirmDialog extends StatefulWidget {
@override
_PolicyConfirmDialogState createState() => _PolicyConfirmDialogState();
}
class PolicyConfirmDialog extends StatelessWidget {
final PolicyDialogModel model;

class _PolicyConfirmDialogState extends State<PolicyConfirmDialog> {
@override
Widget build(BuildContext context) {
return _PolicyConfirmDialogContainer();
}
}
const PolicyConfirmDialog(this.model, {Key key}) : super(key: key);

class _PolicyConfirmDialogContainer extends StatefulWidget {
@override
_PolicyConfirmDialogContainerState createState() =>
_PolicyConfirmDialogContainerState();
}

class _PolicyConfirmDialogContainerState
extends State<_PolicyConfirmDialogContainer> {
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -34,12 +21,21 @@ class _PolicyConfirmDialogContainerState
child: Column(
children: <Widget>[
Text(
'温馨提示',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
model?.title ?? '',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: HexColor.fromHex(model?.titleColor ?? '#333333')),
),
Padding(
padding: const EdgeInsets.only(top: 8.0, bottom: 8.0),
child: Text('若得不到您的同意,我们将无法继续为您服务哦,您要不要在想想?'),
child: Text(
model?.content ?? '',
style: TextStyle(
fontSize: 12,
color: HexColor.fromHex(model?.contentColor ?? '#555555'),
),
),
),
Row(
children: <Widget>[
@@ -50,8 +46,20 @@ class _PolicyConfirmDialogContainerState
},
child: Container(
height: 36,
color: Colors.redAccent,
child: Text('仍不同意'),
child: Center(
child: Text(
model?.leftBfnText ?? '',
style: TextStyle(
color: HexColor.fromHex(
model?.leftBfnTextColor ?? '')),
),
),
decoration: BoxDecoration(
color: HexColor.fromHex(
model?.leftBfnBgColor ?? '#ffffff'),
borderRadius: BorderRadius.circular(18),
border: Border.all(
color: Color(0xffd8d8d8), width: 1)),
),
),
),
@@ -65,10 +73,22 @@ class _PolicyConfirmDialogContainerState
},
child: Container(
height: 36,
color: Colors.redAccent,
child: Center(
child: Text(
model?.rightBfnText ?? '',
style: TextStyle(
color: HexColor.fromHex(
model?.rightBfnTextColor ?? '')),
),
),
decoration: BoxDecoration(
color:
HexColor.fromHex(model?.rightBfnBgColor ?? ''),
borderRadius: BorderRadius.circular(18),
),
),
),
)
),
],
)
],


+ 58
- 42
lib/dialog/global_dialog/policy_dialog/policy_dialog.dart View File

@@ -12,9 +12,9 @@ class PolicyDialog extends StatefulWidget {

static Future<bool> show(BuildContext context) async {
Map json =
await NetUtil.post('/api/v1/app/permissions', method: NetMethod.GET);
await NetUtil.post('/api/v1/app/permissions', method: NetMethod.GET);
PolicyDialogModel model =
PolicyDialogModel.fromJson(Map<String, dynamic>.from(json['data']));
PolicyDialogModel.fromJson(Map<String, dynamic>.from(json['data']));
bool agree = null;
while (agree == null) {
agree = await showCupertinoDialog(
@@ -26,7 +26,8 @@ class PolicyDialog extends StatefulWidget {
bool accept = null;
while (accept == null) {
accept = await showCupertinoDialog(
context: context, builder: (_) => PolicyConfirmDialog());
context: context,
builder: (_) => PolicyConfirmDialog(model.subDialog));
}
return accept;
}
@@ -83,7 +84,7 @@ class _PolicyDialogState extends State<PolicyDialog> {
widget.model?.leftBfnBgColor ?? '#ffffff'),
borderRadius: BorderRadius.circular(18),
border:
Border.all(color: Color(0xffd8d8d8), width: 1)),
Border.all(color: Color(0xffd8d8d8), width: 1)),
),
),
),
@@ -123,47 +124,62 @@ class _PolicyDialogState extends State<PolicyDialog> {
}

Widget _createText() {
String content = widget.model?.content ?? '';
Map<int, PolicyItemModel> replaces = Map();
List<int> indexs = List();
widget.model?.selectedText?.forEach((replace) {
int index = content.indexOf(replace.key);
indexs.add(index);
replaces[index] = replace;
// Logger.debug(replace.key);
});
// 倒序,从后面开始替换
indexs.sort((a, b) {
return b.compareTo(a);
});
List<TextSpan> texts = List();
int end = content.length - 1;
for (int index in indexs) {
// Logger.debug(index);
PolicyItemModel replace = replaces[index];
texts.insert(0,
TextSpan(
text: content.substring(index + replace.key.length, end),
),
);
texts.insert(0,
TextSpan(
text: replace?.text ?? '',
recognizer: TapGestureRecognizer()
..onTap = () {
NativeUtil.openUrl(context, replace?.url ?? '');
},
style: TextStyle(
color: HexColor.fromHex(widget.model?.selectedColor ?? '#FF4242'),
),
),
);
end = index;
}
if (end != 0) {
texts.insert(0,
TextSpan(
text: content.substring(0, end),
),
);
}

return RichText(
textAlign: TextAlign.left,
text: TextSpan(
text: '',
style: TextStyle(
height: 1.2,
fontSize: 12,
color: HexColor.fromHex('#555555'),
),
children: [
TextSpan(
text: '亲爱的用户,感谢您对智莺生活的信任!\n\n我们根据最新的监管政策要求,我们更新了',
),
TextSpan(
text: '《用户协议》',
recognizer: TapGestureRecognizer()
..onTap = () {
NativeUtil.openUrl(context, 'http://www.baidu.com');
},
style: TextStyle(
color: HexColor.fromHex('#FF4242'),
),
),
TextSpan(
text: '和',
),
TextSpan(
text: '《隐私权政策》',
style: TextStyle(
color: HexColor.fromHex('#FF4242'),
),
recognizer: TapGestureRecognizer()
..onTap = () {
NativeUtil.openUrl(context, 'http://www.baidu.com');
},
),
TextSpan(
text:
',请您在点击「同意」之前仔细阅读并充分理解。\n\n为了提供更好的服务,我们在特此说明:\n\n1.在您授权通过的情况下,我们将获取您的设备、位置等信息。您有权拒绝或取消授权;\n\n2.系统的安全保障措施,会严密的保护您的个人信息;\n\n3.未经您本人授权同意,我们不会从任何第三方处获取您的信息,也不会预期分享您的信息。',
),
]),
text: '',
style: TextStyle(
height: 1.2,
fontSize: 12,
color: HexColor.fromHex('#555555'),
),
children: texts,
),
);
}
}

+ 7
- 6
lib/pages/home_page/home_page.dart View File

@@ -11,6 +11,7 @@ import 'package:zhiying_base_widget/dialog/global_dialog/policy_dialog/policy_di
import 'package:zhiying_base_widget/utils/contants.dart';
import 'package:zhiying_comm/models/base/base_tab_model.dart';
import 'package:zhiying_comm/util/image_util.dart';
import 'package:zhiying_comm/util/shared_prefe_util.dart';
import 'package:zhiying_comm/util/update/app_update_util.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

@@ -41,12 +42,12 @@ class _HomePageState extends State<HomePage> {
AppUpdateUtil.updateApp(context);
TaobaoAuth.initAuth(context);

// SharedPreferencesUtil.getStringValue(Constants.isShowPolicy).then((value) {
// Logger.debug(value);
// if (value == null || value == '') {
// _showPolicy();
// }
// });
SharedPreferencesUtil.getStringValue(Constants.isShowPolicy).then((value) {
Logger.debug(value);
if (value == null || value == '') {
_showPolicy();
}
});

super.initState();
}


Loading…
Cancel
Save