From e33857f8e97e840b75b5ccbffdb7c244b36f37e0 Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Thu, 3 Sep 2020 08:52:27 +0200 Subject: [PATCH] Do not show Tag Editing screen if the Note cannot have metadata In the case of '.txt' notes or markdown notes without a yaml header. --- lib/editors/common.dart | 27 ++++++++++++++++----------- lib/editors/scaffold.dart | 5 ++--- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/editors/common.dart b/lib/editors/common.dart index 4ae8fd72..2a7a7521 100644 --- a/lib/editors/common.dart +++ b/lib/editors/common.dart @@ -103,6 +103,7 @@ class EditorBottomBar extends StatelessWidget { final bool allowEdits; final bool zenMode; final Func0 onZenModeChanged; + final bool metaDataEditable; EditorBottomBar({ @required this.editor, @@ -111,6 +112,7 @@ class EditorBottomBar extends StatelessWidget { @required this.allowEdits, @required this.zenMode, @required this.onZenModeChanged, + @required this.metaDataEditable, }); @override @@ -137,6 +139,7 @@ class EditorBottomBar extends StatelessWidget { editorState, zenMode, onZenModeChanged, + metaDataEditable, ), elevation: 0, ); @@ -236,6 +239,7 @@ Widget _buildBottomMenuSheet( EditorState editorState, bool zenModeEnabled, Func0 zenModeChanged, + bool metaDataEditable, ) { return Container( child: Column( @@ -262,19 +266,20 @@ Widget _buildBottomMenuSheet( Share.share(note.body); }, ), - ProOverlay( - feature: Feature.tags, - child: ListTile( - leading: const FaIcon(FontAwesomeIcons.tag), - title: Text(tr('editors.common.tags')), - onTap: () { - var note = editorState.getNote(); - Navigator.of(context).pop(); + if (metaDataEditable) + ProOverlay( + feature: Feature.tags, + child: ListTile( + leading: const FaIcon(FontAwesomeIcons.tag), + title: Text(tr('editors.common.tags')), + onTap: () { + var note = editorState.getNote(); + Navigator.of(context).pop(); - editor.editTagsSelected(note); - }, + editor.editTagsSelected(note); + }, + ), ), - ), ListTile( leading: const Icon(Icons.edit), title: Text(tr('editors.common.editFileName')), diff --git a/lib/editors/scaffold.dart b/lib/editors/scaffold.dart index fedb823d..e8acbc08 100644 --- a/lib/editors/scaffold.dart +++ b/lib/editors/scaffold.dart @@ -57,9 +57,7 @@ class _EditorScaffoldState extends State { editingMode = true; } - if (editingMode == false) { - note = widget.editorState.getNote(); - } + note = widget.editorState.getNote(); } @override @@ -149,6 +147,7 @@ class _EditorScaffoldState extends State { } }); }, + metaDataEditable: note.canHaveMetadata, ), ) ],