mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-01 04:07:53 +08:00
Do not let the RootFolder be renamed
This commit is contained in:
@ -46,7 +46,8 @@ screens:
|
|||||||
discard: Discard
|
discard: Discard
|
||||||
errorDialog:
|
errorDialog:
|
||||||
title: Error
|
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
|
ok: Ok
|
||||||
actions:
|
actions:
|
||||||
rename: Rename Folder
|
rename: Rename Folder
|
||||||
|
@ -68,6 +68,14 @@ class _FolderListingScreenState extends State<FolderListingScreen> {
|
|||||||
},
|
},
|
||||||
onSelected: (String value) async {
|
onSelected: (String value) async {
|
||||||
if (value == "Rename") {
|
if (value == "Rename") {
|
||||||
|
if (selectedFolder.pathSpec().isEmpty) {
|
||||||
|
await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (_) => RenameFolderErrorDialog(),
|
||||||
|
);
|
||||||
|
_folderTreeViewKey.currentState.resetSelection();
|
||||||
|
return;
|
||||||
|
}
|
||||||
var folderName = await showDialog(
|
var folderName = await showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (_) => RenameDialog(
|
builder: (_) => RenameDialog(
|
||||||
@ -95,7 +103,7 @@ class _FolderListingScreenState extends State<FolderListingScreen> {
|
|||||||
if (selectedFolder.hasNotesRecursive) {
|
if (selectedFolder.hasNotesRecursive) {
|
||||||
await showDialog(
|
await showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (_) => FolderErrorDialog(),
|
builder: (_) => DeleteFolderErrorDialog(),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
var container =
|
var container =
|
||||||
@ -217,11 +225,15 @@ class _CreateFolderAlertDialogState extends State<CreateFolderAlertDialog> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class FolderErrorDialog extends StatelessWidget {
|
class FolderErrorDialog extends StatelessWidget {
|
||||||
|
final String content;
|
||||||
|
|
||||||
|
FolderErrorDialog(this.content);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: Text(tr("screens.folders.errorDialog.title")),
|
title: Text(tr("screens.folders.errorDialog.title")),
|
||||||
content: Text(tr("screens.folders.errorDialog.content")),
|
content: Text(content),
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
FlatButton(
|
FlatButton(
|
||||||
child: Text(tr("screens.folders.errorDialog.ok")),
|
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"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user