# Conflicts:
#	lib/providers/user_provider.dart
#	lib/ui/home/answer_idle.dart
#	lib/ui/home/func/contant_func.dart
master
王亚玲 2 years ago
commit fe119a74ec

@ -75,7 +75,7 @@ class UserProvider extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
Future updateConSms( ) async { Future updateConSms() async {
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
final service = FlutterBackgroundService(); final service = FlutterBackgroundService();
var base = await apiClient.request(API.content.find, data: {'status': 1}); var base = await apiClient.request(API.content.find, data: {'status': 1});
@ -121,6 +121,52 @@ class UserProvider extends ChangeNotifier {
notifyListeners(); 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 { Future getExclude() async {
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
final service = FlutterBackgroundService(); final service = FlutterBackgroundService();

@ -2,8 +2,6 @@ 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/ui/home/func/contant_func.dart';
import 'package:project_telephony/ui/widget/plone_bottom.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';
@ -23,13 +21,8 @@ class AnswerIdleList extends StatefulWidget {
final bool isIdle; final bool isIdle;
final int num; final int num;
// final List contant;
const AnswerIdleList( const AnswerIdleList(
{Key? key, {Key? key, required this.refreshController, required this.isIdle,required this.num})
required this.refreshController,
required this.isIdle,
required this.num})
: super(key: key); : super(key: key);
@override @override
@ -41,13 +34,12 @@ class _AnswerIdleListState extends State<AnswerIdleList>
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false); final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
List<String> textList = ['现在无法接听。有什么事吗?', '自定义短信内容']; List<String> textList = ['现在无法接听。有什么事吗?', '自定义短信内容'];
List<SmsContentModel> _model = []; List<SmsContentModel> _model = [];
List<ContantListModel> answerList = []; List<ContantListModel> answerList=[];
List<String> textListSMS = []; List<String> textListSMS = [];
List<int> smsIdList = []; List<int> smsIdList = [];
int isCheck = 0; int isCheck = 0;
bool val = false; bool val = false;
// final EasyRefreshController _easyRefreshController = EasyRefreshController(); // final EasyRefreshController _easyRefreshController = EasyRefreshController();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -57,71 +49,51 @@ class _AnswerIdleListState extends State<AnswerIdleList>
32.hb, 32.hb,
widget.isIdle widget.isIdle
? val ? val
? Expanded( ? Expanded(
// width: 662.w, // width: 662.w,
// height: 800.w, // height: 800.w,
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();
// answerList = print("这是数据$answerList");
// await ContantFunc.getFindByStatus(widget.num); // userProvider.updateRefSms();
// print("这是数据$answerList"); // updateList();
// // userProvider.updateRefSms(); setState(() {});
updateList(); },
setState(() {}); slivers: [
}, SliverList(
slivers: [ delegate:
SliverList( SliverChildBuilderDelegate((context, index) {
delegate: return _getBox(answerList[index], index);
SliverChildBuilderDelegate((context, index) { }, childCount: answerList.length)),
return _getBox(answerList[index], index); ]))
}, childCount: answerList.length)), : _getEmptyList()
]))
: _getEmptyList()
: Expanded( : Expanded(
// width: 662.w, // width: 662.w,
// height: 800.w, // height: 800.w,
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();
answerList = print("这是数据$answerList");
await ContantFunc.getFindByStatus(widget.num); // userProvider.updateRefSms();
print("这是数据$answerList"); // updateList();
// userProvider.updateRefSms(); setState(() {});
// 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();
}, },
)); slivers: [
} SliverList(
} else { delegate:
BotToast.showText(text: '请先开通会员'); SliverChildBuilderDelegate((context, index) {
} return _getBox(answerList[index], index);
setState(() {}); }, childCount: answerList.length))
}), ]))
], ],
); );
} }
@ -132,10 +104,9 @@ class _AnswerIdleListState extends State<AnswerIdleList>
// smsIdList.clear(); // smsIdList.clear();
int i = 0; int i = 0;
// contentRef // contentRef
var base = await apiClient var base = await apiClient.request(API.content.findByStatus, data: {'status': 1});
.request(API.content.findByStatus, data: {'status': 1});
if (base.code == 0) { if (base.code == 0) {
_model = (base.data as List) _model=(base.data as List)
.map((e) => SmsContentModel.fromJson(e)) .map((e) => SmsContentModel.fromJson(e))
.toList(); .toList();
} else { } else {
@ -166,32 +137,33 @@ class _AnswerIdleListState extends State<AnswerIdleList>
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 36.sp), style: TextStyle(fontWeight: FontWeight.bold, fontSize: 36.sp),
), ),
subtitle: Text( subtitle: Text(
widget.isIdle ? "您给朋友去电接听后所发送的短信" : "朋友给你来电接听后所发送的短信", widget.isIdle
? "您给朋友去电接听后所发送的短信":"朋友给你来电接听后所发送的短信",
style: TextStyle(color: const Color(0xFF999999), fontSize: 28.sp), style: TextStyle(color: const Color(0xFF999999), fontSize: 28.sp),
), ),
trailing: widget.isIdle trailing: widget.isIdle
? Switch( ? Switch(
value: val, value: val,
onChanged: (value) async { onChanged: (value) async {
// if(!value){ // if(!value){
// //
// } // }
// await prefs.setBool("kg", value); // await prefs.setBool("kg", value);
// print("这是数据${prefs.getBool("kg")}"); // print("这是数据${prefs.getBool("kg")}");
setState(() { setState(() {
val = value; val = value;
}); });
}) })
: const SizedBox()), : const SizedBox()),
); );
} }
_getBox(ContantListModel item, int index) { _getBox(ContantListModel item,int index) {
return GestureDetector( return GestureDetector(
onTap: () async { onTap: () async {
if (item.content != "自定义短信内容") { if (item.content != "自定义短信内容") {
BaseModel res = await apiClient BaseModel res = await apiClient.request(API.content.checked,
.request(API.content.checked, data: {'id': item.id, 'status': 1}); data: {'id': item.id, 'status': 1});
if (res.code == 0) { if (res.code == 0) {
setState(() {}); setState(() {});
userProvider.updateUserInfo(); userProvider.updateUserInfo();

@ -54,6 +54,34 @@ class _CallingIdleListState extends State<CallingIdleList>
updateList(); updateList();
} }
Future<void> 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return Column(
@ -110,34 +138,6 @@ class _CallingIdleListState extends State<CallingIdleList>
); );
} }
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() { _getText() {
return Container( return Container(
height: 128.w, height: 128.w,
@ -182,12 +182,14 @@ class _CallingIdleListState extends State<CallingIdleList>
if (textListSMS.length > 5) { if (textListSMS.length > 5) {
BotToast.showText(text: '自定义数量已达上限,请先删除不需要的短信'); BotToast.showText(text: '自定义数量已达上限,请先删除不需要的短信');
} else { } else {
Get.to(AddSmsPage( Get.to(
status: 2, AddSmsPage(
ploneBack: (String textContent) { status: widget.status,
widget.refreshController.callRefresh(); ploneBack: (String textContent) {
}, widget.refreshController.callRefresh();
)); },
),
);
} }
} else { } else {
BotToast.showText(text: '请先开通会员'); BotToast.showText(text: '请先开通会员');
@ -232,7 +234,9 @@ class _CallingIdleListState extends State<CallingIdleList>
end: Alignment.centerRight, end: Alignment.centerRight,
colors: [ colors: [
index == isCheck ? widget.themeColor : const Color(0xFFF9F9F9), 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( child: Text(

@ -1,15 +1,13 @@
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/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:tab_indicator_styler/tab_indicator_styler.dart'; import 'package:tab_indicator_styler/tab_indicator_styler.dart';
import 'answer_idle.dart';
class ContentConnectPage extends StatefulWidget { class ContentConnectPage extends StatefulWidget {
const ContentConnectPage({Key? key}) : super(key: key); const ContentConnectPage({Key? key}) : super(key: key);
@ -23,13 +21,15 @@ class _ContentConnectPageState extends State<ContentConnectPage>
final EasyRefreshController _answerRefreshController = final EasyRefreshController _answerRefreshController =
EasyRefreshController(); EasyRefreshController();
final EasyRefreshController _wasAnswerRefreshController = final EasyRefreshController _wasAnswerRefreshController =
EasyRefreshController(); EasyRefreshController();
int state=1;
@override @override
void initState() { void initState() {
_tabController = TabController(length: 2, initialIndex: 0, vsync: this); _tabController = TabController(
length: 2,
initialIndex: 0,
vsync: this,
);
super.initState(); super.initState();
} }
@ -45,74 +45,81 @@ class _ContentConnectPageState extends State<ContentConnectPage>
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context); super.build(context);
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
elevation: 0, elevation: 0,
title: Text( title: Text(
'选择短信内容', '选择短信内容',
style: Theme.of(context).textTheme.headline6, style: Theme.of(context).textTheme.headline6,
),
leading: const CloudBackButton(isSpecial: true),
backgroundColor: kForeGroundColor,
), ),
backgroundColor: Colors.white, leading: const CloudBackButton(isSpecial: true),
body: Column( backgroundColor: kForeGroundColor,
children: [ ),
Container( backgroundColor: Colors.white,
width:double.infinity, body: Column(
height: 88.w, children: [
margin: EdgeInsets.symmetric(horizontal: 66.w), Container(
padding: EdgeInsets.all(8.w), width: double.infinity,
decoration:BoxDecoration(color: const Color(0xFFF9F9F9),borderRadius: BorderRadius.all(Radius.circular(44.w))), height: 88.w,
child: TabBar( margin: EdgeInsets.symmetric(horizontal: 66.w),
// indicator: Decoration(), padding: EdgeInsets.all(8.w),
controller: _tabController, decoration: BoxDecoration(
labelColor:const Color(0xFF1890FF), color: const Color(0xFFF9F9F9),
unselectedLabelColor:const Color(0xFF999999), borderRadius: BorderRadius.all(Radius.circular(44.w))),
unselectedLabelStyle:const TextStyle(fontWeight:FontWeight.bold), child: TabBar(
labelStyle:const TextStyle(fontWeight:FontWeight.bold), controller: _tabController,
onTap: (num) { labelColor: const Color(0xFF1890FF),
if(num==0){ unselectedLabelColor: const Color(0xFF999999),
state=1; unselectedLabelStyle:
_answerRefreshController.callRefresh(); const TextStyle(fontWeight: FontWeight.bold),
}else{ labelStyle: const TextStyle(fontWeight: FontWeight.bold),
state=3; onTap: (num) {
_wasAnswerRefreshController.callRefresh(); if (num == 0) {
} _answerRefreshController.callRefresh();
}, } else {
indicator: RectangularIndicator( _wasAnswerRefreshController.callRefresh();
color: Colors.white, }
bottomLeftRadius: 44.w, },
bottomRightRadius: 44.w, indicator: RectangularIndicator(
topLeftRadius: 44.w, color: Colors.white,
topRightRadius: 44.w, bottomLeftRadius: 44.w,
// paintingStyle: PaintingStyle.fill, bottomRightRadius: 44.w,
), topLeftRadius: 44.w,
// indicatorSize: TabBarIndicatorSize.label, topRightRadius: 44.w,
// isScrollable: true, // paintingStyle: PaintingStyle.fill,
tabs: const [ ),
// _tab(0, "被叫接听"),_tab(1, "主叫接听"), tabs: const [
Tab(text: "被叫接听",),Tab(text: "主叫接听",) Tab(
text: "被叫接听",
]), ),
Tab(
text: "主叫接听",
),
],
), ),
Expanded( ),
child: TabBarView(controller: _tabController, children: [ Expanded(
// _getBox(), child: TabBarView(
AnswerIdleList( controller: _tabController,
// contant: const [], children: [
num: state, CallingIdleList(
refreshController: _answerRefreshController, isIdle: false, refreshController: _answerRefreshController,
), title: '朋友给你来电接听后所发送的短信',
AnswerIdleList( status: 1,
// contant: const [], themeColor: const Color(0xFF1890FF),
num: state, ),
refreshController: _wasAnswerRefreshController, isIdle: true, CallingIdleList(
) refreshController: _answerRefreshController,
])) isIdle: true,
], title: '您给朋友去电接听后所发送的短信',
)); status: 3,
themeColor: const Color(0xFF1890FF),
),
],
),
),
],
),
);
} }
@override @override

@ -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<List<ContantListModel>> 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();
}
}
}

@ -112,7 +112,6 @@ final FocusNode verifyNode=FocusNode();
widget.ploneBack(_controller.text); widget.ploneBack(_controller.text);
UserTool.userProvider.updateUserInfo(); UserTool.userProvider.updateUserInfo();
UserTool.userProvider.updateConSms(); UserTool.userProvider.updateConSms();
UserTool.userProvider.updateRefSms();
Get.back(); Get.back();
} else { } else {
CloudToast.show(res.msg); CloudToast.show(res.msg);

@ -119,7 +119,7 @@ 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();
}); });

@ -24,10 +24,14 @@ class AppDialog extends Dialog {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( 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( decoration: BoxDecoration(
image: image:
DecorationImage(image: AssetImage(Assets.images.bouncedbg.path))), DecorationImage(image: AssetImage(Assets.images.bouncedbg.path,))),
child: Column( child: Column(
children: [ children: [
32.hb, 32.hb,

Loading…
Cancel
Save