From b37aa9ba9a42b385df283d1837e08a287e1c50ed Mon Sep 17 00:00:00 2001 From: Phan An Date: Tue, 23 Jul 2024 22:53:11 +0200 Subject: [PATCH] feat: allow swipe right to queue --- lib/ui/widgets/sliver_playable_list.dart | 33 +++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/lib/ui/widgets/sliver_playable_list.dart b/lib/ui/widgets/sliver_playable_list.dart index b05c7b8..62c65ac 100644 --- a/lib/ui/widgets/sliver_playable_list.dart +++ b/lib/ui/widgets/sliver_playable_list.dart @@ -1,7 +1,10 @@ import 'package:app/constants/constants.dart'; +import 'package:app/main.dart'; import 'package:app/models/models.dart'; import 'package:app/ui/widgets/widgets.dart'; import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:lucide_icons/lucide_icons.dart'; class SliverPlayableList extends StatelessWidget { final List playables; @@ -28,11 +31,35 @@ class SliverPlayableList extends StatelessWidget { listContext: listContext, ) : Dismissible( - direction: DismissDirection.endToStart, - onDismissed: (_) => onDismissed?.call(playables[index]), + direction: DismissDirection.horizontal, + confirmDismiss: (direction) async { + if (direction == DismissDirection.endToStart) { + onDismissed?.call(playables[index]); + return true; + } + + await audioHandler.queueAfterCurrent(playables[index]); + + showOverlay( + context, + icon: CupertinoIcons.arrow_right_circle_fill, + caption: 'Queued', + message: 'To be played next.', + ); + + return false; + }, background: Container( + alignment: AlignmentDirectional.centerStart, + color: Colors.green, + child: Padding( + padding: const EdgeInsets.only(left: 28), + child: const Icon(LucideIcons.listPlus), + ), + ), + secondaryBackground: Container( alignment: AlignmentDirectional.centerEnd, - color: AppColors.highlightAccent, + color: AppColors.red, child: Padding( padding: const EdgeInsets.only(right: 28), child: dismissIcon,