保存更改

master
王亚玲 2 years ago
parent 059051c224
commit d0fc436d0f

@ -54,17 +54,19 @@ void onStart(ServiceInstance service) async {
// }); // });
// Telephony.backgroundInstance.sendSms(to: "13486828191", message: "123123"); // Telephony.backgroundInstance.sendSms(to: "13486828191", message: "123123");
Timer.periodic(const Duration(seconds: 1), (timer) async { Timer.periodic(const Duration(seconds: 1), (timer) async {
final SharedPreferences prefs = await SharedPreferences.getInstance(); final SharedPreferences prefs = await SharedPreferences.getInstance();
CallState state = await Telephony.instance.callState; CallState state = await Telephony.instance.callState;
callState = state.name; callState = state.name;
print("$callState$flag");
// print(entry.first.duration); // print(entry.first.duration);
print(callState+"$flag");
String? ref = prefs.getString('refSms'); String? ref = prefs.getString('refSms');
String? con = prefs.getString('conSms'); String? con = prefs.getString('conSms');
String? call = prefs.getString('callSms'); String? call = prefs.getString('callSms');
String? idle = prefs.getString('idleSms'); String? idle = prefs.getString('idleSms');
bool? callSw = prefs.getBool('callSwitch'); bool? callSw = prefs.getBool('callSwitch');
bool? idleSw = prefs.getBool('idleSwitch'); bool? idleSw = prefs.getBool('idleSwitch');
if (callState == "IDLE") { if (callState == "IDLE") {
if (flag != 0) { if (flag != 0) {
final Iterable<CallLogEntry> entry = await CallLog.query(); final Iterable<CallLogEntry> entry = await CallLog.query();
@ -73,25 +75,33 @@ void onStart(ServiceInstance service) async {
print(phoneNum); print(phoneNum);
if (flag > 0) { if (flag > 0) {
print("来电拒接/未接"); print("来电拒接/未接");
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: ref!); print("${phoneNum!}:${ref!}");
// Telephony.backgroundInstance.sendSms(to: phoneNum!, message: ref!);
print("发送成功"); print("发送成功");
} else if(flag==-1){ } else if(flag==-1){
print("来电接听"); print("来电接听");
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: con!); print("${phoneNum!}:${con!}");
}else { // Telephony.backgroundInstance.sendSms(to: phoneNum!, message: con!);
if(entry.first.duration!>0){
if(callSw!){
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: call!);
}
print("去电接听");
}else{
if(idleSw!){
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: idle!);
}
print("去电未接");
}
print("发送成功");
} }
// else {
// if(entry.first.duration!>0){
// if(callSw!){
// print(callSw);
// print("${phoneNum!}:${call!}");
// // Telephony.backgroundInstance.sendSms(to: phoneNum!, message: call!);
// }
// print("去电接听");
// }else{
// if(idleSw!){
// print(idleSw);
// // ${idle!}
// print("${phoneNum!}:${call!}");
// // Telephony.backgroundInstance.sendSms(to: phoneNum!, message: idle!);
// }
// print("去电未接");
// }
// print("发送成功");
// }
flag = 0; flag = 0;
} }
} else if (callState == "RINGING") { } else if (callState == "RINGING") {

@ -53,13 +53,13 @@ class _CallingIdleListState extends State<CallingIdleList>
@override @override
void initState() { void initState() {
getSwitch();
super.initState(); super.initState();
} }
Future<void> getSwitch() async { Future<void> getSwitch() async {
final SharedPreferences prefs = await _prefs; final SharedPreferences prefs = await _prefs;
val = prefs.getBool(widget.name!)!; val = prefs.getBool(widget.name!)!;
print(val); print(val);
} }
@ -93,39 +93,74 @@ class _CallingIdleListState extends State<CallingIdleList>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return EasyRefresh(
children: [
_getText(),
32.hb,
widget.name!.isEmpty || val
? Expanded(
child: EasyRefresh.custom(
firstRefresh: true, firstRefresh: true,
controller: widget.refreshController, controller: widget.refreshController,
header: MaterialHeader(), header: MaterialHeader(),
// footer: MaterialFooter(), // footer: MaterialFooter(),
onRefresh: () async { onRefresh: () async {
// await userProvider.updateUserInfo(); // await userProvider.updateUserInfo();
getSwitch();
await updateList(); await updateList();
setState(() {}); setState(() {});
}, },
slivers: [ child: ListView(
SliverList( children: [
delegate: SliverChildBuilderDelegate((context, index) { _getText(),
32.hb,
// _getEmptyList(),
widget.name!.isEmpty || val
?
SizedBox(
height: 1000.w,
child: ListView.builder(
itemBuilder: (context, index) {
return _getBox(textListSMS[index], index); return _getBox(textListSMS[index], index);
}, childCount: textListSMS.length), },
), itemCount: textListSMS.length,
], ))
),
)
: _getEmptyList(), : _getEmptyList(),
// SliverList(
// delegate: SliverChildBuilderDelegate((context, index) {
// return _getBox(textListSMS[index], index);
// }, childCount: textListSMS.length),
// ),
], ],
),
); );
// Column(
// children: [
// _getText(),
// 32.hb,
// widget.name!.isEmpty || val
// ? Expanded(
// child: EasyRefresh.custom(
// firstRefresh: true,
// controller: widget.refreshController,
// header: MaterialHeader(),
// // footer: MaterialFooter(),
// onRefresh: () async {
// // await userProvider.updateUserInfo();
// await updateList();
// setState(() {});
// },
// slivers: [
// SliverList(
// delegate: SliverChildBuilderDelegate((context, index) {
// return _getBox(textListSMS[index], index);
// }, childCount: textListSMS.length),
// ),
// ],
// ),
// )
// : _getEmptyList(),
// ],
// );
} }
_getText() { _getText() {
return Container( return Container(
height: 128.w, height: 128.w,
// width: 622.w,
padding: EdgeInsets.only(left: 40.w, top: 45.w), padding: EdgeInsets.only(left: 40.w, top: 45.w),
child: ListTile( child: ListTile(
title: Text( title: Text(

@ -56,6 +56,7 @@ class _UserPageState extends State<UserPage> {
_easyRefreshController.dispose(); _easyRefreshController.dispose();
super.dispose(); super.dispose();
} }
// _load() async { // _load() async {
// // print("123123131313131231231231231313123131232311313131231231"); // // print("123123131313131231231231231313123131232311313131231231");
// vle = await service.isRunning(); // vle = await service.isRunning();
@ -88,6 +89,7 @@ class _UserPageState extends State<UserPage> {
// vle = false; // vle = false;
// } // }
} }
// getRes() async{ // getRes() async{
// var res=await apiClient.request(API.app.trialVip); // var res=await apiClient.request(API.app.trialVip);
// if(res.code==0){ // if(res.code==0){
@ -98,7 +100,6 @@ class _UserPageState extends State<UserPage> {
// } // }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return CloudScaffold( return CloudScaffold(
systemStyle: const SystemUiOverlayStyle( systemStyle: const SystemUiOverlayStyle(
statusBarIconBrightness: Brightness.dark, statusBarIconBrightness: Brightness.dark,
@ -107,10 +108,11 @@ class _UserPageState extends State<UserPage> {
path: Assets.images.bg.path, path: Assets.images.bg.path,
bodyColor: Colors.white, bodyColor: Colors.white,
extendBody: true, extendBody: true,
body: Expanded(child: Column( body: Expanded(
child: Column(
children: [ children: [
Expanded( Expanded(
child:EasyRefresh( child: EasyRefresh(
firstRefresh: true, firstRefresh: true,
header: MaterialHeader(), header: MaterialHeader(),
onRefresh: () async { onRefresh: () async {
@ -119,8 +121,10 @@ class _UserPageState extends State<UserPage> {
// await UserTool.userProvider.updateUserInfo(); // await UserTool.userProvider.updateUserInfo();
if (UserTool.userProvider.isLogin) { if (UserTool.userProvider.isLogin) {
// var res=await apiClient.request(API.app.trialVip); // var res=await apiClient.request(API.app.trialVip);
if(UserTool.userProvider.userInfo.isTrial!=0){ if (UserTool.userProvider.userInfo.isTrial == 0) {
showDialog(context: context, builder: (context){ showDialog(
context: context,
builder: (context) {
return const AppDialog(); return const AppDialog();
}); });
} }
@ -142,14 +146,17 @@ class _UserPageState extends State<UserPage> {
vle = false; vle = false;
} }
setState(() {}); setState(() {});
},child:ListView(children: [ },
child: ListView(
children: [
_getUser(), _getUser(),
72.hb, 72.hb,
_getBanner(), _getBanner(),
120.hb, 120.hb,
_getSwitch2(), _getSwitch2(),
_getSwitch(Assets.icons.privacy.path, "隐私政策", false), _getSwitch(Assets.icons.privacy.path, "隐私政策", false),
_getSwitch(Assets.icons.permissions.path, "权限说明", false), _getSwitch(
Assets.icons.permissions.path, "权限说明", false),
_getSwitch(Assets.icons.sms.path, "短信标签", false), _getSwitch(Assets.icons.sms.path, "短信标签", false),
// const Spacer(), // const Spacer(),
182.hb, 182.hb,
@ -158,7 +165,8 @@ class _UserPageState extends State<UserPage> {
border: false, border: false,
onTap: () async { onTap: () async {
var cancel = CloudToast.loading; var cancel = CloudToast.loading;
var base = await apiClient.request(API.app.logout, var base = await apiClient.request(
API.app.logout,
showMessage: true); showMessage: true);
if (base.code == 0) { if (base.code == 0) {
UserTool.userProvider.logout(); UserTool.userProvider.logout();
@ -171,14 +179,12 @@ class _UserPageState extends State<UserPage> {
color2: const Color(0xFFEBF5FF), color2: const Color(0xFFEBF5FF),
text: "退出登录", text: "退出登录",
) )
: const SizedBox()],) ) : const SizedBox()
],
))),
),], ],
),) ),
));
);
} }
// //
@ -189,7 +195,6 @@ class _UserPageState extends State<UserPage> {
children: [ children: [
GestureDetector( GestureDetector(
onTap: () { onTap: () {
if (!userProvider.isLogin) { if (!userProvider.isLogin) {
Get.to(() => const LoginPage()); Get.to(() => const LoginPage());
} }
@ -273,8 +278,7 @@ class _UserPageState extends State<UserPage> {
} }
_getRequests() async { _getRequests() async {
endDate = DateUtil.formatDateMs( endDate = DateUtil.formatDateMs(UserTool.userProvider.userInfo.end * 1000,
UserTool.userProvider.userInfo.end * 1000,
format: DateFormats.y_mo_d); format: DateFormats.y_mo_d);
UserTool.userProvider.updateUserInfo(); UserTool.userProvider.updateUserInfo();
if (UserTool.userProvider.isLogin) { if (UserTool.userProvider.isLogin) {
@ -335,7 +339,9 @@ class _UserPageState extends State<UserPage> {
_getVip(), _getVip(),
16.hb, 16.hb,
Text( Text(
isVip ? "${DateUtil.formatDateMs(UserTool.userProvider.userInfo.end * 1000, format: DateFormats.y_mo_d)}到期" : "解锁全部功能", isVip
? "${DateUtil.formatDateMs(UserTool.userProvider.userInfo.end * 1000, format: DateFormats.y_mo_d)}到期"
: "解锁全部功能",
style: TextStyle(color: Colors.white, fontSize: BaseStyle.fontSize24), style: TextStyle(color: Colors.white, fontSize: BaseStyle.fontSize24),
) )
], ],
@ -373,6 +379,7 @@ class _UserPageState extends State<UserPage> {
], ],
); );
} }
// //
_getSwitch2() { _getSwitch2() {
return Container( return Container(
@ -402,7 +409,6 @@ class _UserPageState extends State<UserPage> {
// await prefs.setBool("kg", value); // await prefs.setBool("kg", value);
// print("这是数据${prefs.getBool("kg")}"); // print("这是数据${prefs.getBool("kg")}");
setState(() { setState(() {
if (isVip) { if (isVip) {
vle = value; vle = value;
// prefs.setBool("kg", vle); // prefs.setBool("kg", vle);
@ -424,6 +430,7 @@ class _UserPageState extends State<UserPage> {
prefs.remove("kg"); prefs.remove("kg");
prefs.setBool("kg", vle); prefs.setBool("kg", vle);
service.invoke("stopService"); service.invoke("stopService");
/// ///
// exit(0); // exit(0);
// UserTool.userProvider.setKg(vle); // UserTool.userProvider.setKg(vle);
@ -436,8 +443,7 @@ class _UserPageState extends State<UserPage> {
} else { } else {
BotToast.showText(text: "还没有开通会员,不可使用该功能"); BotToast.showText(text: "还没有开通会员,不可使用该功能");
} }
} });
);
}), }),
)); ));
} }

Loading…
Cancel
Save