fixed rendering bug on linux + ip configuration
This commit is contained in:
@ -18,6 +18,7 @@ class ProjectDialog extends StatefulWidget {
|
||||
|
||||
class _ProjectDialogState extends State<ProjectDialog> {
|
||||
late TextEditingController _nameController;
|
||||
late TextEditingController _ipController;
|
||||
late TextEditingController _portController;
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@ -25,6 +26,9 @@ class _ProjectDialogState extends State<ProjectDialog> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
_nameController = TextEditingController(text: widget.project?.name ?? '');
|
||||
_ipController = TextEditingController(
|
||||
text: widget.project?.ipAddress ?? '127.0.0.1',
|
||||
);
|
||||
_portController = TextEditingController(
|
||||
text: widget.project?.port.toString() ?? '8888',
|
||||
);
|
||||
@ -33,6 +37,7 @@ class _ProjectDialogState extends State<ProjectDialog> {
|
||||
@override
|
||||
void dispose() {
|
||||
_nameController.dispose();
|
||||
_ipController.dispose();
|
||||
_portController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
@ -42,6 +47,7 @@ class _ProjectDialogState extends State<ProjectDialog> {
|
||||
final project = Project(
|
||||
id: widget.project?.id ?? DateTime.now().millisecondsSinceEpoch.toString(),
|
||||
name: _nameController.text.trim(),
|
||||
ipAddress: _ipController.text.trim(),
|
||||
port: int.parse(_portController.text),
|
||||
packages: widget.project?.packages ?? [],
|
||||
);
|
||||
@ -74,6 +80,35 @@ class _ProjectDialogState extends State<ProjectDialog> {
|
||||
autofocus: true,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _ipController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'IP Address',
|
||||
prefixIcon: Icon(Icons.computer),
|
||||
hintText: '127.0.0.1',
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || value.trim().isEmpty) {
|
||||
return 'Please enter an IP address';
|
||||
}
|
||||
// Basic IP address validation
|
||||
final ipPattern = RegExp(
|
||||
r'^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$',
|
||||
);
|
||||
if (!ipPattern.hasMatch(value.trim())) {
|
||||
return 'Please enter a valid IP address';
|
||||
}
|
||||
final parts = value.trim().split('.');
|
||||
for (final part in parts) {
|
||||
final num = int.tryParse(part);
|
||||
if (num == null || num < 0 || num > 255) {
|
||||
return 'Each octet must be between 0 and 255';
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _portController,
|
||||
decoration: const InputDecoration(
|
||||
|
||||
Reference in New Issue
Block a user