master
王亚玲 2 years ago
parent 7e97d5064d
commit 099b478f11

@ -0,0 +1,19 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:equatable/equatable.dart';
part 'exclude_pn_model.g.dart';
@JsonSerializable()
class ExcludePnModel extends Equatable{
final String? phone;
final String? remark;
factory ExcludePnModel.fromJson(Map<String, dynamic> json) =>_$ExcludePnModelFromJson(json);
const ExcludePnModel({
required this.phone,
required this.remark,
});
@override
List<Object?> get props => [phone,remark];
}

@ -0,0 +1,13 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'exclude_pn_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
ExcludePnModel _$ExcludePnModelFromJson(Map<String, dynamic> json) =>
ExcludePnModel(
phone: json['phone'] as String,
remark: json['remark'] as String,
);

@ -32,6 +32,7 @@ class _ExcludeSinglePageState extends State<ExcludeSinglePage> {
@override
Widget build(BuildContext context) {
return ScaffoldThemeWidget(
wid: 110,
title: '添加单个或批量号码',
bottom: "添加",
onTap: () {},
@ -57,6 +58,7 @@ class _ExcludeSinglePageState extends State<ExcludeSinglePage> {
color: Colors.black38,
),
),
TextSpan(
text: "如输入000*可屏蔽所有000开头的号码",
style: TextStyle(
@ -78,10 +80,10 @@ class _ExcludeSinglePageState extends State<ExcludeSinglePage> {
children: [
Text(
title,
style: const TextStyle(
fontSize: 16,
color: Color(0xFF999999),
fontWeight: FontWeight.w600,
style: TextStyle(
fontSize: 28.sp,
color: const Color(0xFF999999),
fontWeight: FontWeight.w500,
),
),
15.heightBox,
@ -93,10 +95,10 @@ class _ExcludeSinglePageState extends State<ExcludeSinglePage> {
decoration: InputDecoration(
contentPadding: EdgeInsets.all(30.w),
hintText: content,
hintStyle: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Color(0xFF999999),
hintStyle: TextStyle(
fontSize: 28.sp,
// fontWeight: FontWeight.w600,
color: const Color(0xFF999999),
),
fillColor: const Color(0xFFF9F9F9),
filled: true,

@ -1,8 +1,10 @@
import 'package:project_telephony/constants/api.dart';
import 'package:project_telephony/model/network/api_client.dart';
import 'package:project_telephony/model/network/base_model.dart';
import 'package:project_telephony/utils/inner_model/base_list_model.dart';
import '../../../../model/exclude_phone_model.dart';
import '../../../../model/exclude_pn_model.dart';
import '../../../../utils/toast/cloud_toast.dart';
class ExcludeFunc {
@ -17,5 +19,15 @@ class ExcludeFunc {
}
}
//
// static Future<bool>
static Future<bool> getContactsList(List numList) async{
BaseModel res=await apiClient.request(API.exclude.add,data: {"exclude":numList});
if(res.code==0){
return true;
}else{
CloudToast.show(res.msg);
return false;
}
}
}

@ -5,8 +5,10 @@ import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:project_telephony/base/base_style.dart';
import 'package:project_telephony/constants/api.dart';
import 'package:project_telephony/model/network/api_client.dart';
import 'package:project_telephony/ui/home/set/func/exclude_contacts_func.dart';
import 'package:project_telephony/utils/headers.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../../../model/exclude_pn_model.dart';
import '../../../../model/phone_num_model.dart';
import '../../../../utils/toast/cloud_toast.dart';
import '../../../widget/scaffold_theme_widget.dart';
@ -21,13 +23,17 @@ class CallRecordsList extends StatefulWidget {
class _CallRecordsListState extends State<CallRecordsList> {
List<PhoneNumModel> phoneNum = [];
List<PhoneNumModel> phoneNum2 = [];
List<String> phoneNum3 = [];
// List<ExcludePnModel> phoneNum3 = [];
List phoneNum3=[];
// Map<String, String> get phoneNum3 => {};
final EasyRefreshController _easyRefreshController = EasyRefreshController();
late bool notifications;
late bool trackHistory;
late bool instantOrders;
late SharedPreferences prefs;
List<String> numList = [];
// List<String> =[]
@override
void initState() {
@ -56,7 +62,7 @@ class _CallRecordsListState extends State<CallRecordsList> {
));
}
}
for(int i=0;i<phoneNum.length;i++){
for (int i = 0; i < phoneNum.length; i++) {
phoneNum2.add(PhoneNumModel(
num: phoneNum[i].num,
time: phoneNum[i].time,
@ -85,13 +91,13 @@ class _CallRecordsListState extends State<CallRecordsList> {
title: '从通话记录添加',
isBorder: true,
isOpacity: phoneNum3.isNotEmpty,
onTap: () async{
if(phoneNum3.isEmpty){
onTap: () async {
if (phoneNum3.isEmpty) {
CloudToast.show('请选择手机号');
}else{
var res=await apiClient.request(API.exclude.add,data: {});
} else {
print(phoneNum3);
var res = await ExcludeFunc.getContactsList(phoneNum3);
print(res);
}
// _easyRefreshController.callRefresh();
// phoneNum3.clear();
@ -104,10 +110,9 @@ class _CallRecordsListState extends State<CallRecordsList> {
getList();
setState(() {});
},
child:
ListView.builder(
child: ListView.builder(
itemBuilder: (context, index) {
return _getBox(phoneNum2[index],phoneNum2[index].num!);
return _getBox(phoneNum2[index], phoneNum2[index].num!,phoneNum2[index].name?? "");
},
itemCount: phoneNum2.length,
),
@ -158,15 +163,18 @@ class _CallRecordsListState extends State<CallRecordsList> {
// );
}
_getBox(PhoneNumModel item, String index) {
_getBox(PhoneNumModel item, String num,String name) {
return CheckboxListTile(
onChanged: (bool? value) {
setState(() {
item.state = value!;
if(item.state){
phoneNum3.add(index);
}else{
phoneNum3.remove(index);
if (item.state) {
phoneNum3.add({"phone":num,"remark":name});
// phoneNum3.add((phone: num, remark: name));
} else {
phoneNum3.remove({"phone":num,"remark":name});
// phoneNum3.remove(ExcludePnModel(phone: num, remark: name)) ;
}
});
},

@ -17,6 +17,7 @@ import '../../../model/exclude_phone_model.dart';
import '../../widget/scaffold_theme_widget.dart';
import 'func/exclude_contacts_func.dart';
class SpecifyPhonePage extends StatefulWidget {
const SpecifyPhonePage({Key? key}) : super(key: key);
@ -28,7 +29,7 @@ class SpecifyPhonePage extends StatefulWidget {
class _SpecifyPhonePageState extends State<SpecifyPhonePage> {
final EasyRefreshController _refreshController = EasyRefreshController();
List<ExcludePhoneModel> findList = [
const ExcludePhoneModel(id: 0, phone: '123123123123', remark: '好的')
];
@override
@ -40,6 +41,7 @@ class _SpecifyPhonePageState extends State<SpecifyPhonePage> {
@override
Widget build(BuildContext context) {
return ScaffoldThemeWidget(
wid: 196,
title: "指定号码",
bottom: '添加',
onTap: () {
@ -118,7 +120,7 @@ class _SpecifyPhonePageState extends State<SpecifyPhonePage> {
header: MaterialHeader(),
// footer: MaterialFooter(),
onRefresh: () async {
// findList = await ExcludeFunc.getContacts();
findList = await ExcludeFunc.getContacts();
// await userProvider.updateUserInfo();
setState(() {});

Loading…
Cancel
Save