|
|
@ -2,11 +2,13 @@ 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/utils/headers.dart';
|
|
|
|
import 'package:project_telephony/utils/headers.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
|
|
import '../../base/base_style.dart';
|
|
|
|
import '../../base/base_style.dart';
|
|
|
|
import '../../constants/api.dart';
|
|
|
|
import '../../constants/api.dart';
|
|
|
|
|
|
|
|
import '../../model/contant_list_model.dart';
|
|
|
|
import '../../model/network/api_client.dart';
|
|
|
|
import '../../model/network/api_client.dart';
|
|
|
|
import '../../model/network/base_model.dart';
|
|
|
|
import '../../model/network/base_model.dart';
|
|
|
|
import '../../model/sms_content_model.dart';
|
|
|
|
import '../../model/sms_content_model.dart';
|
|
|
@ -18,11 +20,11 @@ import 'add_sms_page.dart';
|
|
|
|
class AnswerIdleList extends StatefulWidget {
|
|
|
|
class AnswerIdleList extends StatefulWidget {
|
|
|
|
final EasyRefreshController refreshController;
|
|
|
|
final EasyRefreshController refreshController;
|
|
|
|
final bool isIdle;
|
|
|
|
final bool isIdle;
|
|
|
|
|
|
|
|
final int num;
|
|
|
|
// final List contant;
|
|
|
|
// final List contant;
|
|
|
|
|
|
|
|
|
|
|
|
const AnswerIdleList(
|
|
|
|
const AnswerIdleList(
|
|
|
|
{Key? key, required this.refreshController, required this.isIdle})
|
|
|
|
{Key? key, required this.refreshController, required this.isIdle,required this.num})
|
|
|
|
: super(key: key);
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
@ -34,6 +36,7 @@ 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<String> textListSMS = [];
|
|
|
|
List<String> textListSMS = [];
|
|
|
|
List<int> smsIdList = [];
|
|
|
|
List<int> smsIdList = [];
|
|
|
|
int isCheck = 0;
|
|
|
|
int isCheck = 0;
|
|
|
@ -58,16 +61,18 @@ class _AnswerIdleListState extends State<AnswerIdleList>
|
|
|
|
// footer: MaterialFooter(),
|
|
|
|
// footer: MaterialFooter(),
|
|
|
|
onRefresh: () async {
|
|
|
|
onRefresh: () async {
|
|
|
|
await userProvider.updateUserInfo();
|
|
|
|
await userProvider.updateUserInfo();
|
|
|
|
userProvider.updateRefSms();
|
|
|
|
answerList=await ContantFunc.getFindByStatus(widget.num);
|
|
|
|
updateList();
|
|
|
|
print("这是数据$answerList");
|
|
|
|
|
|
|
|
// userProvider.updateRefSms();
|
|
|
|
|
|
|
|
// updateList();
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
slivers: [
|
|
|
|
slivers: [
|
|
|
|
SliverList(
|
|
|
|
SliverList(
|
|
|
|
delegate:
|
|
|
|
delegate:
|
|
|
|
SliverChildBuilderDelegate((context, index) {
|
|
|
|
SliverChildBuilderDelegate((context, index) {
|
|
|
|
return _getBox(textListSMS[index], index);
|
|
|
|
return _getBox(answerList[index], index);
|
|
|
|
}, childCount: textListSMS.length))
|
|
|
|
}, childCount: answerList.length)),
|
|
|
|
]))
|
|
|
|
]))
|
|
|
|
: _getEmptyList()
|
|
|
|
: _getEmptyList()
|
|
|
|
: Expanded(
|
|
|
|
: Expanded(
|
|
|
@ -80,15 +85,18 @@ class _AnswerIdleListState extends State<AnswerIdleList>
|
|
|
|
// footer: MaterialFooter(),
|
|
|
|
// footer: MaterialFooter(),
|
|
|
|
onRefresh: () async {
|
|
|
|
onRefresh: () async {
|
|
|
|
await userProvider.updateUserInfo();
|
|
|
|
await userProvider.updateUserInfo();
|
|
|
|
userProvider.updateRefSms();
|
|
|
|
answerList=await ContantFunc.getFindByStatus(widget.num);
|
|
|
|
updateList();
|
|
|
|
print("这是数据$answerList");
|
|
|
|
|
|
|
|
// userProvider.updateRefSms();
|
|
|
|
|
|
|
|
// updateList();
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
slivers: [
|
|
|
|
slivers: [
|
|
|
|
SliverList(
|
|
|
|
SliverList(
|
|
|
|
delegate: SliverChildBuilderDelegate((context, index) {
|
|
|
|
delegate:
|
|
|
|
return _getBox(textListSMS[index], index);
|
|
|
|
SliverChildBuilderDelegate((context, index) {
|
|
|
|
}, childCount: textListSMS.length))
|
|
|
|
return _getBox(answerList[index], index);
|
|
|
|
|
|
|
|
}, childCount: answerList.length))
|
|
|
|
]))
|
|
|
|
]))
|
|
|
|
],
|
|
|
|
],
|
|
|
|
);
|
|
|
|
);
|
|
|
@ -96,8 +104,8 @@ class _AnswerIdleListState extends State<AnswerIdleList>
|
|
|
|
|
|
|
|
|
|
|
|
updateList() async {
|
|
|
|
updateList() async {
|
|
|
|
if (userProvider.isLogin) {
|
|
|
|
if (userProvider.isLogin) {
|
|
|
|
textListSMS.clear();
|
|
|
|
// textListSMS.clear();
|
|
|
|
smsIdList.clear();
|
|
|
|
// smsIdList.clear();
|
|
|
|
int i = 0;
|
|
|
|
int i = 0;
|
|
|
|
// contentRef
|
|
|
|
// contentRef
|
|
|
|
var base = await apiClient.request(API.content.findByStatus, data: {'status': 1});
|
|
|
|
var base = await apiClient.request(API.content.findByStatus, data: {'status': 1});
|
|
|
@ -154,12 +162,12 @@ class _AnswerIdleListState extends State<AnswerIdleList>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_getBox(String content, int index) {
|
|
|
|
_getBox(ContantListModel item,int index) {
|
|
|
|
return GestureDetector(
|
|
|
|
return GestureDetector(
|
|
|
|
onTap: () async {
|
|
|
|
onTap: () async {
|
|
|
|
if (content != "自定义短信内容") {
|
|
|
|
if (item.content != "自定义短信内容") {
|
|
|
|
BaseModel res = await apiClient.request(API.content.checked,
|
|
|
|
BaseModel res = await apiClient.request(API.app.checked,
|
|
|
|
data: {'id': smsIdList[index], 'status': 1});
|
|
|
|
data: {'id': item.id, 'status': 1});
|
|
|
|
if (res.code == 0) {
|
|
|
|
if (res.code == 0) {
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
userProvider.updateUserInfo();
|
|
|
|
userProvider.updateUserInfo();
|
|
|
@ -170,7 +178,7 @@ class _AnswerIdleListState extends State<AnswerIdleList>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (userProvider.userInfo.isVip == 1) {
|
|
|
|
if (userProvider.userInfo.isVip == 1) {
|
|
|
|
if (textListSMS.length > 5) {
|
|
|
|
if (answerList.length > 5) {
|
|
|
|
BotToast.showText(text: '自定义数量已达上限,请先删除不需要的短信');
|
|
|
|
BotToast.showText(text: '自定义数量已达上限,请先删除不需要的短信');
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Get.to(AddSmsPage(
|
|
|
|
Get.to(AddSmsPage(
|
|
|
@ -187,9 +195,9 @@ class _AnswerIdleListState extends State<AnswerIdleList>
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onLongPress: () {
|
|
|
|
onLongPress: () {
|
|
|
|
if (content != "自定义短信内容") {
|
|
|
|
if (item.content != "自定义短信内容") {
|
|
|
|
if (textListSMS.length == 2 || isCheck == index) {
|
|
|
|
if (answerList.length == 2 || isCheck == index) {
|
|
|
|
if (textListSMS.length == 2) {
|
|
|
|
if (answerList.length == 2) {
|
|
|
|
BotToast.showText(text: '最后一条内容不可删除');
|
|
|
|
BotToast.showText(text: '最后一条内容不可删除');
|
|
|
|
} else if (isCheck == index) {
|
|
|
|
} else if (isCheck == index) {
|
|
|
|
BotToast.showText(text: '当前为选中内容,不可删除');
|
|
|
|
BotToast.showText(text: '当前为选中内容,不可删除');
|
|
|
@ -201,7 +209,7 @@ class _AnswerIdleListState extends State<AnswerIdleList>
|
|
|
|
return Centertipsalterwidget(
|
|
|
|
return Centertipsalterwidget(
|
|
|
|
desText: '你确定要删除这个短信模版吗,删除之后无法还原。',
|
|
|
|
desText: '你确定要删除这个短信模版吗,删除之后无法还原。',
|
|
|
|
title: '删除短信模板',
|
|
|
|
title: '删除短信模板',
|
|
|
|
id: smsIdList[index],
|
|
|
|
id: item.id,
|
|
|
|
callback: (bool status) {
|
|
|
|
callback: (bool status) {
|
|
|
|
widget.refreshController.callRefresh();
|
|
|
|
widget.refreshController.callRefresh();
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -231,7 +239,7 @@ class _AnswerIdleListState extends State<AnswerIdleList>
|
|
|
|
]),
|
|
|
|
]),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Text(
|
|
|
|
child: Text(
|
|
|
|
content,
|
|
|
|
item.content,
|
|
|
|
style: TextStyle(
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: BaseStyle.fontSize28,
|
|
|
|
fontSize: BaseStyle.fontSize28,
|
|
|
|
color: index == isCheck
|
|
|
|
color: index == isCheck
|
|
|
|