|
|
|
|
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:permission_handler/permission_handler.dart';
|
|
|
|
|
import 'package:project_telephony/ui/home/set/func/user_info_func.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/utils/headers.dart';
|
|
|
|
|
import 'package:project_telephony/utils/user_tool.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
|
|
|
|
|
|
import '../../providers/user_provider.dart';
|
|
|
|
|
import '../user/content_details_page.dart';
|
|
|
|
|
import '../user/privacy_rights_page.dart';
|
|
|
|
|
|
|
|
|
|
class HomePage extends StatefulWidget {
|
|
|
|
|
const HomePage({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_HomePageState createState() => _HomePageState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool sms = false;
|
|
|
|
|
bool plone = false;
|
|
|
|
|
bool addressBook = false;
|
|
|
|
|
bool kg = false;
|
|
|
|
|
final service = FlutterBackgroundService();
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
getUpdate();
|
|
|
|
|
// initXUpdate();
|
|
|
|
|
//页面初始化的时候,添加一个状态的监听者
|
|
|
|
|
WidgetsBinding.instance.addObserver(this);
|
|
|
|
|
Future.delayed(const Duration(milliseconds: 500),(){
|
|
|
|
|
_listenForPermissionStatus();
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
super.dispose();
|
|
|
|
|
//页面销毁时移出监听者
|
|
|
|
|
WidgetsBinding.instance.removeObserver(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> _listenForPermissionStatus() async {
|
|
|
|
|
sms = await Permission.sms.request().isGranted;
|
|
|
|
|
plone = await Permission.phone.request().isGranted;
|
|
|
|
|
callLog = await Permission.callLog.request().isGranted;
|
|
|
|
|
addressBook = await Permission.contacts.request().isGranted;
|
|
|
|
|
kg = await service.isRunning();
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getUpdate() async {
|
|
|
|
|
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
|
|
|
|
// String version = packageInfo.version; //版本号
|
|
|
|
|
String buildNumber = packageInfo.buildNumber; //版本构建号
|
|
|
|
|
var res = await UserInfoFunc.getUpdate();
|
|
|
|
|
// print("版本号$version");
|
|
|
|
|
// print('版本构建号$buildNumber');
|
|
|
|
|
// print("服务器上的${res.versionCode}");
|
|
|
|
|
// print("服务器上的${res.versionName}");
|
|
|
|
|
if (int.parse(res.versionCode )> int.parse(buildNumber)) {
|
|
|
|
|
// CloudToast.show("是否进行版本更新");
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (context) {
|
|
|
|
|
return AlertDialog(
|
|
|
|
|
title: const Text("版本更新"),
|
|
|
|
|
content: Text(res.modifyContent),
|
|
|
|
|
actions: [
|
|
|
|
|
_getBox('跳转官网下载', () async {
|
|
|
|
|
await launchUrl(Uri.parse('https://www.dxbs.vip/dxbs.apk'),
|
|
|
|
|
mode: LaunchMode.externalApplication);
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
}),
|
|
|
|
|
_getBox('取消', () {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_getBox(String text, VoidCallback ontap) {
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
onTap: ontap,
|
|
|
|
|
// () async {
|
|
|
|
|
// await launchUrl(Uri.parse('https://www.dxbs.vip/dxbs.apk'),
|
|
|
|
|
// mode: LaunchMode.externalApplication);
|
|
|
|
|
// Navigator.of(context).pop();
|
|
|
|
|
// },
|
|
|
|
|
child: Container(
|
|
|
|
|
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal:24.w, vertical: 24.w),
|
|
|
|
|
margin: EdgeInsets.symmetric(horizontal: 20.w, vertical: 8.w),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(8.w),
|
|
|
|
|
color: const Color(0xFF1890FF)),
|
|
|
|
|
child: Container(
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
width: 175.w,
|
|
|
|
|
child: Text(
|
|
|
|
|
text,
|
|
|
|
|
style:
|
|
|
|
|
const TextStyle(color: Colors.white, fontWeight: FontWeight.w600),
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
extendBodyBehindAppBar: true,
|
|
|
|
|
extendBody: true,
|
|
|
|
|
body: SafeArea(
|
|
|
|
|
child: Stack(
|
|
|
|
|
// fit: StackFit.expand,
|
|
|
|
|
children: [
|
|
|
|
|
Positioned(
|
|
|
|
|
top: 10.w,
|
|
|
|
|
child:
|
|
|
|
|
// Container(
|
|
|
|
|
// height: 722.w,
|
|
|
|
|
// width: 722.w,
|
|
|
|
|
// decoration: BoxDecoration(image: DecorationImage(image:AssetImage(Assets.images.homeBg.path),fit:BoxFit.fill)),
|
|
|
|
|
// child: _warning(),)
|
|
|
|
|
Image.asset(
|
|
|
|
|
Assets.images.homeBg.path,
|
|
|
|
|
height: 722.w,
|
|
|
|
|
width: 722.w,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Positioned(top: 48.w, child: _warning()),
|
|
|
|
|
// Positioned(child: PloneBottom(onTap: (){
|
|
|
|
|
// showDialog(context: context, builder: (context){
|
|
|
|
|
// return const AppDialog();
|
|
|
|
|
// });
|
|
|
|
|
//
|
|
|
|
|
// })),
|
|
|
|
|
Positioned(bottom: 64.w, child: _getBody()),
|
|
|
|
|
Align(
|
|
|
|
|
child: SizedBox(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: 1600.w,
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// bool _getPermissions() {
|
|
|
|
|
// if(sms && plone){
|
|
|
|
|
// return true;
|
|
|
|
|
// }else{
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// String _text(){
|
|
|
|
|
// if(!(sms && plone && callLog && kg)){
|
|
|
|
|
// if(!(sms && plone && callLog )){
|
|
|
|
|
// return "";
|
|
|
|
|
// // return "必须权限没有授予,本APP无法正常使用";
|
|
|
|
|
// }if(!kg){
|
|
|
|
|
// return "功能开关未开启";
|
|
|
|
|
// }
|
|
|
|
|
// }else{
|
|
|
|
|
// return "";
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
_warning() {
|
|
|
|
|
return Offstage(
|
|
|
|
|
offstage: (sms && plone && callLog && addressBook && kg),
|
|
|
|
|
child: GestureDetector(
|
|
|
|
|
onTap: () {
|
|
|
|
|
if (!(sms && plone && callLog && addressBook && kg)) {
|
|
|
|
|
if (!(sms && plone && callLog && addressBook)) {
|
|
|
|
|
Get.to(() => const PrivacyRightsPage(name: "权限说明"));
|
|
|
|
|
// Get.to(()=>const TabNavigator(index: 1,));
|
|
|
|
|
} else {
|
|
|
|
|
BotToast.showText(text: '功能开关未开启');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// openAppSettings();
|
|
|
|
|
},
|
|
|
|
|
child: Container(
|
|
|
|
|
width: 622.w,
|
|
|
|
|
margin: EdgeInsets.symmetric(horizontal: 64.w),
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 20.w),
|
|
|
|
|
height: 88.w,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(8.w),
|
|
|
|
|
color: const Color(0xFFFFF2F2),
|
|
|
|
|
border: Border.all(width: 1.w, color: const Color(0xFFFFC8C8))),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Image(
|
|
|
|
|
image: AssetImage(Assets.icons.horn.path),
|
|
|
|
|
width: 48.w,
|
|
|
|
|
height: 48.w,
|
|
|
|
|
),
|
|
|
|
|
16.wb,
|
|
|
|
|
Text(
|
|
|
|
|
!(sms && plone && callLog && addressBook)
|
|
|
|
|
? "必须权限没有授予,本APP无法正常使用"
|
|
|
|
|
: "功能开关未开启,请到我的页面开启",
|
|
|
|
|
style:
|
|
|
|
|
TextStyle(color: const Color(0xFFFF3F3F), fontSize: 24.sp),
|
|
|
|
|
),
|
|
|
|
|
!(sms && plone && callLog && addressBook) ? 32.wb : 0.wb,
|
|
|
|
|
!(sms && plone && callLog && addressBook)
|
|
|
|
|
? Image(
|
|
|
|
|
image: AssetImage(Assets.icons.right.path),
|
|
|
|
|
width: 28.w,
|
|
|
|
|
height: 28.w,
|
|
|
|
|
fit: BoxFit.fill,
|
|
|
|
|
)
|
|
|
|
|
: const SizedBox()
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_getBody() {
|
|
|
|
|
return Container(
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 64.w),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
"短信帮手",
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 64.sp,
|
|
|
|
|
color: const Color(0xFF333333),
|
|
|
|
|
fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
|
|
|
|
24.hb,
|
|
|
|
|
Text(
|
|
|
|
|
"希望能成为您的短信小助手",
|
|
|
|
|
style: TextStyle(fontSize: 32.sp, color: const Color(0xFF999999)),
|
|
|
|
|
),
|
|
|
|
|
48.hb,
|
|
|
|
|
_getSet(),
|
|
|
|
|
32.hb,
|
|
|
|
|
// _getContainer("接听后", "编辑接听后发送的短信内容", Assets.images.answer.path,
|
|
|
|
|
// const Color(0xFF74BCFF), const Color(0xFF1890FF)),
|
|
|
|
|
// 30.hb,
|
|
|
|
|
_getContainer("编辑短信", "编辑拒接/未接后发送的短信内容", Assets.images.refused.path,
|
|
|
|
|
const Color(0xFF72E4C8), const Color(0xFF13CA9D))
|
|
|
|
|
,50.hb
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_getSet() {
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
onTap: () {
|
|
|
|
|
Navigator.of(context)
|
|
|
|
|
.push(
|
|
|
|
|
MaterialPageRoute(builder: (_) => const PhoneSetPage()),
|
|
|
|
|
)
|
|
|
|
|
.then((val) => _listenForPermissionStatus());
|
|
|
|
|
},
|
|
|
|
|
child: Container(
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 42.w, vertical: 20.w),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: const Color(0xFFF2F9FF),
|
|
|
|
|
border: Border.all(color: const Color(0xFF1890FF), width: 2.w),
|
|
|
|
|
borderRadius: BorderRadius.circular(16.w)),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 48.w,
|
|
|
|
|
height: 48.w,
|
|
|
|
|
child: Image.asset(Assets.icons.set.path),
|
|
|
|
|
),
|
|
|
|
|
16.wb,
|
|
|
|
|
Text(
|
|
|
|
|
"短信发送号码设置",
|
|
|
|
|
style:
|
|
|
|
|
TextStyle(fontSize: 28.sp, color: const Color(0xFF1890FF)),
|
|
|
|
|
),
|
|
|
|
|
190.wb,
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 48.w,
|
|
|
|
|
height: 48.w,
|
|
|
|
|
child: const Icon(
|
|
|
|
|
Icons.chevron_right,
|
|
|
|
|
color: Color(0xFF1890FF),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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 {
|
|
|
|
|
Get.to(() => ContentDetailsPage(ploneBack: (String textContent) { }, content: '',));
|
|
|
|
|
// Get.to(()=>UpdatePage());
|
|
|
|
|
// FlutterXUpdate.checkUpdate(
|
|
|
|
|
// // topImageRes:'vipbanner',
|
|
|
|
|
// widthRatio: 0.8,
|
|
|
|
|
// heightRatio: 0.8,
|
|
|
|
|
// themeColor:"#FF1890FF",
|
|
|
|
|
// // https://www.dxbs.vip/telephony.json
|
|
|
|
|
// // https://gitee.com/xuexiangjys/XUpdate/raw/master/jsonapi/update_test.json
|
|
|
|
|
// url:
|
|
|
|
|
// 'https://www.dxbs.vip/telephony.json',);
|
|
|
|
|
// PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
|
|
|
|
// String version = packageInfo.version;//版本号
|
|
|
|
|
// String buildNumber = packageInfo.buildNumber;//版本构建号
|
|
|
|
|
// print(version);
|
|
|
|
|
// print(buildNumber); supportSilentInstall:
|
|
|
|
|
// print(title);
|
|
|
|
|
// if (title == "接听后") {
|
|
|
|
|
// Get.to(() => const ContentConnectPage());
|
|
|
|
|
// } else {
|
|
|
|
|
// Get.to(() => const ContentRefusePage());
|
|
|
|
|
// // print("未接听");
|
|
|
|
|
// }
|
|
|
|
|
},
|
|
|
|
|
child: Container(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(16.w),
|
|
|
|
|
gradient: LinearGradient(
|
|
|
|
|
begin: Alignment.centerLeft,
|
|
|
|
|
end: Alignment.centerRight,
|
|
|
|
|
colors: [cl1, cl2])),
|
|
|
|
|
width: 622.w,
|
|
|
|
|
height: 300.w,
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 100.w, left: 50.w),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(title,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 60.sp,
|
|
|
|
|
color: const Color(0xFFFFFFFF),
|
|
|
|
|
fontWeight: FontWeight.bold)),
|
|
|
|
|
16.hb,
|
|
|
|
|
Text(
|
|
|
|
|
text,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 28.sp,
|
|
|
|
|
color: const Color(0xFFFFFFFF).withOpacity(0.6)),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const Spacer(),
|
|
|
|
|
Padding(
|
|
|
|
|
padding: EdgeInsets.only(top: 148.w),
|
|
|
|
|
child: Image.asset(
|
|
|
|
|
image,
|
|
|
|
|
width: 166.w,
|
|
|
|
|
height: 152.w,
|
|
|
|
|
fit: BoxFit.fill,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
)));
|
|
|
|
|
}
|
|
|
|
|
}
|