mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-10-21 23:11:45 +02:00
Expose playlist, play-next and queue actions across Library search and album selections, including selected artist albums. Sort playlists, keep long selection toolbars scrollable, separate file operations in metadata menus, and show related local songs without online playback.
71 lines
2.4 KiB
Dart
71 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:spotiflac_android/l10n/l10n.dart';
|
|
import 'package:spotiflac_android/models/unified_library_item.dart';
|
|
import 'package:spotiflac_android/providers/music_player_provider.dart';
|
|
import 'package:spotiflac_android/widgets/playlist_picker_sheet.dart';
|
|
import 'package:spotiflac_android/widgets/selection_action_button.dart';
|
|
|
|
/// Collection actions stay separate from actions that modify audio files.
|
|
class LibrarySelectionPlaybackActions extends ConsumerWidget {
|
|
const LibrarySelectionPlaybackActions({
|
|
super.key,
|
|
required this.items,
|
|
required this.onClose,
|
|
});
|
|
|
|
final List<UnifiedLibraryItem> items;
|
|
final VoidCallback onClose;
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final colors = Theme.of(context).colorScheme;
|
|
final actions = <Widget>[
|
|
SelectionActionButton(
|
|
icon: Icons.playlist_add,
|
|
label: context.l10n.collectionAddToPlaylist,
|
|
colorScheme: colors,
|
|
onPressed: items.isEmpty
|
|
? null
|
|
: () {
|
|
final tracks = items.map((item) => item.toTrack()).toList();
|
|
final navigatorContext = Navigator.of(
|
|
context,
|
|
rootNavigator: true,
|
|
).context;
|
|
onClose();
|
|
showAddTracksToPlaylistSheet(navigatorContext, ref, tracks);
|
|
},
|
|
),
|
|
for (final next in [true, false])
|
|
SelectionActionButton(
|
|
icon: next ? Icons.playlist_play : Icons.queue_music,
|
|
label: next
|
|
? context.l10n.trackPlayNext
|
|
: context.l10n.trackAddToQueue,
|
|
colorScheme: colors,
|
|
onPressed: items.isEmpty
|
|
? null
|
|
: () async {
|
|
final controller = ref.read(musicPlayerControllerProvider);
|
|
await controller.enqueueLibraryItems(items, playNext: next);
|
|
if (context.mounted) onClose();
|
|
},
|
|
),
|
|
];
|
|
return LayoutBuilder(
|
|
builder: (context, constraints) => Padding(
|
|
padding: const EdgeInsets.only(bottom: 12),
|
|
child: Wrap(
|
|
spacing: 8,
|
|
runSpacing: 8,
|
|
children: [
|
|
for (final action in actions)
|
|
SizedBox(width: (constraints.maxWidth - 8) / 2, child: action),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|