diff --git a/lib/features/notes/presentation/widgets/notes_close_button.dart b/lib/features/notes/presentation/widgets/notes_close_button.dart index 6075ab73..efd983d5 100644 --- a/lib/features/notes/presentation/widgets/notes_close_button.dart +++ b/lib/features/notes/presentation/widgets/notes_close_button.dart @@ -1,12 +1,12 @@ import 'dart:convert'; -import 'package:dairy_app/core/utils/note_helper.dart'; import 'package:dairy_app/features/notes/presentation/bloc/notes/notes_bloc.dart'; +import 'package:dairy_app/features/notes/presentation/mixins/note_helper_mixin.dart'; import 'package:dairy_app/features/notes/presentation/widgets/show_notes_close_dialog.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -class NotesCloseButton extends StatelessWidget { +class NotesCloseButton extends StatelessWidget with NoteHelperMixin { final Function() onNotesClosed; const NotesCloseButton({Key? key, required this.onNotesClosed}) @@ -39,15 +39,15 @@ class NotesCloseButton extends StatelessWidget { // calculate note hash String noteBodyWithAssetPathsRemoved = - NoteHelper.replaceAssetPathsByAssetNames(_body); + replaceAssetPathsByAssetNames(_body); - String _hash = NoteHelper.generateHash(state.title! + + String _hash = generateHash(state.title! + state.createdAt!.millisecondsSinceEpoch.toString() + noteBodyWithAssetPathsRemoved + state.tags!.join(",")); // Compare old and new hash - if (NoteHelper.areNotesIdentical(state, _hash)) { + if (areNotesIdentical(state, _hash)) { onNotesClosed(); } else { bool? result = await showCloseDialog(context);