diff --git a/lib/model/exclude_pn_model.dart b/lib/model/exclude_pn_model.dart new file mode 100644 index 0000000..f0fe4b9 --- /dev/null +++ b/lib/model/exclude_pn_model.dart @@ -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 json) =>_$ExcludePnModelFromJson(json); + + + const ExcludePnModel({ + required this.phone, + required this.remark, + }); + @override + List get props => [phone,remark]; +} \ No newline at end of file diff --git a/lib/model/exclude_pn_model.g.dart b/lib/model/exclude_pn_model.g.dart new file mode 100644 index 0000000..55ec5fe --- /dev/null +++ b/lib/model/exclude_pn_model.g.dart @@ -0,0 +1,13 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'exclude_pn_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +ExcludePnModel _$ExcludePnModelFromJson(Map json) => + ExcludePnModel( + phone: json['phone'] as String, + remark: json['remark'] as String, + ); diff --git a/lib/ui/exclude/exclude_single_page.dart b/lib/ui/exclude/exclude_single_page.dart index ec84cd2..129dfae 100644 --- a/lib/ui/exclude/exclude_single_page.dart +++ b/lib/ui/exclude/exclude_single_page.dart @@ -32,6 +32,7 @@ class _ExcludeSinglePageState extends State { @override Widget build(BuildContext context) { return ScaffoldThemeWidget( + wid: 110, title: '添加单个或批量号码', bottom: "添加", onTap: () {}, @@ -57,6 +58,7 @@ class _ExcludeSinglePageState extends State { color: Colors.black38, ), ), + TextSpan( text: "如输入000*,可屏蔽所有000开头的号码", style: TextStyle( @@ -78,10 +80,10 @@ class _ExcludeSinglePageState extends State { 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 { 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, diff --git a/lib/ui/home/set/func/exclude_contacts_func.dart b/lib/ui/home/set/func/exclude_contacts_func.dart index c0e679a..af34370 100644 --- a/lib/ui/home/set/func/exclude_contacts_func.dart +++ b/lib/ui/home/set/func/exclude_contacts_func.dart @@ -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 +static Future 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; + } + + +} } diff --git a/lib/ui/home/set/phone_num_list/call_records_list.dart b/lib/ui/home/set/phone_num_list/call_records_list.dart index 822f94f..7906537 100644 --- a/lib/ui/home/set/phone_num_list/call_records_list.dart +++ b/lib/ui/home/set/phone_num_list/call_records_list.dart @@ -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 { List phoneNum = []; List phoneNum2 = []; - List phoneNum3 = []; + // List phoneNum3 = []; + List phoneNum3=[]; + // Map get phoneNum3 => {}; + final EasyRefreshController _easyRefreshController = EasyRefreshController(); late bool notifications; late bool trackHistory; late bool instantOrders; late SharedPreferences prefs; List numList = []; + // List =[] @override void initState() { @@ -56,7 +62,7 @@ class _CallRecordsListState extends State { )); } } - for(int i=0;i { 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 { 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 { // ); } - _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)) ; } }); }, diff --git a/lib/ui/home/set/specify_phone_page.dart b/lib/ui/home/set/specify_phone_page.dart index a4fe73a..8f903b7 100644 --- a/lib/ui/home/set/specify_phone_page.dart +++ b/lib/ui/home/set/specify_phone_page.dart @@ -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 { final EasyRefreshController _refreshController = EasyRefreshController(); List findList = [ - const ExcludePhoneModel(id: 0, phone: '123123123123', remark: '好的') + ]; @override @@ -40,6 +41,7 @@ class _SpecifyPhonePageState extends State { @override Widget build(BuildContext context) { return ScaffoldThemeWidget( + wid: 196, title: "指定号码", bottom: '添加', onTap: () { @@ -118,7 +120,7 @@ class _SpecifyPhonePageState extends State { header: MaterialHeader(), // footer: MaterialFooter(), onRefresh: () async { - // findList = await ExcludeFunc.getContacts(); + findList = await ExcludeFunc.getContacts(); // await userProvider.updateUserInfo(); setState(() {});