You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

156 lines
4.7 KiB

2 years ago
import 'package:bot_toast/bot_toast.dart';
2 years ago
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
2 years ago
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
2 years ago
import 'package:project_telephony/ui/widget/scaffold_theme_widget.dart';
import 'package:velocity_x/velocity_x.dart';
2 years ago
import '../../constants/api.dart';
import '../../model/exclude_phone_model.dart';
import '../../model/network/api_client.dart';
import '../../model/network/base_model.dart';
2 years ago
class ExcludeSinglePage extends StatefulWidget {
const ExcludeSinglePage({Key? key}) : super(key: key);
@override
_ExcludeSinglePageState createState() => _ExcludeSinglePageState();
}
class _ExcludeSinglePageState extends State<ExcludeSinglePage> {
late TextEditingController _phoneController;
late TextEditingController _nameController;
@override
void initState() {
super.initState();
_phoneController = TextEditingController();
_nameController = TextEditingController();
}
@override
void dispose() {
super.dispose();
_phoneController.dispose();
_nameController.dispose();
}
2 years ago
@override
Widget build(BuildContext context) {
return ScaffoldThemeWidget(
2 years ago
wid: 110,
2 years ago
title: '添加单个或批量号码',
bottom: "添加",
2 years ago
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();
Get.back();
2 years ago
}
}
},
isOpacity:
2 years ago
_phoneController.text.isNotEmpty || _nameController.text.isNotEmpty,
2 years ago
child: Container(
padding: EdgeInsets.only(top: 25.h, left: 50.w, right: 50.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
addNumber("号码", "请输入号码", _phoneController),
2 years ago
15.heightBox,
addNumber("名称", "请输入名称", _nameController),
30.heightBox,
// RichText(
// text: const TextSpan(
// children: [
// TextSpan(
// text: "使用说明:\n",
// style: TextStyle(
// fontWeight: FontWeight.w600,
// color: Colors.black38,
// ),
// ),
// TextSpan(
// text: "如输入000*可屏蔽所有000开头的号码",
// style: TextStyle(
// color: Colors.black38,
// ),
// ),
// ],
// ),
// ),
2 years ago
],
),
),
);
}
addNumber(String title, content, TextEditingController controller) {
2 years ago
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
2 years ago
style: TextStyle(
2 years ago
fontSize: 28.sp,
color: const Color(0xFF999999),
fontWeight: FontWeight.w500,
2 years ago
),
),
15.heightBox,
TextField(
controller: controller,
onChanged: (value) {
setState(() {});
},
2 years ago
decoration: InputDecoration(
contentPadding: EdgeInsets.all(30.w),
2 years ago
hintText: content,
2 years ago
hintStyle: TextStyle(
2 years ago
fontSize: 28.sp,
// fontWeight: FontWeight.w600,
color: const Color(0xFF999999),
),
fillColor: const Color(0xFFF9F9F9),
filled: true,
enabledBorder: const OutlineInputBorder(
/*边角*/
borderRadius: BorderRadius.all(
Radius.circular(5), //边角为5
),
borderSide: BorderSide(
color: Colors.white, //边线颜色为白色
width: 1, //边线宽度为2
),
),
focusedBorder: const OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white, //边框颜色为白色
width: 1, //宽度为5
),
borderRadius: BorderRadius.all(
Radius.circular(5), //边角为30
),
2 years ago
),
),
),
],
);
}
}