parent
5cdb5e7ff9
commit
b2effe383b
After Width: | Height: | Size: 9.8 KiB |
@ -0,0 +1,272 @@
|
||||
import 'package:bot_toast/bot_toast.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
||||
import 'package:project_telephony/utils/headers.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../base/base_style.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 '../widget/centertipsalterwidget.dart';
|
||||
import 'add_sms_page.dart';
|
||||
|
||||
class AnswerIdleList extends StatefulWidget {
|
||||
final EasyRefreshController refreshController;
|
||||
final bool isIdle;
|
||||
|
||||
// final List contant;
|
||||
|
||||
const AnswerIdleList(
|
||||
{Key? key, required this.refreshController, required this.isIdle})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_AnswerIdleListState createState() => _AnswerIdleListState();
|
||||
}
|
||||
|
||||
class _AnswerIdleListState extends State<AnswerIdleList>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
|
||||
List<String> textList = ['现在无法接听。有什么事吗?', '自定义短信内容'];
|
||||
List<String> textListSMS = [];
|
||||
List<int> smsIdList = [];
|
||||
int isCheck = 0;
|
||||
bool val = false;
|
||||
|
||||
// final EasyRefreshController _easyRefreshController = EasyRefreshController();
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
_getText(),
|
||||
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();
|
||||
userProvider.updateRefSms();
|
||||
updateList();
|
||||
setState(() {});
|
||||
},
|
||||
slivers: [
|
||||
SliverList(
|
||||
delegate:
|
||||
SliverChildBuilderDelegate((context, index) {
|
||||
return _getBox(textListSMS[index], index);
|
||||
}, childCount: textListSMS.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();
|
||||
userProvider.updateRefSms();
|
||||
updateList();
|
||||
setState(() {});
|
||||
},
|
||||
slivers: [
|
||||
SliverList(
|
||||
delegate: SliverChildBuilderDelegate((context, index) {
|
||||
return _getBox(textListSMS[index], index);
|
||||
}, childCount: textListSMS.length))
|
||||
]))
|
||||
],
|
||||
);
|
||||
|
||||
// ListView.builder(
|
||||
// itemBuilder: (context, index) {
|
||||
// return _getBox(textListSMS[index], index);
|
||||
// },
|
||||
// itemCount: textListSMS.length,
|
||||
// ),
|
||||
}
|
||||
|
||||
updateList() async {
|
||||
if (userProvider.isLogin) {
|
||||
textListSMS.clear();
|
||||
smsIdList.clear();
|
||||
int i = 0;
|
||||
userProvider.userInfo.contentRef?.forEach((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,
|
||||
// margin: EdgeInsets.only(top: 32.w, left: 64.w, right: 64.w),
|
||||
padding: EdgeInsets.only(left: 40.w, top: 45.w),
|
||||
child: ListTile(
|
||||
title: Text(
|
||||
"功能讲解",
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 36.sp),
|
||||
),
|
||||
subtitle: Text(
|
||||
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;
|
||||
});
|
||||
})
|
||||
: const SizedBox()),
|
||||
);
|
||||
}
|
||||
|
||||
_getBox(String content, int index) {
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
if (content != "自定义短信内容") {
|
||||
BaseModel res = await apiClient.request(API.app.checked,
|
||||
data: {'id': smsIdList[index], 'status': 1});
|
||||
if (res.code == 0) {
|
||||
setState(() {});
|
||||
userProvider.updateUserInfo();
|
||||
userProvider.updateConSms();
|
||||
widget.refreshController.callRefresh();
|
||||
} else {
|
||||
CloudToast.show(res.msg);
|
||||
}
|
||||
} else {
|
||||
if (userProvider.userInfo.isVip == 1) {
|
||||
if (textListSMS.length > 5) {
|
||||
BotToast.showText(text: '自定义数量已达上限,请先删除不需要的短信');
|
||||
} else {
|
||||
Get.to(AddSmsPage(
|
||||
status: 1,
|
||||
ploneBack: (String textContent) {
|
||||
widget.refreshController.callRefresh();
|
||||
},
|
||||
));
|
||||
}
|
||||
} else {
|
||||
BotToast.showText(text: '请先开通会员');
|
||||
}
|
||||
}
|
||||
setState(() {});
|
||||
},
|
||||
onLongPress: () {
|
||||
if (content != "自定义短信内容") {
|
||||
if (textListSMS.length == 2 || isCheck == index) {
|
||||
if (textListSMS.length == 2) {
|
||||
BotToast.showText(text: '最后一条内容不可删除');
|
||||
} else if (isCheck == index) {
|
||||
BotToast.showText(text: '当前为选中内容,不可删除');
|
||||
}
|
||||
} else {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return Centertipsalterwidget(
|
||||
desText: '你确定要删除这个短信模版吗,删除之后无法还原。',
|
||||
title: '删除短信模板',
|
||||
id: smsIdList[index],
|
||||
callback: (bool status) {
|
||||
widget.refreshController.callRefresh();
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
setState(() {});
|
||||
},
|
||||
child: Container(
|
||||
// width: 686.w,
|
||||
height: 128.w,
|
||||
margin: EdgeInsets.only(top: 32.w, left: 64.w, right: 64.w),
|
||||
padding: EdgeInsets.only(left: 40.w, top: 45.w),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.centerLeft,
|
||||
end: Alignment.centerRight,
|
||||
colors: [
|
||||
index == isCheck
|
||||
? const Color(0xFF1890FF)
|
||||
: const Color(0xFFF9F9F9),
|
||||
index == isCheck
|
||||
? const Color(0xFF74BCFF)
|
||||
: const Color(0xFFF9F9F9),
|
||||
]),
|
||||
),
|
||||
child: Text(
|
||||
content,
|
||||
style: TextStyle(
|
||||
fontSize: BaseStyle.fontSize28,
|
||||
color: index == isCheck
|
||||
? const Color(0xFFF9F9F9)
|
||||
: BaseStyle.color333333,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_getEmptyList() {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
234.hb,
|
||||
Image.asset(
|
||||
Assets.images.emptylist.path,
|
||||
width: 240.w,
|
||||
height: 212.w,
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
48.hb,
|
||||
Text(
|
||||
"功能已关闭",
|
||||
style: TextStyle(
|
||||
color: const Color(0xFF999999),
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 36.sp),
|
||||
),
|
||||
16.hb,
|
||||
Text(
|
||||
"去电接听后将不会发送短信",
|
||||
style: TextStyle(color: const Color(0xFF999999), fontSize: 28.sp),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
}
|
@ -0,0 +1,275 @@
|
||||
import 'package:bot_toast/bot_toast.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:project_telephony/extensions/num_ext.dart';
|
||||
import 'package:project_telephony/utils/headers.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../base/base_style.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 '../widget/centertipsalterwidget.dart';
|
||||
import 'add_sms_page.dart';
|
||||
|
||||
class CallingIdleList extends StatefulWidget {
|
||||
final EasyRefreshController refreshController;
|
||||
final bool isIdle;
|
||||
|
||||
// final List contant;
|
||||
|
||||
const CallingIdleList(
|
||||
{Key? key, required this.refreshController, required this.isIdle})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_CallingIdleListState createState() => _CallingIdleListState();
|
||||
}
|
||||
|
||||
class _CallingIdleListState extends State<CallingIdleList>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
|
||||
List<String> textList = ['现在无法接听。有什么事吗?', '自定义短信内容'];
|
||||
List<String> textListSMS = [];
|
||||
List<int> smsIdList = [];
|
||||
int isCheck = 0;
|
||||
bool val = false;
|
||||
|
||||
// final EasyRefreshController _easyRefreshController = EasyRefreshController();
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
_getText(),
|
||||
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();
|
||||
userProvider.updateRefSms();
|
||||
updateList();
|
||||
setState(() {});
|
||||
},
|
||||
slivers: [
|
||||
SliverList(
|
||||
delegate:
|
||||
SliverChildBuilderDelegate((context, index) {
|
||||
return _getBox(textListSMS[index], index);
|
||||
}, childCount: textListSMS.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();
|
||||
userProvider.updateRefSms();
|
||||
updateList();
|
||||
setState(() {});
|
||||
},
|
||||
slivers: [
|
||||
SliverList(
|
||||
delegate: SliverChildBuilderDelegate((context, index) {
|
||||
return _getBox(textListSMS[index], index);
|
||||
}, childCount: textListSMS.length))
|
||||
]))
|
||||
],
|
||||
);
|
||||
|
||||
// ListView.builder(
|
||||
// itemBuilder: (context, index) {
|
||||
// return _getBox(textListSMS[index], index);
|
||||
// },
|
||||
// itemCount: textListSMS.length,
|
||||
// ),
|
||||
}
|
||||
|
||||
updateList() async {
|
||||
if (userProvider.isLogin) {
|
||||
textListSMS.clear();
|
||||
smsIdList.clear();
|
||||
int i = 0;
|
||||
userProvider.userInfo.contentRef?.forEach((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,
|
||||
// margin: EdgeInsets.only(top: 32.w, left: 64.w, right: 64.w),
|
||||
padding: EdgeInsets.only(left: 40.w, top: 45.w),
|
||||
child: ListTile(
|
||||
title: Text(
|
||||
"功能讲解",
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 36.sp),
|
||||
),
|
||||
subtitle: Text(
|
||||
widget.isIdle
|
||||
? "您给朋友去电拒接/未接后所发送的短信":"朋友给你来电接听后所发送的短信",
|
||||
style: TextStyle(color: const Color(0xFF999999), fontSize: 27.sp),
|
||||
),
|
||||
trailing: widget.isIdle
|
||||
? Switch(
|
||||
value: val,
|
||||
onChanged: (value) async {
|
||||
// if(!value){
|
||||
//
|
||||
// }
|
||||
// await prefs.setBool("kg", value);
|
||||
// print("这是数据${prefs.getBool("kg")}");
|
||||
setState(() {
|
||||
val = value;
|
||||
});
|
||||
})
|
||||
: const SizedBox()),
|
||||
);
|
||||
}
|
||||
|
||||
_getBox(String content, int index) {
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
if (content != "自定义短信内容") {
|
||||
BaseModel res = await apiClient.request(API.app.checked,
|
||||
data: {'id': smsIdList[index], 'status': 2});
|
||||
if (res.code == 0) {
|
||||
setState(() {});
|
||||
userProvider.updateUserInfo();
|
||||
userProvider.updateRefSms();
|
||||
widget.refreshController.callRefresh();
|
||||
} else {
|
||||
CloudToast.show(res.msg);
|
||||
}
|
||||
} else {
|
||||
if (userProvider.userInfo.isVip == 1) {
|
||||
if (textListSMS.length > 5) {
|
||||
BotToast.showText(text: '自定义数量已达上限,请先删除不需要的短信');
|
||||
} else {
|
||||
Get.to(AddSmsPage(
|
||||
status: 2,
|
||||
ploneBack: (String textContent) {
|
||||
widget.refreshController.callRefresh();
|
||||
},
|
||||
));
|
||||
}
|
||||
} else {
|
||||
BotToast.showText(text: '请先开通会员');
|
||||
}
|
||||
}
|
||||
setState(() {});
|
||||
},
|
||||
onLongPress: () {
|
||||
if (content != "自定义短信内容") {
|
||||
if (textListSMS.length == 2 || isCheck == index) {
|
||||
if (textListSMS.length == 2) {
|
||||
BotToast.showText(text: '最后一条内容不可删除');
|
||||
} else if (isCheck == index) {
|
||||
BotToast.showText(text: '当前为选中内容,不可删除');
|
||||
}
|
||||
} else {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return Centertipsalterwidget(
|
||||
desText: '你确定要删除这个短信模版吗,删除之后无法还原。',
|
||||
title: '删除短信模板',
|
||||
id: smsIdList[index],
|
||||
callback: (bool status) {
|
||||
widget.refreshController.callRefresh();
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
setState(() {});
|
||||
},
|
||||
child: Container(
|
||||
// width: 686.w,
|
||||
height: 128.w,
|
||||
margin: EdgeInsets.only(top: 32.w, left: 64.w, right: 64.w),
|
||||
padding: EdgeInsets.only(left: 40.w, top: 45.w),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.centerLeft,
|
||||
end: Alignment.centerRight,
|
||||
colors: [
|
||||
index == isCheck
|
||||
? const Color(0xFF13CA9D)
|
||||
: const Color(0xFFF9F9F9),
|
||||
index == isCheck
|
||||
? const Color(0xFF72E4C8)
|
||||
: const Color(0xFFF9F9F9),
|
||||
]),
|
||||
),
|
||||
child: Text(
|
||||
content,
|
||||
style: TextStyle(
|
||||
fontSize: BaseStyle.fontSize28,
|
||||
color: index == isCheck
|
||||
? const Color(0xFFF9F9F9)
|
||||
: BaseStyle.color333333,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
_getEmptyList() {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
234.hb,
|
||||
Image.asset(
|
||||
Assets.images.emptylist.path,
|
||||
width: 240.w,
|
||||
height: 212.w,
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
48.hb,
|
||||
Text(
|
||||
"功能已关闭",
|
||||
style: TextStyle(
|
||||
color: const Color(0xFF999999),
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 36.sp),
|
||||
),
|
||||
16.hb,
|
||||
Text(
|
||||
"去电拒接/未接后将不会发送短信",
|
||||
style: TextStyle(color: const Color(0xFF999999), fontSize: 28.sp),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
}
|
Loading…
Reference in new issue