列表刷新

master
王亚玲 2 years ago
parent 3b0bdfac3a
commit cd8ed0c77f

@ -104,7 +104,8 @@ class _AnswerIdleListState extends State<AnswerIdleList>
textListSMS.clear(); textListSMS.clear();
smsIdList.clear(); smsIdList.clear();
int i = 0; int i = 0;
userProvider.userInfo.contentRef?.forEach((model) { // contentRef
userProvider.userInfo.contentCon?.forEach((model) {
textListSMS.add(model.content); textListSMS.add(model.content);
smsIdList.add(model.id); smsIdList.add(model.id);
if (model.isChecked == 1) { if (model.isChecked == 1) {

@ -49,7 +49,10 @@ void onStart(ServiceInstance service) async {
int flag = 0; int flag = 0;
String? phoneNum = ""; String? phoneNum = "";
int? callRecords = 0; int? callRecords = 0;
String? state1="";
// CallType? state1;
String callState; String callState;
final Iterable<CallLogEntry> entry = await CallLog.query();
service.on('stopService').listen((event) { service.on('stopService').listen((event) {
service.stopSelf(); service.stopSelf();
}); });
@ -63,33 +66,49 @@ void onStart(ServiceInstance service) 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(entry.first.duration);
print(callState+"$flag"); print(callState+"$flag");
String? ref = prefs.getString('refSms'); String? ref = prefs.getString('refSms');
String? con = prefs.getString('conSms'); String? con = prefs.getString('conSms');
// print(con); // print(con);
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();
phoneNum = entry.first.number; phoneNum = entry.first.number;
callRecords = entry.first.duration; callRecords = entry.first.duration;
print(phoneNum); print(phoneNum);
if (flag > 0) { if (flag > 0) {
print("2"); print("来电拒接/未接");
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: ref!); // Telephony.backgroundInstance.sendSms(to: phoneNum!, message: ref!);
print("发送成功"); print("发送成功");
} else { } else if(flag==-1){
print("3"); print("来电接听");
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: con!); // Telephony.backgroundInstance.sendSms(to: phoneNum!, message: con!);
}else {
print(entry.first.callType);
print(entry.first.duration);
if(entry.first.duration!>0){
print("去电接听");
}else{
print("去电未接");
}
// Telephony.backgroundInstance.sendSms(to: phoneNum!, message: con!);
print("发送成功"); print("发送成功");
} }
flag = 0; flag = 0;
} }
} else if (callState == "RINGING") { } else if (callState == "RINGING") {
flag++; //
flag=1;
print('通话'); print('通话');
} else if (callState == "OFFHOOK") { } else if (callState == "OFFHOOK") {
//
if (flag > 0) flag *= -1; if (flag > 0) flag *= -1;
if(flag==0)flag=-2;
print('不通话'); print('不通话');
} }
}); });
} }

@ -41,6 +41,8 @@ class _CallingIdleListState extends State<CallingIdleList>
bool val = false; bool val = false;
// final EasyRefreshController _easyRefreshController = EasyRefreshController(); // final EasyRefreshController _easyRefreshController = EasyRefreshController();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return Column(

@ -21,9 +21,9 @@ class ContentConnectPage extends StatefulWidget {
class _ContentConnectPageState extends State<ContentConnectPage> class _ContentConnectPageState extends State<ContentConnectPage>
with AutomaticKeepAliveClientMixin, SingleTickerProviderStateMixin { with AutomaticKeepAliveClientMixin, SingleTickerProviderStateMixin {
late TabController _tabController; late TabController _tabController;
final EasyRefreshController _callingRefreshController = final EasyRefreshController _answerRefreshController =
EasyRefreshController(); EasyRefreshController();
final EasyRefreshController _wasCalledRefreshController = final EasyRefreshController _wasAnswerRefreshController =
EasyRefreshController(); EasyRefreshController();
@override @override
@ -35,8 +35,8 @@ class _ContentConnectPageState extends State<ContentConnectPage>
@override @override
void dispose() { void dispose() {
_tabController.dispose(); _tabController.dispose();
_callingRefreshController.dispose(); _answerRefreshController.dispose();
_wasCalledRefreshController.dispose(); _wasAnswerRefreshController.dispose();
super.dispose(); super.dispose();
} }
@ -69,9 +69,14 @@ class _ContentConnectPageState extends State<ContentConnectPage>
unselectedLabelColor:const Color(0xFF999999), unselectedLabelColor:const Color(0xFF999999),
unselectedLabelStyle:const TextStyle(fontWeight:FontWeight.bold), unselectedLabelStyle:const TextStyle(fontWeight:FontWeight.bold),
labelStyle:const TextStyle(fontWeight:FontWeight.bold), labelStyle:const TextStyle(fontWeight:FontWeight.bold),
// onTap: () async{ onTap: (num) {
// _refreshController.callRefresh(); if(num==0){
// }, _answerRefreshController.callRefresh();
}else{
_wasAnswerRefreshController.callRefresh();
}
//
},
indicator: RectangularIndicator( indicator: RectangularIndicator(
color: Colors.white, color: Colors.white,
bottomLeftRadius: 44.w, bottomLeftRadius: 44.w,
@ -95,32 +100,32 @@ class _ContentConnectPageState extends State<ContentConnectPage>
// _getBox(), // _getBox(),
AnswerIdleList( AnswerIdleList(
// contant: const [], // contant: const [],
refreshController: _callingRefreshController, isIdle: false, refreshController: _answerRefreshController, isIdle: false,
), ),
AnswerIdleList( AnswerIdleList(
// contant: const [], // contant: const [],
refreshController: _callingRefreshController, isIdle: true, refreshController: _wasAnswerRefreshController, isIdle: true,
) )
])) ]))
], ],
)); ));
} }
_getBox() { // _getBox() {
return Container( // return Container(
color: Colors.red, // color: Colors.red,
width: 200.w, // width: 200.w,
height: 200.w, // height: 200.w,
); // );
} // }
//
_tab(int int, String string) { // _tab(int int, String string) {
return Text( // return Text(
string, // string,
style: TextStyle( // style: TextStyle(
fontSize: BaseStyle.fontSize28, color:const Color(0xFF1890FF) ), // fontSize: BaseStyle.fontSize28, color:const Color(0xFF1890FF) ),
); // );
} // }
@override @override
bool get wantKeepAlive => true; bool get wantKeepAlive => true;

