diff --git a/web/repertory/lib/widgets/mount_widget.dart b/web/repertory/lib/widgets/mount_widget.dart index 452397c6..dfa3e052 100644 --- a/web/repertory/lib/widgets/mount_widget.dart +++ b/web/repertory/lib/widgets/mount_widget.dart @@ -27,10 +27,9 @@ class _MountWidgetState extends State { child: Consumer( builder: (context, Mount mount, _) { final textColor = Theme.of(context).colorScheme.onSurface; - final subTextColor = - Theme.of(context).brightness == Brightness.dark - ? Colors.white38 - : Colors.black87; + final subTextColor = Theme.of(context).brightness == Brightness.dark + ? Colors.white38 + : Colors.black87; final nameText = SelectableText( formatMountName(mount.type, mount.name), @@ -41,8 +40,8 @@ class _MountWidgetState extends State { isThreeLine: true, leading: IconButton( icon: Icon(Icons.settings, color: textColor), - onPressed: - () => Navigator.pushNamed(context, '/edit', arguments: mount), + onPressed: () => + Navigator.pushNamed(context, '/edit', arguments: mount), ), subtitle: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -95,17 +94,15 @@ class _MountWidgetState extends State { : mount.mounted! ? Icons.toggle_on : Icons.toggle_off, - color: - mount.mounted ?? false - ? Color.fromARGB(255, 163, 96, 76) - : subTextColor, + color: mount.mounted ?? false + ? Theme.of(context).colorScheme.primary + : subTextColor, ), - tooltip: - mount.mounted == null - ? '' - : mount.mounted! - ? 'Unmount' - : 'Mount', + tooltip: mount.mounted == null + ? '' + : mount.mounted! + ? 'Unmount' + : 'Mount', onPressed: _createMountHandler(context, mount), ), ], @@ -119,43 +116,43 @@ class _MountWidgetState extends State { VoidCallback? _createMountHandler(context, Mount mount) { return _enabled && mount.mounted != null ? () async { - if (mount.mounted == null) { - return; - } + if (mount.mounted == null) { + return; + } - final mounted = mount.mounted!; + final mounted = mount.mounted!; - setState(() { - _enabled = false; - }); - - final location = await _getMountLocation(context, mount); - - cleanup() { setState(() { - _enabled = true; + _enabled = false; }); - } - if (!mounted && location == null) { - displayErrorMessage(context, "Mount location is not set"); - return cleanup(); - } + final location = await _getMountLocation(context, mount); - final success = await mount.mount(mounted, location: location); - if (success || - mounted || - constants.navigatorKey.currentContext == null || - !constants.navigatorKey.currentContext!.mounted) { - return cleanup(); - } + cleanup() { + setState(() { + _enabled = true; + }); + } - displayErrorMessage( - context, - "Mount location is not available: $location", - ); - cleanup(); - } + if (!mounted && location == null) { + displayErrorMessage(context, "Mount location is not set"); + return cleanup(); + } + + final success = await mount.mount(mounted, location: location); + if (success || + mounted || + constants.navigatorKey.currentContext == null || + !constants.navigatorKey.currentContext!.mounted) { + return cleanup(); + } + + displayErrorMessage( + context, + "Mount location is not available: $location", + ); + cleanup(); + } : null; }