diff --git a/lib/ui/exclude/exclude_contacts_page.dart b/lib/ui/exclude/exclude_contacts_page.dart index 888f436..aae3f23 100644 --- a/lib/ui/exclude/exclude_contacts_page.dart +++ b/lib/ui/exclude/exclude_contacts_page.dart @@ -5,6 +5,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:project_telephony/ui/widget/scaffold_theme_widget.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:velocity_x/velocity_x.dart'; import '../../constants/api.dart'; import '../../model/exclude_phone_model.dart'; @@ -36,7 +37,11 @@ class _ExcludeContactsPageState extends State { contacts = await FlutterContacts.getContacts(); for (var element in contacts!) { final full = await FlutterContacts.getContact(element.id); - numbers.add(full!.phones.first.number); + if(full?.phones.length==0){ + numbers.add('无'); + }else{ + numbers.add(full!.phones.first.number); + } status.add(false); } // await prefs.setStringList("addressList", numbers); @@ -107,6 +112,7 @@ class _ExcludeContactsPageState extends State { BaseModel res = await apiClient .request(API.exclude.add, data: {'exclude': excludeList}); if (res.code == 0) { + BotToast.showText(text: res.msg); Get.back(); } } else { diff --git a/lib/ui/exclude/exclude_single_page.dart b/lib/ui/exclude/exclude_single_page.dart index f0cfa5d..20bbcd2 100644 --- a/lib/ui/exclude/exclude_single_page.dart +++ b/lib/ui/exclude/exclude_single_page.dart @@ -1,9 +1,17 @@ +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; +import 'package:get/get_core/src/get_main.dart'; import 'package:project_telephony/ui/widget/scaffold_theme_widget.dart'; import 'package:velocity_x/velocity_x.dart'; +import '../../constants/api.dart'; +import '../../model/exclude_phone_model.dart'; +import '../../model/network/api_client.dart'; +import '../../model/network/base_model.dart'; + class ExcludeSinglePage extends StatefulWidget { const ExcludeSinglePage({Key? key}) : super(key: key); @@ -35,13 +43,27 @@ class _ExcludeSinglePageState extends State { wid: 110, title: '添加单个或批量号码', bottom: "添加", - onTap: () { - - - + onTap: () async { + if (_phoneController.text.isEmpty) { + BotToast.showText(text: "未输入手机号"); + } else { + BaseModel res = await apiClient.request( + API.exclude.add, + data: { + 'exclude': [Exclude( + phone: _phoneController.text, + remark: _nameController.text, + )], + }, + ); + BotToast.showText(text: res.msg); + if (res.code == 0) { + Get.back(); + } + } }, isOpacity: - _phoneController.text.isNotEmpty && _nameController.text.isNotEmpty, + _phoneController.text.isNotEmpty || _nameController.text.isNotEmpty, child: Container( padding: EdgeInsets.only(top: 25.h, left: 50.w, right: 50.w), child: Column( @@ -62,7 +84,6 @@ class _ExcludeSinglePageState extends State { color: Colors.black38, ), ), - TextSpan( text: "如输入000*,可屏蔽所有000开头的号码", style: TextStyle( @@ -84,7 +105,7 @@ class _ExcludeSinglePageState extends State { children: [ Text( title, - style: TextStyle( + style: TextStyle( fontSize: 28.sp, color: const Color(0xFF999999), fontWeight: FontWeight.w500, @@ -99,7 +120,7 @@ class _ExcludeSinglePageState extends State { decoration: InputDecoration( contentPadding: EdgeInsets.all(30.w), hintText: content, - hintStyle: TextStyle( + hintStyle: TextStyle( fontSize: 28.sp, // fontWeight: FontWeight.w600, color: const Color(0xFF999999),