You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

632 lines
24 KiB

2 years ago
2 years ago
import 'package:bot_toast/bot_toast.dart';
2 years ago
import 'package:flutter/material.dart';
2 years ago
import 'package:flutter/services.dart';
2 years ago
import 'package:flutter_contacts/flutter_contacts.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
2 years ago
import 'package:project_telephony/ui/home/set/specify_phone_page.dart';
2 years ago
import 'package:project_telephony/utils/headers.dart';
import 'package:project_telephony/utils/user_tool.dart';
2 years ago
import 'package:provider/provider.dart';
2 years ago
import 'package:shared_preferences/shared_preferences.dart';
2 years ago
2 years ago
import '../../../base/base_style.dart';
2 years ago
import '../../../providers/user_provider.dart';
2 years ago
import '../../widget/plone_back_button.dart';
2 years ago
import '../call.dart';
2 years ago
import '../home_page.dart';
2 years ago
class PhoneSetPage extends StatefulWidget {
const PhoneSetPage({Key? key}) : super(key: key);
@override
_PhoneSetPageState createState() => _PhoneSetPageState();
}
class _PhoneSetPageState extends State<PhoneSetPage> {
2 years ago
2 years ago
int select = 0;
2 years ago
List<Contact>? contact;
List<String> numbers = [];
List<String>? numList = [];
2 years ago
bool vle = false;
bool isVip = false;
2 years ago
String? endDate;
final EasyRefreshController _refreshController = EasyRefreshController();
2 years ago
final Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
2 years ago
final EasyRefreshController _easyRefreshController = EasyRefreshController();
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
2 years ago
List setList = [
2 years ago
{
"icon": Assets.icons.switch1.path,
"title": "功能开关",
"text": "功能开启所有号码都发送",
// "select": true,
},
2 years ago
// {
// "icon": Assets.icons.rylyphone.path,
// "title": "只发来电接听",
// "text": "",
// // "select": true,
// },
2 years ago
{
2 years ago
"icon": Assets.icons.txlphone.path,
"title": "只发来电接听/挂断",
"text": "",
// "select": false,
2 years ago
},
{
2 years ago
"icon": Assets.icons.notxlphone.path,
"title": "只发去电接听/挂断",
"text": "",
2 years ago
// "select": false,
},
2 years ago
// {
// "icon": Assets.icons.notxlphone.path,
// "title": "只发去电挂断",
// "text": "",
// // "select": false,
// },
2 years ago
{
"icon": Assets.icons.notxlphone.path,
2 years ago
"title": "发送周期",
"text": "",
2 years ago
// "select": false,
},
];
2 years ago
List cycleList = [
'每天发送',
"一天内发送一次",
"三天内发送一次",
"七天天内发送一次",
"十五天内发送一次",
"三十天内发送一次"
];
String cycleText = "";
@override
2 years ago
void initState() {
2 years ago
// UserTool.userProvider.viewLoading();
2 years ago
super.initState();
}
2 years ago
2 years ago
@override
void dispose() {
_easyRefreshController.dispose();
super.dispose();
}
2 years ago
static const platform= MethodChannel('com.jump/setting');
2 years ago
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
elevation: 0,
title: Text(
'发送号码设置',
style: TextStyle(
fontSize: BaseStyle.fontSize34,
color: BaseStyle.color333333,
fontWeight: FontWeight.bold),
2 years ago
),
titleSpacing: 162.w,
leading: const CloudBackButton(isSpecial: true),
backgroundColor: kForeGroundColor),
backgroundColor: kForeGroundColor,
body: EasyRefresh(
firstRefresh: true,
controller: _refreshController,
header: MaterialHeader(),
// footer: MaterialFooter(),
onRefresh: () async {
2 years ago
final SharedPreferences prefs =
2 years ago
await SharedPreferences.getInstance();
// print(prefs.getInt("numIndex"));
select = (prefs.getInt("numIndex")) ?? 0;
2 years ago
cycleText = prefs.getString("cycle") ?? "每天发送";
2 years ago
UserTool.userProvider.viewLoading();
2 years ago
2 years ago
_getRequests();
2 years ago
// _viewLoading();
setState(() {});
},
child: ListView(
children: [
2 years ago
// _getSwitch(),
2 years ago
_getListBox(
Assets.icons.switch1.path,
"功能开关",
"功能开启所有号码都发送",
() async {},
Checkbox(
value: vle,
// 改变后的事件
onChanged: (value) async {
final SharedPreferences prefs = await _prefs;
// if(!value){
//
// }
// await prefs.setBool("kg", value);
// print("这是数据${prefs.getBool("kg")}");
setState(() {
if (isVip) {
vle = value!;
// prefs.setBool("kg", vle);
// initializeService();
// print(vle);
if (vle) {
// print("true");
// prefs.remove("kg");
prefs.setBool("kg", vle);
2 years ago
initializeService();
2 years ago
service.startService();
BotToast.showText(text: " 你开启了该功能");
} else {
// print("false");
// prefs.remove("kg");
prefs.setBool("kg", vle);
service.invoke("stopService");
BotToast.showText(text: "你已经关闭该功能");
// print("这是数据${prefs.getBool("kg")}");
}
} else {
BotToast.showText(text: "还没有开通会员,不可使用该功能");
}
});
},
),
),
2 years ago
GestureDetector(
onTap: () async{
2 years ago
// print("12");
await platform. invokeMethod("MobileInfoUtils");
print("34");
// try
2 years ago
// // 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),
),
),
),
2 years ago
_getListBox(
Assets.icons.rylyphone.path,
"所有都发送",
"",
() async {},
Radio(
groupValue: select,
value: 0,
onChanged: (int? value) async {
2 years ago
final SharedPreferences prefs =
await SharedPreferences.getInstance();
2 years ago
select = 0;
await prefs.setInt("numIndex", 0);
2 years ago
// service.invoke("stopService");
vle = true;
// if (prefs.getBool('kg') ?? false) {
// Future.delayed(const Duration(milliseconds: 500), () async {
// vle = true;
// service.startService();
// });
// }
// UserTool.userProvider.viewLoading();
2 years ago
_refreshController.callRefresh();
// select = 0;
setState(() {});
},
)),
_getListBox(
Assets.icons.rylyphone.path,
"只发来电接听/挂断",
"",
() async {},
Radio(
groupValue: select,
value: 1,
onChanged: (int? value) async {
2 years ago
final SharedPreferences prefs =
await SharedPreferences.getInstance();
2 years ago
select = 1;
await prefs.setInt("numIndex", 1);
2 years ago
// service.invoke("stopService");
vle = true;
// if (prefs.getBool('kg') ?? false) {
// Future.delayed(const Duration(milliseconds: 500), () async {
//
// service.startService();
//
// });
// }
// UserTool.userProvider.viewLoading();
2 years ago
_refreshController.callRefresh();
// select = 1;
setState(() {});
},
)),
_getListBox(
Assets.icons.rylyphone.path,
"只发去电接听/挂断",
"",
() async {},
Radio(
groupValue: select,
2 years ago
value: 2,
2 years ago
onChanged: (int? value) async {
2 years ago
final SharedPreferences prefs =
await SharedPreferences.getInstance();
2 years ago
select = 2;
await prefs.setInt("numIndex", 2);
2 years ago
// service.invoke("stopService");
vle = true;
// if (prefs.getBool('kg') ?? false) {
// Future.delayed(const Duration(milliseconds: 500), () async {
// vle = true;
// service.startService();
// });
// }
// UserTool.userProvider.viewLoading();
2 years ago
_refreshController.callRefresh();
// select = 2;
setState(() {});
},
)),
ListTile(
leading: SizedBox(
width: 72.w,
height: 72.w,
child: Image.asset(
Assets.icons.notxlphone.path,
fit: BoxFit.fill,
),
),
title: SizedBox(
child: Row(
children: [
Text(
2 years ago
"发送周期",
style: TextStyle(
fontSize: 32.sp, fontWeight: FontWeight.bold),
2 years ago
),
const Spacer(),
SizedBox(
child: Text(
cycleText,
style: TextStyle(fontSize: 24.sp, color: Colors.grey),
),
)
],
),
),
trailing: SizedBox(
width: 40.w,
height: 40.h,
child: const Icon(
Icons.keyboard_arrow_right,
)),
onTap: () {
showModalBottomSheet(
context: context,
backgroundColor: const Color.fromRGBO(255, 255, 255, 0),
builder: (BuildContext context) {
2 years ago
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(
2 years ago
children: [
2 years ago
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,
],
2 years ago
),
2 years ago
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,
2 years ago
],
),
2 years ago
);
});
2 years ago
});
},
),
GestureDetector(
onTap: () {
Get.to(() => const SpecifyPhonePage());
},
child: SizedBox(
height: 144.w,
child: ListTile(
leading: SizedBox(
width: 72.w,
height: 72.w,
child: Image.asset(
Assets.icons.zdphone.path,
fit: BoxFit.fill,
),
),
title: Text(
"指定号码不发送",
style: TextStyle(
fontSize: 32.sp, fontWeight: FontWeight.bold),
),
subtitle: Text(
"通过添加指定号码来设置不发送",
style: TextStyle(
fontSize: 28.sp, color: const Color(0xFF999999)),
),
2 years ago
trailing: SizedBox(
2 years ago
width: 40.w,
height: 40.h,
child: const Icon(
Icons.keyboard_arrow_right,
))),
),
)
],
),
2 years ago
));
2 years ago
}
2 years ago
//内容
// _getSwitch() {
// return Container(
// padding: EdgeInsets.symmetric(horizontal: 32.w),
// child: ListTile(
// // onTap: (() {}),
// leading: Image.asset(
// Assets.icons.switch1.path,
// height: 54.w,
// width: 56.w,
// fit: BoxFit.fill,
// ),
// title: Text(
// "功能开关",
// style: TextStyle(
// color: BaseStyle.color333333,
// fontSize: BaseStyle.fontSize34,
// fontWeight: FontWeight.bold),
// ),
// trailing: Checkbox(
// value: vle,
// // 改变后的事件
// onChanged: (value) {
// setState(() {
// vle=value!;
// });
// },
// // 选中后的颜色
// activeColor: Colors.blue,
// // 选中后对号的颜色
// checkColor: Colors.white,
// ),
//
//
// // Switch(
// // value: vle,
// // onChanged: (value) async {
// // final SharedPreferences prefs = await _prefs;
// // setState(() {
// // if (isVip) {
// // vle = value;
// // if (vle) {
// // print("true");
// // prefs.remove("kg");
// // prefs.setBool("kg", vle);
// // service.startService();
// // initializeService();
// // BotToast.showText(text: " 你开启了该功能");
// // } else {
// // prefs.remove("kg");
// // prefs.setBool("kg", vle);
// // service.invoke("stopService");
// // BotToast.showText(text: "你已经关闭该功能");
// // }
// // } else {
// // BotToast.showText(text: "还没有开通会员,不可使用该功能");
// // }
// // });
// // }),
// ));
// }
// Future _viewLoading() async {
// final SharedPreferences prefs = await SharedPreferences.getInstance();
// contact = await FlutterContacts.getContacts();
// for (var element in contact!) {
// final full = await FlutterContacts.getContact(element.id);
// numbers.add(full!.phones.first.number.replaceAll(" ", ""));
// // status.add(false);
// }
// var numberList = await ExcludeFunc.getContacts();
// for (int i = 0; i < numberList.length; i++) {
// numList?.add(numberList[i].phone);
// }
// await prefs.setStringList("specified", numList!);
// await prefs.setStringList("addressList", numbers);
// // phoneNum.clear();
// // final Iterable<CallLogEntry> entries = await CallLog.query();
// // numList= prefs.getStringList('addressList');
// // count=numList?.length;
// // for (CallLogEntry entrie in entries) {
// // if (!numList2.contains(numList)) {
// // numList2.add(entrie.number!);
// // }
// // }
// // for(int i=0;i<count!;i++){
// // numList2.remove(numList![i]);
// // }
// // print(numList2);
// // await prefs.setStringList("noAddressList", numList2);
// // for (int i = 0; i < phoneNum.length; i++) {
// // phoneNum2.add(PhoneNumModel(
// // num: phoneNum[i].num,
// // time: phoneNum[i].time,
// // name: phoneNum[i].name,
// // state: phoneNum[i].state,
// // ));
// // }
// setState(() {});
// }
2 years ago
_getRequests() async {
UserTool.userProvider.updateUserInfo();
if (UserTool.userProvider.isLogin) {
// print(UserTool.userProvider.userInfo.end * 1000);
// print(DateTime.now().millisecondsSinceEpoch);
if (UserTool.userProvider.userInfo.isVip != 1) {
isVip = false;
vle = false;
// UserTool.userProvider.updateUserInfo();
_easyRefreshController.callRefresh();
} else {
isVip = true;
vle = await service.isRunning();
// print(vle);
// _easyRefreshController.callRefresh();
}
//service.isRunning() as bool;
// endDate = DateUtil.formatDateMs(
// UserTool.userProvider.userInfo.end * 1000,
// format: DateFormats.y_mo_d);
} else {
vle = false;
}
//
setState(() {});
}
2 years ago
_getListBox(
String url, String title, String text, VoidCallback ontap, Widget child) {
// final service = FlutterBackgroundService();
return GestureDetector(
onTap: ontap,
2 years ago
child: ListTile(
leading: SizedBox(
width: 72.w,
height: 72.w,
child: Image.asset(
2 years ago
url,
2 years ago
fit: BoxFit.fill,
)),
title: Text(
2 years ago
title,
2 years ago
style: TextStyle(fontSize: 32.sp, fontWeight: FontWeight.bold),
),
subtitle: Text(
2 years ago
text,
2 years ago
style: TextStyle(fontSize: 28.sp, color: const Color(0xFF999999)),
),
2 years ago
trailing: SizedBox(width: 40.w, height: 40.w, child: child),
2 years ago
// BeeCheckRadio(
// value: index,
// groupValue: [select],
// ),
),
);
}
2 years ago
2 years ago
_buildButton({
required String title,
required VoidCallback? onPressed,
required Color color,
}) {
return GestureDetector(
onTap: onPressed,
// height: 48.w,
child: Text(title,
style: TextStyle(
color: color,
fontSize: 28.sp,
fontWeight: FontWeight.bold,
)),
);
}
2 years ago
}