From d1677327c23d683a5608f1d36d1c4340c37a2fc4 Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Tue, 2 Jun 2020 00:33:36 +0200 Subject: [PATCH] Do not show the Markdown Editor for txt files Fixes #55 --- lib/screens/note_editor.dart | 8 +++++++- lib/widgets/note_editor_selector.dart | 17 ++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/screens/note_editor.dart b/lib/screens/note_editor.dart index fd0da2cc..7bf51332 100644 --- a/lib/screens/note_editor.dart +++ b/lib/screens/note_editor.dart @@ -111,6 +111,12 @@ class NoteEditorState extends State { break; } } + + // Txt files + if (note.fileFormat == NoteFileFormat.Txt && + editorType == EditorType.Markdown) { + editorType = EditorType.Raw; + } } @override @@ -190,7 +196,7 @@ class NoteEditorState extends State { var newEditorType = await showDialog( context: context, builder: (BuildContext context) { - return NoteEditorSelector(editorType); + return NoteEditorSelector(editorType, _note.fileFormat); }, ); diff --git a/lib/widgets/note_editor_selector.dart b/lib/widgets/note_editor_selector.dart index 05a8b4f5..83c0961a 100644 --- a/lib/widgets/note_editor_selector.dart +++ b/lib/widgets/note_editor_selector.dart @@ -1,23 +1,26 @@ import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/fa_icon.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:gitjournal/core/note.dart'; import 'package:gitjournal/screens/note_editor.dart'; class NoteEditorSelector extends StatelessWidget { final EditorType currentEditor; + final NoteFileFormat fileFormat; - NoteEditorSelector(this.currentEditor); + NoteEditorSelector(this.currentEditor, this.fileFormat); @override Widget build(BuildContext context) { var list = Column( children: [ - _buildTile( - context, - EditorType.Markdown, - "Markdown Editor", - FontAwesomeIcons.markdown, - ), + if (fileFormat != NoteFileFormat.Txt) + _buildTile( + context, + EditorType.Markdown, + "Markdown Editor", + FontAwesomeIcons.markdown, + ), _buildTile( context, EditorType.Raw,