|
|
|
@ -1,22 +1,15 @@
|
|
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
|
|
import 'package:bot_toast/bot_toast.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_background_service/flutter_background_service.dart';
|
|
|
|
|
import 'package:package_info/package_info.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter_xupdate/flutter_xupdate.dart';
|
|
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
|
import 'package:project_telephony/ui/home/content_connect_page.dart';
|
|
|
|
|
import 'package:project_telephony/ui/home/content_refuse_page.dart';
|
|
|
|
|
import 'package:project_telephony/ui/home/set/phone_set_page.dart';
|
|
|
|
|
import 'package:project_telephony/ui/user/privacy_rights_page.dart';
|
|
|
|
|
import 'package:project_telephony/ui/widget/appdialog.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:project_telephony/ui/widget/plone_bottom.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:project_telephony/utils/headers.dart';
|
|
|
|
|
|
|
|
|
|
import '../tab_navigator.dart';
|
|
|
|
|
import '../../utils/toast/cloud_toast.dart';
|
|
|
|
|
import '../user/privacy_rights_page.dart';
|
|
|
|
|
|
|
|
|
|
class HomePage extends StatefulWidget {
|
|
|
|
@ -28,7 +21,7 @@ class HomePage extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
bool sms = false;
|
|
|
|
|
bool plone = false;
|
|
|
|
|
bool addressBook=false;
|
|
|
|
|
bool addressBook = false;
|
|
|
|
|
bool kg = false;
|
|
|
|
|
|
|
|
|
|
final service = FlutterBackgroundService();
|
|
|
|
@ -38,6 +31,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
initXUpdate();
|
|
|
|
|
//页面初始化的时候,添加一个状态的监听者
|
|
|
|
|
WidgetsBinding.instance.addObserver(this);
|
|
|
|
|
_listenForPermissionStatus();
|
|
|
|
@ -55,11 +49,52 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
|
|
|
|
|
sms = await Permission.sms.request().isGranted;
|
|
|
|
|
plone = await Permission.phone.request().isGranted;
|
|
|
|
|
callLog = await Permission.callLog.request().isGranted;
|
|
|
|
|
addressBook= await Permission.contacts.request().isGranted;
|
|
|
|
|
addressBook = await Permission.contacts.request().isGranted;
|
|
|
|
|
kg = await service.isRunning();
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///初始化
|
|
|
|
|
void initXUpdate() {
|
|
|
|
|
FlutterXUpdate.init(
|
|
|
|
|
|
|
|
|
|
///是否输出日志
|
|
|
|
|
debug: true,
|
|
|
|
|
|
|
|
|
|
///是否使用post请求
|
|
|
|
|
isPost: false,
|
|
|
|
|
|
|
|
|
|
///post请求是否是上传json
|
|
|
|
|
isPostJson: false,
|
|
|
|
|
|
|
|
|
|
///请求响应超时时间
|
|
|
|
|
timeout: 25000,
|
|
|
|
|
|
|
|
|
|
///是否开启自动模式
|
|
|
|
|
isWifiOnly: false,
|
|
|
|
|
|
|
|
|
|
///是否开启自动模式
|
|
|
|
|
isAutoMode: false,
|
|
|
|
|
|
|
|
|
|
///需要设置的公共参数
|
|
|
|
|
supportSilentInstall: false,
|
|
|
|
|
|
|
|
|
|
///在下载过程中,如果点击了取消的话,是否弹出切换下载方式的重试提示弹窗
|
|
|
|
|
enableRetry: false)
|
|
|
|
|
.then((value) {
|
|
|
|
|
// CloudToast.show("初始化成功: $value");
|
|
|
|
|
}).catchError((error) {
|
|
|
|
|
print(error);
|
|
|
|
|
});
|
|
|
|
|
// FlutterXUpdate.setErrorHandler(
|
|
|
|
|
// onUpdateError: (Map<String, dynamic> message) async {
|
|
|
|
|
// print(message);
|
|
|
|
|
// setState(() {
|
|
|
|
|
// _message = "$message";
|
|
|
|
|
// });
|
|
|
|
|
// });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
@ -124,7 +159,6 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
|
|
|
|
|
// }
|
|
|
|
|
_warning() {
|
|
|
|
|
return Offstage(
|
|
|
|
|
|
|
|
|
|
offstage: (sms && plone && callLog && addressBook && kg),
|
|
|
|
|
child: GestureDetector(
|
|
|
|
|
onTap: () {
|
|
|
|
@ -212,13 +246,12 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
|
|
|
|
|
|
|
|
|
|
_getSet() {
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
onTap: (){
|
|
|
|
|
onTap: () {
|
|
|
|
|
Navigator.of(context)
|
|
|
|
|
.push(
|
|
|
|
|
MaterialPageRoute(builder: (_) => const PhoneSetPage()),
|
|
|
|
|
)
|
|
|
|
|
.then((val) => _listenForPermissionStatus());
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
child: Container(
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 42.w, vertical: 20.w),
|
|
|
|
@ -236,7 +269,8 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
|
|
|
|
|
16.wb,
|
|
|
|
|
Text(
|
|
|
|
|
"短信发送号码设置",
|
|
|
|
|
style: TextStyle(fontSize: 28.sp, color: const Color(0xFF1890FF)),
|
|
|
|
|
style:
|
|
|
|
|
TextStyle(fontSize: 28.sp, color: const Color(0xFF1890FF)),
|
|
|
|
|
),
|
|
|
|
|
190.wb,
|
|
|
|
|
SizedBox(
|
|
|
|
@ -249,26 +283,29 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// void checkUpdateDefault() {
|
|
|
|
|
// FlutterXUpdate.checkUpdate(url: 'https://gitee.com/xuexiangjys/XUpdate/raw/master/jsonapi/update_test.json');
|
|
|
|
|
// }
|
|
|
|
|
_getContainer(String title, String text, String image, Color cl1, Color cl2) {
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
|
|
|
|
|
onTap: () async{
|
|
|
|
|
onTap: () async {
|
|
|
|
|
FlutterXUpdate.checkUpdate(
|
|
|
|
|
url:'');
|
|
|
|
|
// PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
|
|
|
|
// String version = packageInfo.version;//版本号
|
|
|
|
|
// String buildNumber = packageInfo.buildNumber;//版本构建号
|
|
|
|
|
// print(version);
|
|
|
|
|
// print(buildNumber);
|
|
|
|
|
// print(title);
|
|
|
|
|
if (title == "接听后") {
|
|
|
|
|
Get.to(() => const ContentConnectPage());
|
|
|
|
|
} else {
|
|
|
|
|
Get.to(() => const ContentRefusePage());
|
|
|
|
|
// print("未接听");
|
|
|
|
|
}
|
|
|
|
|
// if (title == "接听后") {
|
|
|
|
|
// Get.to(() => const ContentConnectPage());
|
|
|
|
|
// } else {
|
|
|
|
|
// Get.to(() => const ContentRefusePage());
|
|
|
|
|
// // print("未接听");
|
|
|
|
|
// }
|
|
|
|
|
},
|
|
|
|
|
child: Container(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|