🐛 Fix source track details
This commit is contained in:
parent
6509cd2511
commit
e30e7a5c24
@ -1,15 +1,19 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rhythm_box/services/server/active_sourced_track.dart';
|
||||
import 'package:rhythm_box/services/sourced_track/sourced_track.dart';
|
||||
import 'package:rhythm_box/widgets/player/track_source_details.dart';
|
||||
|
||||
class SourceDetailsPopup extends StatelessWidget {
|
||||
const SourceDetailsPopup({super.key});
|
||||
|
||||
Future<SourcedTrack?> _pullActiveTrack() async {
|
||||
final ActiveSourcedTrackProvider activeSourcedTrack = Get.find();
|
||||
return activeSourcedTrack.state.value;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ActiveSourcedTrackProvider activeTrack = Get.find();
|
||||
|
||||
return SizedBox(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@ -20,8 +24,19 @@ class SourceDetailsPopup extends StatelessWidget {
|
||||
).paddingOnly(left: 24, right: 24, top: 32, bottom: 16),
|
||||
Expanded(
|
||||
child: Obx(
|
||||
() => TrackSourceDetails(
|
||||
track: activeTrack.state.value!,
|
||||
() => FutureBuilder(
|
||||
future: _pullActiveTrack(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return TrackSourceDetails(
|
||||
track: snapshot.data!,
|
||||
);
|
||||
}
|
||||
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
},
|
||||
).paddingSymmetric(horizontal: 24),
|
||||
),
|
||||
)
|
||||
|
@ -311,8 +311,10 @@ class _PlayerScreenState extends State<PlayerScreen> {
|
||||
const Gap(20),
|
||||
SizedBox(
|
||||
height: 40,
|
||||
child: ListView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Wrap(
|
||||
alignment: WrapAlignment.center,
|
||||
spacing: 4,
|
||||
runSpacing: 4,
|
||||
children: [
|
||||
TextButton.icon(
|
||||
icon: const Icon(Icons.queue_music),
|
||||
|
@ -4,10 +4,9 @@ import 'package:rhythm_box/services/sourced_track/sourced_track.dart';
|
||||
import 'package:rhythm_box/services/sourced_track/sources/netease.dart';
|
||||
import 'package:rhythm_box/services/sourced_track/sources/piped.dart';
|
||||
import 'package:rhythm_box/services/sourced_track/sources/youtube.dart';
|
||||
import 'package:spotify/spotify.dart';
|
||||
|
||||
class TrackSourceDetails extends StatelessWidget {
|
||||
final Track track;
|
||||
final SourcedTrack track;
|
||||
|
||||
const TrackSourceDetails({super.key, required this.track});
|
||||
|
||||
@ -25,14 +24,11 @@ class TrackSourceDetails extends StatelessWidget {
|
||||
'Title': track.name!,
|
||||
'Artist': track.artists?.map((x) => x.name).join(', '),
|
||||
'Album': track.album!.name!,
|
||||
'Duration': (track is SourcedTrack
|
||||
? (track as SourcedTrack).sourceInfo.duration
|
||||
: track.duration!)
|
||||
.toHumanReadableString(),
|
||||
'Duration': track.sourceInfo.duration.toHumanReadableString(),
|
||||
if (track.album!.releaseDate != null)
|
||||
'Released': track.album!.releaseDate,
|
||||
'Popularity': track.popularity?.toString() ?? '0',
|
||||
'Provider': sourceInfoToLabelMap[track.runtimeType],
|
||||
'Provider': sourceInfoToLabelMap[track.sourceInfo.runtimeType],
|
||||
};
|
||||
|
||||
return Table(
|
||||
|
Loading…
Reference in New Issue
Block a user