diff --git a/lib/ui/home/set/phone_set_page.dart b/lib/ui/home/set/phone_set_page.dart index 54c110e..1f874be 100644 --- a/lib/ui/home/set/phone_set_page.dart +++ b/lib/ui/home/set/phone_set_page.dart @@ -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 { + int select = 0; List? contact; List numbers = []; @@ -82,8 +87,6 @@ class _PhoneSetPageState extends State { ]; String cycleText = ""; - - @override void initState() { // UserTool.userProvider.viewLoading(); @@ -95,7 +98,7 @@ class _PhoneSetPageState extends State { _easyRefreshController.dispose(); super.dispose(); } - + // static const platform= MethodChannel('com.jump/setting'); @override Widget build(BuildContext context) { return Scaffold( @@ -119,11 +122,13 @@ class _PhoneSetPageState extends State { // footer: MaterialFooter(), onRefresh: () async { final SharedPreferences prefs = - await SharedPreferences.getInstance(); - print(prefs.getInt("numIndex")); + await SharedPreferences.getInstance(); + // 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 { // 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 { }, ), ), + 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 { - vle = true; - service.startService(); - - }); - } - UserTool.userProvider.viewLoading(); + // service.invoke("stopService"); + vle = true; + // 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 { 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 { - vle = true; - service.startService(); - - }); - } - UserTool.userProvider.viewLoading(); + // service.invoke("stopService"); + vle = true; + // 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 { () 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 { - vle = true; - service.startService(); - }); - } - UserTool.userProvider.viewLoading(); + // service.invoke("stopService"); + vle = true; + + // if (prefs.getBool('kg') ?? false) { + // Future.delayed(const Duration(milliseconds: 500), () async { + // vle = true; + // service.startService(); + // }); + // } + // UserTool.userProvider.viewLoading(); _refreshController.callRefresh(); // select = 2; setState(() {}); @@ -265,9 +307,9 @@ class _PhoneSetPageState extends State { child: Row( children: [ Text( - "发送周期", - style: - TextStyle(fontSize: 32.sp, fontWeight: FontWeight.bold), + "发送周期", + style: TextStyle( + fontSize: 32.sp, fontWeight: FontWeight.bold), ), const Spacer(), SizedBox( @@ -290,81 +332,86 @@ class _PhoneSetPageState extends State { context: context, backgroundColor: const Color.fromRGBO(255, 255, 255, 0), builder: (BuildContext context) { - return StatefulBuilder(builder: (context, dialogSetState) { - return Container( - width: double.infinity, - height: 600.w, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: - BorderRadius.all(Radius.circular(16.w))), - child: Column( - children: [ - 32.hb, - Row( + return StatefulBuilder( + builder: (context, dialogSetState) { + return Container( + width: double.infinity, + height: 600.w, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: + BorderRadius.all(Radius.circular(16.w))), + child: Column( children: [ - 32.wb, - _buildButton( - title: '取消', - onPressed: () => Navigator.pop(context), - color: Colors.black26, - ), - 210.wb, - Text( - '选择周期', - textAlign: TextAlign.center, - style: TextStyle( - color: const Color(0xFF111111), - fontWeight: FontWeight.bold, - fontSize: 32.sp, - ), + 32.hb, + Row( + children: [ + 32.wb, + _buildButton( + title: '取消', + onPressed: () => Navigator.pop(context), + color: Colors.black26, + ), + 210.wb, + Text( + '选择周期', + textAlign: TextAlign.center, + 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( - // title: '确定', - // onPressed: () async { - // BotToast.showText(text: "成功"); - // Navigator.pop(context); - // setState(() {}); - // }, - // color: Colors.blue, - // ), - // 32.wb, + 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, ], ), - 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 { 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 { ), ); } + _buildButton({ required String title, required VoidCallback? onPressed,