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,14 +41,17 @@ class _AddMountScreenState extends State<AddMountScreen> {
), ),
], ],
), ),
body: Column( body: Padding(
padding: const EdgeInsets.all(_padding),
child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Row( Card(
child: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
const Text('Provider Type'), const Text('Provider Type'),
const SizedBox(width: 15.0), const SizedBox(width: _padding),
DropdownButton<String>( DropdownButton<String>(
value: _mountType, value: _mountType,
onChanged: (newValue) { onChanged: (newValue) {
@ -60,13 +70,55 @@ class _AddMountScreenState extends State<AddMountScreen> {
), ),
], ],
), ),
),
if (_mountType.isNotEmpty) const SizedBox(height: _padding),
if (_mountType.isNotEmpty)
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) if (_mount != null)
MountSettingsWidget(mount: _mount!, showAdvanced: _showAdvanced), 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) {