master
王亚玲 2 years ago
parent adbf8fcdd7
commit 2c254fdb78

@ -1,18 +1,22 @@
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_contacts/flutter_contacts.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:project_telephony/ui/home/set/specify_phone_page.dart';
import 'package:project_telephony/utils/headers.dart';
import 'package:project_telephony/utils/user_tool.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../../base/base_style.dart';
import '../../../providers/user_provider.dart';
import '../../widget/plone_back_button.dart';
import '../call.dart';
import '../home_page.dart';
class PhoneSetPage extends StatefulWidget {
@ -23,6 +27,7 @@ class PhoneSetPage extends StatefulWidget {
}
class _PhoneSetPageState extends State<PhoneSetPage> {
int select = 0;
List<Contact>? contact;
List<String> numbers = [];
@ -82,8 +87,6 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
];
String cycleText = "";
@override
void initState() {
// UserTool.userProvider.viewLoading();
@ -95,7 +98,7 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
_easyRefreshController.dispose();
super.dispose();
}
// static const platform= MethodChannel('com.jump/setting');
@override
Widget build(BuildContext context) {
return Scaffold(
@ -120,10 +123,12 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
onRefresh: () async {
final SharedPreferences prefs =
await SharedPreferences.getInstance();
print(prefs.getInt("numIndex"));
// print(prefs.getInt("numIndex"));
select = (prefs.getInt("numIndex")) ?? 0;
cycleText = prefs.getString("cycle") ?? "每天发送";
UserTool.userProvider.viewLoading();
_getRequests();
// _viewLoading();
setState(() {});
},
@ -155,8 +160,8 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
// print("true");
// prefs.remove("kg");
prefs.setBool("kg", vle);
initializeService();
service.startService();
// initializeService();
BotToast.showText(text: " 你开启了该功能");
} else {
// print("false");
@ -173,28 +178,61 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
},
),
),
GestureDetector(
onTap: () async{
// try{
// // await platform.invokeMethod("jumpSetting");
// }catch (e){
// BotToast.showText(text: e.toString());
// }
// DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
// AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
//
// print(androidInfo.model);
// print(packageName);
// platform.invokeMethod("");
// openAppSettings();
},
child: Container(
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: Text(
"未防止功能停止,请确保开启后台运行权限,软件默认首次不开启",
style: TextStyle(
color: Colors.grey, fontSize: 24.sp),
),
),
),
_getListBox(
Assets.icons.rylyphone.path,
"所有都发送",
"",
() async {},
Radio(
groupValue: select,
value: 0,
onChanged: (int? value) async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
final SharedPreferences prefs =
await SharedPreferences.getInstance();
select = 0;
await prefs.setInt("numIndex", 0);
service.invoke("stopService");
if (prefs.getBool('kg') ?? false) {
Future.delayed(const Duration(milliseconds: 500), () async {
// service.invoke("stopService");
vle = true;
service.startService();
});
}
UserTool.userProvider.viewLoading();
// if (prefs.getBool('kg') ?? false) {
// Future.delayed(const Duration(milliseconds: 500), () async {
// vle = true;
// service.startService();
// });
// }
// UserTool.userProvider.viewLoading();
_refreshController.callRefresh();
// select = 0;
setState(() {});
@ -204,24 +242,25 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
Assets.icons.rylyphone.path,
"只发来电接听/挂断",
"",
() async {},
Radio(
groupValue: select,
value: 1,
onChanged: (int? value) async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
final SharedPreferences prefs =
await SharedPreferences.getInstance();
select = 1;
await prefs.setInt("numIndex", 1);
service.invoke("stopService");
if (prefs.getBool('kg') ?? false) {
Future.delayed(const Duration(milliseconds: 500), () async {
// service.invoke("stopService");
vle = true;
service.startService();
});
}
UserTool.userProvider.viewLoading();
// if (prefs.getBool('kg') ?? false) {
// Future.delayed(const Duration(milliseconds: 500), () async {
//
// service.startService();
//
// });
// }
// UserTool.userProvider.viewLoading();
_refreshController.callRefresh();
// select = 1;
setState(() {});
@ -234,19 +273,22 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
() async {},
Radio(
groupValue: select,
value:2,
value: 2,
onChanged: (int? value) async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
final SharedPreferences prefs =
await SharedPreferences.getInstance();
select = 2;
await prefs.setInt("numIndex", 2);
service.invoke("stopService");
if (prefs.getBool('kg') ?? false) {
Future.delayed(const Duration(milliseconds: 500), () async {
// service.invoke("stopService");
vle = true;
service.startService();
});
}
UserTool.userProvider.viewLoading();
// if (prefs.getBool('kg') ?? false) {
// Future.delayed(const Duration(milliseconds: 500), () async {
// vle = true;
// service.startService();
// });
// }
// UserTool.userProvider.viewLoading();
_refreshController.callRefresh();
// select = 2;
setState(() {});
@ -266,8 +308,8 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
children: [
Text(
"发送周期",
style:
TextStyle(fontSize: 32.sp, fontWeight: FontWeight.bold),
style: TextStyle(
fontSize: 32.sp, fontWeight: FontWeight.bold),
),
const Spacer(),
SizedBox(
@ -290,7 +332,8 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
context: context,
backgroundColor: const Color.fromRGBO(255, 255, 255, 0),
builder: (BuildContext context) {
return StatefulBuilder(builder: (context, dialogSetState) {
return StatefulBuilder(
builder: (context, dialogSetState) {
return Container(
width: double.infinity,
height: 600.w,
@ -338,10 +381,13 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
return GestureDetector(
onTap: () async {
final SharedPreferences prefs =
await SharedPreferences.getInstance();
await SharedPreferences
.getInstance();
BotToast.showText(text: "成功");
prefs.setString("cycle", cycleList[index]);
BotToast.showText(text: cycleList[index]);
prefs.setString(
"cycle", cycleList[index]);
BotToast.showText(
text: cycleList[index]);
Navigator.pop(context);
_refreshController.callRefresh();
dialogSetState(() {});
@ -354,7 +400,8 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
child: Text(cycleList[index],
style: TextStyle(
color: const Color(0xFF330000),
fontSize: BaseStyle.fontSize28)),
fontSize:
BaseStyle.fontSize28)),
),
);
},
@ -393,7 +440,7 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
style: TextStyle(
fontSize: 28.sp, color: const Color(0xFF999999)),
),
trailing:SizedBox(
trailing: SizedBox(
width: 40.w,
height: 40.h,
child: const Icon(
@ -562,6 +609,7 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
),
);
}
_buildButton({
required String title,
required VoidCallback? onPressed,

Loading…
Cancel
Save