diff --git a/web/repertory/lib/screens/add_mount_screen.dart b/web/repertory/lib/screens/add_mount_screen.dart index f1025aa1..b9d19980 100644 --- a/web/repertory/lib/screens/add_mount_screen.dart +++ b/web/repertory/lib/screens/add_mount_screen.dart @@ -181,7 +181,7 @@ class _AddMountScreenState extends State { Navigator.pop(context); }, label: const Text('Add'), - icon: Icon(Icons.add), + icon: const Icon(Icons.add), ); }, ), diff --git a/web/repertory/lib/widgets/mount_settings.dart b/web/repertory/lib/widgets/mount_settings.dart index 8c8c9820..3d085f23 100644 --- a/web/repertory/lib/widgets/mount_settings.dart +++ b/web/repertory/lib/widgets/mount_settings.dart @@ -30,7 +30,7 @@ class _MountSettingsWidgetState extends State { if (!isAdvanced || widget.showAdvanced) { list.add( SettingsTile.switchTile( - leading: Icon(Icons.quiz), + leading: const Icon(Icons.quiz), title: Text(key), initialValue: (value as bool), onPressed: @@ -60,7 +60,7 @@ class _MountSettingsWidgetState extends State { if (!isAdvanced || widget.showAdvanced) { list.add( SettingsTile.navigation( - leading: Icon(Icons.onetwothree), + leading: const Icon(Icons.onetwothree), title: Text(key), value: Text(value.toString()), onPressed: (_) { @@ -71,11 +71,11 @@ class _MountSettingsWidgetState extends State { return AlertDialog( actions: [ TextButton( - child: Text('Cancel'), + child: const Text('Cancel'), onPressed: () => Navigator.of(context).pop(), ), TextButton( - child: Text('OK'), + child: const Text('OK'), onPressed: () { final result = validators.firstWhereOrNull( (validator) => !validator(updatedValue), @@ -197,7 +197,7 @@ class _MountSettingsWidgetState extends State { if (!isAdvanced || widget.showAdvanced) { list.add( SettingsTile.navigation( - leading: Icon(Icons.password), + leading: const Icon(Icons.password), title: Text(key), value: Text('*' * (value as String).length), onPressed: (_) { @@ -209,11 +209,11 @@ class _MountSettingsWidgetState extends State { return AlertDialog( actions: [ TextButton( - child: Text('Cancel'), + child: const Text('Cancel'), onPressed: () => Navigator.of(context).pop(), ), TextButton( - child: Text('OK'), + child: const Text('OK'), onPressed: () { if (updatedValue1 != updatedValue2) { ScaffoldMessenger.of(context).showSnackBar( @@ -305,11 +305,11 @@ class _MountSettingsWidgetState extends State { return AlertDialog( actions: [ TextButton( - child: Text('Cancel'), + child: const Text('Cancel'), onPressed: () => Navigator.of(context).pop(), ), TextButton( - child: Text('OK'), + child: const Text('OK'), onPressed: () { final result = validators.firstWhereOrNull( (validator) => !validator(updatedValue), diff --git a/web/repertory/lib/widgets/mount_widget.dart b/web/repertory/lib/widgets/mount_widget.dart index 44c28200..ae1735b9 100644 --- a/web/repertory/lib/widgets/mount_widget.dart +++ b/web/repertory/lib/widgets/mount_widget.dart @@ -1,6 +1,8 @@ import 'dart:async'; +import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; import 'package:repertory/helpers.dart'; import 'package:repertory/models/mount.dart'; @@ -71,7 +73,82 @@ class _MountWidgetState extends State { String? location = mount.path; if (!isActive && mount.path.isEmpty) { location = await mount.getMountLocation(); - if (location == null) {} + if (location == null) { + String? updatedValue; + if (context.mounted) { + location = await showDialog( + context: context, + builder: (context) { + return AlertDialog( + actions: [ + TextButton( + child: const Text('Cancel'), + onPressed: + () => + Navigator.of(context).pop(null), + ), + TextButton( + child: const Text('OK'), + onPressed: () { + final result = getSettingValidators( + 'Path', + ).firstWhereOrNull( + (validator) => + !validator(updatedValue ?? ''), + ); + if (result != null) { + ScaffoldMessenger.of( + context, + ).showSnackBar( + SnackBar( + content: const Text( + "mount location is not valid", + textAlign: TextAlign.center, + ), + ), + ); + return; + } + Navigator.of( + context, + ).pop(updatedValue); + }, + ), + ], + content: TextField( + autofocus: true, + controller: TextEditingController( + text: updatedValue, + ), + inputFormatters: [ + FilteringTextInputFormatter.deny( + RegExp(r'\s'), + ), + ], + onChanged: null, + ), + title: const Text('Set Mount Location'), + ); + }, + ); + } + } + } + + if (location == null) { + if (!context.mounted) { + return; + } + + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: const Text( + "mount location is not set", + textAlign: TextAlign.center, + ), + ), + ); + return; } mount