diff --git a/lib/providers/user_provider.dart b/lib/providers/user_provider.dart index 68e98fe..863364c 100644 --- a/lib/providers/user_provider.dart +++ b/lib/providers/user_provider.dart @@ -75,7 +75,7 @@ class UserProvider extends ChangeNotifier { notifyListeners(); } - Future updateConSms( ) async { + Future updateConSms() async { final prefs = await SharedPreferences.getInstance(); final service = FlutterBackgroundService(); var base = await apiClient.request(API.content.find, data: {'status': 1}); @@ -121,6 +121,52 @@ class UserProvider extends ChangeNotifier { notifyListeners(); } + Future updateSms() async { + final prefs = await SharedPreferences.getInstance(); + final service = FlutterBackgroundService(); + var base = await apiClient.request(API.content.find, data: {'status': 2}); + if (base.code == 0) { + await prefs.remove('refSms'); + await prefs.setString( + 'refSms', + (UserTool.userProvider.userInfo.tag) == "" + ? "${base.data['content']}" + : "【${UserTool.userProvider.userInfo.tag}】${base.data['content']}"); + service.invoke("stopService"); + if (prefs.getBool('kg')!) { + Future.delayed(const Duration(seconds: 1), () async { + service.startService(); + }); + } + } else { + CloudToast.show(base.msg); + } + notifyListeners(); + } + + Future updateIdleSms() async { + final prefs = await SharedPreferences.getInstance(); + final service = FlutterBackgroundService(); + var base = await apiClient.request(API.content.find, data: {'status': 2}); + if (base.code == 0) { + await prefs.remove('refSms'); + await prefs.setString( + 'refSms', + (UserTool.userProvider.userInfo.tag) == "" + ? "${base.data['content']}" + : "【${UserTool.userProvider.userInfo.tag}】${base.data['content']}"); + service.invoke("stopService"); + if (prefs.getBool('kg')!) { + Future.delayed(const Duration(seconds: 1), () async { + service.startService(); + }); + } + } else { + CloudToast.show(base.msg); + } + notifyListeners(); + } + Future getExclude() async { final prefs = await SharedPreferences.getInstance(); final service = FlutterBackgroundService(); diff --git a/lib/ui/home/answer_idle.dart b/lib/ui/home/answer_idle.dart index 6f97500..7431fa1 100644 --- a/lib/ui/home/answer_idle.dart +++ b/lib/ui/home/answer_idle.dart @@ -2,8 +2,6 @@ import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; -import 'package:project_telephony/ui/home/func/contant_func.dart'; -import 'package:project_telephony/ui/widget/plone_bottom.dart'; import 'package:project_telephony/utils/headers.dart'; import 'package:provider/provider.dart'; @@ -23,13 +21,8 @@ class AnswerIdleList extends StatefulWidget { final bool isIdle; final int num; - // final List contant; - const AnswerIdleList( - {Key? key, - required this.refreshController, - required this.isIdle, - required this.num}) + {Key? key, required this.refreshController, required this.isIdle,required this.num}) : super(key: key); @override @@ -41,13 +34,12 @@ class _AnswerIdleListState extends State final userProvider = Provider.of(Get.context!, listen: false); List textList = ['现在无法接听。有什么事吗?', '自定义短信内容']; List _model = []; - List answerList = []; + List answerList=[]; List textListSMS = []; List smsIdList = []; int isCheck = 0; bool val = false; - // final EasyRefreshController _easyRefreshController = EasyRefreshController(); @override Widget build(BuildContext context) { @@ -57,71 +49,51 @@ class _AnswerIdleListState extends State 32.hb, widget.isIdle ? val - ? Expanded( - // width: 662.w, - // height: 800.w, - child: EasyRefresh.custom( - firstRefresh: true, - controller: widget.refreshController, - header: MaterialHeader(), - // footer: MaterialFooter(), - onRefresh: () async { - // await userProvider.updateUserInfo(); - // answerList = - // await ContantFunc.getFindByStatus(widget.num); - // print("这是数据$answerList"); - // // userProvider.updateRefSms(); - updateList(); - setState(() {}); - }, - slivers: [ - SliverList( - delegate: - SliverChildBuilderDelegate((context, index) { - return _getBox(answerList[index], index); - }, childCount: answerList.length)), - ])) - : _getEmptyList() + ? Expanded( + // width: 662.w, + // height: 800.w, + child: EasyRefresh.custom( + firstRefresh: true, + controller: widget.refreshController, + header: MaterialHeader(), + // footer: MaterialFooter(), + onRefresh: () async { + await userProvider.updateUserInfo(); + print("这是数据$answerList"); + // userProvider.updateRefSms(); + // updateList(); + setState(() {}); + }, + slivers: [ + SliverList( + delegate: + SliverChildBuilderDelegate((context, index) { + return _getBox(answerList[index], index); + }, childCount: answerList.length)), + ])) + : _getEmptyList() : Expanded( - // width: 662.w, - // height: 800.w, - child: EasyRefresh.custom( - firstRefresh: true, - controller: widget.refreshController, - header: MaterialHeader(), - // footer: MaterialFooter(), - onRefresh: () async { - await userProvider.updateUserInfo(); - answerList = - await ContantFunc.getFindByStatus(widget.num); - print("这是数据$answerList"); - // userProvider.updateRefSms(); - // updateList(); - setState(() {}); - }, - slivers: [ - SliverList( - delegate: SliverChildBuilderDelegate((context, index) { - return _getBox(answerList[index], index); - }, childCount: answerList.length)) - ])), - PloneBottom(onTap: () { - if (userProvider.userInfo.isVip == 1) { - if (answerList.length > 5) { - BotToast.showText(text: '自定义数量已达上限,请先删除不需要的短信'); - } else { - Get.to(AddSmsPage( - status: 1, - ploneBack: (String textContent) { - widget.refreshController.callRefresh(); + // width: 662.w, + // height: 800.w, + child: EasyRefresh.custom( + firstRefresh: true, + controller: widget.refreshController, + header: MaterialHeader(), + // footer: MaterialFooter(), + onRefresh: () async { + await userProvider.updateUserInfo(); + print("这是数据$answerList"); + // userProvider.updateRefSms(); + // updateList(); + setState(() {}); }, - )); - } - } else { - BotToast.showText(text: '请先开通会员'); - } - setState(() {}); - }), + slivers: [ + SliverList( + delegate: + SliverChildBuilderDelegate((context, index) { + return _getBox(answerList[index], index); + }, childCount: answerList.length)) + ])) ], ); } @@ -132,10 +104,9 @@ class _AnswerIdleListState extends State // smsIdList.clear(); int i = 0; // contentRef - var base = await apiClient - .request(API.content.findByStatus, data: {'status': 1}); + var base = await apiClient.request(API.content.findByStatus, data: {'status': 1}); if (base.code == 0) { - _model = (base.data as List) + _model=(base.data as List) .map((e) => SmsContentModel.fromJson(e)) .toList(); } else { @@ -166,32 +137,33 @@ class _AnswerIdleListState extends State style: TextStyle(fontWeight: FontWeight.bold, fontSize: 36.sp), ), subtitle: Text( - widget.isIdle ? "您给朋友去电接听后所发送的短信" : "朋友给你来电接听后所发送的短信", + widget.isIdle + ? "您给朋友去电接听后所发送的短信":"朋友给你来电接听后所发送的短信", style: TextStyle(color: const Color(0xFF999999), fontSize: 28.sp), ), trailing: widget.isIdle ? Switch( - value: val, - onChanged: (value) async { - // if(!value){ - // - // } - // await prefs.setBool("kg", value); - // print("这是数据${prefs.getBool("kg")}"); - setState(() { - val = value; - }); - }) + value: val, + onChanged: (value) async { + // if(!value){ + // + // } + // await prefs.setBool("kg", value); + // print("这是数据${prefs.getBool("kg")}"); + setState(() { + val = value; + }); + }) : const SizedBox()), ); } - _getBox(ContantListModel item, int index) { + _getBox(ContantListModel item,int index) { return GestureDetector( onTap: () async { if (item.content != "自定义短信内容") { - BaseModel res = await apiClient - .request(API.content.checked, data: {'id': item.id, 'status': 1}); + BaseModel res = await apiClient.request(API.content.checked, + data: {'id': item.id, 'status': 1}); if (res.code == 0) { setState(() {}); userProvider.updateUserInfo(); diff --git a/lib/ui/home/calling_idle_list.dart b/lib/ui/home/calling_idle_list.dart index 4bd632a..1c9e635 100644 --- a/lib/ui/home/calling_idle_list.dart +++ b/lib/ui/home/calling_idle_list.dart @@ -54,6 +54,34 @@ class _CallingIdleListState extends State updateList(); } + Future updateList() async { + if (userProvider.isLogin) { + textListSMS.clear(); + smsIdList.clear(); + int i = 0; + var base = await apiClient + .request(API.content.findByStatus, data: {'status': widget.status}); + if (base.code == 0) { + _model = (base.data as List) + .map((e) => SmsContentModel.fromJson(e)) + .toList(); + } else { + CloudToast.show(base.msg); + } + for (var model in _model) { + textListSMS.add(model.content); + smsIdList.add(model.id); + if (model.isChecked == 1) { + isCheck = i; + } + i++; + } + textListSMS.add("自定义短信内容"); + } else { + textListSMS = textList; + } + } + @override Widget build(BuildContext context) { return Column( @@ -110,34 +138,6 @@ class _CallingIdleListState extends State ); } - updateList() async { - if (userProvider.isLogin) { - textListSMS.clear(); - smsIdList.clear(); - int i = 0; - var base = await apiClient - .request(API.content.findByStatus, data: {'status': widget.status}); - if (base.code == 0) { - _model = (base.data as List) - .map((e) => SmsContentModel.fromJson(e)) - .toList(); - } else { - CloudToast.show(base.msg); - } - for (var model in _model) { - textListSMS.add(model.content); - smsIdList.add(model.id); - if (model.isChecked == 1) { - isCheck = i; - } - i++; - } - textListSMS.add("自定义短信内容"); - } else { - textListSMS = textList; - } - } - _getText() { return Container( height: 128.w, @@ -182,12 +182,14 @@ class _CallingIdleListState extends State if (textListSMS.length > 5) { BotToast.showText(text: '自定义数量已达上限,请先删除不需要的短信'); } else { - Get.to(AddSmsPage( - status: 2, - ploneBack: (String textContent) { - widget.refreshController.callRefresh(); - }, - )); + Get.to( + AddSmsPage( + status: widget.status, + ploneBack: (String textContent) { + widget.refreshController.callRefresh(); + }, + ), + ); } } else { BotToast.showText(text: '请先开通会员'); @@ -232,7 +234,9 @@ class _CallingIdleListState extends State end: Alignment.centerRight, colors: [ index == isCheck ? widget.themeColor : const Color(0xFFF9F9F9), - index == isCheck ? widget.themeColor : const Color(0xFFF9F9F9), + index == isCheck + ? widget.themeColor.withOpacity(0.5) + : const Color(0xFFF9F9F9), ]), ), child: Text( diff --git a/lib/ui/home/content_connect_page.dart b/lib/ui/home/content_connect_page.dart index 69a30d6..130938e 100644 --- a/lib/ui/home/content_connect_page.dart +++ b/lib/ui/home/content_connect_page.dart @@ -1,15 +1,13 @@ - 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/home/calling_idle_list.dart'; import 'package:project_telephony/ui/widget/plone_back_button.dart'; import 'package:project_telephony/utils/headers.dart'; import 'package:tab_indicator_styler/tab_indicator_styler.dart'; -import 'answer_idle.dart'; - class ContentConnectPage extends StatefulWidget { const ContentConnectPage({Key? key}) : super(key: key); @@ -23,13 +21,15 @@ class _ContentConnectPageState extends State final EasyRefreshController _answerRefreshController = EasyRefreshController(); final EasyRefreshController _wasAnswerRefreshController = - EasyRefreshController(); - int state=1; - + EasyRefreshController(); @override void initState() { - _tabController = TabController(length: 2, initialIndex: 0, vsync: this); + _tabController = TabController( + length: 2, + initialIndex: 0, + vsync: this, + ); super.initState(); } @@ -45,74 +45,81 @@ class _ContentConnectPageState extends State Widget build(BuildContext context) { super.build(context); return Scaffold( - appBar: AppBar( - elevation: 0, - title: Text( - '选择短信内容', - style: Theme.of(context).textTheme.headline6, - ), - leading: const CloudBackButton(isSpecial: true), - backgroundColor: kForeGroundColor, + appBar: AppBar( + elevation: 0, + title: Text( + '选择短信内容', + style: Theme.of(context).textTheme.headline6, ), - backgroundColor: Colors.white, - body: Column( - children: [ - Container( - width:double.infinity, - height: 88.w, - margin: EdgeInsets.symmetric(horizontal: 66.w), - 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: (num) { - if(num==0){ - state=1; - _answerRefreshController.callRefresh(); - }else{ - state=3; - _wasAnswerRefreshController.callRefresh(); - } - }, - indicator: RectangularIndicator( - color: Colors.white, - bottomLeftRadius: 44.w, - bottomRightRadius: 44.w, - topLeftRadius: 44.w, - topRightRadius: 44.w, - // paintingStyle: PaintingStyle.fill, - ), - // indicatorSize: TabBarIndicatorSize.label, - // isScrollable: true, - tabs: const [ - // _tab(0, "被叫接听"),_tab(1, "主叫接听"), - Tab(text: "被叫接听",),Tab(text: "主叫接听",) - - ]), - - + leading: const CloudBackButton(isSpecial: true), + backgroundColor: kForeGroundColor, + ), + backgroundColor: Colors.white, + body: Column( + children: [ + Container( + width: double.infinity, + height: 88.w, + margin: EdgeInsets.symmetric(horizontal: 66.w), + padding: EdgeInsets.all(8.w), + decoration: BoxDecoration( + color: const Color(0xFFF9F9F9), + borderRadius: BorderRadius.all(Radius.circular(44.w))), + child: TabBar( + controller: _tabController, + labelColor: const Color(0xFF1890FF), + unselectedLabelColor: const Color(0xFF999999), + unselectedLabelStyle: + const TextStyle(fontWeight: FontWeight.bold), + labelStyle: const TextStyle(fontWeight: FontWeight.bold), + onTap: (num) { + if (num == 0) { + _answerRefreshController.callRefresh(); + } else { + _wasAnswerRefreshController.callRefresh(); + } + }, + indicator: RectangularIndicator( + color: Colors.white, + bottomLeftRadius: 44.w, + bottomRightRadius: 44.w, + topLeftRadius: 44.w, + topRightRadius: 44.w, + // paintingStyle: PaintingStyle.fill, + ), + tabs: const [ + Tab( + text: "被叫接听", + ), + Tab( + text: "主叫接听", + ), + ], ), - Expanded( - child: TabBarView(controller: _tabController, children: [ - // _getBox(), - AnswerIdleList( - // contant: const [], - num: state, - refreshController: _answerRefreshController, isIdle: false, - ), - AnswerIdleList( - // contant: const [], - num: state, - refreshController: _wasAnswerRefreshController, isIdle: true, - ) - ])) - ], - )); + ), + Expanded( + child: TabBarView( + controller: _tabController, + children: [ + CallingIdleList( + refreshController: _answerRefreshController, + title: '朋友给你来电接听后所发送的短信', + status: 1, + themeColor: const Color(0xFF1890FF), + ), + CallingIdleList( + refreshController: _answerRefreshController, + isIdle: true, + title: '您给朋友去电接听后所发送的短信', + status: 3, + themeColor: const Color(0xFF1890FF), + ), + ], + ), + ), + ], + ), + ); } @override diff --git a/lib/ui/home/func/contant_func.dart b/lib/ui/home/func/contant_func.dart deleted file mode 100644 index 04a8abb..0000000 --- a/lib/ui/home/func/contant_func.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:project_telephony/constants/api.dart'; -import 'package:project_telephony/model/contant_list_model.dart'; -import 'package:project_telephony/model/network/api_client.dart'; -import 'package:project_telephony/utils/inner_model/base_list_model.dart'; - - -import '../../../utils/toast/cloud_toast.dart'; - -class ContantFunc { - static Future> getFindByStatus(int status) async { - BaseListModel res = - await apiClient.requestList(API.content.findByStatus, data:{'status': status}); - if(res.code!=0) { - CloudToast.show(res.msg); - return []; - }else{ - return res.nullSafetyList.map((e) => ContantListModel.fromJson(e)).toList(); - } - } -} diff --git a/lib/ui/user/content_details_page.dart b/lib/ui/user/content_details_page.dart index 7a84d38..4e1a29a 100644 --- a/lib/ui/user/content_details_page.dart +++ b/lib/ui/user/content_details_page.dart @@ -112,7 +112,6 @@ final FocusNode verifyNode=FocusNode(); widget.ploneBack(_controller.text); UserTool.userProvider.updateUserInfo(); UserTool.userProvider.updateConSms(); - UserTool.userProvider.updateRefSms(); Get.back(); } else { CloudToast.show(res.msg); diff --git a/lib/ui/user/user_page.dart b/lib/ui/user/user_page.dart index 86e04b7..d1b6223 100644 --- a/lib/ui/user/user_page.dart +++ b/lib/ui/user/user_page.dart @@ -119,7 +119,7 @@ class _UserPageState extends State { // await UserTool.userProvider.updateUserInfo(); if (UserTool.userProvider.isLogin) { // 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){ return const AppDialog(); }); diff --git a/lib/ui/widget/appdialog.dart b/lib/ui/widget/appdialog.dart index 888ad2b..5a61972 100644 --- a/lib/ui/widget/appdialog.dart +++ b/lib/ui/widget/appdialog.dart @@ -24,10 +24,14 @@ class AppDialog extends Dialog { @override Widget build(BuildContext context) { return Container( - margin: EdgeInsets.symmetric(horizontal: 95.w,vertical: 452.w), + + margin:EdgeInsets.only(left: 95.w,top: 452.w), + + + // EdgeInsets.symmetric(horizontal: 95.w,vertical: 452.w), decoration: BoxDecoration( image: - DecorationImage(image: AssetImage(Assets.images.bouncedbg.path))), + DecorationImage(image: AssetImage(Assets.images.bouncedbg.path,))), child: Column( children: [ 32.hb,