Create management portal in Flutter #39

This commit is contained in:
Scott E. Graves 2025-03-06 08:44:17 -06:00
parent 0318489b6c
commit 02157d21ea

View File

@ -1,6 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:repertory/constants.dart'; import 'package:repertory/constants.dart';
import 'package:repertory/models/mount.dart'; import 'package:repertory/models/mount.dart';
import 'package:repertory/types/mount_config.dart';
import 'package:repertory/widgets/mount_settings.dart'; import 'package:repertory/widgets/mount_settings.dart';
class AddMountScreen extends StatefulWidget { class AddMountScreen extends StatefulWidget {
@ -12,7 +14,12 @@ class AddMountScreen extends StatefulWidget {
} }
class _AddMountScreenState extends State<AddMountScreen> { class _AddMountScreenState extends State<AddMountScreen> {
static const _padding = 15.0;
late TextEditingController _mountNameController;
Mount? _mount; Mount? _mount;
String _mountName = "";
String _mountType = ""; String _mountType = "";
bool _showAdvanced = false; bool _showAdvanced = false;
@ -34,39 +41,84 @@ class _AddMountScreenState extends State<AddMountScreen> {
), ),
], ],
), ),
body: Column( body: Padding(
mainAxisSize: MainAxisSize.min, padding: const EdgeInsets.all(_padding),
children: [ child: Column(
Row( mainAxisSize: MainAxisSize.min,
mainAxisSize: MainAxisSize.min, children: [
children: [ Card(
const Text('Provider Type'), child: Row(
const SizedBox(width: 15.0), mainAxisSize: MainAxisSize.min,
DropdownButton<String>( children: [
value: _mountType, const Text('Provider Type'),
onChanged: (newValue) { const SizedBox(width: _padding),
setState(() { DropdownButton<String>(
_mountType = newValue ?? ""; value: _mountType,
if (_mountType.isNotEmpty) {} onChanged: (newValue) {
}); setState(() {
}, _mountType = newValue ?? "";
items: if (_mountType.isNotEmpty) {}
providerTypeList.map<DropdownMenuItem<String>>((item) { });
return DropdownMenuItem<String>( },
value: item, items:
child: Text(item), providerTypeList.map<DropdownMenuItem<String>>((item) {
); return DropdownMenuItem<String>(
}).toList(), value: item,
child: Text(item),
);
}).toList(),
),
],
), ),
], ),
), if (_mountType.isNotEmpty) const SizedBox(height: _padding),
if (_mount != null) if (_mountType.isNotEmpty)
MountSettingsWidget(mount: _mount!, showAdvanced: _showAdvanced), Card(
], child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Text('Configuration Name'),
const SizedBox(width: _padding),
TextField(
autofocus: true,
controller: _mountNameController,
keyboardType: TextInputType.number,
onChanged: (value) {
if (_mountName == value) {
return;
}
setState(() {
_mountName = value;
_mount =
(_mountName.isEmpty)
? null
: Mount(
MountConfig(
name: _mountName,
type: _mountType,
),
);
});
},
),
],
),
),
if (_mount != null)
MountSettingsWidget(mount: _mount!, showAdvanced: _showAdvanced),
],
),
), ),
); );
} }
@override
void initState() {
_mountNameController = TextEditingController(text: _mountName);
super.initState();
}
@override @override
void setState(VoidCallback fn) { void setState(VoidCallback fn) {
if (!mounted) { if (!mounted) {