Skip to content

Commit

Permalink
chore: in-between selection for batch download page
Browse files Browse the repository at this point in the history
(by long pressing the item)
  • Loading branch information
MSOB7YY committed Nov 30, 2023
1 parent c818f31 commit 7026a1e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/youtube/pages/yt_playlist_download_subpage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,25 @@ class _YTPlaylistDownloadPageState extends State<YTPlaylistDownloadPage> {
))
: const BoxDecoration(),
onTap: () => _onItemTap(id),
onLongPress: () {
if (_selectedList.isEmpty) return;
int? latestIndex;
for (int i = widget.ids.length - 1; i >= 0; i--) {
final item = widget.ids[i];
if (_selectedList.contains(item.id)) {
latestIndex = i;
break;
}
}
if (latestIndex != null && index > latestIndex) {
final selectedRange = widget.ids.getRange(latestIndex + 1, index + 1);
selectedRange.toList().loop((e, index) {
if (!_selectedList.contains(e.id)) _selectedList.add(e.id);
});
} else {
_onItemTap(id);
}
},
child: Stack(
children: [
Row(
Expand Down

0 comments on commit 7026a1e

Please sign in to comment.