王亚玲 2 years ago
commit 059051c224

@ -27,7 +27,10 @@ class AddSmsPage extends StatefulWidget {
class _AddSmsPageState extends State<AddSmsPage> { class _AddSmsPageState extends State<AddSmsPage> {
late TextEditingController _controller; late TextEditingController _controller;
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
String contant=""; String contant="";
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -99,8 +102,20 @@ class _AddSmsPageState extends State<AddSmsPage> {
if (res.code == 0) { if (res.code == 0) {
setState(() {}); setState(() {});
widget.ploneBack(_controller.text); widget.ploneBack(_controller.text);
UserTool.userProvider.updateUserInfo(); switch (widget.status) {
// userProvider.updateUserInfo(); case 1:
await userProvider.updateConSms();
break;
case 2:
await userProvider.updateRefSms();
break;
case 3:
await userProvider.updateCallSms();
break;
case 4:
await userProvider.updateIdleSms();
break;
}
} else { } else {
CloudToast.show(res.msg); CloudToast.show(res.msg);
} }

@ -63,6 +63,8 @@ void onStart(ServiceInstance service) async {
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? 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();
@ -78,13 +80,16 @@ void onStart(ServiceInstance service) async {
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: con!); Telephony.backgroundInstance.sendSms(to: phoneNum!, message: con!);
}else { }else {
if(entry.first.duration!>0){ if(entry.first.duration!>0){
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: call!); if(callSw!){
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: call!);
}
print("去电接听"); print("去电接听");
}else{ }else{
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: idle!); if(idleSw!){
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: idle!);
}
print("去电未接"); print("去电未接");
} }
// Telephony.backgroundInstance.sendSms(to: phoneNum!, message: con!);
print("发送成功"); print("发送成功");
} }
flag = 0; flag = 0;

