添加单个

master
戴余标 2 years ago
parent 1e43a0090a
commit bab79194f1

@ -4,6 +4,7 @@ import 'package:flutter_contacts/flutter_contacts.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.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';
@ -26,14 +27,17 @@ class _ExcludeContactsPageState extends State<ExcludeContactsPage> {
@override
void initState() {
super.initState();
_viewLoading();
}
Future _viewLoading() async {
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);
}
setState(() {});
@ -99,6 +103,7 @@ class _ExcludeContactsPageState extends State<ExcludeContactsPage> {
BaseModel res = await apiClient
.request(API.exclude.add, data: {'exclude': excludeList});
if (res.code == 0) {
BotToast.showText(text: res.msg);
Get.back();
}
} else {

@ -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,9 +43,27 @@ class _ExcludeSinglePageState extends State<ExcludeSinglePage> {
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(
@ -58,7 +84,6 @@ class _ExcludeSinglePageState extends State<ExcludeSinglePage> {
color: Colors.black38,
),
),
TextSpan(
text: "如输入000*可屏蔽所有000开头的号码",
style: TextStyle(
@ -80,7 +105,7 @@ class _ExcludeSinglePageState extends State<ExcludeSinglePage> {
children: [
Text(
title,
style: TextStyle(
style: TextStyle(
fontSize: 28.sp,
color: const Color(0xFF999999),
fontWeight: FontWeight.w500,
@ -95,7 +120,7 @@ class _ExcludeSinglePageState extends State<ExcludeSinglePage> {
decoration: InputDecoration(
contentPadding: EdgeInsets.all(30.w),
hintText: content,
hintStyle: TextStyle(
hintStyle: TextStyle(
fontSize: 28.sp,
// fontWeight: FontWeight.w600,
color: const Color(0xFF999999),

Loading…
Cancel
Save