added clear mount location

This commit is contained in:
Scott E. Graves 2025-03-24 12:57:47 -05:00
parent 9841c3f29c
commit 89507bd0bd
2 changed files with 51 additions and 13 deletions

View File

@ -253,4 +253,33 @@ class Mount with ChangeNotifier {
debugPrint('$e');
}
}
Future<void> clearPath() async {
try {
mountConfig.path = "";
final auth = await _auth.createAuth();
final response = await http.delete(
Uri.parse(
Uri.encodeFull(
'${getBaseUri()}/api/v1/mount_location?auth=$auth&name=$name&type=$type',
),
),
);
if (response.statusCode == 401) {
_auth.logoff();
return;
}
if (response.statusCode == 404) {
_mountList?.reset();
return;
}
return refresh();
} catch (e) {
debugPrint('$e');
}
}
}

View File

@ -61,19 +61,28 @@ class _MountWidgetState extends State<MountWidget> {
mount.provider,
style: TextStyle(color: textColor, fontWeight: FontWeight.bold),
),
trailing: IconButton(
icon: Icon(
mount.mounted == null
? Icons.hourglass_top
: mount.mounted!
? Icons.toggle_on
: Icons.toggle_off,
color:
mount.mounted ?? false
? Color.fromARGB(255, 163, 96, 76)
: subTextColor,
),
onPressed: _createMountHandler(context, mount),
trailing: Row(
children: [
if (mount.mounted != null && !mount.mounted!)
IconButton(
icon: Icon(Icons.clear),
onPressed: () => mount.clearPath(),
),
IconButton(
icon: Icon(
mount.mounted == null
? Icons.hourglass_top
: mount.mounted!
? Icons.toggle_on
: Icons.toggle_off,
color:
mount.mounted ?? false
? Color.fromARGB(255, 163, 96, 76)
: subTextColor,
),
onPressed: _createMountHandler(context, mount),
),
],
),
);
},