|
|
@@ -6,6 +6,7 @@ import 'package:flutter/cupertino.dart'; |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:permission_handler/permission_handler.dart'; |
|
|
|
import 'package:provider/provider.dart'; |
|
|
|
import 'package:zhiying_base_widget/dialog/global_dialog/intellect_search_goods_dialog/intellect_create.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_dialog.dart'; |
|
|
|
import 'package:zhiying_base_widget/utils/contants.dart'; |
|
|
@@ -22,12 +23,13 @@ class HomePage extends StatefulWidget { |
|
|
|
_HomePageState createState() => _HomePageState(); |
|
|
|
} |
|
|
|
|
|
|
|
class _HomePageState extends State<HomePage> { |
|
|
|
class _HomePageState extends State<HomePage> with WidgetsBindingObserver { |
|
|
|
int _currentIndex = 0; |
|
|
|
List<Map<String, dynamic>> _data = List(); |
|
|
|
|
|
|
|
@override |
|
|
|
void initState() { |
|
|
|
WidgetsBinding.instance.addObserver(this); |
|
|
|
String data = BaseSettingModel.setting.tab['data']; |
|
|
|
try { |
|
|
|
List list = convert.jsonDecode(data); |
|
|
@@ -42,19 +44,23 @@ 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(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
_showPolicy(); |
|
|
|
super.initState(); |
|
|
|
} |
|
|
|
|
|
|
|
@override |
|
|
|
void didChangeDependencies() { |
|
|
|
super.didChangeDependencies(); |
|
|
|
void dispose() { |
|
|
|
WidgetsBinding.instance.removeObserver(this); |
|
|
|
super.dispose(); |
|
|
|
} |
|
|
|
|
|
|
|
@override |
|
|
|
void didChangeAppLifecycleState(AppLifecycleState state) async { |
|
|
|
///智能粘贴板 |
|
|
|
|
|
|
|
IntellectCreate.checkAndCreate(state, context); |
|
|
|
|
|
|
|
super.didChangeAppLifecycleState(state); |
|
|
|
} |
|
|
|
|
|
|
|
@override |
|
|
@@ -155,10 +161,18 @@ class _HomePageState extends State<HomePage> { |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
void _showPolicy() async { |
|
|
|
bool isAccept = await PolicyDialog.show(context); |
|
|
|
if (!isAccept) { |
|
|
|
exit(0); |
|
|
|
Future _showPolicy() async { |
|
|
|
String isShowPolicy = |
|
|
|
await SharedPreferencesUtil.getStringValue(Constants.isShowPolicy); |
|
|
|
isShowPolicy = ''; |
|
|
|
Logger.debug(isShowPolicy); |
|
|
|
if (isShowPolicy == null || isShowPolicy != '1') { |
|
|
|
bool isAccept = await PolicyDialog.show(context); |
|
|
|
if (!isAccept) { |
|
|
|
exit(0); |
|
|
|
} else { |
|
|
|
await SharedPreferencesUtil.setStringValue(Constants.isShowPolicy, "1"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
PermissionStatus status = await Permission.notification.status; |
|
|
@@ -166,5 +180,7 @@ class _HomePageState extends State<HomePage> { |
|
|
|
await showCupertinoDialog( |
|
|
|
context: context, builder: (_) => NotificationSettingDialog()); |
|
|
|
} |
|
|
|
|
|
|
|
IntellectCreate.checkAndCreateFirst(context); |
|
|
|
} |
|
|
|
} |