Do not let the RootFolder be renamed

This commit is contained in:
Vishesh Handa
2020-05-18 00:31:55 +02:00
parent 26ed82fdbc
commit 07576bb624
2 changed files with 30 additions and 3 deletions

View File

@ -46,7 +46,8 @@ screens:
discard: Discard
errorDialog:
title: Error
content: Cannot delete a Folder which contains notes
deleteContent: Cannot delete a Folder which contains notes
renameContent: Cannot rename Root Folder
ok: Ok
actions:
rename: Rename Folder

View File

@ -68,6 +68,14 @@ class _FolderListingScreenState extends State<FolderListingScreen> {
},
onSelected: (String value) async {
if (value == "Rename") {
if (selectedFolder.pathSpec().isEmpty) {
await showDialog(
context: context,
builder: (_) => RenameFolderErrorDialog(),
);
_folderTreeViewKey.currentState.resetSelection();
return;
}
var folderName = await showDialog(
context: context,
builder: (_) => RenameDialog(
@ -95,7 +103,7 @@ class _FolderListingScreenState extends State<FolderListingScreen> {
if (selectedFolder.hasNotesRecursive) {
await showDialog(
context: context,
builder: (_) => FolderErrorDialog(),
builder: (_) => DeleteFolderErrorDialog(),
);
} else {
var container =
@ -217,11 +225,15 @@ class _CreateFolderAlertDialogState extends State<CreateFolderAlertDialog> {
}
class FolderErrorDialog extends StatelessWidget {
final String content;
FolderErrorDialog(this.content);
@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text(tr("screens.folders.errorDialog.title")),
content: Text(tr("screens.folders.errorDialog.content")),
content: Text(content),
actions: <Widget>[
FlatButton(
child: Text(tr("screens.folders.errorDialog.ok")),
@ -231,3 +243,17 @@ class FolderErrorDialog extends StatelessWidget {
);
}
}
class DeleteFolderErrorDialog extends StatelessWidget {
@override
Widget build(BuildContext context) {
return FolderErrorDialog(tr("screens.folders.errorDialog.deleteContent"));
}
}
class RenameFolderErrorDialog extends StatelessWidget {
@override
Widget build(BuildContext context) {
return FolderErrorDialog(tr("screens.folders.errorDialog.renameContent"));
}
}