Skip to content

Commit

Permalink
Merge pull request #112 from enrique-lozano/feat/delete-tag
Browse files Browse the repository at this point in the history
Add missing delete tag action in the UI
  • Loading branch information
enrique-lozano authored Feb 2, 2024
2 parents 8141656 + 92336a4 commit 3a31f5b
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions lib/app/tags/tag_form_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:monekin/core/database/app_db.dart';
import 'package:monekin/core/database/services/tags/tags_service.dart';
import 'package:monekin/core/models/tags/tag.dart';
import 'package:monekin/core/presentation/widgets/color_picker.dart';
import 'package:monekin/core/presentation/widgets/confirm_dialog.dart';
import 'package:monekin/core/presentation/widgets/persistent_footer_button.dart';
import 'package:monekin/core/utils/color_utils.dart';
import 'package:monekin/core/utils/constants.dart';
Expand Down Expand Up @@ -89,8 +90,40 @@ class _TagFormPageState extends State<TagFormPage> {
final t = Translations.of(context);

return Scaffold(
appBar:
AppBar(title: Text(widget.tag != null ? t.tags.edit : t.tags.add)),
appBar: AppBar(
title: Text(widget.tag != null ? t.tags.edit : t.tags.add),
actions: [
if (widget.tag != null)
IconButton(
onPressed: () {
final scaffold = ScaffoldMessenger.of(context);

confirmDialog(
context,
dialogTitle: t.tags.delete_warning_header,
contentParagraphs: [Text(t.tags.delete_warning_message)],
confirmationText: t.general.continue_text,
showCancelButton: true,
icon: Icons.delete,
).then(
(isConfirmed) {
if (isConfirmed != true) return;

TagService.instance.deleteTag(widget.tag!.id).then((value) {
Navigator.pop(context);

scaffold.showSnackBar(
SnackBar(content: Text(t.tags.delete_success)));
}).catchError((err) {
scaffold.showSnackBar(SnackBar(content: Text('$err')));
});
},
);
},
icon: const Icon(Icons.delete),
)
],
),
persistentFooterButtons: [
PersistentFooterButton(
child: FilledButton.icon(
Expand Down

0 comments on commit 3a31f5b

Please sign in to comment.