@@ -405,7 +405,7 @@ | |||||
}, | }, | ||||
{ | { | ||||
"name": "pull_to_refresh", | "name": "pull_to_refresh", | ||||
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/pull_to_refresh-1.6.2", | |||||
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/pull_to_refresh-1.6.3", | |||||
"packageUri": "lib/", | "packageUri": "lib/", | ||||
"languageVersion": "2.1" | "languageVersion": "2.1" | ||||
}, | }, | ||||
@@ -650,7 +650,7 @@ | |||||
"languageVersion": "2.8" | "languageVersion": "2.8" | ||||
} | } | ||||
], | ], | ||||
"generated": "2020-11-16T07:14:17.614805Z", | |||||
"generated": "2020-11-17T09:51:34.034604Z", | |||||
"generator": "pub", | "generator": "pub", | ||||
"generatorVersion": "2.8.2" | "generatorVersion": "2.8.2" | ||||
} | } |
@@ -1,25 +1,41 @@ | |||||
import 'package:flutter/cupertino.dart'; | |||||
import 'package:flutter/gestures.dart'; | import 'package:flutter/gestures.dart'; | ||||
import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
import 'package:zhiying_base_widget/dialog/global_dialog/policy_dialog/policy_confirm_dialog.dart'; | |||||
import 'package:zhiying_base_widget/dialog/global_dialog/policy_dialog/policy_dialog_model.dart'; | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | import 'package:zhiying_comm/zhiying_comm.dart'; | ||||
class PolicyDialog extends StatefulWidget { | class PolicyDialog extends StatefulWidget { | ||||
@override | |||||
_PolicyDialogState createState() => _PolicyDialogState(); | |||||
} | |||||
final PolicyDialogModel model; | |||||
class _PolicyDialogState extends State<PolicyDialog> { | |||||
@override | |||||
Widget build(BuildContext context) { | |||||
return _PolicyDialogContainer(); | |||||
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); | |||||
PolicyDialogModel model = | |||||
PolicyDialogModel.fromJson(Map<String, dynamic>.from(json['data'])); | |||||
bool agree = null; | |||||
while (agree == null) { | |||||
agree = await showCupertinoDialog( | |||||
context: context, builder: (_) => PolicyDialog(model)); | |||||
} | |||||
if (agree) { | |||||
return agree; | |||||
} | |||||
bool accept = null; | |||||
while (accept == null) { | |||||
accept = await showCupertinoDialog( | |||||
context: context, builder: (_) => PolicyConfirmDialog()); | |||||
} | |||||
return accept; | |||||
} | } | ||||
} | |||||
class _PolicyDialogContainer extends StatefulWidget { | |||||
@override | @override | ||||
_PolicyDialogContainerState createState() => _PolicyDialogContainerState(); | |||||
_PolicyDialogState createState() => _PolicyDialogState(); | |||||
} | } | ||||
class _PolicyDialogContainerState extends State<_PolicyDialogContainer> { | |||||
class _PolicyDialogState extends State<PolicyDialog> { | |||||
@override | @override | ||||
Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
return Scaffold( | return Scaffold( | ||||
@@ -34,7 +50,7 @@ class _PolicyDialogContainerState extends State<_PolicyDialogContainer> { | |||||
child: Column( | child: Column( | ||||
children: <Widget>[ | children: <Widget>[ | ||||
Text( | Text( | ||||
'温馨提示', | |||||
widget.model?.title ?? '', | |||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), | style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), | ||||
), | ), | ||||
Expanded( | Expanded( | ||||
@@ -54,7 +70,20 @@ class _PolicyDialogContainerState extends State<_PolicyDialogContainer> { | |||||
}, | }, | ||||
child: Container( | child: Container( | ||||
height: 36, | height: 36, | ||||
color: Colors.redAccent, | |||||
child: Center( | |||||
child: Text( | |||||
widget.model?.leftBfnText ?? '', | |||||
style: TextStyle( | |||||
color: HexColor.fromHex( | |||||
widget.model?.leftBfnTextColor ?? '')), | |||||
), | |||||
), | |||||
decoration: BoxDecoration( | |||||
color: HexColor.fromHex( | |||||
widget.model?.leftBfnBgColor ?? '#ffffff'), | |||||
borderRadius: BorderRadius.circular(18), | |||||
border: | |||||
Border.all(color: Color(0xffd8d8d8), width: 1)), | |||||
), | ), | ||||
), | ), | ||||
), | ), | ||||
@@ -68,10 +97,22 @@ class _PolicyDialogContainerState extends State<_PolicyDialogContainer> { | |||||
}, | }, | ||||
child: Container( | child: Container( | ||||
height: 36, | height: 36, | ||||
color: Colors.redAccent, | |||||
child: Center( | |||||
child: Text( | |||||
widget.model?.rightBfnText ?? '', | |||||
style: TextStyle( | |||||
color: HexColor.fromHex( | |||||
widget.model?.rightBfnTextColor ?? '')), | |||||
), | |||||
), | |||||
decoration: BoxDecoration( | |||||
color: HexColor.fromHex( | |||||
widget.model?.rightBfnBgColor ?? ''), | |||||
borderRadius: BorderRadius.circular(18), | |||||
), | |||||
), | ), | ||||
), | ), | ||||
) | |||||
), | |||||
], | ], | ||||
) | ) | ||||
], | ], | ||||
@@ -0,0 +1,97 @@ | |||||
class PolicyDialogModel { | |||||
String title; | |||||
String titleColor; | |||||
String content; | |||||
String contentColor; | |||||
List<PolicyItemModel> selectedText; | |||||
String selectedColor; | |||||
PolicyDialogModel subDialog; | |||||
String leftBfnText; | |||||
String leftBfnTextColor; | |||||
String leftBfnBgColor; | |||||
String rightBfnText; | |||||
String rightBfnTextColor; | |||||
String rightBfnBgColor; | |||||
PolicyDialogModel( | |||||
{this.title, | |||||
this.titleColor, | |||||
this.content, | |||||
this.contentColor, | |||||
this.selectedText, | |||||
this.selectedColor, | |||||
this.subDialog, | |||||
this.leftBfnText, | |||||
this.leftBfnTextColor, | |||||
this.leftBfnBgColor, | |||||
this.rightBfnText, | |||||
this.rightBfnTextColor, | |||||
this.rightBfnBgColor}); | |||||
PolicyDialogModel.fromJson(Map<String, dynamic> json) { | |||||
title = json['title']; | |||||
titleColor = json['title_color']; | |||||
content = json['content']; | |||||
contentColor = json['content_color']; | |||||
if (json['selected_text'] != null) { | |||||
selectedText = new List<PolicyItemModel>(); | |||||
json['selected_text'].forEach((v) { | |||||
selectedText.add(new PolicyItemModel.fromJson(v)); | |||||
}); | |||||
} | |||||
selectedColor = json['selected_color']; | |||||
subDialog = json['sub_dialog'] != null | |||||
? new PolicyDialogModel.fromJson(json['sub_dialog']) | |||||
: null; | |||||
leftBfnText = json['left_bfn_text']; | |||||
leftBfnTextColor = json['left_bfn_text_color']; | |||||
leftBfnBgColor = json['left_bfn_bg_color']; | |||||
rightBfnText = json['right_bfn_text']; | |||||
rightBfnTextColor = json['right_bfn__text_color']; | |||||
rightBfnBgColor = json['right_bfn_bg_color']; | |||||
} | |||||
Map<String, dynamic> toJson() { | |||||
final Map<String, dynamic> data = new Map<String, dynamic>(); | |||||
data['title'] = this.title; | |||||
data['title_color'] = this.titleColor; | |||||
data['content'] = this.content; | |||||
data['content_color'] = this.contentColor; | |||||
if (this.selectedText != null) { | |||||
data['selected_text'] = this.selectedText.map((v) => v.toJson()).toList(); | |||||
} | |||||
data['selected_color'] = this.selectedColor; | |||||
if (this.subDialog != null) { | |||||
data['sub_dialog'] = this.subDialog.toJson(); | |||||
} | |||||
data['left_bfn_text'] = this.leftBfnText; | |||||
data['left_bfn_text_color'] = this.leftBfnTextColor; | |||||
data['left_bfn_bg_color'] = this.leftBfnBgColor; | |||||
data['right_bfn_text'] = this.rightBfnText; | |||||
data['right_bfn__text_color'] = this.rightBfnTextColor; | |||||
data['right_bfn_bg_color'] = this.rightBfnBgColor; | |||||
return data; | |||||
} | |||||
} | |||||
class PolicyItemModel { | |||||
String key; | |||||
String text; | |||||
String url; | |||||
PolicyItemModel({this.key, this.text, this.url}); | |||||
PolicyItemModel.fromJson(Map<String, dynamic> json) { | |||||
key = json['key']; | |||||
text = json['text']; | |||||
url = json['url']; | |||||
} | |||||
Map<String, dynamic> toJson() { | |||||
final Map<String, dynamic> data = new Map<String, dynamic>(); | |||||
data['key'] = this.key; | |||||
data['text'] = this.text; | |||||
data['url'] = this.url; | |||||
return data; | |||||
} | |||||
} |
@@ -7,7 +7,6 @@ import 'package:flutter/material.dart'; | |||||
import 'package:permission_handler/permission_handler.dart'; | import 'package:permission_handler/permission_handler.dart'; | ||||
import 'package:provider/provider.dart'; | import 'package:provider/provider.dart'; | ||||
import 'package:zhiying_base_widget/dialog/global_dialog/notification_setting_dialog/notification_setting_dialog.dart'; | import 'package:zhiying_base_widget/dialog/global_dialog/notification_setting_dialog/notification_setting_dialog.dart'; | ||||
import 'package:zhiying_base_widget/dialog/global_dialog/policy_dialog/policy_confirm_dialog.dart'; | |||||
import 'package:zhiying_base_widget/dialog/global_dialog/policy_dialog/policy_dialog.dart'; | import 'package:zhiying_base_widget/dialog/global_dialog/policy_dialog/policy_dialog.dart'; | ||||
import 'package:zhiying_base_widget/utils/contants.dart'; | import 'package:zhiying_base_widget/utils/contants.dart'; | ||||
import 'package:zhiying_comm/models/base/base_tab_model.dart'; | import 'package:zhiying_comm/models/base/base_tab_model.dart'; | ||||
@@ -42,6 +41,13 @@ class _HomePageState extends State<HomePage> { | |||||
AppUpdateUtil.updateApp(context); | AppUpdateUtil.updateApp(context); | ||||
TaobaoAuth.initAuth(context); | TaobaoAuth.initAuth(context); | ||||
// SharedPreferencesUtil.getStringValue(Constants.isShowPolicy).then((value) { | |||||
// Logger.debug(value); | |||||
// if (value == null || value == '') { | |||||
// _showPolicy(); | |||||
// } | |||||
// }); | |||||
super.initState(); | super.initState(); | ||||
} | } | ||||
@@ -134,28 +140,6 @@ class _HomePageState extends State<HomePage> { | |||||
} | } | ||||
Future<bool> _checkLimit(BaseTabModel model) async { | Future<bool> _checkLimit(BaseTabModel model) async { | ||||
// bool agree = null; | |||||
// while (agree == null) { | |||||
// agree = await showCupertinoDialog( | |||||
// context: context, builder: (_) => PolicyDialog()); | |||||
// } | |||||
// if (!agree) { | |||||
// bool accept = null; | |||||
// while (accept == null) { | |||||
// accept = await showCupertinoDialog( | |||||
// context: context, builder: (_) => PolicyConfirmDialog()); | |||||
// } | |||||
// if (!accept) { | |||||
// exit(0); | |||||
// } | |||||
// } | |||||
// | |||||
// PermissionStatus status = await Permission.notification.status; | |||||
// if (status != PermissionStatus.granted) { | |||||
// await showCupertinoDialog( | |||||
// context: context, builder: (_) => NotificationSettingDialog()); | |||||
// } | |||||
if (model.requiredLogin == '1') { | if (model.requiredLogin == '1') { | ||||
UserInfoModel user = | UserInfoModel user = | ||||
await Provider.of<UserInfoNotifier>(context, listen: false) | await Provider.of<UserInfoNotifier>(context, listen: false) | ||||
@@ -169,4 +153,17 @@ class _HomePageState extends State<HomePage> { | |||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
void _showPolicy() async { | |||||
bool isAccept = await PolicyDialog.show(context); | |||||
if (!isAccept) { | |||||
exit(0); | |||||
} | |||||
PermissionStatus status = await Permission.notification.status; | |||||
if (status != PermissionStatus.granted) { | |||||
await showCupertinoDialog( | |||||
context: context, builder: (_) => NotificationSettingDialog()); | |||||
} | |||||
} | |||||
} | } |
@@ -4,15 +4,23 @@ import 'package:flutter/material.dart'; | |||||
class Constants { | class Constants { | ||||
///获取模块类型 | ///获取模块类型 | ||||
static const String SkipIdentifierName = "skip_identifier"; | static const String SkipIdentifierName = "skip_identifier"; | ||||
///全局context | ///全局context | ||||
//==============================智能粘贴版===================================start | //==============================智能粘贴版===================================start | ||||
static BuildContext context; | static BuildContext context; | ||||
///智能搜索版是否弹起 | ///智能搜索版是否弹起 | ||||
static bool isShowIntellectDialog=false; | |||||
static bool isShowIntellectDialog = false; | |||||
///是否缓存设置信息 | ///是否缓存设置信息 | ||||
static String spIsCacheSetModel="spIsCacheSetModel"; | |||||
static String spIsCacheSetModel = "spIsCacheSetModel"; | |||||
//==============================智能粘贴版===================================end | //==============================智能粘贴版===================================end | ||||
//==============================用户协议===================================start | |||||
///用户协议显示 | |||||
static String isShowPolicy = "is_show_policy"; | |||||
//==============================用户协议===================================end | |||||
} | } |