11import 'package:flutter/material.dart' ;
2+ import 'package:note_app/model/Note.dart' ;
23import 'package:note_app/model/NotesList.dart' ;
34import 'package:note_app/model/Plaintext.dart' ;
5+ import 'package:note_app/model/checklist/Checklist.dart' ;
46import 'package:note_app/model/checklist/ChecklistManager.dart' ;
57import 'package:note_app/screen/ChecklistPage.dart' ;
68import 'package:note_app/screen/PlaintextPage.dart' ;
@@ -41,7 +43,9 @@ class _NoteTileState extends State<NoteTile> {
4143 String title = note.title == '' ? 'New note' : note.title;
4244 return ListTile (
4345 onTap: _onTap,
46+ onLongPress: _onLongPress,
4447 leading: icon,
48+ trailing: note.pinned ? Icon (Icons .push_pin_rounded) : null ,
4549 title: Text (title),
4650 minVerticalPadding: 20 ,
4751 horizontalTitleGap: 10 ,
@@ -60,4 +64,17 @@ class _NoteTileState extends State<NoteTile> {
6064 }
6165 Navigator .push (context, MaterialPageRoute (builder: (context) => notePage));
6266 }
67+
68+ void _onLongPress () {
69+ Note note = NotesList ().getNoteWithID (widget.noteID);
70+ if (note is Plaintext ) {
71+ Plaintext toggled = Plaintext (widget.noteID,
72+ title: note.title, content: note.content, pinned: ! note.pinned);
73+ NotesList ().togglePin (toggled);
74+ } else if (note is Checklist ) {
75+ Checklist toggled = Checklist (widget.noteID,
76+ title: note.title, chContent: note.chContent, pinned: ! note.pinned);
77+ NotesList ().togglePin (toggled);
78+ }
79+ }
6380}
0 commit comments