Create management portal in Flutter #39

This commit is contained in:
Scott E. Graves 2025-03-05 10:31:18 -06:00
parent dce856b2be
commit 8a18e7a4c9

View File

@ -30,6 +30,7 @@ class AddMountWidget extends StatefulWidget {
class _AddMountWidgetState extends State<AddMountWidget> { class _AddMountWidgetState extends State<AddMountWidget> {
static const _items = <String>['Encrypt', 'Remote', 'S3', 'Sia']; static const _items = <String>['Encrypt', 'Remote', 'S3', 'Sia'];
static const _padding = 10.0;
String? _mountType; String? _mountType;
@ -39,6 +40,21 @@ class _AddMountWidgetState extends State<AddMountWidget> {
super.initState(); super.initState();
} }
List<Widget> _createTextField(String name, onChanged) {
return [
const SizedBox(height: _padding),
Text(
name,
textAlign: TextAlign.left,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
fontWeight: FontWeight.bold,
),
),
TextField(decoration: InputDecoration(), onChanged: onChanged),
];
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final mountTypeLower = _mountType?.toLowerCase(); final mountTypeLower = _mountType?.toLowerCase();
@ -59,7 +75,7 @@ class _AddMountWidgetState extends State<AddMountWidget> {
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
const SizedBox(width: 10), const SizedBox(width: _padding),
DropdownButton<String>( DropdownButton<String>(
value: _mountType, value: _mountType,
onChanged: (value) { onChanged: (value) {
@ -78,103 +94,21 @@ class _AddMountWidgetState extends State<AddMountWidget> {
), ),
], ],
), ),
const SizedBox(height: 10), ..._createTextField('Configuration Name', widget.onNameChanged),
Text(
'Configuration Name',
textAlign: TextAlign.left,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
fontWeight: FontWeight.bold,
),
),
TextField(
autofocus: true,
decoration: InputDecoration(),
onChanged: widget.onNameChanged,
),
if (mountTypeLower == 'encrypt') if (mountTypeLower == 'encrypt')
Text( ..._createTextField('Path', widget.onPathChanged),
'Path',
textAlign: TextAlign.left,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
fontWeight: FontWeight.bold,
),
),
if (mountTypeLower == 'encrypt')
TextField(
decoration: InputDecoration(),
onChanged: widget.onPathChanged,
),
if (mountTypeLower == 'sia') if (mountTypeLower == 'sia')
Text( ..._createTextField('ApiAuth', widget.onApiAuthChanged),
'ApiAuth',
textAlign: TextAlign.left,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
fontWeight: FontWeight.bold,
),
),
if (mountTypeLower == 'sia')
TextField(
decoration: InputDecoration(),
onChanged: widget.onApiAuthChanged,
),
if (mountTypeLower == 's3' || mountTypeLower == 'sia') if (mountTypeLower == 's3' || mountTypeLower == 'sia')
Text( ..._createTextField('Bucket', widget.onBucketChanged),
'Bucket',
textAlign: TextAlign.left,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
fontWeight: FontWeight.bold,
),
),
if (mountTypeLower == 's3' || mountTypeLower == 'sia')
TextField(
decoration: InputDecoration(),
onChanged: widget.onBucketChanged,
),
if (mountTypeLower == 'remote') if (mountTypeLower == 'remote')
Text( ..._createTextField('HostNameOrIp', widget.onHostNameOrIpChanged),
'HostNameOrIp',
textAlign: TextAlign.left,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
fontWeight: FontWeight.bold,
),
),
if (mountTypeLower == 'remote') if (mountTypeLower == 'remote')
TextField( ..._createTextField('ApiPort', widget.onApiPortChanged),
decoration: InputDecoration(),
onChanged: widget.onHostNameOrIpChanged,
),
if (mountTypeLower == 'remote') if (mountTypeLower == 'remote')
Text( ..._createTextField(
'ApiPort',
textAlign: TextAlign.left,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
fontWeight: FontWeight.bold,
),
),
if (mountTypeLower == 'remote')
TextField(
decoration: InputDecoration(),
onChanged: widget.onApiPortChanged,
),
if (mountTypeLower == 'remote')
Text(
'EncryptionToken', 'EncryptionToken',
textAlign: TextAlign.left, widget.onEncryptionTokenChanged,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
fontWeight: FontWeight.bold,
),
),
if (mountTypeLower == 'remote')
TextField(
decoration: InputDecoration(),
onChanged: widget.onEncryptionTokenChanged,
), ),
], ],
); );