NoteTagEditor: Add the tag when hitting Enter

This commit is contained in:
Vishesh Handa
2020-07-09 17:51:01 +02:00
parent 27bcb09edf
commit 4e61c21088

View File

@ -53,6 +53,7 @@ class _NoteTagEditorState extends State<NoteTagEditor> {
hintText: tr('editors.common.tags'), hintText: tr('editors.common.tags'),
hintStyle: theme.inputDecorationTheme.hintStyle, hintStyle: theme.inputDecorationTheme.hintStyle,
), ),
onSubmitted: _addTag,
), ),
), ),
body: buildView(_textController.text), body: buildView(_textController.text),
@ -109,13 +110,15 @@ class _NoteTagEditorState extends State<NoteTagEditor> {
return ListTile( return ListTile(
leading: const Icon(Icons.add), leading: const Icon(Icons.add),
title: Text(tag), title: Text(tag),
onTap: () { onTap: () => _addTag(tag),
setState(() {
_selectedTags.add(tag);
_allTags.add(tag);
_textController.text = "";
});
},
); );
} }
void _addTag(String tag) {
setState(() {
_selectedTags.add(tag);
_allTags.add(tag);
_textController.text = "";
});
}
} }