添加单个

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:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:project_telephony/ui/widget/scaffold_theme_widget.dart'; import 'package:project_telephony/ui/widget/scaffold_theme_widget.dart';
import 'package:velocity_x/velocity_x.dart';
import '../../constants/api.dart'; import '../../constants/api.dart';
import '../../model/exclude_phone_model.dart'; import '../../model/exclude_phone_model.dart';
@ -26,14 +27,17 @@ class _ExcludeContactsPageState extends State<ExcludeContactsPage> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_viewLoading();
} }
Future _viewLoading() async { Future _viewLoading() async {
contacts = await FlutterContacts.getContacts(); contacts = await FlutterContacts.getContacts();
for (var element in contacts!) { for (var element in contacts!) {
final full = await FlutterContacts.getContact(element.id); final full = await FlutterContacts.getContact(element.id);
if(full?.phones.length==0){
numbers.add('');
}else{
numbers.add(full!.phones.first.number); numbers.add(full!.phones.first.number);
}
status.add(false); status.add(false);
} }
setState(() {}); setState(() {});
@ -99,6 +103,7 @@ class _ExcludeContactsPageState extends State<ExcludeContactsPage> {
BaseModel res = await apiClient BaseModel res = await apiClient
.request(API.exclude.add, data: {'exclude': excludeList}); .request(API.exclude.add, data: {'exclude': excludeList});
if (res.code == 0) { if (res.code == 0) {
BotToast.showText(text: res.msg);
Get.back(); Get.back();
} }
} else { } else {

@ -1,9 +1,17 @@
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.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:project_telephony/ui/widget/scaffold_theme_widget.dart';
import 'package:velocity_x/velocity_x.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 { class ExcludeSinglePage extends StatefulWidget {
const ExcludeSinglePage({Key? key}) : super(key: key); const ExcludeSinglePage({Key? key}) : super(key: key);
@ -35,9 +43,27 @@ class _ExcludeSinglePageState extends State<ExcludeSinglePage> {
wid: 110, wid: 110,
title: '添加单个或批量号码', title: '添加单个或批量号码',
bottom: "添加", 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: isOpacity:
_phoneController.text.isNotEmpty && _nameController.text.isNotEmpty, _phoneController.text.isNotEmpty || _nameController.text.isNotEmpty,
child: Container( child: Container(
padding: EdgeInsets.only(top: 25.h, left: 50.w, right: 50.w), padding: EdgeInsets.only(top: 25.h, left: 50.w, right: 50.w),
child: Column( child: Column(
@ -58,7 +84,6 @@ class _ExcludeSinglePageState extends State<ExcludeSinglePage> {
color: Colors.black38, color: Colors.black38,
), ),
), ),
TextSpan( TextSpan(
text: "如输入000*可屏蔽所有000开头的号码", text: "如输入000*可屏蔽所有000开头的号码",
style: TextStyle( style: TextStyle(

Loading…
Cancel
Save