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