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.

155 lines
4.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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);
@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();
}
@override
Widget build(BuildContext context) {
return ScaffoldThemeWidget(
wid: 110,
title: '添加单个或批量号码',
bottom: "添加",
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,
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),
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,
),
),
],
),
),
],
),
),
);
}
addNumber(String title, content, TextEditingController controller) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: TextStyle(
fontSize: 28.sp,
color: const Color(0xFF999999),
fontWeight: FontWeight.w500,
),
),
15.heightBox,
TextField(
controller: controller,
onChanged: (value) {
setState(() {});
},
decoration: InputDecoration(
contentPadding: EdgeInsets.all(30.w),
hintText: content,
hintStyle: TextStyle(
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
),
),
),
),
],
);
}
}