提交 6ac80678 authored 作者: yueweilu's avatar yueweilu

阅读页 笔记删除

上级 57e655c8
...@@ -50,13 +50,21 @@ class NoteController extends GetxController { ...@@ -50,13 +50,21 @@ class NoteController extends GetxController {
update(); update();
} }
void delNotes({required String notesId,required String bookId}) async { void delNotes({required NoteModel noteModel,required String bookId}) async {
final result = await MineAPI.delNotes(notesId: notesId, bookId: bookId); final result = await MineAPI.delNotes(notesId: noteModel.notesId.toString(), bookId: bookId);
if (result){ if (result){
Toast.show('删除笔记成功'); Toast.show('删除笔记成功');
onRefresh(); notes.remove(noteModel);
} }
update();
} }
// void delNotes({required String notesId,required String bookId}) async {
// final result = await MineAPI.delNotes(notesId: notesId, bookId: bookId);
// if (result){
// Toast.show('删除笔记成功');
// onRefresh();
// }
// }
// 播放音频 // 播放音频
void playAudio(MediaModel mediaModel){ void playAudio(MediaModel mediaModel){
......
...@@ -103,11 +103,21 @@ class _ReadNotePageState extends State<ReadNotePage> { ...@@ -103,11 +103,21 @@ class _ReadNotePageState extends State<ReadNotePage> {
NoteModel model = controller.notes[index]; NoteModel model = controller.notes[index];
// 划线 // 划线
if(model.types == 1){ if(model.types == 1){
return BuildLine(model: model,); return BuildLine(
model: model,
onTapDel: (){
controller.delNotes(noteModel: model, bookId:widget.bookDetailModel.bookId.toString());
},
);
} }
// 高亮 // 高亮
else if(model.types == 2){ else if(model.types == 2){
return BuildHigh(model: model,); return BuildHigh(
model: model,
onTapDel: (){
controller.delNotes(noteModel: model, bookId:widget.bookDetailModel.bookId.toString());
},
);
} }
// 笔记 // 笔记
else if(model.types == 3){ else if(model.types == 3){
...@@ -117,7 +127,10 @@ class _ReadNotePageState extends State<ReadNotePage> { ...@@ -117,7 +127,10 @@ class _ReadNotePageState extends State<ReadNotePage> {
controller.playAudio(mediaModel); controller.playAudio(mediaModel);
}, },
onTapDel: (){ onTapDel: (){
controller.delNotes(notesId: model.notesId.toString(), bookId:widget.bookDetailModel.bookId.toString()); controller.delNotes(noteModel: model, bookId:widget.bookDetailModel.bookId.toString());
},
onTapEdit: (){
context.pushNamed(Routes.editNote,extra: model,queryParameters: {'book_id':widget.bookDetailModel.bookId});
}, },
); );
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论