Skip to content

Commit 2505808

Browse files
committed
feat: Ubah widget yang digunakan untuk icon delete di halaman sync_page.dart
1 parent c9a0ce5 commit 2505808

File tree

1 file changed

+59
-44
lines changed

1 file changed

+59
-44
lines changed

lib/feature/presentation/page/sync/sync_page.dart

Lines changed: 59 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class _SyncPageState extends State<SyncPage> {
7272
listener: (context, state) {
7373
if (state is! LoadingSyncManualState) {
7474
// untuk menutup dialog loading
75-
Navigator.pop(context);
75+
context.pop();
7676
}
7777

7878
if (state is FailureSyncManualState) {
@@ -484,51 +484,66 @@ class _SyncPageState extends State<SyncPage> {
484484
}
485485

486486
Widget buildWidgetIconDelete(int? id, double heightImage) {
487-
return Positioned(
488-
right: -4,
489-
top: heightImage - 4,
490-
child: IconButton(
491-
onPressed: () {
492-
if (id == null) {
493-
widgetHelper.showSnackBar(context, 'invalid_id_track'.tr());
494-
}
487+
return Align(
488+
alignment: Alignment.center,
489+
child: Padding(
490+
padding: EdgeInsets.only(top: heightImage),
491+
child: Row(
492+
mainAxisSize: MainAxisSize.max,
493+
mainAxisAlignment: MainAxisAlignment.end,
494+
children: [
495+
Material(
496+
borderRadius: BorderRadius.circular(999),
497+
child: InkWell(
498+
borderRadius: BorderRadius.circular(999),
499+
onTap: () {
500+
if (id == null) {
501+
widgetHelper.showSnackBar(context, 'invalid_id_track'.tr());
502+
}
495503

496-
showDialog<bool?>(
497-
context: context,
498-
builder: (context) {
499-
return AlertDialog(
500-
title: Text('title_delete_track'.tr()),
501-
content: Text('content_delete_track'.tr()),
502-
actions: [
503-
TextButton(
504-
onPressed: () => Navigator.pop(context, false),
505-
child: Text('cancel'.tr()),
506-
),
507-
TextButton(
508-
onPressed: () => Navigator.pop(context, true),
509-
style: TextButton.styleFrom(
510-
foregroundColor: Colors.red,
511-
),
512-
child: Text('delete'.tr()),
504+
showDialog<bool?>(
505+
context: context,
506+
builder: (context) {
507+
return AlertDialog(
508+
title: Text('title_delete_track'.tr()),
509+
content: Text('content_delete_track'.tr()),
510+
actions: [
511+
TextButton(
512+
onPressed: () => context.pop(false),
513+
child: Text('cancel'.tr()),
514+
),
515+
TextButton(
516+
onPressed: () => context.pop(true),
517+
style: TextButton.styleFrom(
518+
foregroundColor: Colors.red,
519+
),
520+
child: Text('delete'.tr()),
521+
),
522+
],
523+
);
524+
},
525+
).then((value) async {
526+
if (value != null && value) {
527+
await trackDao.deleteTrackById(id!);
528+
listTracks.removeWhere((element) => element.id != null && element.id == id);
529+
setState(() {});
530+
if (mounted) {
531+
widgetHelper.showSnackBar(context, 'track_data_deleted_successfully'.tr());
532+
}
533+
}
534+
});
535+
},
536+
child: const Padding(
537+
padding: EdgeInsets.all(8.0),
538+
child: FaIcon(
539+
FontAwesomeIcons.trashCan,
540+
color: Colors.red,
541+
size: 14,
513542
),
514-
],
515-
);
516-
},
517-
).then((value) async {
518-
if (value != null && value) {
519-
await trackDao.deleteTrackById(id!);
520-
listTracks.removeWhere((element) => element.id != null && element.id == id);
521-
setState(() {});
522-
if (mounted) {
523-
widgetHelper.showSnackBar(context, 'track_data_deleted_successfully'.tr());
524-
}
525-
}
526-
});
527-
},
528-
icon: const FaIcon(
529-
FontAwesomeIcons.trashCan,
530-
size: 14,
531-
color: Colors.red,
543+
),
544+
),
545+
),
546+
],
532547
),
533548
),
534549
);

0 commit comments

Comments
 (0)