Skip to content

Commit

Permalink
feat: allow swipe right to queue
Browse files Browse the repository at this point in the history
  • Loading branch information
phanan committed Jul 23, 2024
1 parent ea29918 commit b37aa9b
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions lib/ui/widgets/sliver_playable_list.dart
Original file line number Diff line number Diff line change
@@ -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<Playable> playables;
Expand All @@ -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,
Expand Down

0 comments on commit b37aa9b

Please sign in to comment.