Compare commits
No commits in common. "cd9ad1e32221aa2e455c28fd4f873bf56ce0b319" and "2ff72eebcefbe00e610c5a29c2f46362a4a52523" have entirely different histories.
cd9ad1e322
...
2ff72eebce
@ -1,6 +1,5 @@
|
|||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:repertory/constants.dart' as constants;
|
import 'package:repertory/constants.dart' as constants;
|
||||||
|
|
||||||
typedef Validator = bool Function(String);
|
typedef Validator = bool Function(String);
|
||||||
@ -96,16 +95,6 @@ Map<String, dynamic> createDefaultSettings(String mountType) {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void displayErrorMessage(context, text) {
|
|
||||||
if (!context.mounted) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ScaffoldMessenger.of(
|
|
||||||
context,
|
|
||||||
).showSnackBar(SnackBar(content: Text(text, textAlign: TextAlign.center)));
|
|
||||||
}
|
|
||||||
|
|
||||||
String formatMountName(String type, String name) {
|
String formatMountName(String type, String name) {
|
||||||
if (type == 'remote') {
|
if (type == 'remote') {
|
||||||
return name.replaceAll('_', ':');
|
return name.replaceAll('_', ':');
|
||||||
|
@ -115,11 +115,6 @@ class MountList with ChangeNotifier {
|
|||||||
await constants.navigatorKey.currentState?.pushReplacementNamed('/');
|
await constants.navigatorKey.currentState?.pushReplacementNamed('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
displayErrorMessage(
|
|
||||||
constants.navigatorKey.currentContext!,
|
|
||||||
'Mount removed externally. Reloading...',
|
|
||||||
);
|
|
||||||
|
|
||||||
_mountList = [];
|
_mountList = [];
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
||||||
|
@ -137,19 +137,28 @@ class _AddMountScreenState extends State<AddMountScreen> {
|
|||||||
List<String> failed = [];
|
List<String> failed = [];
|
||||||
if (!validateSettings(_settings[_mountType]!, failed)) {
|
if (!validateSettings(_settings[_mountType]!, failed)) {
|
||||||
for (var key in failed) {
|
for (var key in failed) {
|
||||||
displayErrorMessage(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
context,
|
SnackBar(
|
||||||
"Setting '$key' is not valid",
|
content: Text(
|
||||||
|
"Setting '$key' is not valid",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mountList.hasConfigName(_mountNameController.text)) {
|
if (mountList.hasConfigName(_mountNameController.text)) {
|
||||||
return displayErrorMessage(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
context,
|
SnackBar(
|
||||||
"Configuration name '${_mountNameController.text}' already exists",
|
content: Text(
|
||||||
|
"Configuration name '${_mountNameController.text}' already exists",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_mountType == "Sia" || _mountType == "S3") {
|
if (_mountType == "Sia" || _mountType == "S3") {
|
||||||
@ -157,10 +166,15 @@ class _AddMountScreenState extends State<AddMountScreen> {
|
|||||||
_settings[_mountType]!["${_mountType}Config"]["Bucket"]
|
_settings[_mountType]!["${_mountType}Config"]["Bucket"]
|
||||||
as String;
|
as String;
|
||||||
if (mountList.hasBucketName(_mountType, bucket)) {
|
if (mountList.hasBucketName(_mountType, bucket)) {
|
||||||
return displayErrorMessage(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
context,
|
SnackBar(
|
||||||
"Bucket '$bucket' already exists",
|
content: Text(
|
||||||
|
"Bucket '$bucket' already exists",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,8 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:repertory/constants.dart' as constants;
|
import 'package:repertory/constants.dart' as constants;
|
||||||
import 'package:repertory/helpers.dart'
|
import 'package:repertory/helpers.dart' show Validator, getSettingValidators;
|
||||||
show Validator, displayErrorMessage, getSettingValidators;
|
|
||||||
import 'package:repertory/models/mount.dart';
|
import 'package:repertory/models/mount.dart';
|
||||||
import 'package:repertory/models/mount_list.dart';
|
import 'package:repertory/models/mount_list.dart';
|
||||||
import 'package:settings_ui/settings_ui.dart';
|
import 'package:settings_ui/settings_ui.dart';
|
||||||
@ -84,10 +83,15 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
|
|||||||
(validator) => !validator(updatedValue),
|
(validator) => !validator(updatedValue),
|
||||||
);
|
);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
return displayErrorMessage(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
context,
|
SnackBar(
|
||||||
"Setting '$key' is not valid",
|
content: Text(
|
||||||
|
"Setting '$key' is not valid",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
root[key] = int.parse(updatedValue);
|
root[key] = int.parse(updatedValue);
|
||||||
@ -214,20 +218,30 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
|
|||||||
child: const Text('OK'),
|
child: const Text('OK'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (updatedValue1 != updatedValue2) {
|
if (updatedValue1 != updatedValue2) {
|
||||||
return displayErrorMessage(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
context,
|
SnackBar(
|
||||||
"Setting '$key' does not match",
|
content: Text(
|
||||||
|
"Setting '$key' does not match",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final result = validators.firstWhereOrNull(
|
final result = validators.firstWhereOrNull(
|
||||||
(validator) => !validator(updatedValue1),
|
(validator) => !validator(updatedValue1),
|
||||||
);
|
);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
return displayErrorMessage(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
context,
|
SnackBar(
|
||||||
"Setting '$key' is not valid",
|
content: Text(
|
||||||
|
"Setting '$key' is not valid",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -303,10 +317,15 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
|
|||||||
(validator) => !validator(updatedValue),
|
(validator) => !validator(updatedValue),
|
||||||
);
|
);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
return displayErrorMessage(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
context,
|
SnackBar(
|
||||||
"Setting '$key' is not valid",
|
content: Text(
|
||||||
|
"Setting '$key' is not valid",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
root[key] = updatedValue;
|
root[key] = updatedValue;
|
||||||
|
@ -92,7 +92,19 @@ class _MountWidgetState extends State<MountWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isMounted && location == null) {
|
if (!isMounted && location == null) {
|
||||||
displayErrorMessage(context, "Mount location is not set");
|
if (!context.mounted) {
|
||||||
|
return cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: const Text(
|
||||||
|
"Mount location is not set",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
return cleanup();
|
return cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +117,17 @@ class _MountWidgetState extends State<MountWidget> {
|
|||||||
return cleanup();
|
return cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
displayErrorMessage(context, "Mount location not found");
|
ScaffoldMessenger.of(
|
||||||
|
constants.navigatorKey.currentContext!,
|
||||||
|
).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: const Text(
|
||||||
|
"Mount location not found",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
return cleanup();
|
return cleanup();
|
||||||
}
|
}
|
||||||
: null;
|
: null;
|
||||||
@ -153,10 +175,15 @@ class _MountWidgetState extends State<MountWidget> {
|
|||||||
(validator) => !validator(currentLocation ?? ''),
|
(validator) => !validator(currentLocation ?? ''),
|
||||||
);
|
);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
return displayErrorMessage(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
context,
|
SnackBar(
|
||||||
"Mount location is not valid",
|
content: const Text(
|
||||||
|
"Mount location is not valid",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
Navigator.of(context).pop(currentLocation);
|
Navigator.of(context).pop(currentLocation);
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user