|
|
|
@ -7,7 +7,11 @@ import 'package:project_telephony/ui/widget/centertipsalterwidget.dart';
|
|
|
|
|
import 'package:project_telephony/ui/widget/plone_back_button.dart';
|
|
|
|
|
import 'package:project_telephony/utils/headers.dart';
|
|
|
|
|
import 'package:provider/provider.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 'add_sms_page.dart';
|
|
|
|
|
|
|
|
|
|
class ContentRefusePage extends StatefulWidget {
|
|
|
|
@ -18,10 +22,11 @@ class ContentRefusePage extends StatefulWidget {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _ContentRefusePageState extends State<ContentRefusePage> {
|
|
|
|
|
int _select = 0;
|
|
|
|
|
List<String> textList = ['现在无法接听。有什么事吗?', '我马上会打给你。', '我稍后会打给你。', "自定义短信内容"];
|
|
|
|
|
List<String> textList = ['现在无法接听。有什么事吗?', '自定义短信内容'];
|
|
|
|
|
List<String> textListSMS = [];
|
|
|
|
|
List<int> smsIdList = [];
|
|
|
|
|
int isCheck=0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
|
|
|
|
|
final EasyRefreshController _easyRefreshController = EasyRefreshController();
|
|
|
|
@ -38,12 +43,18 @@ class _ContentRefusePageState extends State<ContentRefusePage> {
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future updateList() async{
|
|
|
|
|
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 {
|
|
|
|
@ -79,29 +90,42 @@ class _ContentRefusePageState extends State<ContentRefusePage> {
|
|
|
|
|
footer: MaterialFooter(),
|
|
|
|
|
controller: _easyRefreshController,
|
|
|
|
|
onRefresh: () async {
|
|
|
|
|
await updateList();
|
|
|
|
|
await userProvider.updateUserInfo();
|
|
|
|
|
updateList();
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
child: ListView.builder(
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
return _getBox(textListSMS[index], index == _select, index);
|
|
|
|
|
return _getBox(textListSMS[index], index);
|
|
|
|
|
},
|
|
|
|
|
itemCount: textListSMS.length,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_getBox(String content, bool pd, int index) {
|
|
|
|
|
_getBox(String content, int index) {
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
onTap: () async {
|
|
|
|
|
if (content != "自定义短信内容") {
|
|
|
|
|
_select = index;
|
|
|
|
|
BaseModel res = await apiClient.request(API.app.checked,
|
|
|
|
|
data: {'id': smsIdList[index], 'status': 2});
|
|
|
|
|
if (res.code == 0) {
|
|
|
|
|
setState(() {});
|
|
|
|
|
userProvider.updateUserInfo();
|
|
|
|
|
_easyRefreshController.callRefresh();
|
|
|
|
|
} else {
|
|
|
|
|
CloudToast.show(res.msg);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (userProvider.isLogin) {
|
|
|
|
|
if (textListSMS.length > 5) {
|
|
|
|
|
BotToast.showText(text: '自定义数量已达上限,请先删除不需要的短信');
|
|
|
|
|
} else {
|
|
|
|
|
Get.to(AddSmsPage(
|
|
|
|
|
status: 2, ploneBack: (String textContent) { },
|
|
|
|
|
status: 2,
|
|
|
|
|
ploneBack: (String textContent) {
|
|
|
|
|
_easyRefreshController.callRefresh();
|
|
|
|
|
},
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
@ -112,7 +136,7 @@ class _ContentRefusePageState extends State<ContentRefusePage> {
|
|
|
|
|
},
|
|
|
|
|
onLongPress: () {
|
|
|
|
|
if (content != "自定义短信内容") {
|
|
|
|
|
if (textListSMS.length<2 ) {
|
|
|
|
|
if (textListSMS.length == 1) {
|
|
|
|
|
BotToast.showText(text: '不能再删了');
|
|
|
|
|
} else {
|
|
|
|
|
showDialog(
|
|
|
|
@ -120,14 +144,16 @@ class _ContentRefusePageState extends State<ContentRefusePage> {
|
|
|
|
|
builder: (context) {
|
|
|
|
|
return Centertipsalterwidget(
|
|
|
|
|
desText: '你确定要删除这个短信模版吗,删除之后无法还原。',
|
|
|
|
|
title: '删除短信模板', id: smsIdList[index],
|
|
|
|
|
title: '删除短信模板',
|
|
|
|
|
id: smsIdList[index],
|
|
|
|
|
callback: (bool status) {
|
|
|
|
|
_easyRefreshController.callRefresh();
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
setState(() {
|
|
|
|
|
_easyRefreshController.callRefresh();
|
|
|
|
|
});
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
child: Container(
|
|
|
|
|
// width: 686.w,
|
|
|
|
@ -135,13 +161,13 @@ class _ContentRefusePageState extends State<ContentRefusePage> {
|
|
|
|
|
padding: EdgeInsets.all(40.w),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(16),
|
|
|
|
|
color: pd ? const Color(0xFF72E4C8) : const Color(0xFFF9F9F9),
|
|
|
|
|
color: index==isCheck?const Color(0xFF72E4C8) :const Color(0xFFF9F9F9),
|
|
|
|
|
),
|
|
|
|
|
child: Text(
|
|
|
|
|
content,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: BaseStyle.fontSize28,
|
|
|
|
|
color: pd ? const Color(0xFFF9F9F9) : BaseStyle.color333333,
|
|
|
|
|
color: index==isCheck?const Color(0xFFF9F9F9):BaseStyle.color333333,
|
|
|
|
|
fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|