mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-28 18:03:14 +08:00
Allow a note of a different 'type' to easily created
This adds a bottom bar, which hopefully doesn't make the app too cluttered.
This commit is contained in:
@ -5,6 +5,7 @@ import 'package:gitjournal/core/notes_folder.dart';
|
|||||||
import 'package:gitjournal/folder_views/card_view.dart';
|
import 'package:gitjournal/folder_views/card_view.dart';
|
||||||
import 'package:gitjournal/folder_views/journal_view.dart';
|
import 'package:gitjournal/folder_views/journal_view.dart';
|
||||||
import 'package:gitjournal/screens/note_editor.dart';
|
import 'package:gitjournal/screens/note_editor.dart';
|
||||||
|
import 'package:gitjournal/settings.dart';
|
||||||
import 'package:gitjournal/utils.dart';
|
import 'package:gitjournal/utils.dart';
|
||||||
|
|
||||||
import 'standard_view.dart';
|
import 'standard_view.dart';
|
||||||
@ -25,7 +26,10 @@ Widget buildFolderView(
|
|||||||
) {
|
) {
|
||||||
var noteSelectionFn = (Note note) async {
|
var noteSelectionFn = (Note note) async {
|
||||||
var route = MaterialPageRoute(
|
var route = MaterialPageRoute(
|
||||||
builder: (context) => NoteEditor.fromNote(note),
|
builder: (context) => NoteEditor.fromNote(
|
||||||
|
note,
|
||||||
|
Settings.instance.defaultEditor.toEditorType(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
var showUndoSnackBar = await Navigator.of(context).push(route);
|
var showUndoSnackBar = await Navigator.of(context).push(route);
|
||||||
if (showUndoSnackBar != null) {
|
if (showUndoSnackBar != null) {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
|
|
||||||
import 'package:gitjournal/core/notes_folder.dart';
|
import 'package:gitjournal/core/notes_folder.dart';
|
||||||
import 'package:gitjournal/core/sorted_notes_folder.dart';
|
import 'package:gitjournal/core/sorted_notes_folder.dart';
|
||||||
import 'package:gitjournal/core/sorting_mode.dart';
|
import 'package:gitjournal/core/sorting_mode.dart';
|
||||||
@ -80,7 +82,8 @@ class _FolderViewState extends State<FolderView> {
|
|||||||
|
|
||||||
var createButton = FloatingActionButton(
|
var createButton = FloatingActionButton(
|
||||||
key: const ValueKey("FAB"),
|
key: const ValueKey("FAB"),
|
||||||
onPressed: () => _newPost(context),
|
onPressed: () =>
|
||||||
|
_newPost(context, Settings.instance.defaultEditor.toEditorType()),
|
||||||
child: Icon(Icons.add),
|
child: Icon(Icons.add),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -152,7 +155,6 @@ class _FolderViewState extends State<FolderView> {
|
|||||||
extraAction,
|
extraAction,
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
floatingActionButton: createButton,
|
|
||||||
body: Center(
|
body: Center(
|
||||||
child: Builder(
|
child: Builder(
|
||||||
builder: (context) => RefreshIndicator(
|
builder: (context) => RefreshIndicator(
|
||||||
@ -162,6 +164,39 @@ class _FolderViewState extends State<FolderView> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
drawer: AppDrawer(),
|
drawer: AppDrawer(),
|
||||||
|
floatingActionButton: createButton,
|
||||||
|
floatingActionButtonLocation: FloatingActionButtonLocation.endDocked,
|
||||||
|
bottomNavigationBar: BottomAppBar(
|
||||||
|
color: Theme.of(context).bottomAppBarColor,
|
||||||
|
shape: const CircularNotchedRectangle(),
|
||||||
|
child: Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(4.0),
|
||||||
|
child: IconButton(
|
||||||
|
icon: const FaIcon(FontAwesomeIcons.tasks),
|
||||||
|
onPressed: () => _newPost(context, EditorType.Checklist),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(4.0),
|
||||||
|
child: IconButton(
|
||||||
|
icon: const FaIcon(FontAwesomeIcons.markdown),
|
||||||
|
onPressed: () => _newPost(context, EditorType.Markdown),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(4.0),
|
||||||
|
child: IconButton(
|
||||||
|
icon: const FaIcon(FontAwesomeIcons.book),
|
||||||
|
onPressed: () => _newPost(context, EditorType.Journal),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,9 +209,10 @@ class _FolderViewState extends State<FolderView> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _newPost(BuildContext context) {
|
void _newPost(BuildContext context, EditorType editorType) {
|
||||||
var route = MaterialPageRoute(
|
var route = MaterialPageRoute(
|
||||||
builder: (context) => NoteEditor.newNote(widget.notesFolder.fsFolder));
|
builder: (context) =>
|
||||||
|
NoteEditor.newNote(widget.notesFolder.fsFolder, editorType));
|
||||||
Navigator.of(context).push(route);
|
Navigator.of(context).push(route);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import 'package:gitjournal/editors/journal_editor.dart';
|
|||||||
import 'package:gitjournal/editors/markdown_editor.dart';
|
import 'package:gitjournal/editors/markdown_editor.dart';
|
||||||
import 'package:gitjournal/editors/raw_editor.dart';
|
import 'package:gitjournal/editors/raw_editor.dart';
|
||||||
import 'package:gitjournal/editors/checklist_editor.dart';
|
import 'package:gitjournal/editors/checklist_editor.dart';
|
||||||
import 'package:gitjournal/settings.dart';
|
|
||||||
import 'package:gitjournal/state_container.dart';
|
import 'package:gitjournal/state_container.dart';
|
||||||
import 'package:gitjournal/widgets/folder_selection_dialog.dart';
|
import 'package:gitjournal/widgets/folder_selection_dialog.dart';
|
||||||
import 'package:gitjournal/widgets/rename_dialog.dart';
|
import 'package:gitjournal/widgets/rename_dialog.dart';
|
||||||
@ -18,9 +17,10 @@ class ShowUndoSnackbar {}
|
|||||||
class NoteEditor extends StatefulWidget {
|
class NoteEditor extends StatefulWidget {
|
||||||
final Note note;
|
final Note note;
|
||||||
final NotesFolder notesFolder;
|
final NotesFolder notesFolder;
|
||||||
|
final EditorType defaultEditorType;
|
||||||
|
|
||||||
NoteEditor.fromNote(this.note) : notesFolder = null;
|
NoteEditor.fromNote(this.note, this.defaultEditorType) : notesFolder = null;
|
||||||
NoteEditor.newNote(this.notesFolder) : note = null;
|
NoteEditor.newNote(this.notesFolder, this.defaultEditorType) : note = null;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
NoteEditorState createState() {
|
NoteEditorState createState() {
|
||||||
@ -59,18 +59,7 @@ class NoteEditorState extends State<NoteEditor> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
editorType = widget.defaultEditorType;
|
||||||
switch (Settings.instance.defaultEditor) {
|
|
||||||
case SettingsEditorType.Markdown:
|
|
||||||
editorType = EditorType.Markdown;
|
|
||||||
break;
|
|
||||||
case SettingsEditorType.Raw:
|
|
||||||
editorType = EditorType.Raw;
|
|
||||||
break;
|
|
||||||
case SettingsEditorType.Journal:
|
|
||||||
editorType = EditorType.Journal;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:gitjournal/screens/note_editor.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:gitjournal/core/sorting_mode.dart';
|
import 'package:gitjournal/core/sorting_mode.dart';
|
||||||
|
|
||||||
@ -225,6 +226,7 @@ class SettingsEditorType {
|
|||||||
static const Markdown = SettingsEditorType("Markdown", "Markdown");
|
static const Markdown = SettingsEditorType("Markdown", "Markdown");
|
||||||
static const Raw = SettingsEditorType("Raw", "Raw");
|
static const Raw = SettingsEditorType("Raw", "Raw");
|
||||||
static const Journal = SettingsEditorType("Journal", "Journal");
|
static const Journal = SettingsEditorType("Journal", "Journal");
|
||||||
|
static const Checklist = SettingsEditorType("Checklist", "Checklist");
|
||||||
static const Default = Markdown;
|
static const Default = Markdown;
|
||||||
|
|
||||||
final String _str;
|
final String _str;
|
||||||
@ -239,10 +241,26 @@ class SettingsEditorType {
|
|||||||
return _publicString;
|
return _publicString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EditorType toEditorType() {
|
||||||
|
switch (this) {
|
||||||
|
case Markdown:
|
||||||
|
return EditorType.Markdown;
|
||||||
|
case Raw:
|
||||||
|
return EditorType.Raw;
|
||||||
|
case Journal:
|
||||||
|
return EditorType.Journal;
|
||||||
|
case Checklist:
|
||||||
|
return EditorType.Checklist;
|
||||||
|
default:
|
||||||
|
return EditorType.Markdown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static const options = <SettingsEditorType>[
|
static const options = <SettingsEditorType>[
|
||||||
Markdown,
|
Markdown,
|
||||||
Raw,
|
Raw,
|
||||||
Journal,
|
Journal,
|
||||||
|
Checklist,
|
||||||
];
|
];
|
||||||
|
|
||||||
static SettingsEditorType fromInternalString(String str) {
|
static SettingsEditorType fromInternalString(String str) {
|
||||||
|
@ -238,6 +238,13 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
font_awesome_flutter:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: font_awesome_flutter
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "8.7.0"
|
||||||
freezed_annotation:
|
freezed_annotation:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -38,6 +38,7 @@ dependencies:
|
|||||||
git_url_parse2: ^0.0.1
|
git_url_parse2: ^0.0.1
|
||||||
synchronized: ^2.2.0
|
synchronized: ^2.2.0
|
||||||
steel_crypt: ^1.7.1+1
|
steel_crypt: ^1.7.1+1
|
||||||
|
font_awesome_flutter: ^8.7.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_launcher_icons: "^0.7.2"
|
flutter_launcher_icons: "^0.7.2"
|
||||||
|
Reference in New Issue
Block a user