mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-30 03:19:11 +08:00
NoteEditor: Build a bottom bar which shows the current folder
Also allow notes to be moved to a folder.
This commit is contained in:
@ -159,6 +159,8 @@ class ChecklistEditorState extends State<ChecklistEditor>
|
||||
Expanded(child: FocusScope(child: checklistWidget)),
|
||||
],
|
||||
),
|
||||
bottomNavigationBar:
|
||||
buildEditorBottonBar(context, widget, this, checklist.note),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ abstract class EditorState {
|
||||
Note getNote();
|
||||
}
|
||||
|
||||
enum DropDownChoices { Rename, MoveToFolder, DiscardChanges, Share }
|
||||
enum DropDownChoices { Rename, DiscardChanges, Share }
|
||||
|
||||
AppBar buildEditorAppBar(
|
||||
Editor editor,
|
||||
@ -58,11 +58,6 @@ AppBar buildEditorAppBar(
|
||||
editor.renameNoteSelected(note);
|
||||
return;
|
||||
|
||||
case DropDownChoices.MoveToFolder:
|
||||
var note = editorState.getNote();
|
||||
editor.moveNoteToFolderSelected(note);
|
||||
return;
|
||||
|
||||
case DropDownChoices.DiscardChanges:
|
||||
var note = editorState.getNote();
|
||||
editor.discardChangesSelected(note);
|
||||
@ -80,10 +75,6 @@ AppBar buildEditorAppBar(
|
||||
value: DropDownChoices.Rename,
|
||||
child: Text('Edit File Name'),
|
||||
),
|
||||
const PopupMenuItem<DropDownChoices>(
|
||||
value: DropDownChoices.MoveToFolder,
|
||||
child: Text('Move to Folder'),
|
||||
),
|
||||
const PopupMenuItem<DropDownChoices>(
|
||||
value: DropDownChoices.DiscardChanges,
|
||||
child: Text('Discard Changes'),
|
||||
@ -97,3 +88,33 @@ AppBar buildEditorAppBar(
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
BottomAppBar buildEditorBottonBar(
|
||||
BuildContext context,
|
||||
Editor editor,
|
||||
EditorState editorState,
|
||||
Note note,
|
||||
) {
|
||||
var folderName = note.parent.pathSpec();
|
||||
if (folderName.isEmpty) {
|
||||
folderName = "Root Folder";
|
||||
}
|
||||
|
||||
return BottomAppBar(
|
||||
elevation: 0.0,
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
FlatButton.icon(
|
||||
icon: Icon(Icons.folder),
|
||||
label: Text(folderName),
|
||||
onPressed: () {
|
||||
var note = editorState.getNote();
|
||||
editor.moveNoteToFolderSelected(note);
|
||||
},
|
||||
)
|
||||
],
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -84,6 +84,7 @@ class JournalEditorState extends State<JournalEditor> implements EditorState {
|
||||
return Scaffold(
|
||||
appBar: buildEditorAppBar(widget, this, noteModified: _noteModified),
|
||||
body: editor,
|
||||
bottomNavigationBar: buildEditorBottonBar(context, widget, this, note),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -115,6 +115,7 @@ class MarkdownEditorState extends State<MarkdownEditor> implements EditorState {
|
||||
extraButtons: [extraButton],
|
||||
),
|
||||
body: body,
|
||||
bottomNavigationBar: buildEditorBottonBar(context, widget, this, note),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -81,6 +81,7 @@ class RawEditorState extends State<RawEditor> implements EditorState {
|
||||
return Scaffold(
|
||||
appBar: buildEditorAppBar(widget, this, noteModified: _noteModified),
|
||||
body: editor,
|
||||
bottomNavigationBar: buildEditorBottonBar(context, widget, this, note),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -287,8 +287,14 @@ class NoteEditorState extends State<NoteEditor> {
|
||||
builder: (context) => FolderSelectionDialog(),
|
||||
);
|
||||
if (destFolder != null) {
|
||||
var stateContainer = Provider.of<StateContainer>(context, listen: false);
|
||||
stateContainer.moveNote(note, destFolder);
|
||||
if (_isNewNote) {
|
||||
note.parent = destFolder;
|
||||
setState(() {});
|
||||
} else {
|
||||
var stateContainer =
|
||||
Provider.of<StateContainer>(context, listen: false);
|
||||
stateContainer.moveNote(note, destFolder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user