mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-01 04:07:53 +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)),
|
Expanded(child: FocusScope(child: checklistWidget)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
bottomNavigationBar:
|
||||||
|
buildEditorBottonBar(context, widget, this, checklist.note),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ abstract class EditorState {
|
|||||||
Note getNote();
|
Note getNote();
|
||||||
}
|
}
|
||||||
|
|
||||||
enum DropDownChoices { Rename, MoveToFolder, DiscardChanges, Share }
|
enum DropDownChoices { Rename, DiscardChanges, Share }
|
||||||
|
|
||||||
AppBar buildEditorAppBar(
|
AppBar buildEditorAppBar(
|
||||||
Editor editor,
|
Editor editor,
|
||||||
@ -58,11 +58,6 @@ AppBar buildEditorAppBar(
|
|||||||
editor.renameNoteSelected(note);
|
editor.renameNoteSelected(note);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case DropDownChoices.MoveToFolder:
|
|
||||||
var note = editorState.getNote();
|
|
||||||
editor.moveNoteToFolderSelected(note);
|
|
||||||
return;
|
|
||||||
|
|
||||||
case DropDownChoices.DiscardChanges:
|
case DropDownChoices.DiscardChanges:
|
||||||
var note = editorState.getNote();
|
var note = editorState.getNote();
|
||||||
editor.discardChangesSelected(note);
|
editor.discardChangesSelected(note);
|
||||||
@ -80,10 +75,6 @@ AppBar buildEditorAppBar(
|
|||||||
value: DropDownChoices.Rename,
|
value: DropDownChoices.Rename,
|
||||||
child: Text('Edit File Name'),
|
child: Text('Edit File Name'),
|
||||||
),
|
),
|
||||||
const PopupMenuItem<DropDownChoices>(
|
|
||||||
value: DropDownChoices.MoveToFolder,
|
|
||||||
child: Text('Move to Folder'),
|
|
||||||
),
|
|
||||||
const PopupMenuItem<DropDownChoices>(
|
const PopupMenuItem<DropDownChoices>(
|
||||||
value: DropDownChoices.DiscardChanges,
|
value: DropDownChoices.DiscardChanges,
|
||||||
child: Text('Discard Changes'),
|
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(
|
return Scaffold(
|
||||||
appBar: buildEditorAppBar(widget, this, noteModified: _noteModified),
|
appBar: buildEditorAppBar(widget, this, noteModified: _noteModified),
|
||||||
body: editor,
|
body: editor,
|
||||||
|
bottomNavigationBar: buildEditorBottonBar(context, widget, this, note),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,6 +115,7 @@ class MarkdownEditorState extends State<MarkdownEditor> implements EditorState {
|
|||||||
extraButtons: [extraButton],
|
extraButtons: [extraButton],
|
||||||
),
|
),
|
||||||
body: body,
|
body: body,
|
||||||
|
bottomNavigationBar: buildEditorBottonBar(context, widget, this, note),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,6 +81,7 @@ class RawEditorState extends State<RawEditor> implements EditorState {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: buildEditorAppBar(widget, this, noteModified: _noteModified),
|
appBar: buildEditorAppBar(widget, this, noteModified: _noteModified),
|
||||||
body: editor,
|
body: editor,
|
||||||
|
bottomNavigationBar: buildEditorBottonBar(context, widget, this, note),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,10 +287,16 @@ class NoteEditorState extends State<NoteEditor> {
|
|||||||
builder: (context) => FolderSelectionDialog(),
|
builder: (context) => FolderSelectionDialog(),
|
||||||
);
|
);
|
||||||
if (destFolder != null) {
|
if (destFolder != null) {
|
||||||
var stateContainer = Provider.of<StateContainer>(context, listen: false);
|
if (_isNewNote) {
|
||||||
|
note.parent = destFolder;
|
||||||
|
setState(() {});
|
||||||
|
} else {
|
||||||
|
var stateContainer =
|
||||||
|
Provider.of<StateContainer>(context, listen: false);
|
||||||
stateContainer.moveNote(note, destFolder);
|
stateContainer.moveNote(note, destFolder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _discardChangesSelected(Note note) {
|
void _discardChangesSelected(Note note) {
|
||||||
if (_noteModified(note)) {
|
if (_noteModified(note)) {
|
||||||
|
Reference in New Issue
Block a user