feat(flutter/player): mini PlayerBar in shell + tap-to-play wiring
PlayerBar reads playbackState + mediaItem streams; hidden when no queue. Home track-row tap, album play button, album track tap, artist play button (shuffle) all route to playerActions.playTracks. Token + baseUrl forwarded to the audio handler before each new queue.
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../api/endpoints/likes.dart';
|
||||
import '../likes/like_button.dart';
|
||||
import '../player/player_provider.dart';
|
||||
import '../theme/theme_extension.dart';
|
||||
import 'library_providers.dart';
|
||||
import 'widgets/track_row.dart';
|
||||
@@ -42,7 +43,7 @@ class AlbumDetailScreen extends ConsumerWidget {
|
||||
decoration: BoxDecoration(color: fs.accent, shape: BoxShape.circle),
|
||||
child: IconButton(
|
||||
icon: Icon(Icons.play_arrow, color: fs.parchment),
|
||||
onPressed: () { /* play wired in Task 18 */ },
|
||||
onPressed: () => ref.read(playerActionsProvider).playTracks(r.tracks),
|
||||
),
|
||||
),
|
||||
LikeButton(kind: LikeKind.album, id: r.album.id, size: 28),
|
||||
@@ -51,7 +52,10 @@ class AlbumDetailScreen extends ConsumerWidget {
|
||||
for (final t in r.tracks)
|
||||
TrackRow(
|
||||
track: t,
|
||||
onTap: () { /* play wired in Task 18 */ },
|
||||
onTap: () {
|
||||
final start = r.tracks.indexOf(t);
|
||||
ref.read(playerActionsProvider).playTracks(r.tracks, initialIndex: start);
|
||||
},
|
||||
trailing: LikeButton(kind: LikeKind.track, id: t.id),
|
||||
),
|
||||
]),
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:go_router/go_router.dart';
|
||||
import '../api/endpoints/likes.dart';
|
||||
import '../likes/like_button.dart';
|
||||
import '../models/album.dart';
|
||||
import '../player/player_provider.dart';
|
||||
import '../theme/theme_extension.dart';
|
||||
import 'library_providers.dart';
|
||||
import 'widgets/album_card.dart';
|
||||
@@ -49,7 +50,12 @@ class ArtistDetailScreen extends ConsumerWidget {
|
||||
decoration: BoxDecoration(color: fs.accent, shape: BoxShape.circle),
|
||||
child: IconButton(
|
||||
icon: Icon(Icons.play_arrow, color: fs.parchment),
|
||||
onPressed: () { /* play wired in Task 18 */ },
|
||||
onPressed: () async {
|
||||
final tracks = await ref.read(artistTracksProvider(id).future);
|
||||
if (tracks.isEmpty) return;
|
||||
final shuffled = [...tracks]..shuffle();
|
||||
ref.read(playerActionsProvider).playTracks(shuffled);
|
||||
},
|
||||
),
|
||||
),
|
||||
LikeButton(kind: LikeKind.artist, id: a.id, size: 28),
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:go_router/go_router.dart';
|
||||
import '../models/album.dart';
|
||||
import '../models/artist.dart';
|
||||
import '../models/track.dart';
|
||||
import '../player/player_provider.dart';
|
||||
import '../theme/theme_extension.dart';
|
||||
import 'library_providers.dart';
|
||||
import 'widgets/album_card.dart';
|
||||
@@ -66,7 +67,10 @@ class HomeScreen extends ConsumerWidget {
|
||||
for (final t in tracks)
|
||||
SizedBox(
|
||||
width: 280,
|
||||
child: TrackRow(track: t, onTap: () { /* play wired in Task 18 */ }),
|
||||
child: TrackRow(
|
||||
track: t,
|
||||
onTap: () => ref.read(playerActionsProvider).playTracks([t]),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user