|
|
@ -12,6 +12,7 @@ import '../../base/base_style.dart';
|
|
|
|
import '../../constants/api.dart';
|
|
|
|
import '../../constants/api.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 '../../providers/user_provider.dart';
|
|
|
|
import '../../providers/user_provider.dart';
|
|
|
|
import '../../utils/toast/cloud_toast.dart';
|
|
|
|
import '../../utils/toast/cloud_toast.dart';
|
|
|
|
import '../widget/centertipsalterwidget.dart';
|
|
|
|
import '../widget/centertipsalterwidget.dart';
|
|
|
@ -19,13 +20,19 @@ import 'add_sms_page.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class CallingIdleList extends StatefulWidget {
|
|
|
|
class CallingIdleList extends StatefulWidget {
|
|
|
|
final EasyRefreshController refreshController;
|
|
|
|
final EasyRefreshController refreshController;
|
|
|
|
final bool isIdle;
|
|
|
|
final String title;
|
|
|
|
|
|
|
|
final int status;
|
|
|
|
|
|
|
|
final bool? isIdle;
|
|
|
|
|
|
|
|
final Color themeColor;
|
|
|
|
|
|
|
|
|
|
|
|
// final List contant;
|
|
|
|
const CallingIdleList({
|
|
|
|
|
|
|
|
Key? key,
|
|
|
|
const CallingIdleList(
|
|
|
|
required this.title,
|
|
|
|
{Key? key, required this.refreshController, required this.isIdle})
|
|
|
|
required this.status,
|
|
|
|
: super(key: key);
|
|
|
|
this.isIdle = false,
|
|
|
|
|
|
|
|
required this.themeColor,
|
|
|
|
|
|
|
|
required this.refreshController,
|
|
|
|
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
_CallingIdleListState createState() => _CallingIdleListState();
|
|
|
|
_CallingIdleListState createState() => _CallingIdleListState();
|
|
|
@ -35,13 +42,17 @@ class _CallingIdleListState extends State<CallingIdleList>
|
|
|
|
with AutomaticKeepAliveClientMixin {
|
|
|
|
with AutomaticKeepAliveClientMixin {
|
|
|
|
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<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();
|
|
|
|
@override
|
|
|
|
|
|
|
|
void initState() {
|
|
|
|
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
updateList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
@ -49,11 +60,9 @@ class _CallingIdleListState extends State<CallingIdleList>
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
_getText(),
|
|
|
|
_getText(),
|
|
|
|
32.hb,
|
|
|
|
32.hb,
|
|
|
|
widget.isIdle
|
|
|
|
widget.isIdle!
|
|
|
|
? val
|
|
|
|
? val
|
|
|
|
? Expanded(
|
|
|
|
? Expanded(
|
|
|
|
// width: 662.w,
|
|
|
|
|
|
|
|
// height: 800.w,
|
|
|
|
|
|
|
|
child: EasyRefresh.custom(
|
|
|
|
child: EasyRefresh.custom(
|
|
|
|
firstRefresh: true,
|
|
|
|
firstRefresh: true,
|
|
|
|
controller: widget.refreshController,
|
|
|
|
controller: widget.refreshController,
|
|
|
@ -62,7 +71,7 @@ class _CallingIdleListState extends State<CallingIdleList>
|
|
|
|
onRefresh: () async {
|
|
|
|
onRefresh: () async {
|
|
|
|
await userProvider.updateUserInfo();
|
|
|
|
await userProvider.updateUserInfo();
|
|
|
|
userProvider.updateRefSms();
|
|
|
|
userProvider.updateRefSms();
|
|
|
|
updateList();
|
|
|
|
await updateList();
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
slivers: [
|
|
|
|
slivers: [
|
|
|
@ -70,12 +79,13 @@ class _CallingIdleListState extends State<CallingIdleList>
|
|
|
|
delegate:
|
|
|
|
delegate:
|
|
|
|
SliverChildBuilderDelegate((context, index) {
|
|
|
|
SliverChildBuilderDelegate((context, index) {
|
|
|
|
return _getBox(textListSMS[index], index);
|
|
|
|
return _getBox(textListSMS[index], index);
|
|
|
|
}, childCount: textListSMS.length))
|
|
|
|
}, childCount: textListSMS.length),
|
|
|
|
]))
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
)
|
|
|
|
: _getEmptyList()
|
|
|
|
: _getEmptyList()
|
|
|
|
: Expanded(
|
|
|
|
: Expanded(
|
|
|
|
// width: 662.w,
|
|
|
|
|
|
|
|
// height: 800.w,
|
|
|
|
|
|
|
|
child: EasyRefresh.custom(
|
|
|
|
child: EasyRefresh.custom(
|
|
|
|
firstRefresh: true,
|
|
|
|
firstRefresh: true,
|
|
|
|
controller: widget.refreshController,
|
|
|
|
controller: widget.refreshController,
|
|
|
@ -84,24 +94,20 @@ class _CallingIdleListState extends State<CallingIdleList>
|
|
|
|
onRefresh: () async {
|
|
|
|
onRefresh: () async {
|
|
|
|
await userProvider.updateUserInfo();
|
|
|
|
await userProvider.updateUserInfo();
|
|
|
|
userProvider.updateRefSms();
|
|
|
|
userProvider.updateRefSms();
|
|
|
|
updateList();
|
|
|
|
await updateList();
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
slivers: [
|
|
|
|
slivers: [
|
|
|
|
SliverList(
|
|
|
|
SliverList(
|
|
|
|
delegate: SliverChildBuilderDelegate((context, index) {
|
|
|
|
delegate: SliverChildBuilderDelegate((context, index) {
|
|
|
|
return _getBox(textListSMS[index], index);
|
|
|
|
return _getBox(textListSMS[index], index);
|
|
|
|
}, childCount: textListSMS.length))
|
|
|
|
}, childCount: textListSMS.length),
|
|
|
|
]))
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
// ListView.builder(
|
|
|
|
|
|
|
|
// itemBuilder: (context, index) {
|
|
|
|
|
|
|
|
// return _getBox(textListSMS[index], index);
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// itemCount: textListSMS.length,
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
updateList() async {
|
|
|
|
updateList() async {
|
|
|
@ -109,14 +115,23 @@ class _CallingIdleListState extends State<CallingIdleList>
|
|
|
|
textListSMS.clear();
|
|
|
|
textListSMS.clear();
|
|
|
|
smsIdList.clear();
|
|
|
|
smsIdList.clear();
|
|
|
|
int i = 0;
|
|
|
|
int i = 0;
|
|
|
|
userProvider.userInfo.contentRef?.forEach((model) {
|
|
|
|
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);
|
|
|
|
textListSMS.add(model.content);
|
|
|
|
smsIdList.add(model.id);
|
|
|
|
smsIdList.add(model.id);
|
|
|
|
if (model.isChecked == 1) {
|
|
|
|
if (model.isChecked == 1) {
|
|
|
|
isCheck = i;
|
|
|
|
isCheck = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
i++;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
textListSMS.add("自定义短信内容");
|
|
|
|
textListSMS.add("自定义短信内容");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
textListSMS = textList;
|
|
|
|
textListSMS = textList;
|
|
|
@ -126,7 +141,6 @@ class _CallingIdleListState extends State<CallingIdleList>
|
|
|
|
_getText() {
|
|
|
|
_getText() {
|
|
|
|
return Container(
|
|
|
|
return Container(
|
|
|
|
height: 128.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),
|
|
|
|
padding: EdgeInsets.only(left: 40.w, top: 45.w),
|
|
|
|
child: ListTile(
|
|
|
|
child: ListTile(
|
|
|
|
title: Text(
|
|
|
|
title: Text(
|
|
|
@ -134,19 +148,13 @@ class _CallingIdleListState extends State<CallingIdleList>
|
|
|
|
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 36.sp),
|
|
|
|
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 36.sp),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
subtitle: Text(
|
|
|
|
subtitle: Text(
|
|
|
|
widget.isIdle
|
|
|
|
widget.title,
|
|
|
|
? "您给朋友去电拒接/未接后所发送的短信":"朋友给你来电接听后所发送的短信",
|
|
|
|
|
|
|
|
style: TextStyle(color: const Color(0xFF999999), fontSize: 27.sp),
|
|
|
|
style: TextStyle(color: const Color(0xFF999999), fontSize: 27.sp),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
trailing: widget.isIdle
|
|
|
|
trailing: widget.isIdle!
|
|
|
|
? Switch(
|
|
|
|
? Switch(
|
|
|
|
value: val,
|
|
|
|
value: val,
|
|
|
|
onChanged: (value) async {
|
|
|
|
onChanged: (value) async {
|
|
|
|
// if(!value){
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// await prefs.setBool("kg", value);
|
|
|
|
|
|
|
|
// print("这是数据${prefs.getBool("kg")}");
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
setState(() {
|
|
|
|
val = value;
|
|
|
|
val = value;
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -159,7 +167,7 @@ class _CallingIdleListState extends State<CallingIdleList>
|
|
|
|
return GestureDetector(
|
|
|
|
return GestureDetector(
|
|
|
|
onTap: () async {
|
|
|
|
onTap: () async {
|
|
|
|
if (content != "自定义短信内容") {
|
|
|
|
if (content != "自定义短信内容") {
|
|
|
|
BaseModel res = await apiClient.request(API.app.checked,
|
|
|
|
BaseModel res = await apiClient.request(API.content.checked,
|
|
|
|
data: {'id': smsIdList[index], 'status': 2});
|
|
|
|
data: {'id': smsIdList[index], 'status': 2});
|
|
|
|
if (res.code == 0) {
|
|
|
|
if (res.code == 0) {
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
@ -223,12 +231,8 @@ class _CallingIdleListState extends State<CallingIdleList>
|
|
|
|
begin: Alignment.centerLeft,
|
|
|
|
begin: Alignment.centerLeft,
|
|
|
|
end: Alignment.centerRight,
|
|
|
|
end: Alignment.centerRight,
|
|
|
|
colors: [
|
|
|
|
colors: [
|
|
|
|
index == isCheck
|
|
|
|
index == isCheck ? widget.themeColor : const Color(0xFFF9F9F9),
|
|
|
|
? const Color(0xFF13CA9D)
|
|
|
|
index == isCheck ? widget.themeColor : const Color(0xFFF9F9F9),
|
|
|
|
: const Color(0xFFF9F9F9),
|
|
|
|
|
|
|
|
index == isCheck
|
|
|
|
|
|
|
|
? const Color(0xFF72E4C8)
|
|
|
|
|
|
|
|
: const Color(0xFFF9F9F9),
|
|
|
|
|
|
|
|
]),
|
|
|
|
]),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Text(
|
|
|
|
child: Text(
|
|
|
|