master
王亚玲 2 years ago
parent 2ffec297aa
commit 688a7933e5

@ -75,7 +75,7 @@ class UserProvider extends ChangeNotifier {
notifyListeners();
}
Future updateConSms(int num ) async {
Future updateConSms( ) async {
final prefs = await SharedPreferences.getInstance();
final service = FlutterBackgroundService();
var base = await apiClient.request(API.content.find, data: {'status': 1});

@ -3,6 +3,7 @@ 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';
@ -21,10 +22,14 @@ class AnswerIdleList extends StatefulWidget {
final EasyRefreshController refreshController;
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
@ -36,12 +41,13 @@ class _AnswerIdleListState extends State<AnswerIdleList>
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
List<String> textList = ['现在无法接听。有什么事吗?', '自定义短信内容'];
List<SmsContentModel> _model = [];
List<ContantListModel> answerList=[];
List<ContantListModel> answerList = [];
List<String> textListSMS = [];
List<int> smsIdList = [];
int isCheck = 0;
bool val = false;
// final EasyRefreshController _easyRefreshController = EasyRefreshController();
@override
Widget build(BuildContext context) {
@ -51,53 +57,71 @@ class _AnswerIdleListState extends State<AnswerIdleList>
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();
// 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();
answerList=await ContantFunc.getFindByStatus(widget.num);
print("这是数据$answerList");
// userProvider.updateRefSms();
// updateList();
setState(() {});
// 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();
},
slivers: [
SliverList(
delegate:
SliverChildBuilderDelegate((context, index) {
return _getBox(answerList[index], index);
}, childCount: answerList.length))
]))
));
}
} else {
BotToast.showText(text: '请先开通会员');
}
setState(() {});
}),
],
);
}
@ -108,9 +132,10 @@ class _AnswerIdleListState extends State<AnswerIdleList>
// 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 {
@ -141,33 +166,32 @@ class _AnswerIdleListState extends State<AnswerIdleList>
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.app.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();

@ -9,7 +9,7 @@ import '../../../utils/toast/cloud_toast.dart';
class ContantFunc {
static Future<List<ContantListModel>> getFindByStatus(int status) async {
BaseListModel res =
await apiClient.requestList(API.app.findByStatus, data:{'status': status});
await apiClient.requestList(API.content.findByStatus, data:{'status': status});
if(res.code!=0) {
CloudToast.show(res.msg);
return [];

Loading…
Cancel
Save