|
|
@ -7,6 +7,7 @@ import 'package:get/get.dart';
|
|
|
|
import 'package:project_telephony/extensions/num_ext.dart';
|
|
|
|
import 'package:project_telephony/extensions/num_ext.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 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
|
|
|
|
|
|
|
|
import '../../base/base_style.dart';
|
|
|
|
import '../../base/base_style.dart';
|
|
|
|
import '../../constants/api.dart';
|
|
|
|
import '../../constants/api.dart';
|
|
|
@ -17,19 +18,20 @@ 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';
|
|
|
|
import 'add_sms_page.dart';
|
|
|
|
import 'add_sms_page.dart';
|
|
|
|
|
|
|
|
import 'home_page.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class CallingIdleList extends StatefulWidget {
|
|
|
|
class CallingIdleList extends StatefulWidget {
|
|
|
|
final EasyRefreshController refreshController;
|
|
|
|
final EasyRefreshController refreshController;
|
|
|
|
final String title;
|
|
|
|
final String title;
|
|
|
|
final int status;
|
|
|
|
final int status;
|
|
|
|
final bool? isIdle;
|
|
|
|
final String? name;
|
|
|
|
final Color themeColor;
|
|
|
|
final Color themeColor;
|
|
|
|
|
|
|
|
|
|
|
|
const CallingIdleList({
|
|
|
|
const CallingIdleList({
|
|
|
|
Key? key,
|
|
|
|
Key? key,
|
|
|
|
required this.title,
|
|
|
|
required this.title,
|
|
|
|
required this.status,
|
|
|
|
required this.status,
|
|
|
|
this.isIdle = false,
|
|
|
|
this.name = '',
|
|
|
|
required this.themeColor,
|
|
|
|
required this.themeColor,
|
|
|
|
required this.refreshController,
|
|
|
|
required this.refreshController,
|
|
|
|
}) : super(key: key);
|
|
|
|
}) : super(key: key);
|
|
|
@ -41,17 +43,24 @@ class CallingIdleList extends StatefulWidget {
|
|
|
|
class _CallingIdleListState extends State<CallingIdleList>
|
|
|
|
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);
|
|
|
|
|
|
|
|
final Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
|
|
|
|
List<String> textList = ['现在无法接听。有什么事吗?', '自定义短信内容'];
|
|
|
|
List<String> textList = ['现在无法接听。有什么事吗?', '自定义短信内容'];
|
|
|
|
List<SmsContentModel> _model = [];
|
|
|
|
List<SmsContentModel> _model = [];
|
|
|
|
List<String> textListSMS = [];
|
|
|
|
List<String> textListSMS = [];
|
|
|
|
List<int> smsIdList = [];
|
|
|
|
List<int> smsIdList = [];
|
|
|
|
int isCheck = 0;
|
|
|
|
int isCheck = 0;
|
|
|
|
bool val = false;
|
|
|
|
late bool val = false;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
void initState() {
|
|
|
|
|
|
|
|
getSwitch();
|
|
|
|
super.initState();
|
|
|
|
super.initState();
|
|
|
|
updateList();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> getSwitch() async {
|
|
|
|
|
|
|
|
final SharedPreferences prefs = await _prefs;
|
|
|
|
|
|
|
|
val = prefs.getBool(widget.name!)!;
|
|
|
|
|
|
|
|
print(val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> updateList() async {
|
|
|
|
Future<void> updateList() async {
|
|
|
@ -88,39 +97,15 @@ class _CallingIdleListState extends State<CallingIdleList>
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
_getText(),
|
|
|
|
_getText(),
|
|
|
|
32.hb,
|
|
|
|
32.hb,
|
|
|
|
widget.isIdle!
|
|
|
|
widget.name!.isEmpty || val
|
|
|
|
? val
|
|
|
|
? Expanded(
|
|
|
|
? Expanded(
|
|
|
|
|
|
|
|
child: EasyRefresh.custom(
|
|
|
|
|
|
|
|
firstRefresh: true,
|
|
|
|
|
|
|
|
controller: widget.refreshController,
|
|
|
|
|
|
|
|
header: MaterialHeader(),
|
|
|
|
|
|
|
|
// footer: MaterialFooter(),
|
|
|
|
|
|
|
|
onRefresh: () async {
|
|
|
|
|
|
|
|
await userProvider.updateUserInfo();
|
|
|
|
|
|
|
|
await updateList();
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
slivers: [
|
|
|
|
|
|
|
|
SliverList(
|
|
|
|
|
|
|
|
delegate:
|
|
|
|
|
|
|
|
SliverChildBuilderDelegate((context, index) {
|
|
|
|
|
|
|
|
return _getBox(textListSMS[index], index);
|
|
|
|
|
|
|
|
}, childCount: textListSMS.length),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
: _getEmptyList()
|
|
|
|
|
|
|
|
: Expanded(
|
|
|
|
|
|
|
|
child: EasyRefresh.custom(
|
|
|
|
child: EasyRefresh.custom(
|
|
|
|
firstRefresh: true,
|
|
|
|
firstRefresh: true,
|
|
|
|
controller: widget.refreshController,
|
|
|
|
controller: widget.refreshController,
|
|
|
|
header: MaterialHeader(),
|
|
|
|
header: MaterialHeader(),
|
|
|
|
// footer: MaterialFooter(),
|
|
|
|
// footer: MaterialFooter(),
|
|
|
|
onRefresh: () async {
|
|
|
|
onRefresh: () async {
|
|
|
|
await userProvider.updateUserInfo();
|
|
|
|
// await userProvider.updateUserInfo();
|
|
|
|
userProvider.updateRefSms();
|
|
|
|
|
|
|
|
await updateList();
|
|
|
|
await updateList();
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -132,7 +117,8 @@ class _CallingIdleListState extends State<CallingIdleList>
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
: _getEmptyList(),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -142,23 +128,35 @@ class _CallingIdleListState extends State<CallingIdleList>
|
|
|
|
height: 128.w,
|
|
|
|
height: 128.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(
|
|
|
|
"功能讲解",
|
|
|
|
"功能讲解",
|
|
|
|
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 36.sp),
|
|
|
|
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 36.sp),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
subtitle: Text(
|
|
|
|
subtitle: Text(
|
|
|
|
widget.title,
|
|
|
|
widget.title,
|
|
|
|
style: TextStyle(color: const Color(0xFF999999), fontSize: 27.sp),
|
|
|
|
style: TextStyle(color: const Color(0xFF999999), fontSize: 27.sp),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
trailing: Offstage(
|
|
|
|
|
|
|
|
offstage: widget.name!.isEmpty,
|
|
|
|
|
|
|
|
child: Switch(
|
|
|
|
|
|
|
|
value: val,
|
|
|
|
|
|
|
|
onChanged: (value) async {
|
|
|
|
|
|
|
|
final SharedPreferences prefs = await _prefs;
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
val = value;
|
|
|
|
|
|
|
|
prefs.remove(widget.name!);
|
|
|
|
|
|
|
|
prefs.setBool(widget.name!, val);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
service.invoke("stopService");
|
|
|
|
|
|
|
|
if (prefs.getBool('kg')!) {
|
|
|
|
|
|
|
|
Future.delayed(const Duration(seconds: 1), () async {
|
|
|
|
|
|
|
|
service.startService();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
trailing: widget.isIdle!
|
|
|
|
),
|
|
|
|
? Switch(
|
|
|
|
),
|
|
|
|
value: val,
|
|
|
|
|
|
|
|
onChanged: (value) async {
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
val = value;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
: const SizedBox()),
|
|
|
|
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -170,7 +168,7 @@ class _CallingIdleListState extends State<CallingIdleList>
|
|
|
|
data: {'id': smsIdList[index], 'status': widget.status});
|
|
|
|
data: {'id': smsIdList[index], 'status': widget.status});
|
|
|
|
if (res.code == 0) {
|
|
|
|
if (res.code == 0) {
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
await userProvider.updateUserInfo();
|
|
|
|
// await userProvider.updateUserInfo();
|
|
|
|
switch (widget.status) {
|
|
|
|
switch (widget.status) {
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
|
await userProvider.updateConSms();
|
|
|
|
await userProvider.updateConSms();
|
|
|
|