added clear mount location
This commit is contained in:
parent
9841c3f29c
commit
89507bd0bd
@ -253,4 +253,33 @@ class Mount with ChangeNotifier {
|
|||||||
debugPrint('$e');
|
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');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,19 +61,28 @@ class _MountWidgetState extends State<MountWidget> {
|
|||||||
mount.provider,
|
mount.provider,
|
||||||
style: TextStyle(color: textColor, fontWeight: FontWeight.bold),
|
style: TextStyle(color: textColor, fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
trailing: IconButton(
|
trailing: Row(
|
||||||
icon: Icon(
|
children: [
|
||||||
mount.mounted == null
|
if (mount.mounted != null && !mount.mounted!)
|
||||||
? Icons.hourglass_top
|
IconButton(
|
||||||
: mount.mounted!
|
icon: Icon(Icons.clear),
|
||||||
? Icons.toggle_on
|
onPressed: () => mount.clearPath(),
|
||||||
: Icons.toggle_off,
|
),
|
||||||
color:
|
IconButton(
|
||||||
mount.mounted ?? false
|
icon: Icon(
|
||||||
? Color.fromARGB(255, 163, 96, 76)
|
mount.mounted == null
|
||||||
: subTextColor,
|
? Icons.hourglass_top
|
||||||
),
|
: mount.mounted!
|
||||||
onPressed: _createMountHandler(context, mount),
|
? Icons.toggle_on
|
||||||
|
: Icons.toggle_off,
|
||||||
|
color:
|
||||||
|
mount.mounted ?? false
|
||||||
|
? Color.fromARGB(255, 163, 96, 76)
|
||||||
|
: subTextColor,
|
||||||
|
),
|
||||||
|
onPressed: _createMountHandler(context, mount),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user