refactor
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
Scott E. Graves 2025-03-05 20:38:15 -06:00
parent 6e42899dd3
commit 847bf68f85

View File

@ -144,62 +144,60 @@ class _MyHomePageState extends State<MyHomePage> {
floatingActionButton: FloatingActionButton( floatingActionButton: FloatingActionButton(
onPressed: onPressed:
_allowAdd _allowAdd
? () { ? () async => showDialog(
showDialog( context: context,
context: context, builder: (context) {
builder: (context) { return AlertDialog(
return AlertDialog( title: const Text('Add Mount'),
title: const Text('Add Mount'), content: Consumer<MountList>(
content: Consumer<MountList>( builder: (_, MountList mountList, __) {
builder: (_, MountList mountList, __) { return AddMountWidget(
return AddMountWidget( mountType: _mountType,
mountType: _mountType, onDataChanged: _updateData,
onDataChanged: _updateData, );
); },
),
actions: [
TextButton(
child: const Text('Cancel'),
onPressed: () {
_resetData();
Navigator.of(context).pop();
}, },
), ),
actions: [ TextButton(
TextButton( child: const Text('OK'),
child: const Text('Cancel'), onPressed: () {
onPressed: () { setState(() => _allowAdd = false);
_resetData();
Navigator.of(context).pop();
},
),
TextButton(
child: const Text('OK'),
onPressed: () {
setState(() => _allowAdd = false);
Provider.of<MountList>(context, listen: false) Provider.of<MountList>(context, listen: false)
.add( .add(
_mountType, _mountType,
_mountName, _mountName,
apiPassword: _apiPassword, apiPassword: _apiPassword,
apiPort: _apiPort, apiPort: _apiPort,
bucket: _bucket, bucket: _bucket,
encryptionToken: _encryptionToken, encryptionToken: _encryptionToken,
hostNameOrIp: _hostNameOrIp, hostNameOrIp: _hostNameOrIp,
path: _path, path: _path,
) )
.then((_) { .then((_) {
_resetData(); _resetData();
setState(() { setState(() {
_allowAdd = true; _allowAdd = true;
});
})
.catchError((_) {
setState(() => _allowAdd = true);
}); });
})
.catchError((_) {
setState(() => _allowAdd = true);
});
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
), ),
], ],
); );
}, },
); )
}
: null, : null,
tooltip: 'Add Mount', tooltip: 'Add Mount',
child: const Icon(Icons.add), child: const Icon(Icons.add),