From 29b26d623eb43a9e4cd8241aa5b478382adc0489 Mon Sep 17 00:00:00 2001 From: wylyl22 <2373073266@qq.com> Date: Tue, 13 Sep 2022 15:13:52 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=B8=83=E5=B1=80=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ui/exclude/exclude_contacts_page.dart | 11 +- lib/ui/exclude/exclude_single_page.dart | 92 +++-- .../home/set/func/exclude_contacts_func.dart | 21 ++ .../set/phone_num_list/call_records_list.dart | 139 +++++--- lib/ui/home/set/phone_set_page.dart | 1 + lib/ui/home/set/specify_phone_page.dart | 315 ++++++++---------- lib/ui/widget/appdialog.dart | 108 +++++- lib/ui/widget/scaffold_theme_widget.dart | 8 +- 8 files changed, 455 insertions(+), 240 deletions(-) create mode 100644 lib/ui/home/set/func/exclude_contacts_func.dart diff --git a/lib/ui/exclude/exclude_contacts_page.dart b/lib/ui/exclude/exclude_contacts_page.dart index f72f850..b6052dd 100644 --- a/lib/ui/exclude/exclude_contacts_page.dart +++ b/lib/ui/exclude/exclude_contacts_page.dart @@ -1,11 +1,12 @@ import 'package:bot_toast/bot_toast.dart'; -import 'package:flutter/cupertino.dart'; + import 'package:flutter/material.dart'; +import 'package:flutter_contacts/contact.dart'; import 'package:flutter_contacts/flutter_contacts.dart'; + import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'package:get/get_core/src/get_main.dart'; -import 'package:get/get_utils/get_utils.dart'; + import 'package:project_telephony/ui/widget/scaffold_theme_widget.dart'; class ExcludeContactsPage extends StatefulWidget { @@ -86,11 +87,11 @@ class _ExcludeContactsPageState extends State { title: "从通讯录添加", bottom: "添加", onTap: () { - if(status.contains(true)){ + if (status.contains(true)) { // BotToast.showText(text: "有"); Get.back(); - }else{ + } else { BotToast.showText(text: "还未选中手机号"); } }, diff --git a/lib/ui/exclude/exclude_single_page.dart b/lib/ui/exclude/exclude_single_page.dart index f47907b..b1c994d 100644 --- a/lib/ui/exclude/exclude_single_page.dart +++ b/lib/ui/exclude/exclude_single_page.dart @@ -1,9 +1,12 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:project_telephony/ui/widget/scaffold_theme_widget.dart'; +import 'package:project_telephony/utils/headers.dart'; import 'package:velocity_x/velocity_x.dart'; +import '../../base/base_style.dart'; +import '../widget/plone_back_button.dart'; +import '../widget/plone_bottom.dart'; + class ExcludeSinglePage extends StatefulWidget { const ExcludeSinglePage({Key? key}) : super(key: key); @@ -12,33 +15,59 @@ class ExcludeSinglePage extends StatefulWidget { } class _ExcludeSinglePageState extends State { + + String phone=""; + String name=""; @override Widget build(BuildContext context) { - return ScaffoldThemeWidget( - title: '添加单个或批量号码', - bottom: "添加", - onTap: () {}, - child: Container( + return Scaffold( + appBar: AppBar( + elevation: 0, + title: Text( + '添加单个或批量号码', + style: TextStyle( + fontSize: BaseStyle.fontSize34, + color: BaseStyle.color333333, + fontWeight: FontWeight.bold), + ), + titleSpacing: 110.w, + leading: const CloudBackButton(isSpecial: true), + backgroundColor: kForeGroundColor), + backgroundColor: Colors.white, + body: Container( padding: EdgeInsets.only(top: 25.h, left: 50.w, right: 50.w), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ addNumber("号码", "请输入号码"), - 15.heightBox, + 40.hb, addNumber("名称", "请输入名称"), - 15.heightBox, - RichText( - text: const TextSpan( - children: [ - TextSpan(text: "使用说明:"), - TextSpan(text: "如输入000*,可屏蔽所有000开头的号码") - ], - ), + 43.hb, + Text( + "使用说明:", + style: TextStyle(color: BaseStyle.color999999, fontSize: 28.sp), ), + 12.hb, + Text("如输入00852*,可匹配所有00852开头的号码", + style: TextStyle(color: BaseStyle.color999999, fontSize: 28.sp)) + // RichText( + // text: const TextSpan( + // children: [ + // TextSpan(text: "使用说明:"), + // TextSpan(text: "如输入000*,可屏蔽所有000开头的号码") + // ], + // ), + // ), ], ), ), + bottomNavigationBar: PloneBottom( + onTap: (){}, + border: name.isEmpty || phone.isEmpty, + opacity:name.isEmpty || phone.isEmpty ? 0.4 : 1, + text: "添加", + ).paddingOnly(bottom: 30.w), ); } @@ -48,19 +77,34 @@ class _ExcludeSinglePageState extends State { children: [ Text( title, - style: const TextStyle( - fontSize: 18, + style: TextStyle( + fontSize: 28.sp, color: Colors.black38, fontWeight: FontWeight.w600, ), ), 15.heightBox, - TextField( - decoration: InputDecoration( - hintText: content, - border: const OutlineInputBorder( - ), - ), + CupertinoTextField( + padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 20.w), + decoration: BoxDecoration( + border: Border.all(color: Colors.white), + // borderRadius: BorderRadius.all( + // Radius.circular(4.w) + // ), + color: const Color(0xFFF9F9F9)), + placeholderStyle: + TextStyle(color: BaseStyle.color999999, fontSize: 28.sp), + placeholder: content, + onChanged: (value) { + if(title=="号码"){ + phone=value; + print("phone:$phone"); + }else{ + name=value; + print("name:$name"); + } + setState(() {}); + }, ), ], ); diff --git a/lib/ui/home/set/func/exclude_contacts_func.dart b/lib/ui/home/set/func/exclude_contacts_func.dart new file mode 100644 index 0000000..c0e679a --- /dev/null +++ b/lib/ui/home/set/func/exclude_contacts_func.dart @@ -0,0 +1,21 @@ +import 'package:project_telephony/constants/api.dart'; +import 'package:project_telephony/model/network/api_client.dart'; +import 'package:project_telephony/utils/inner_model/base_list_model.dart'; + +import '../../../../model/exclude_phone_model.dart'; +import '../../../../utils/toast/cloud_toast.dart'; + +class ExcludeFunc { +// 查看手机号码 + static Future> getContacts() async { + BaseListModel res=await apiClient.requestList(API.exclude.find,); + if(res.code==0){ + return res.nullSafetyList.map((e) => ExcludePhoneModel.fromJson(e)).toList(); + }else{ + CloudToast.show(res.msg); + return []; + } + } + //添加手机号码 +// static Future +} 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 08768ae..822f94f 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 @@ -3,13 +3,14 @@ import 'package:flustars/flustars.dart'; import 'package:flutter/material.dart'; 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/utils/headers.dart'; import 'package:shared_preferences/shared_preferences.dart'; import '../../../../model/phone_num_model.dart'; +import '../../../../utils/toast/cloud_toast.dart'; import '../../../widget/scaffold_theme_widget.dart'; - - class CallRecordsList extends StatefulWidget { const CallRecordsList({Key? key}) : super(key: key); @@ -20,68 +21,122 @@ class CallRecordsList extends StatefulWidget { class _CallRecordsListState extends State { List phoneNum = []; List phoneNum2 = []; + List phoneNum3 = []; final EasyRefreshController _easyRefreshController = EasyRefreshController(); late bool notifications; late bool trackHistory; late bool instantOrders; late SharedPreferences prefs; - List numList=[]; - - - + List numList = []; + // List =[] @override void initState() { // getList(); getList(); super.initState(); - } + @override void dispose() { _easyRefreshController.dispose(); super.dispose(); } + getList() async { - phoneNum.clear(); - final Iterable entries = await CallLog.query(); - for (CallLogEntry entrie in entries) { - if(!numList.contains(entrie.number)){ - numList.add(entrie.number!); - phoneNum.add(PhoneNumModel( + phoneNum.clear(); + final Iterable entries = await CallLog.query(); + for (CallLogEntry entrie in entries) { + if (!numList.contains(entrie.number)) { + numList.add(entrie.number!); + phoneNum.add(PhoneNumModel( num: entrie.number, time: entrie.timestamp, name: entrie.name, state: false, )); - } - } + } + } + for(int i=0;i or null - builder: (BuildContext context, AsyncSnapshot snapshot) { - if(snapshot.connectionState==ConnectionState.done){ - return ListView.builder( - itemBuilder: (context, index) { - return _getBox(phoneNum[index]); - }, - itemCount: phoneNum.length, - ); + return ScaffoldThemeWidget( + bottom: '添加', + title: '从通话记录添加', + isBorder: true, + isOpacity: phoneNum3.isNotEmpty, + onTap: () async{ + if(phoneNum3.isEmpty){ + CloudToast.show('请选择手机号'); }else{ - return const SizedBox(); - } - }); -return ScaffoldThemeWidget( - bottom: '添加', - title: '从通话记录添加', - isBorder: true, - isOpacity: false, - onTap: () { + var res=await apiClient.request(API.exclude.add,data: {}); + print(phoneNum3); - }, - child: profileBuilder -); + } + // _easyRefreshController.callRefresh(); + // phoneNum3.clear(); + }, + child: EasyRefresh( + firstRefresh: true, + header: MaterialHeader(), + controller: _easyRefreshController, + onRefresh: () async { + getList(); + setState(() {}); + }, + child: + ListView.builder( + itemBuilder: (context, index) { + return _getBox(phoneNum2[index],phoneNum2[index].num!); + }, + itemCount: phoneNum2.length, + ), + )); +// var profileBuilder = FutureBuilder( +// // future: _incrementCounter(), +// future: getList() , // a Future or null +// builder: (BuildContext context, AsyncSnapshot snapshot) { +// if(snapshot.connectionState==ConnectionState.done){ +// return ListView.builder( +// itemBuilder: (context, index) { +// return _getBox(phoneNum[index]); +// }, +// itemCount: phoneNum.length, +// ); +// }else{ +// return const SizedBox(); +// } +// }); +// return ScaffoldThemeWidget( +// bottom: '添加', +// title: '从通话记录添加', +// isBorder: true, +// isOpacity: false, +// onTap: () { +// +// }, +// child: profileBuilder +// ); // Column( // children: [ // Container(width: 750.w, height: 1000.w, child: Text("") @@ -103,12 +158,16 @@ return ScaffoldThemeWidget( // ); } - _getBox(PhoneNumModel item) { + _getBox(PhoneNumModel item, String index) { return CheckboxListTile( onChanged: (bool? value) { - setState((){ + setState(() { item.state = value!; - + if(item.state){ + phoneNum3.add(index); + }else{ + phoneNum3.remove(index); + } }); }, value: item.state, diff --git a/lib/ui/home/set/phone_set_page.dart b/lib/ui/home/set/phone_set_page.dart index 118e826..dbe7eda 100644 --- a/lib/ui/home/set/phone_set_page.dart +++ b/lib/ui/home/set/phone_set_page.dart @@ -11,6 +11,7 @@ import '../../widget/plone_back_button.dart'; // } class PhoneSetPage extends StatefulWidget { + const PhoneSetPage({Key? key}) : super(key: key); @override diff --git a/lib/ui/home/set/specify_phone_page.dart b/lib/ui/home/set/specify_phone_page.dart index da382d9..9b84ff1 100644 --- a/lib/ui/home/set/specify_phone_page.dart +++ b/lib/ui/home/set/specify_phone_page.dart @@ -1,18 +1,21 @@ -import 'package:call_log/call_log.dart'; -import 'package:flustars/flustars.dart'; +import 'dart:ffi'; + +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:project_telephony/constants/api.dart'; +import 'package:project_telephony/model/network/api_client.dart'; import 'package:project_telephony/ui/exclude/exclude_contacts_page.dart'; import 'package:project_telephony/ui/exclude/exclude_single_page.dart'; -import 'package:project_telephony/ui/home/home_page.dart'; import 'package:project_telephony/ui/home/set/phone_num_list/call_records_list.dart'; import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/ui/widget/plone_bottom.dart'; - +import 'package:project_telephony/utils/toast/cloud_toast.dart'; import '../../../base/base_style.dart'; -import '../../../model/phone_num_model.dart'; +import '../../../model/exclude_phone_model.dart'; +import '../../widget/appdialog.dart'; import '../../widget/scaffold_theme_widget.dart'; class SpecifyPhonePage extends StatefulWidget { @@ -24,6 +27,9 @@ class SpecifyPhonePage extends StatefulWidget { class _SpecifyPhonePageState extends State { final EasyRefreshController _refreshController = EasyRefreshController(); + List findList = [ + const ExcludePhoneModel(id: 0, phone: '123123123123', remark: '好的') + ]; @override void dispose() { @@ -34,7 +40,7 @@ class _SpecifyPhonePageState extends State { @override Widget build(BuildContext context) { return ScaffoldThemeWidget( - title: "发送号码设置", + title: "指定号码", bottom: '添加', onTap: () { showModalBottomSheet( @@ -55,13 +61,14 @@ class _SpecifyPhonePageState extends State { child: ListView( children: [ _getAddPhone("通话记录添加", "通过本机通话记录添加号码", () { - Get.to(() => ScaffoldThemeWidget( - bottom: '添加', - title: '从通话记录添加', - isBorder: true, - isOpacity: false, - onTap: () {}, - child: const CallRecordsList())); + Navigator.of(context) + .push( + MaterialPageRoute( + builder: (_) => const CallRecordsList()), + ) + .then((val) => _getNullList()); + + // Get.to(() => const CallRecordsList()); }), _getAddPhone("通迅录添加", "通过本机通讯录添加号码", () { Get.to(() => (const ExcludeContactsPage())); @@ -95,167 +102,141 @@ class _SpecifyPhonePageState extends State { header: MaterialHeader(), // footer: MaterialFooter(), onRefresh: () async { + // findList = await ExcludeFunc.getContacts(); // await userProvider.updateUserInfo(); setState(() {}); }, - child: ListView( - children: [ - _getNullList(), - ], - )), + child: findList.isEmpty ? _getNullList() : _getNum() + + // ListView( + // children: [findList.isEmpty ? _getNullList() : _getNum()], + // ) + + ), ); - // PloneBottom( - // onTap: () { - // showModalBottomSheet( - // builder: (BuildContext context) { - // return Container( - // width: double.infinity, - // height: 750.w, - // padding: EdgeInsets.symmetric(horizontal: 32.w), - // child: Column( - // children: [ - // 48.hb, - // Text( - // "添加号码", - // style: TextStyle( - // fontSize: 34.w, - // fontWeight: FontWeight.bold), - // ), - // Expanded( - // child: ListView( - // children: [ - // _getAddPhone("通话记录添加", "通过本机通话记录添加号码", () { - // Get.to(() => ScaffoldThemeWidget( - // bottom: '添加', - // title: '从通话记录添加', - // isBorder: true, - // isOpacity: false, - // onTap: () { }, - // child: CallRecordsList() - // )); - // }), - // _getAddPhone("通迅录添加", "通过本机通讯录添加号码", () { - // Get.to(() => (const ExcludeContactsPage())); - // }), - // _getAddPhone( - // "添加单个或批量号码", "通过输入号码段添加批量号码", () {}), - // ], - // )), - // PloneBottom( - // onTap: () { - // Navigator.pop(context); - // }, - // hPadding: 32, - // border: true, - // textColor: const Color(0xFF1890FF), - // color2: const Color(0xFFF9F9F9), - // color1: const Color(0xFFF9F9F9), - // text: "取消", - // ), - // 32.hb - // ], - // ), - // ); - // }, - // context: context); - // }, - // border: true, - // color2: const Color(0xFF74BCFF), - // color1: const Color(0xFF1890FF), - // text: "添加", - // ), - // Scaffold( - // appBar: AppBar( - // elevation: 0, - // title: Text( - // '发送号码设置', - // style: TextStyle( - // fontSize: BaseStyle.fontSize34, - // color: BaseStyle.color333333, - // fontWeight: FontWeight.bold), - // ), - // titleSpacing: 162.w, - // leading: const CloudBackButton(isSpecial: true), - // backgroundColor: kForeGroundColor), - // backgroundColor: kForeGroundColor, - // body: EasyRefresh( - // firstRefresh: true, - // controller: _refreshController, - // header: MaterialHeader(), - // // footer: MaterialFooter(), - // onRefresh: () async { - // // await userProvider.updateUserInfo(); - // - // setState(() {}); - // }, - // child: ListView( - // children: [ - // _getNullList(), - // PloneBottom( - // onTap: () { - // showModalBottomSheet( - // builder: (BuildContext context) { - // return Container( - // width: double.infinity, - // height: 750.w, - // padding: EdgeInsets.symmetric(horizontal: 32.w), - // child: Column( - // children: [ - // 48.hb, - // Text( - // "添加号码", - // style: TextStyle( - // fontSize: 34.w, - // fontWeight: FontWeight.bold), - // ), - // Expanded( - // child: ListView( - // children: [ - // _getAddPhone("通话记录添加", "通过本机通话记录添加号码", () { - // Get.to(() => const ScaffoldThemeWidget( - // bottom: '添加', - // title: '从通话记录添加', - // isBorder: true, - // isOpacity: false, - // child: CallRecordsList() - // )); - // }), - // _getAddPhone("通迅录添加", "通过本机通讯录添加号码", () { - // Get.to(() => (const ExcludeContactsPage())); - // }), - // _getAddPhone( - // "添加单个或批量号码", "通过输入号码段添加批量号码", () {}), - // ], - // )), - // PloneBottom( - // onTap: () { - // Navigator.pop(context); - // }, - // hPadding: 32, - // border: true, - // textColor: const Color(0xFF1890FF), - // color2: const Color(0xFFF9F9F9), - // color1: const Color(0xFFF9F9F9), - // text: "取消", - // ), - // 32.hb - // ], - // ), - // ); - // }, - // context: context); - // }, - // border: true, - // color2: const Color(0xFF74BCFF), - // color1: const Color(0xFF1890FF), - // text: "添加", - // ), - // ], - // )), - // ); + } + _getNum() { + return ListView.builder( + itemBuilder: (context, index) { + return _getNumContant(findList[index]); + }, + itemCount: findList.length, + ); + } + + _getNumContant(ExcludePhoneModel item) { + return Container( + margin: EdgeInsets.symmetric(horizontal: 16.w), + child: ListTile( + onTap: () { + showDialog( + context: context, + builder: (context) { + return CupertinoAlertDialog( + title: Text( + "修改名称", + style: TextStyle( + color: BaseStyle.color333333, fontSize: 34.sp), + ), + content: Column( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "名称", + style: TextStyle( + fontSize: 28.sp, + color: BaseStyle.color999999, + ), + ), + 24.hb, + CupertinoTextField( + padding: EdgeInsets.symmetric(horizontal: 24.w,vertical: 20.w), + decoration: BoxDecoration( + border: Border.all(color: Colors.white), + // borderRadius: BorderRadius.all( + // Radius.circular(4.w) + // ), + color: const Color(0xFFF9F9F9)), + placeholderStyle: + const TextStyle(color: BaseStyle.color333333), + placeholder: item.remark, + onChanged: (value) {}, + ), + 20.hb, + Text( + "号码", + style: TextStyle( + fontSize: 28.sp, + color: BaseStyle.color999999, + ), + ), + 24.hb, + CupertinoTextField( + padding: EdgeInsets.symmetric(horizontal: 24.w,vertical: 20.w), + decoration: BoxDecoration( + border: Border.all(color: Colors.white), + // borderRadius: BorderRadius.all( + // Radius.circular(4.w) + // ), + color: const Color(0xFFF9F9F9)), + placeholder: item.phone, + onChanged: (value) {}, + ), + 82.hb, + // _getUpdate("爸爸", "123123123"), + PloneBottom( + blM:false, + border: true, + color1:const Color(0xFF1890FF), + color2:const Color(0xFF74BCFF), + onTap: () {}, + text: "保存", + ) + ], + ), + ], + ), + ); + }); + }, + title: Text(item.phone, + style: TextStyle( + fontSize: 32.sp, + color: BaseStyle.color333333, + fontWeight: FontWeight.bold)), + subtitle: Text( + item.remark, + style: TextStyle(fontSize: 28.sp, color: BaseStyle.color999999), + ), + trailing: TextButton( + style: ButtonStyle( + side: MaterialStateProperty.all( + BorderSide(width: 2.w, color: const Color(0xFFE8E8E8)))), + onPressed: () async { + var res = + await apiClient.request(API.exclude.find, data: {item.id}); + if (res.code == 0) { + _refreshController.callRefresh(); + CloudToast.show(res.msg); + } else { + CloudToast.show(res.msg); + } + }, + child: Text( + "删除", + style: TextStyle(fontSize: 28.sp, color: BaseStyle.color333333), + ), + ), + ), + ); + } + + _getAddPhone(String title, String text, VoidCallback widget) { return GestureDetector( onTap: widget, diff --git a/lib/ui/widget/appdialog.dart b/lib/ui/widget/appdialog.dart index 798e85b..662fc8f 100644 --- a/lib/ui/widget/appdialog.dart +++ b/lib/ui/widget/appdialog.dart @@ -1,4 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:project_telephony/base/base_style.dart'; +import 'package:project_telephony/ui/widget/plone_bottom.dart'; import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/utils/user_tool.dart'; @@ -74,7 +77,6 @@ _getBotton(String bContent, context) { CloudToast.show(res.msg); } }, - child: Container( margin: EdgeInsets.symmetric(horizontal: 64.w), width: 500.w, @@ -160,3 +162,107 @@ _getVip() { ), ); } + +// class FindDialog extends StatefulWidget{ +// final String title; +// +// // final Widget widget; +// final VoidCallback ontap; +// final String name; +// final String phone; +// +// const FindDialog( +// {Key? key, +// required this.title, +// required this.ontap, +// // required this.widget, +// required this.name, +// required this.phone}) +// : super(key: key); +// +// @override +// Widget build(BuildContext context) { +// return Scaffold( +// body:Container( +// margin: EdgeInsets.only( +// left: 100.w, +// right: 100.w, +// ), +// height: 720.w, +// child: Column( +// mainAxisAlignment: MainAxisAlignment.center, +// children: [ +// Text( +// title, +// style: TextStyle( +// fontSize: 36.sp, +// ), +// ), +// _getUpdate(name, phone), +// PloneBottom( +// onTap: ontap, +// text: "保存", +// ) +// ], +// ), +// ), +// ); +// } +// +// _getUpdate(String name, String phone) { +// return Container( +// height: 400.w, +// padding: EdgeInsets.zero, +// child: Column( +// children: [ +// Text( +// "名称", +// style: TextStyle( +// fontSize: 28.sp, +// color: BaseStyle.color999999, +// ), +// ), +// 24.hb, +// SizedBox( +// height: 96.w, +// child: TextField( +// decoration: InputDecoration.collapsed( +// hintText: name, +// hintStyle: +// TextStyle(fontSize: 28.sp, color: BaseStyle.color333333), +// fillColor: Colors.transparent, +// // contentPadding: EdgeInsets.zero, +// ), +// ), +// ), +// 48.hb, +// Text( +// "名称", +// style: TextStyle( +// fontSize: 28.sp, +// color: BaseStyle.color999999, +// ), +// ), +// 24.hb, +// SizedBox( +// height: 96.w, +// child: TextField( +// decoration: InputDecoration.collapsed( +// hintText: phone, +// hintStyle: +// TextStyle(fontSize: 28.sp, color: BaseStyle.color333333), +// fillColor: Colors.transparent, +// // contentPadding: EdgeInsets.zero, +// ), +// ), +// ) +// ], +// ), +// ); +// } +// +// @override +// State createState() { +// throw UnimplementedError(); +// } +// } diff --git a/lib/ui/widget/scaffold_theme_widget.dart b/lib/ui/widget/scaffold_theme_widget.dart index a6a8e7d..92914c3 100644 --- a/lib/ui/widget/scaffold_theme_widget.dart +++ b/lib/ui/widget/scaffold_theme_widget.dart @@ -23,7 +23,7 @@ class ScaffoldThemeWidget extends StatefulWidget { final bool isBorder; final bool isOpacity; final VoidCallback onTap; - + final int wid; const ScaffoldThemeWidget({ Key? key, required this.title, @@ -32,6 +32,7 @@ class ScaffoldThemeWidget extends StatefulWidget { this.isBorder = false, this.isOpacity = true, required this.onTap, + this.wid=162 }) : super(key: key); @override @@ -54,12 +55,13 @@ class _ScaffoldThemeWidgetState extends State { color: BaseStyle.color333333, fontWeight: FontWeight.bold), ), - titleSpacing: 162.w, + titleSpacing: widget.wid.w, leading: const CloudBackButton(isSpecial: true), backgroundColor: kForeGroundColor), backgroundColor: Colors.white, body: widget.child, - bottomNavigationBar: PloneBottom( + bottomNavigationBar: + PloneBottom( onTap: widget.onTap, border: widget.isBorder, opacity: widget.isOpacity ? 1 : 0.4, From 099b478f112fca9d75d309e742c6bf16d9e2550d Mon Sep 17 00:00:00 2001 From: wylyl22 <2373073266@qq.com> Date: Tue, 13 Sep 2022 17:14:48 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/model/exclude_pn_model.dart | 19 ++++++++++ lib/model/exclude_pn_model.g.dart | 13 +++++++ lib/ui/exclude/exclude_single_page.dart | 18 +++++---- .../home/set/func/exclude_contacts_func.dart | 14 ++++++- .../set/phone_num_list/call_records_list.dart | 38 +++++++++++-------- lib/ui/home/set/specify_phone_page.dart | 6 ++- 6 files changed, 82 insertions(+), 26 deletions(-) create mode 100644 lib/model/exclude_pn_model.dart create mode 100644 lib/model/exclude_pn_model.g.dart 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(() {});