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

This commit is contained in:
Scott E. Graves 2025-03-14 20:38:21 -05:00
parent 79262ef862
commit 7dd56cf715
3 changed files with 88 additions and 11 deletions

View File

@ -181,7 +181,7 @@ class _AddMountScreenState extends State<AddMountScreen> {
Navigator.pop(context);
},
label: const Text('Add'),
icon: Icon(Icons.add),
icon: const Icon(Icons.add),
);
},
),

View File

@ -30,7 +30,7 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
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<MountSettingsWidget> {
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<MountSettingsWidget> {
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<MountSettingsWidget> {
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<MountSettingsWidget> {
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<MountSettingsWidget> {
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),

View File

@ -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<MountWidget> {
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