@ -7,6 +7,7 @@ import 'package:get/get.dart';
import 'package:project_telephony/extensions/num_ext.dart'; import 'package:project_telephony/extensions/num_ext.dart';
import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/utils/headers.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../base/base_style.dart'; import '../../base/base_style.dart';
import '../../constants/api.dart'; import '../../constants/api.dart';
@ -17,19 +18,20 @@ import '../../providers/user_provider.dart';
import '../../utils/toast/cloud_toast.dart'; import '../../utils/toast/cloud_toast.dart';
import '../widget/centertipsalterwidget.dart'; import '../widget/centertipsalterwidget.dart';
import 'add_sms_page.dart'; import 'add_sms_page.dart';
import 'home_page.dart';
class CallingIdleList extends StatefulWidget { class CallingIdleList extends StatefulWidget {
final EasyRefreshController refreshController; final EasyRefreshController refreshController;
final String title; final String title;
final int status; final int status;
final bool? isIdle; final String? name;
final Color themeColor; final Color themeColor;
const CallingIdleList({ const CallingIdleList({
Key? key, Key? key,
required this.title, required this.title,
required this.status, required this.status,
this.isIdle = false, this.name = '',
required this.themeColor, required this.themeColor,
required this.refreshController, required this.refreshController,
}) : super(key: key); }) : super(key: key);
@ -41,17 +43,24 @@ class CallingIdleList extends StatefulWidget {
class _CallingIdleListState extends State<CallingIdleList> class _CallingIdleListState extends State<CallingIdleList>
with AutomaticKeepAliveClientMixin { with AutomaticKeepAliveClientMixin {
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false); final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
final Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
List<String> textList = ['现在无法接听。有什么事吗?', '自定义短信内容']; List<String> textList = ['现在无法接听。有什么事吗?', '自定义短信内容'];
List<SmsContentModel> _model = []; List<SmsContentModel> _model = [];
List<String> textListSMS = []; List<String> textListSMS = [];
List<int> smsIdList = []; List<int> smsIdList = [];
int isCheck = 0; int isCheck = 0;
bool val = false; late bool val = false;
@override @override
void initState() { void initState() {
getSwitch();
super.initState(); super.initState();
updateList(); }
Future<void> getSwitch() async {
final SharedPreferences prefs = await _prefs;
val = prefs.getBool(widget.name!)!;
print(val);
} }
Future<void> updateList() async { Future<void> updateList() async {
@ -88,39 +97,15 @@ class _CallingIdleListState extends State<CallingIdleList>
children: [ children: [
_getText(), _getText(),
32.hb, 32.hb,
widget.isIdle! widget.name!.isEmpty || val
? val ? Expanded(
? 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()
: Expanded(
child: EasyRefresh.custom( 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();
userProvider.updateRefSms();
await updateList(); await updateList();
setState(() {}); setState(() {});
}, },
@ -132,7 +117,8 @@ class _CallingIdleListState extends State<CallingIdleList>
), ),
], ],
), ),
), )
: _getEmptyList(),
], ],
); );
} }
@ -142,23 +128,35 @@ class _CallingIdleListState extends State<CallingIdleList>
height: 128.w, height: 128.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(
"功能讲解", "功能讲解",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 36.sp), style: TextStyle(fontWeight: FontWeight.bold, fontSize: 36.sp),
), ),
subtitle: Text( subtitle: Text(
widget.title, widget.title,
style: TextStyle(color: const Color(0xFF999999), fontSize: 27.sp), style: TextStyle(color: const Color(0xFF999999), fontSize: 27.sp),
),
trailing: Offstage(
offstage: widget.name!.isEmpty,
child: Switch(
value: val,
onChanged: (value) async {
final SharedPreferences prefs = await _prefs;
setState(() {
val = value;
prefs.remove(widget.name!);
prefs.setBool(widget.name!, val);
});
service.invoke("stopService");
if (prefs.getBool('kg')!) {
Future.delayed(const Duration(seconds: 1), () async {
service.startService();
});
}
},
), ),
trailing: widget.isIdle! ),
? Switch( ),
value: val,
onChanged: (value) async {
setState(() {
val = value;
});
})
: const SizedBox()),
); );
} }
@ -170,7 +168,7 @@ class _CallingIdleListState extends State<CallingIdleList>
data: {'id': smsIdList[index], 'status': widget.status}); data: {'id': smsIdList[index], 'status': widget.status});
if (res.code == 0) { if (res.code == 0) {
setState(() {}); setState(() {});
await userProvider.updateUserInfo(); // await userProvider.updateUserInfo();
switch (widget.status) { switch (widget.status) {
case 1: case 1:
await userProvider.updateConSms(); await userProvider.updateConSms();

@ -5,6 +5,7 @@ import 'package:project_telephony/ui/home/calling_idle_list.dart';
import 'package:project_telephony/ui/widget/plone_back_button.dart'; import 'package:project_telephony/ui/widget/plone_back_button.dart';
import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/utils/headers.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:tab_indicator_styler/tab_indicator_styler.dart'; import 'package:tab_indicator_styler/tab_indicator_styler.dart';
@ -25,12 +26,12 @@ class _ContentConnectPageState extends State<ContentConnectPage>
@override @override
void initState() { void initState() {
super.initState();
_tabController = TabController( _tabController = TabController(
length: 2, length: 2,
initialIndex: 0, initialIndex: 0,
vsync: this, vsync: this,
); );
super.initState();
} }
@override @override
@ -109,7 +110,7 @@ class _ContentConnectPageState extends State<ContentConnectPage>
), ),
CallingIdleList( CallingIdleList(
refreshController: _answerRefreshController, refreshController: _answerRefreshController,
isIdle: true, name: "callSwitch",
title: '您给朋友去电接听后所发送的短信', title: '您给朋友去电接听后所发送的短信',
status: 3, status: 3,
themeColor: const Color(0xFF1890FF), themeColor: const Color(0xFF1890FF),

@ -3,6 +3,7 @@ import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:project_telephony/base/base_style.dart'; import 'package:project_telephony/base/base_style.dart';
import 'package:project_telephony/ui/widget/plone_back_button.dart'; import 'package:project_telephony/ui/widget/plone_back_button.dart';
import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/utils/headers.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:tab_indicator_styler/tab_indicator_styler.dart'; import 'package:tab_indicator_styler/tab_indicator_styler.dart';
import 'calling_idle_list.dart'; import 'calling_idle_list.dart';
@ -21,10 +22,12 @@ class _ContentRefusePageState extends State<ContentRefusePage>
EasyRefreshController(); EasyRefreshController();
final EasyRefreshController _wasCalledRefreshController = final EasyRefreshController _wasCalledRefreshController =
EasyRefreshController(); EasyRefreshController();
bool? idleSwitch=true;
@override @override
void initState() { void initState() {
_tabController = TabController(length: 2, initialIndex: 0, vsync: this); _tabController = TabController(length: 2, initialIndex: 0, vsync: this);
getSwitch();
super.initState(); super.initState();
} }
@ -36,6 +39,11 @@ class _ContentRefusePageState extends State<ContentRefusePage>
super.dispose(); super.dispose();
} }
Future<void> getSwitch()async{
final SharedPreferences prefs = await SharedPreferences.getInstance();
idleSwitch=prefs.getBool("idleSwitch");
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context); super.build(context);
@ -97,13 +105,12 @@ class _ContentRefusePageState extends State<ContentRefusePage>
controller: _tabController, controller: _tabController,
children:[ children:[
CallingIdleList( CallingIdleList(
isIdle: false,
status: 2, status: 2,
themeColor: const Color(0xFF13CA9D), themeColor: const Color(0xFF13CA9D),
title: '朋友给你来电接听后所发送的短信', refreshController: _callingRefreshController, title: '朋友给你来电接听后所发送的短信', refreshController: _callingRefreshController,
), ),
CallingIdleList( CallingIdleList(
isIdle: true, name: "idleSwitch",
status: 4, status: 4,
title: '您给朋友去电拒接/未接后所发送的短信', title: '您给朋友去电拒接/未接后所发送的短信',
themeColor: const Color(0xFF13CA9D), refreshController: _wasCalledRefreshController, themeColor: const Color(0xFF13CA9D), refreshController: _wasCalledRefreshController,

@ -43,12 +43,12 @@ class AppDialog extends Dialog {
_getVip(), _getVip(),
200.hb, 200.hb,
Row( Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
72.wb,
_getText("接听发送"), _getText("接听发送"),
64.wb, 60.wb,
_getText("拒接发送"), _getText("拒接发送"),
64.wb, 60.wb,
_getText("提升形象"), _getText("提升形象"),
], ],
), ),

Loading…
Cancel
Save