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

@ -1,18 +1,22 @@
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_contacts/flutter_contacts.dart'; import 'package:flutter_contacts/flutter_contacts.dart';
import 'package:flutter_easyrefresh/easy_refresh.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/ui/home/set/specify_phone_page.dart';
import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/utils/headers.dart';
import 'package:project_telephony/utils/user_tool.dart'; import 'package:project_telephony/utils/user_tool.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import '../../../base/base_style.dart'; import '../../../base/base_style.dart';
import '../../../providers/user_provider.dart'; import '../../../providers/user_provider.dart';
import '../../widget/plone_back_button.dart'; import '../../widget/plone_back_button.dart';
import '../call.dart';
import '../home_page.dart'; import '../home_page.dart';
class PhoneSetPage extends StatefulWidget { class PhoneSetPage extends StatefulWidget {
@ -23,6 +27,7 @@ class PhoneSetPage extends StatefulWidget {
} }
class _PhoneSetPageState extends State<PhoneSetPage> { class _PhoneSetPageState extends State<PhoneSetPage> {
int select = 0; int select = 0;
List<Contact>? contact; List<Contact>? contact;
List<String> numbers = []; List<String> numbers = [];
@ -82,8 +87,6 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
]; ];
String cycleText = ""; String cycleText = "";
@override @override
void initState() { void initState() {
// UserTool.userProvider.viewLoading(); // UserTool.userProvider.viewLoading();
@ -95,7 +98,7 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
_easyRefreshController.dispose(); _easyRefreshController.dispose();
super.dispose(); super.dispose();
} }
// static const platform= MethodChannel('com.jump/setting');
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -119,11 +122,13 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
// footer: MaterialFooter(), // footer: MaterialFooter(),
onRefresh: () async { onRefresh: () async {
final SharedPreferences prefs = final SharedPreferences prefs =
await SharedPreferences.getInstance(); await SharedPreferences.getInstance();
print(prefs.getInt("numIndex")); // print(prefs.getInt("numIndex"));
select = (prefs.getInt("numIndex")) ?? 0; select = (prefs.getInt("numIndex")) ?? 0;
cycleText = prefs.getString("cycle") ?? "每天发送"; cycleText = prefs.getString("cycle") ?? "每天发送";
UserTool.userProvider.viewLoading();
_getRequests(); _getRequests();
// _viewLoading(); // _viewLoading();
setState(() {}); setState(() {});
}, },
@ -155,8 +160,8 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
// print("true"); // print("true");
// prefs.remove("kg"); // prefs.remove("kg");
prefs.setBool("kg", vle); prefs.setBool("kg", vle);
initializeService();
service.startService(); service.startService();
// initializeService();
BotToast.showText(text: " 你开启了该功能"); BotToast.showText(text: " 你开启了该功能");
} else { } else {
// print("false"); // 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( _getListBox(
Assets.icons.rylyphone.path, Assets.icons.rylyphone.path,
"所有都发送", "所有都发送",
"", "",
() async {}, () async {},
Radio( Radio(
groupValue: select, groupValue: select,
value: 0, value: 0,
onChanged: (int? value) async { onChanged: (int? value) async {
final SharedPreferences prefs = await SharedPreferences.getInstance(); final SharedPreferences prefs =
await SharedPreferences.getInstance();
select = 0; select = 0;
await prefs.setInt("numIndex", 0); await prefs.setInt("numIndex", 0);
service.invoke("stopService"); // service.invoke("stopService");
if (prefs.getBool('kg') ?? false) { vle = true;
Future.delayed(const Duration(milliseconds: 500), () async { // if (prefs.getBool('kg') ?? false) {
vle = true; // Future.delayed(const Duration(milliseconds: 500), () async {
service.startService(); // vle = true;
// service.startService();
}); // });
} // }
UserTool.userProvider.viewLoading(); // UserTool.userProvider.viewLoading();
_refreshController.callRefresh(); _refreshController.callRefresh();
// select = 0; // select = 0;
setState(() {}); setState(() {});
@ -204,24 +242,25 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
Assets.icons.rylyphone.path, Assets.icons.rylyphone.path,
"只发来电接听/挂断", "只发来电接听/挂断",
"", "",
() async {}, () async {},
Radio( Radio(
groupValue: select, groupValue: select,
value: 1, value: 1,
onChanged: (int? value) async { onChanged: (int? value) async {
final SharedPreferences prefs = await SharedPreferences.getInstance(); final SharedPreferences prefs =
await SharedPreferences.getInstance();
select = 1; select = 1;
await prefs.setInt("numIndex", 1); await prefs.setInt("numIndex", 1);
service.invoke("stopService"); // service.invoke("stopService");
if (prefs.getBool('kg') ?? false) { vle = true;
Future.delayed(const Duration(milliseconds: 500), () async { // if (prefs.getBool('kg') ?? false) {
vle = true; // Future.delayed(const Duration(milliseconds: 500), () async {
service.startService(); //
// service.startService();
}); //
} // });
UserTool.userProvider.viewLoading(); // }
// UserTool.userProvider.viewLoading();
_refreshController.callRefresh(); _refreshController.callRefresh();
// select = 1; // select = 1;
setState(() {}); setState(() {});
@ -234,19 +273,22 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
() async {}, () async {},
Radio( Radio(
groupValue: select, groupValue: select,
value:2, value: 2,
onChanged: (int? value) async { onChanged: (int? value) async {
final SharedPreferences prefs = await SharedPreferences.getInstance(); final SharedPreferences prefs =
await SharedPreferences.getInstance();
select = 2; select = 2;
await prefs.setInt("numIndex", 2); await prefs.setInt("numIndex", 2);
service.invoke("stopService"); // service.invoke("stopService");
if (prefs.getBool('kg') ?? false) { vle = true;
Future.delayed(const Duration(milliseconds: 500), () async {
vle = true; // if (prefs.getBool('kg') ?? false) {
service.startService(); // Future.delayed(const Duration(milliseconds: 500), () async {
}); // vle = true;
} // service.startService();
UserTool.userProvider.viewLoading(); // });
// }
// UserTool.userProvider.viewLoading();
_refreshController.callRefresh(); _refreshController.callRefresh();
// select = 2; // select = 2;
setState(() {}); setState(() {});
@ -265,9 +307,9 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
child: Row( child: Row(
children: [ children: [
Text( Text(
"发送周期", "发送周期",
style: style: TextStyle(
TextStyle(fontSize: 32.sp, fontWeight: FontWeight.bold), fontSize: 32.sp, fontWeight: FontWeight.bold),
), ),
const Spacer(), const Spacer(),
SizedBox( SizedBox(
@ -290,81 +332,86 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
context: context, context: context,
backgroundColor: const Color.fromRGBO(255, 255, 255, 0), backgroundColor: const Color.fromRGBO(255, 255, 255, 0),
builder: (BuildContext context) { builder: (BuildContext context) {
return StatefulBuilder(builder: (context, dialogSetState) { return StatefulBuilder(
return Container( builder: (context, dialogSetState) {
width: double.infinity, return Container(
height: 600.w, width: double.infinity,
decoration: BoxDecoration( height: 600.w,
color: Colors.white, decoration: BoxDecoration(
borderRadius: color: Colors.white,
BorderRadius.all(Radius.circular(16.w))), borderRadius:
child: Column( BorderRadius.all(Radius.circular(16.w))),
children: [ child: Column(
32.hb,
Row(
children: [ children: [
32.wb, 32.hb,
_buildButton( Row(
title: '取消', children: [
onPressed: () => Navigator.pop(context), 32.wb,
color: Colors.black26, _buildButton(
), title: '取消',
210.wb, onPressed: () => Navigator.pop(context),
Text( color: Colors.black26,
'选择周期', ),
textAlign: TextAlign.center, 210.wb,
style: TextStyle( Text(
color: const Color(0xFF111111), '选择周期',
fontWeight: FontWeight.bold, textAlign: TextAlign.center,
fontSize: 32.sp, style: TextStyle(
), color: const Color(0xFF111111),
fontWeight: FontWeight.bold,
fontSize: 32.sp,
),
),
// _buildButton(
// title: '确定',
// onPressed: () async {
// BotToast.showText(text: "成功");
// Navigator.pop(context);
// setState(() {});
// },
// color: Colors.blue,
// ),
// 32.wb,
],
), ),
// _buildButton( 40.hb,
// title: '确定', Expanded(
// onPressed: () async { child: ListView.builder(
// BotToast.showText(text: "成功"); itemBuilder: (context, index) {
// Navigator.pop(context); return GestureDetector(
// setState(() {}); onTap: () async {
// }, final SharedPreferences prefs =
// color: Colors.blue, await SharedPreferences
// ), .getInstance();
// 32.wb, BotToast.showText(text: "成功");
prefs.setString(
"cycle", cycleList[index]);
BotToast.showText(
text: cycleList[index]);
Navigator.pop(context);
_refreshController.callRefresh();
dialogSetState(() {});
},
child: Container(
alignment: Alignment.center,
height: 80.w,
width: double.infinity,
color: Colors.white,
child: Text(cycleList[index],
style: TextStyle(
color: const Color(0xFF330000),
fontSize:
BaseStyle.fontSize28)),
),
);
},
itemCount: cycleList.length,
)),
40.hb,
], ],
), ),
40.hb, );
Expanded( });
child: ListView.builder(
itemBuilder: (context, index) {
return GestureDetector(
onTap: () async {
final SharedPreferences prefs =
await SharedPreferences.getInstance();
BotToast.showText(text: "成功");
prefs.setString("cycle", cycleList[index]);
BotToast.showText(text: cycleList[index]);
Navigator.pop(context);
_refreshController.callRefresh();
dialogSetState(() {});
},
child: Container(
alignment: Alignment.center,
height: 80.w,
width: double.infinity,
color: Colors.white,
child: Text(cycleList[index],
style: TextStyle(
color: const Color(0xFF330000),
fontSize: BaseStyle.fontSize28)),
),
);
},
itemCount: cycleList.length,
)),
40.hb,
],
),
);
});
}); });
}, },
), ),
@ -393,7 +440,7 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
style: TextStyle( style: TextStyle(
fontSize: 28.sp, color: const Color(0xFF999999)), fontSize: 28.sp, color: const Color(0xFF999999)),
), ),
trailing:SizedBox( trailing: SizedBox(
width: 40.w, width: 40.w,
height: 40.h, height: 40.h,
child: const Icon( child: const Icon(
@ -562,6 +609,7 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
), ),
); );
} }
_buildButton({ _buildButton({
required String title, required String title,
required VoidCallback? onPressed, required VoidCallback? onPressed,

Loading…
Cancel
Save