255 lines
10 KiB
Dart
255 lines
10 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
|
|
class AddNoteDialog extends StatefulWidget {
|
|
Function onTap;
|
|
|
|
AddNoteDialog({
|
|
super.key,
|
|
required this.onTap,
|
|
});
|
|
|
|
@override
|
|
State<AddNoteDialog> createState() => _AddNoteDialogState();
|
|
}
|
|
|
|
class _AddNoteDialogState extends State<AddNoteDialog> {
|
|
final TextEditingController _businessNameController = TextEditingController();
|
|
|
|
final TextEditingController _portNumber1Controller = TextEditingController();
|
|
final TextEditingController _portNumber2Controller = TextEditingController();
|
|
final TextEditingController _portNumber3Controller = TextEditingController();
|
|
|
|
@override
|
|
void initState() {
|
|
// TODO: implement initState
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
// TODO: implement dispose
|
|
_businessNameController.dispose();
|
|
_portNumber1Controller.dispose();
|
|
_portNumber2Controller.dispose();
|
|
_portNumber3Controller.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
submitInfo() {
|
|
if (_businessNameController.text == "") {
|
|
EasyLoading.showToast("请输入业务名称");
|
|
return;
|
|
}
|
|
|
|
if (_portNumber1Controller.text == "" || _portNumber2Controller.text == "" || _portNumber3Controller.text == "") {
|
|
EasyLoading.showToast("请输入端口号");
|
|
return;
|
|
}
|
|
|
|
widget.onTap(_businessNameController.text, "${_portNumber1Controller.text}/${_portNumber2Controller.text}/${_portNumber3Controller.text}");
|
|
|
|
Navigator.pop(context);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final bottomInset = MediaQuery.of(context).viewInsets.bottom;
|
|
return Material(
|
|
type: MaterialType.transparency, //透明类型
|
|
color: const Color(0x1A000000),
|
|
child: Center(
|
|
child: ClipRRect(
|
|
borderRadius: BorderRadius.circular(10),
|
|
child: Container(
|
|
width: 307,
|
|
color: Colors.white,
|
|
padding: EdgeInsets.only(left: 5, right: 5, top: 5, bottom: bottomInset),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Container(
|
|
child: Text(
|
|
"添加备注",
|
|
style: TextStyle(fontWeight: FontWeight.w600),
|
|
),
|
|
),
|
|
|
|
///
|
|
Container(
|
|
alignment: Alignment.centerLeft,
|
|
margin: EdgeInsets.all(10),
|
|
child: Text(
|
|
"业务名称",
|
|
style: TextStyle(fontSize: 12),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(left: 10, right: 10),
|
|
padding: EdgeInsets.symmetric(horizontal: 5),
|
|
height: 35,
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(color: Color(0xFFEBEBEB), borderRadius: BorderRadius.all(Radius.circular(7))),
|
|
child: TextField(
|
|
cursorColor: Color(0xFF1A73EC),
|
|
controller: _businessNameController,
|
|
decoration: InputDecoration(
|
|
isDense: true,
|
|
contentPadding: EdgeInsets.zero,
|
|
hintText: '请输入业务名称',
|
|
border: InputBorder.none,
|
|
enabledBorder: InputBorder.none,
|
|
focusedBorder: InputBorder.none,
|
|
hintStyle: TextStyle(color: Color(0xFF999999), fontSize: 12),
|
|
),
|
|
style: TextStyle(fontSize: 12),
|
|
),
|
|
),
|
|
|
|
///端口号数
|
|
Container(
|
|
alignment: Alignment.centerLeft,
|
|
margin: EdgeInsets.all(10),
|
|
child: Text(
|
|
"端口号数",
|
|
style: TextStyle(fontSize: 12),
|
|
),
|
|
),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
flex: 1,
|
|
child: Container(
|
|
margin: EdgeInsets.only(left: 10, right: 10),
|
|
padding: EdgeInsets.symmetric(horizontal: 5),
|
|
height: 35,
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(color: Color(0xFFEBEBEB), borderRadius: BorderRadius.all(Radius.circular(5))),
|
|
child: TextField(
|
|
cursorColor: Color(0xFF1A73EC),
|
|
controller: _portNumber1Controller,
|
|
keyboardType: TextInputType.number,
|
|
decoration: const InputDecoration(
|
|
isDense: true,
|
|
contentPadding: EdgeInsets.zero,
|
|
hintText: '1号端口数',
|
|
border: InputBorder.none,
|
|
enabledBorder: InputBorder.none,
|
|
focusedBorder: InputBorder.none,
|
|
hintStyle: TextStyle(color: Color(0xFF999999), fontSize: 12),
|
|
),
|
|
style: TextStyle(fontSize: 12),
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
flex: 1,
|
|
child: Container(
|
|
margin: const EdgeInsets.only(left: 10, right: 10),
|
|
padding: const EdgeInsets.symmetric(horizontal: 5),
|
|
height: 35,
|
|
alignment: Alignment.center,
|
|
decoration: const BoxDecoration(color: Color(0xFFEBEBEB), borderRadius: BorderRadius.all(Radius.circular(5))),
|
|
child: TextField(
|
|
cursorColor: const Color(0xFF1A73EC),
|
|
controller: _portNumber2Controller,
|
|
keyboardType: TextInputType.number,
|
|
decoration: const InputDecoration(
|
|
isDense: true,
|
|
contentPadding: EdgeInsets.zero,
|
|
hintText: '2号端口数',
|
|
border: InputBorder.none,
|
|
enabledBorder: InputBorder.none,
|
|
focusedBorder: InputBorder.none,
|
|
hintStyle: TextStyle(color: Color(0xFF999999), fontSize: 12),
|
|
),
|
|
style: TextStyle(fontSize: 12),
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
flex: 1,
|
|
child: Container(
|
|
margin: const EdgeInsets.only(left: 10, right: 10),
|
|
padding: const EdgeInsets.symmetric(horizontal: 5),
|
|
height: 35,
|
|
alignment: Alignment.center,
|
|
decoration: const BoxDecoration(color: Color(0xFFEBEBEB), borderRadius: BorderRadius.all(Radius.circular(5))),
|
|
child: TextField(
|
|
cursorColor: const Color(0xFF1A73EC),
|
|
controller: _portNumber3Controller,
|
|
keyboardType: TextInputType.number,
|
|
decoration: const InputDecoration(
|
|
isDense: true,
|
|
contentPadding: EdgeInsets.zero,
|
|
hintText: '3号端口数',
|
|
border: InputBorder.none,
|
|
enabledBorder: InputBorder.none,
|
|
focusedBorder: InputBorder.none,
|
|
hintStyle: TextStyle(color: Color(0xFF999999), fontSize: 12),
|
|
),
|
|
style: TextStyle(fontSize: 12),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
|
|
Container(
|
|
margin: EdgeInsets.symmetric(vertical: 10),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
flex: 1,
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
Navigator.pop(context);
|
|
},
|
|
child: Container(
|
|
height: 32,
|
|
alignment: Alignment.center,
|
|
margin: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
|
|
decoration: BoxDecoration(
|
|
color: Colors.grey,
|
|
borderRadius: BorderRadius.all(Radius.circular(6)),
|
|
),
|
|
child: Text(
|
|
"取消",
|
|
style: TextStyle(fontSize: 14, color: Colors.white),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
flex: 2,
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
submitInfo();
|
|
},
|
|
child: Container(
|
|
height: 32,
|
|
alignment: Alignment.center,
|
|
margin: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFF1A73EC),
|
|
borderRadius: BorderRadius.all(Radius.circular(6)),
|
|
),
|
|
child: Text(
|
|
"提交",
|
|
style: TextStyle(fontSize: 14, color: Colors.white),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|