@ -1,20 +1,11 @@
import 'dart:async';
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart'; 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/centertipsalterwidget.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:project_telephony/utils/user_tool.dart';
import 'package:provider/provider.dart';
import 'package:tab_indicator_styler/tab_indicator_styler.dart'; import 'package:tab_indicator_styler/tab_indicator_styler.dart';
import '../../constants/api.dart';
import '../../model/network/api_client.dart';
import '../../model/network/base_model.dart';
import '../../providers/user_provider.dart';
import '../../utils/toast/cloud_toast.dart';
import 'add_sms_page.dart';
import 'calling_idle_list.dart'; import 'calling_idle_list.dart';
class ContentRefusePage extends StatefulWidget { class ContentRefusePage extends StatefulWidget {
@ -69,15 +60,21 @@ class _ContentRefusePageState extends State<ContentRefusePage>
padding: EdgeInsets.all(8.w), padding: EdgeInsets.all(8.w),
decoration:BoxDecoration(color: const Color(0xFFF9F9F9),borderRadius: BorderRadius.all(Radius.circular(44.w))), decoration:BoxDecoration(color: const Color(0xFFF9F9F9),borderRadius: BorderRadius.all(Radius.circular(44.w))),
child: TabBar( child: TabBar(
// indicator: Decoration(), // indicator: Decoration(),
controller: _tabController, controller: _tabController,
labelColor:const Color(0xFF1890FF), labelColor:const Color(0xFF1890FF),
unselectedLabelColor:const Color(0xFF999999), unselectedLabelColor:const Color(0xFF999999),
unselectedLabelStyle:const TextStyle(fontWeight:FontWeight.bold), unselectedLabelStyle:const TextStyle(fontWeight:FontWeight.bold),
labelStyle:const TextStyle(fontWeight:FontWeight.bold), labelStyle:const TextStyle(fontWeight:FontWeight.bold),
// onTap: () async{ onTap: (num) {
// _refreshController.callRefresh(); if(num==0){
// }, _callingRefreshController.callRefresh();
}else{
_wasCalledRefreshController.callRefresh();
}
//
},
indicator: RectangularIndicator( indicator: RectangularIndicator(
color: Colors.white, color: Colors.white,
bottomLeftRadius: 44.w, bottomLeftRadius: 44.w,
@ -91,7 +88,6 @@ class _ContentRefusePageState extends State<ContentRefusePage>
tabs: const [ tabs: const [
// _tab(0, "被叫接听"),_tab(1, "主叫接听"), // _tab(0, "被叫接听"),_tab(1, "主叫接听"),
Tab(text: "被叫拒接/未接",),Tab(text: "主叫拒接/未接",) Tab(text: "被叫拒接/未接",),Tab(text: "主叫拒接/未接",)
]), ]),
@ -101,11 +97,12 @@ class _ContentRefusePageState extends State<ContentRefusePage>
// _getBox(), // _getBox(),
CallingIdleList( CallingIdleList(
// contant: const [], // contant: const [],
refreshController: _callingRefreshController, isIdle: false, refreshController: _callingRefreshController,
isIdle: false,
), ),
CallingIdleList( CallingIdleList(
// contant: const [], // contant: const [],
refreshController: _callingRefreshController, isIdle: true, refreshController: _wasCalledRefreshController, isIdle: true,
) )
])) ]))
], ],

@ -28,11 +28,11 @@ class _LoadingState extends State<Loading> {
void initState() { void initState() {
super.initState(); super.initState();
final userProvider = Provider.of<UserProvider>(context, listen: false); final userProvider = Provider.of<UserProvider>(context, listen: false);
// var env = const String.fromEnvironment('ENV', defaultValue: 'dev'); var env = const String.fromEnvironment('ENV', defaultValue: 'dev');
// if (kDebugMode) { if (kDebugMode) {
// print('env :$env'); print('env :$env');
// } }
// DevEV.instance.setEnvironment( context, environment: env == 'dev',); DevEV.instance.setEnvironment( context, environment: env == 'dev',);
Future.delayed(const Duration(milliseconds: 1000), () async { Future.delayed(const Duration(milliseconds: 1000), () async {
await initialAll(); await initialAll();
if (!await userProvider.init()) { if (!await userProvider.init()) {

Loading…
Cancel
Save