|
|
@@ -11,8 +11,8 @@ class PolicyDialog extends StatefulWidget { |
|
|
|
const PolicyDialog(this.model, {Key key}) : super(key: key); |
|
|
|
|
|
|
|
static Future<bool> show(BuildContext context) async { |
|
|
|
Map json = |
|
|
|
await NetUtil.post('/api/v1/app/permissions', method: NetMethod.GET); |
|
|
|
// 旧接口:/api/v1/app/permissions |
|
|
|
Map json = await NetUtil.post('/api/v1/app/new_permissions', method: NetMethod.GET); |
|
|
|
PolicyDialogModel model = |
|
|
|
PolicyDialogModel.fromJson(Map<String, dynamic>.from(json['data'])); |
|
|
|
bool agree = null; |
|
|
@@ -58,7 +58,7 @@ class _PolicyDialogState extends State<PolicyDialog> { |
|
|
|
child: Padding( |
|
|
|
padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), |
|
|
|
child: SingleChildScrollView( |
|
|
|
child: _createText(), |
|
|
|
child: _createNewText(), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
@@ -123,6 +123,55 @@ class _PolicyDialogState extends State<PolicyDialog> { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
/// 新的替换方法 |
|
|
|
Widget _createNewText() { |
|
|
|
String content = widget.model?.content ?? ''; |
|
|
|
List<TextSpan> texts = List(); |
|
|
|
if (!EmptyUtil.isEmpty(content)) { |
|
|
|
// 需要替换 |
|
|
|
if (!EmptyUtil.isEmpty(widget?.model?.selectedText)) { |
|
|
|
widget.model.selectedText.forEach((item) { |
|
|
|
// 切割关键字不等于null,并且content内有找到切割关键字才进行操作 |
|
|
|
if (!EmptyUtil.isEmpty(item?.key) && content.indexOf(item.key) != -1) { |
|
|
|
List<String> tempArr = content.split(item.key); |
|
|
|
if (!EmptyUtil.isEmpty(tempArr) && tempArr.length == 2) { |
|
|
|
// step1、普通文字 |
|
|
|
texts.add(TextSpan(text: tempArr[0])); |
|
|
|
// step2、点击链接 |
|
|
|
texts.add(TextSpan( |
|
|
|
text: item?.text ?? '', |
|
|
|
recognizer: TapGestureRecognizer() |
|
|
|
..onTap = () { |
|
|
|
NativeUtil.openUrl(context, item?.url ?? ''); |
|
|
|
}, |
|
|
|
style: TextStyle(color: HexColor.fromHex(widget.model?.selectedColor ?? '#FF4242')), |
|
|
|
)); |
|
|
|
// step3、更新切割后的数据 |
|
|
|
content = tempArr[1]; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
// 无需替换 |
|
|
|
texts.add(TextSpan( |
|
|
|
text: content |
|
|
|
)); |
|
|
|
} |
|
|
|
} |
|
|
|
return EmptyUtil.isEmpty(texts) ? Container() : RichText( |
|
|
|
textAlign: TextAlign.left, |
|
|
|
text: TextSpan( |
|
|
|
text: '', |
|
|
|
style: TextStyle( |
|
|
|
height: 1.2, |
|
|
|
fontSize: 14, |
|
|
|
color: HexColor.fromHex('#555555'), |
|
|
|
), |
|
|
|
children: texts), |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
// 弃用 |
|
|
|
Widget _createText() { |
|
|
|
String content = widget.model?.content ?? ''; |
|
|
|
Map<int, PolicyItemModel> replaces = Map(); |
|
|
|