diff --git a/lib/ui/home/answer_idle.dart b/lib/ui/home/answer_idle.dart index 982916d..7e6ea85 100644 --- a/lib/ui/home/answer_idle.dart +++ b/lib/ui/home/answer_idle.dart @@ -104,7 +104,8 @@ class _AnswerIdleListState extends State textListSMS.clear(); smsIdList.clear(); int i = 0; - userProvider.userInfo.contentRef?.forEach((model) { + // contentRef + userProvider.userInfo.contentCon?.forEach((model) { textListSMS.add(model.content); smsIdList.add(model.id); if (model.isChecked == 1) { diff --git a/lib/ui/home/call.dart b/lib/ui/home/call.dart index b19c050..4bdedff 100644 --- a/lib/ui/home/call.dart +++ b/lib/ui/home/call.dart @@ -49,7 +49,10 @@ void onStart(ServiceInstance service) async { int flag = 0; String? phoneNum = ""; int? callRecords = 0; + String? state1=""; + // CallType? state1; String callState; + final Iterable entry = await CallLog.query(); service.on('stopService').listen((event) { service.stopSelf(); }); @@ -63,33 +66,49 @@ void onStart(ServiceInstance service) async { final SharedPreferences prefs = await SharedPreferences.getInstance(); CallState state = await Telephony.instance.callState; callState = state.name; + // print(entry.first.duration); print(callState+"$flag"); String? ref = prefs.getString('refSms'); String? con = prefs.getString('conSms'); // print(con); + + if (callState == "IDLE") { + //闲置 if (flag != 0) { final Iterable entry = await CallLog.query(); phoneNum = entry.first.number; callRecords = entry.first.duration; print(phoneNum); if (flag > 0) { - print("2"); - Telephony.backgroundInstance.sendSms(to: phoneNum!, message: ref!); + print("来电拒接/未接"); + // Telephony.backgroundInstance.sendSms(to: phoneNum!, message: ref!); print("发送成功"); - } else { - print("3"); - Telephony.backgroundInstance.sendSms(to: phoneNum!, message: con!); + } else if(flag==-1){ + print("来电接听"); + // 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("发送成功"); } flag = 0; } } else if (callState == "RINGING") { - flag++; + //响铃 + flag=1; print('通话'); } else if (callState == "OFFHOOK") { + //通话 if (flag > 0) flag *= -1; + if(flag==0)flag=-2; print('不通话'); } }); -} +} \ No newline at end of file diff --git a/lib/ui/home/calling_idle_list.dart b/lib/ui/home/calling_idle_list.dart index f721d04..009ff79 100644 --- a/lib/ui/home/calling_idle_list.dart +++ b/lib/ui/home/calling_idle_list.dart @@ -41,6 +41,8 @@ class _CallingIdleListState extends State bool val = false; // final EasyRefreshController _easyRefreshController = EasyRefreshController(); + + @override Widget build(BuildContext context) { return Column( diff --git a/lib/ui/home/content_connect_page.dart b/lib/ui/home/content_connect_page.dart index 144adbc..1e0ad22 100644 --- a/lib/ui/home/content_connect_page.dart +++ b/lib/ui/home/content_connect_page.dart @@ -21,9 +21,9 @@ class ContentConnectPage extends StatefulWidget { class _ContentConnectPageState extends State with AutomaticKeepAliveClientMixin, SingleTickerProviderStateMixin { late TabController _tabController; - final EasyRefreshController _callingRefreshController = + final EasyRefreshController _answerRefreshController = EasyRefreshController(); - final EasyRefreshController _wasCalledRefreshController = + final EasyRefreshController _wasAnswerRefreshController = EasyRefreshController(); @override @@ -35,8 +35,8 @@ class _ContentConnectPageState extends State @override void dispose() { _tabController.dispose(); - _callingRefreshController.dispose(); - _wasCalledRefreshController.dispose(); + _answerRefreshController.dispose(); + _wasAnswerRefreshController.dispose(); super.dispose(); } @@ -69,9 +69,14 @@ class _ContentConnectPageState extends State unselectedLabelColor:const Color(0xFF999999), unselectedLabelStyle:const TextStyle(fontWeight:FontWeight.bold), labelStyle:const TextStyle(fontWeight:FontWeight.bold), - // onTap: () async{ - // _refreshController.callRefresh(); - // }, + onTap: (num) { + if(num==0){ + _answerRefreshController.callRefresh(); + }else{ + _wasAnswerRefreshController.callRefresh(); + } + // + }, indicator: RectangularIndicator( color: Colors.white, bottomLeftRadius: 44.w, @@ -95,32 +100,32 @@ class _ContentConnectPageState extends State // _getBox(), AnswerIdleList( // contant: const [], - refreshController: _callingRefreshController, isIdle: false, + refreshController: _answerRefreshController, isIdle: false, ), AnswerIdleList( // contant: const [], - refreshController: _callingRefreshController, isIdle: true, + refreshController: _wasAnswerRefreshController, isIdle: true, ) ])) ], )); } - _getBox() { - return Container( - color: Colors.red, - width: 200.w, - height: 200.w, - ); - } - - _tab(int int, String string) { - return Text( - string, - style: TextStyle( - fontSize: BaseStyle.fontSize28, color:const Color(0xFF1890FF) ), - ); - } + // _getBox() { + // return Container( + // color: Colors.red, + // width: 200.w, + // height: 200.w, + // ); + // } + // + // _tab(int int, String string) { + // return Text( + // string, + // style: TextStyle( + // fontSize: BaseStyle.fontSize28, color:const Color(0xFF1890FF) ), + // ); + // } @override bool get wantKeepAlive => true; diff --git a/lib/ui/home/content_refuse_page.dart b/lib/ui/home/content_refuse_page.dart index 7389f5d..8c0af24 100644 --- a/lib/ui/home/content_refuse_page.dart +++ b/lib/ui/home/content_refuse_page.dart @@ -1,20 +1,11 @@ -import 'dart:async'; -import 'package:bot_toast/bot_toast.dart'; + import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.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/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 '../../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'; class ContentRefusePage extends StatefulWidget { @@ -69,15 +60,21 @@ class _ContentRefusePageState extends State padding: EdgeInsets.all(8.w), decoration:BoxDecoration(color: const Color(0xFFF9F9F9),borderRadius: BorderRadius.all(Radius.circular(44.w))), child: TabBar( + // indicator: Decoration(), controller: _tabController, labelColor:const Color(0xFF1890FF), unselectedLabelColor:const Color(0xFF999999), unselectedLabelStyle:const TextStyle(fontWeight:FontWeight.bold), labelStyle:const TextStyle(fontWeight:FontWeight.bold), - // onTap: () async{ - // _refreshController.callRefresh(); - // }, + onTap: (num) { + if(num==0){ + _callingRefreshController.callRefresh(); + }else{ + _wasCalledRefreshController.callRefresh(); + } + // + }, indicator: RectangularIndicator( color: Colors.white, bottomLeftRadius: 44.w, @@ -91,7 +88,6 @@ class _ContentRefusePageState extends State tabs: const [ // _tab(0, "被叫接听"),_tab(1, "主叫接听"), Tab(text: "被叫拒接/未接",),Tab(text: "主叫拒接/未接",) - ]), @@ -101,11 +97,12 @@ class _ContentRefusePageState extends State // _getBox(), CallingIdleList( // contant: const [], - refreshController: _callingRefreshController, isIdle: false, + refreshController: _callingRefreshController, + isIdle: false, ), CallingIdleList( // contant: const [], - refreshController: _callingRefreshController, isIdle: true, + refreshController: _wasCalledRefreshController, isIdle: true, ) ])) ], diff --git a/lib/ui/loading.dart b/lib/ui/loading.dart index 7e618f9..aeae694 100644 --- a/lib/ui/loading.dart +++ b/lib/ui/loading.dart @@ -28,11 +28,11 @@ class _LoadingState extends State { void initState() { super.initState(); final userProvider = Provider.of(context, listen: false); - // var env = const String.fromEnvironment('ENV', defaultValue: 'dev'); - // if (kDebugMode) { - // print('env :$env'); - // } - // DevEV.instance.setEnvironment( context, environment: env == 'dev',); + var env = const String.fromEnvironment('ENV', defaultValue: 'dev'); + if (kDebugMode) { + print('env :$env'); + } + DevEV.instance.setEnvironment( context, environment: env == 'dev',); Future.delayed(const Duration(milliseconds: 1000), () async { await initialAll(); if (!await userProvider.init()) {