diff --git a/lib/folder_views/card_view.dart b/lib/folder_views/card_view.dart index d8a479f9..6f6d412f 100644 --- a/lib/folder_views/card_view.dart +++ b/lib/folder_views/card_view.dart @@ -7,14 +7,16 @@ import 'package:gitjournal/core/notes_folder.dart'; import 'package:gitjournal/folder_views/note_tile.dart'; class CardView extends StatelessWidget { - final NoteSelectedFunction noteSelectedFunction; + final NoteSelectedFunction noteTapped; + final NoteSelectedFunction noteLongPressed; final NotesFolder folder; final String emptyText; final bool fixedHeight; CardView({ @required this.folder, - @required this.noteSelectedFunction, + @required this.noteTapped, + @required this.noteLongPressed, @required this.emptyText, this.fixedHeight = false, }); @@ -46,7 +48,11 @@ class CardView extends StatelessWidget { itemCount: folder.notes.length, itemBuilder: (BuildContext context, int index) { var note = folder.notes[index]; - return NoteTile(note, noteSelectedFunction); + return NoteTile( + note: note, + noteTapped: noteTapped, + noteLongPressed: noteLongPressed, + ); }, maxCrossAxisExtent: 200.0, staggeredTileBuilder: (int i) => stagTile, diff --git a/lib/folder_views/common.dart b/lib/folder_views/common.dart index 393bcae0..3460b070 100644 --- a/lib/folder_views/common.dart +++ b/lib/folder_views/common.dart @@ -29,12 +29,14 @@ Widget buildFolderView( bool showSummary, ) { var noteSelectionFn = (Note note) => openNoteEditor(context, note); + var noteLongPressedFn = (Note note) {}; switch (viewType) { case FolderViewType.Standard: return StandardView( folder: folder, - noteSelectedFunction: noteSelectionFn, + noteTapped: noteSelectionFn, + noteLongPressed: noteLongPressedFn, emptyText: emptyText, headerType: header, showSummary: showSummary, @@ -42,19 +44,22 @@ Widget buildFolderView( case FolderViewType.Journal: return JournalView( folder: folder, - noteSelectedFunction: noteSelectionFn, + noteTapped: noteSelectionFn, + noteLongPressed: noteLongPressedFn, emptyText: emptyText, ); case FolderViewType.Card: return CardView( folder: folder, - noteSelectedFunction: noteSelectionFn, + noteTapped: noteSelectionFn, + noteLongPressed: noteLongPressedFn, emptyText: emptyText, ); case FolderViewType.Grid: return GridFolderView( folder: folder, - noteSelectedFunction: noteSelectionFn, + noteTapped: noteSelectionFn, + noteLongPressed: noteLongPressedFn, emptyText: emptyText, ); } diff --git a/lib/folder_views/grid_view.dart b/lib/folder_views/grid_view.dart index 452d33aa..2169406a 100644 --- a/lib/folder_views/grid_view.dart +++ b/lib/folder_views/grid_view.dart @@ -6,13 +6,15 @@ import 'package:gitjournal/folder_views/card_view.dart'; import 'package:gitjournal/folder_views/note_tile.dart'; class GridFolderView extends StatelessWidget { - final NoteSelectedFunction noteSelectedFunction; + final NoteSelectedFunction noteTapped; + final NoteSelectedFunction noteLongPressed; final NotesFolder folder; final String emptyText; GridFolderView({ @required this.folder, - @required this.noteSelectedFunction, + @required this.noteTapped, + @required this.noteLongPressed, @required this.emptyText, }); @@ -20,7 +22,8 @@ class GridFolderView extends StatelessWidget { Widget build(BuildContext context) { return CardView( folder: folder, - noteSelectedFunction: noteSelectedFunction, + noteTapped: noteTapped, + noteLongPressed: noteLongPressed, emptyText: emptyText, fixedHeight: true, ); diff --git a/lib/folder_views/journal_view.dart b/lib/folder_views/journal_view.dart index db73ab23..5b0e41ad 100644 --- a/lib/folder_views/journal_view.dart +++ b/lib/folder_views/journal_view.dart @@ -9,7 +9,8 @@ import 'package:gitjournal/core/sorting_mode.dart'; import 'package:gitjournal/folder_views/list_view.dart'; class JournalView extends StatelessWidget { - final NoteSelectedFunction noteSelectedFunction; + final NoteSelectedFunction noteTapped; + final NoteSelectedFunction noteLongPressed; final NotesFolder folder; final String emptyText; @@ -18,7 +19,8 @@ class JournalView extends StatelessWidget { JournalView({ @required this.folder, - @required this.noteSelectedFunction, + @required this.noteTapped, + @required this.noteLongPressed, @required this.emptyText, }); @@ -77,7 +79,8 @@ class JournalView extends StatelessWidget { children: children, crossAxisAlignment: CrossAxisAlignment.start, ), - onTap: () => noteSelectedFunction(note), + onTap: () => noteTapped(note), + onLongPress: () => noteLongPressed(note), ); var dc = Theme.of(context).dividerColor; diff --git a/lib/folder_views/note_tile.dart b/lib/folder_views/note_tile.dart index 1f2f34e3..d664b636 100644 --- a/lib/folder_views/note_tile.dart +++ b/lib/folder_views/note_tile.dart @@ -9,9 +9,14 @@ typedef void NoteSelectedFunction(Note note); class NoteTile extends StatelessWidget { final Note note; - final NoteSelectedFunction noteSelectedFunction; + final NoteSelectedFunction noteTapped; + final NoteSelectedFunction noteLongPressed; - NoteTile(this.note, this.noteSelectedFunction); + NoteTile({ + @required this.note, + @required this.noteTapped, + @required this.noteLongPressed, + }); @override Widget build(BuildContext context) { @@ -76,7 +81,8 @@ class NoteTile extends StatelessWidget { child: InkWell( child: tileContent, borderRadius: borderRadius, - onTap: () => noteSelectedFunction(note), + onTap: () => noteTapped(note), + onLongPress: () => noteLongPressed(note), ), ); } diff --git a/lib/folder_views/standard_view.dart b/lib/folder_views/standard_view.dart index be6a6cbb..3f58e867 100644 --- a/lib/folder_views/standard_view.dart +++ b/lib/folder_views/standard_view.dart @@ -15,7 +15,8 @@ enum StandardViewHeader { } class StandardView extends StatelessWidget { - final NoteSelectedFunction noteSelectedFunction; + final NoteSelectedFunction noteTapped; + final NoteSelectedFunction noteLongPressed; final NotesFolder folder; final String emptyText; @@ -26,7 +27,8 @@ class StandardView extends StatelessWidget { StandardView({ @required this.folder, - @required this.noteSelectedFunction, + @required this.noteTapped, + @required this.noteLongPressed, @required this.emptyText, @required this.headerType, @required this.showSummary, @@ -115,13 +117,15 @@ class StandardView extends StatelessWidget { children: summary, crossAxisAlignment: CrossAxisAlignment.start, ), - onTap: () => noteSelectedFunction(note), + onTap: () => noteTapped(note), + onLongPress: () => noteLongPressed(note), ); } else { tile = ListTile( isThreeLine: false, title: titleRow, - onTap: () => noteSelectedFunction(note), + onTap: () => noteTapped(note), + onLongPress: () => noteLongPressed(note), ); }