2023-09-26 00:06:59 +00:00
|
|
|
import 'package:audio_service/audio_service.dart';
|
2023-07-29 02:17:26 +00:00
|
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:fluttericon/octicons_icons.dart';
|
|
|
|
import 'package:freezer/api/deezer.dart';
|
|
|
|
import 'package:freezer/api/download.dart';
|
|
|
|
import 'package:freezer/api/player.dart';
|
|
|
|
import 'package:freezer/translations.i18n.dart';
|
|
|
|
|
|
|
|
import '../api/definitions.dart';
|
|
|
|
import 'cached_image.dart';
|
|
|
|
|
|
|
|
import 'dart:async';
|
|
|
|
|
2023-09-26 00:06:59 +00:00
|
|
|
class TrackTile extends StatelessWidget {
|
2023-07-29 02:17:26 +00:00
|
|
|
final Track track;
|
|
|
|
final void Function()? onTap;
|
|
|
|
final void Function()? onHold;
|
|
|
|
final Widget? trailing;
|
|
|
|
|
2023-10-12 22:09:37 +00:00
|
|
|
const TrackTile(this.track,
|
|
|
|
{this.onTap, this.onHold, this.trailing, Key? key})
|
2023-07-29 02:17:26 +00:00
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ListTile(
|
2023-09-26 00:06:59 +00:00
|
|
|
title: StreamBuilder<MediaItem?>(
|
|
|
|
stream: audioHandler.mediaItem,
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
final bool isHighlighted;
|
|
|
|
final mediaItem = snapshot.data;
|
2023-10-12 22:09:37 +00:00
|
|
|
if (!snapshot.hasData || snapshot.data == null) {
|
2023-09-26 00:06:59 +00:00
|
|
|
isHighlighted = false;
|
2023-10-12 22:09:37 +00:00
|
|
|
} else {
|
2023-09-26 00:06:59 +00:00
|
|
|
isHighlighted = mediaItem!.id == track.id;
|
2023-10-12 22:09:37 +00:00
|
|
|
}
|
2023-09-26 00:06:59 +00:00
|
|
|
return Text(
|
|
|
|
track.title!,
|
|
|
|
maxLines: 1,
|
|
|
|
overflow: TextOverflow.clip,
|
|
|
|
style: TextStyle(
|
|
|
|
color: isHighlighted
|
|
|
|
? Theme.of(context).colorScheme.primary
|
|
|
|
: null),
|
|
|
|
);
|
|
|
|
}),
|
2023-07-29 02:17:26 +00:00
|
|
|
subtitle: Text(
|
2023-09-26 00:06:59 +00:00
|
|
|
track.artistString,
|
2023-07-29 02:17:26 +00:00
|
|
|
maxLines: 1,
|
|
|
|
),
|
|
|
|
leading: CachedImage(
|
2023-09-26 00:06:59 +00:00
|
|
|
url: track.albumArt!.thumb,
|
|
|
|
width: 48.0,
|
|
|
|
height: 48.0,
|
2023-07-29 02:17:26 +00:00
|
|
|
),
|
2023-09-26 00:06:59 +00:00
|
|
|
onTap: onTap,
|
|
|
|
onLongPress: onHold,
|
2023-07-29 02:17:26 +00:00
|
|
|
trailing: Row(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
2023-09-26 00:06:59 +00:00
|
|
|
FutureBuilder<bool>(
|
|
|
|
future: downloadManager.checkOffline(track: track),
|
|
|
|
builder: (context, snapshot) {
|
2023-10-12 22:09:37 +00:00
|
|
|
if (snapshot.data == true) {
|
2023-09-26 00:06:59 +00:00
|
|
|
return const Padding(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 2.0),
|
|
|
|
child: Icon(
|
|
|
|
Octicons.primitive_dot,
|
|
|
|
color: Colors.green,
|
|
|
|
size: 12.0,
|
|
|
|
),
|
|
|
|
);
|
2023-10-12 22:09:37 +00:00
|
|
|
}
|
2023-09-26 00:06:59 +00:00
|
|
|
return const SizedBox.shrink();
|
|
|
|
}),
|
|
|
|
if (track.explicit ?? false)
|
|
|
|
const Padding(
|
2023-07-29 02:17:26 +00:00
|
|
|
padding: EdgeInsets.symmetric(horizontal: 2.0),
|
|
|
|
child: Text(
|
|
|
|
'E',
|
|
|
|
style: TextStyle(color: Colors.red),
|
|
|
|
),
|
|
|
|
),
|
2023-09-26 00:06:59 +00:00
|
|
|
SizedBox(
|
2023-07-29 02:17:26 +00:00
|
|
|
width: 42.0,
|
|
|
|
child: Text(
|
2023-09-26 00:06:59 +00:00
|
|
|
track.durationString,
|
2023-07-29 02:17:26 +00:00
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
|
|
|
),
|
2023-09-26 00:06:59 +00:00
|
|
|
if (trailing != null) trailing!
|
2023-07-29 02:17:26 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class AlbumTile extends StatelessWidget {
|
|
|
|
final Album? album;
|
|
|
|
final void Function()? onTap;
|
|
|
|
final void Function()? onHold;
|
|
|
|
final Widget? trailing;
|
|
|
|
|
2023-10-12 22:09:37 +00:00
|
|
|
const AlbumTile(this.album,
|
|
|
|
{super.key, this.onTap, this.onHold, this.trailing});
|
2023-07-29 02:17:26 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ListTile(
|
|
|
|
title: Text(
|
|
|
|
album!.title!,
|
|
|
|
maxLines: 1,
|
|
|
|
),
|
|
|
|
subtitle: Text(
|
|
|
|
album!.artistString,
|
|
|
|
maxLines: 1,
|
|
|
|
),
|
|
|
|
leading: CachedImage(
|
|
|
|
url: album!.art!.thumb,
|
|
|
|
width: 48,
|
|
|
|
),
|
|
|
|
onTap: onTap,
|
|
|
|
onLongPress: onHold,
|
|
|
|
trailing: trailing,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ArtistTile extends StatelessWidget {
|
|
|
|
final Artist? artist;
|
|
|
|
final void Function()? onTap;
|
|
|
|
final void Function()? onHold;
|
|
|
|
|
2023-10-12 22:09:37 +00:00
|
|
|
const ArtistTile(this.artist, {super.key, this.onTap, this.onHold});
|
2023-07-29 02:17:26 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-09-26 00:06:59 +00:00
|
|
|
return InkWell(
|
2023-10-12 22:09:37 +00:00
|
|
|
borderRadius: const BorderRadius.all(Radius.circular(4.0)),
|
2023-09-26 00:06:59 +00:00
|
|
|
onTap: onTap,
|
|
|
|
onLongPress: onHold,
|
|
|
|
child: Column(mainAxisSize: MainAxisSize.min, children: <Widget>[
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
CachedImage(
|
|
|
|
url: artist!.picture!.thumb,
|
|
|
|
circular: true,
|
|
|
|
width: 100,
|
|
|
|
),
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
Text(
|
|
|
|
artist!.name!,
|
|
|
|
maxLines: 1,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: const TextStyle(fontSize: 14.0),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
]));
|
2023-07-29 02:17:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class PlaylistTile extends StatelessWidget {
|
|
|
|
final Playlist? playlist;
|
|
|
|
final void Function()? onTap;
|
|
|
|
final void Function()? onHold;
|
|
|
|
final Widget? trailing;
|
|
|
|
|
2023-10-12 22:09:37 +00:00
|
|
|
const PlaylistTile(this.playlist,
|
|
|
|
{super.key, this.onHold, this.onTap, this.trailing});
|
2023-07-29 02:17:26 +00:00
|
|
|
|
|
|
|
String? get subtitle {
|
|
|
|
if (playlist!.user == null ||
|
|
|
|
playlist!.user!.name == null ||
|
|
|
|
playlist!.user!.name == '' ||
|
|
|
|
playlist!.user!.id == deezerAPI.userId) {
|
|
|
|
if (playlist!.trackCount == null) return '';
|
2023-10-12 22:09:37 +00:00
|
|
|
return '${playlist!.trackCount} ${'Tracks'.i18n}';
|
2023-07-29 02:17:26 +00:00
|
|
|
}
|
|
|
|
return playlist!.user!.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ListTile(
|
|
|
|
title: Text(
|
|
|
|
playlist!.title!,
|
|
|
|
maxLines: 1,
|
|
|
|
),
|
|
|
|
subtitle: Text(
|
|
|
|
subtitle!,
|
|
|
|
maxLines: 1,
|
|
|
|
),
|
|
|
|
leading: CachedImage(
|
|
|
|
url: playlist!.image!.thumb,
|
|
|
|
width: 48,
|
|
|
|
),
|
|
|
|
onTap: onTap,
|
|
|
|
onLongPress: onHold,
|
|
|
|
trailing: trailing,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ArtistHorizontalTile extends StatelessWidget {
|
|
|
|
final Artist? artist;
|
|
|
|
final void Function()? onTap;
|
|
|
|
final void Function()? onHold;
|
|
|
|
final Widget? trailing;
|
|
|
|
|
2023-10-12 22:09:37 +00:00
|
|
|
const ArtistHorizontalTile(this.artist,
|
|
|
|
{super.key, this.onHold, this.onTap, this.trailing});
|
2023-07-29 02:17:26 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Padding(
|
2023-10-12 22:09:37 +00:00
|
|
|
padding: const EdgeInsets.symmetric(vertical: 2.0),
|
2023-07-29 02:17:26 +00:00
|
|
|
child: ListTile(
|
|
|
|
title: Text(
|
|
|
|
artist!.name!,
|
|
|
|
maxLines: 1,
|
|
|
|
),
|
|
|
|
leading: CircleAvatar(
|
|
|
|
backgroundImage:
|
2023-09-26 00:06:59 +00:00
|
|
|
CachedNetworkImageProvider(artist!.picture!.thumb)),
|
2023-07-29 02:17:26 +00:00
|
|
|
onTap: onTap,
|
|
|
|
onLongPress: onHold,
|
|
|
|
trailing: trailing,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class PlaylistCardTile extends StatelessWidget {
|
|
|
|
final Playlist? playlist;
|
|
|
|
final Function? onTap;
|
|
|
|
final Function? onHold;
|
2023-10-12 22:09:37 +00:00
|
|
|
const PlaylistCardTile(this.playlist, {super.key, this.onTap, this.onHold});
|
2023-07-29 02:17:26 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-09-26 00:06:59 +00:00
|
|
|
return SizedBox(
|
2023-07-29 02:17:26 +00:00
|
|
|
height: 180.0,
|
|
|
|
child: InkWell(
|
|
|
|
onTap: onTap as void Function()?,
|
|
|
|
onLongPress: onHold as void Function()?,
|
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Padding(
|
2023-10-12 22:09:37 +00:00
|
|
|
padding: const EdgeInsets.all(8.0),
|
2023-09-26 00:06:59 +00:00
|
|
|
child: Stack(
|
|
|
|
children: [
|
|
|
|
CachedImage(
|
|
|
|
url: playlist!.image!.thumb,
|
|
|
|
width: 128.0,
|
|
|
|
height: 128.0,
|
|
|
|
rounded: true,
|
|
|
|
),
|
|
|
|
Positioned(
|
|
|
|
bottom: 8.0,
|
|
|
|
left: 8.0,
|
|
|
|
child: PlayItemButton(
|
|
|
|
onTap: () async {
|
|
|
|
final Playlist fullPlaylist =
|
|
|
|
await deezerAPI.fullPlaylist(playlist!.id);
|
|
|
|
await playerHelper.playFromPlaylist(fullPlaylist);
|
|
|
|
},
|
|
|
|
))
|
|
|
|
],
|
2023-07-29 02:17:26 +00:00
|
|
|
),
|
|
|
|
),
|
2023-09-26 00:06:59 +00:00
|
|
|
const SizedBox(height: 2.0),
|
|
|
|
SizedBox(
|
2023-07-29 02:17:26 +00:00
|
|
|
width: 144,
|
|
|
|
child: Text(
|
|
|
|
playlist!.title!,
|
|
|
|
maxLines: 1,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
2023-10-12 22:09:37 +00:00
|
|
|
style: const TextStyle(fontSize: 14.0),
|
2023-07-29 02:17:26 +00:00
|
|
|
),
|
|
|
|
),
|
2023-09-26 00:06:59 +00:00
|
|
|
const SizedBox(
|
2023-07-29 02:17:26 +00:00
|
|
|
height: 4.0,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-26 00:06:59 +00:00
|
|
|
class PlayItemButton extends StatefulWidget {
|
|
|
|
final FutureOr<void> Function() onTap;
|
|
|
|
final double size;
|
|
|
|
const PlayItemButton({required this.onTap, this.size = 32.0, Key? key})
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<PlayItemButton> createState() => _PlayItemButtonState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _PlayItemButtonState extends State<PlayItemButton> {
|
|
|
|
final _isLoading = ValueNotifier(false);
|
|
|
|
void _onTap() {
|
|
|
|
final ret = widget.onTap();
|
|
|
|
if (ret is Future) {
|
|
|
|
_isLoading.value = true;
|
|
|
|
ret.whenComplete(() => _isLoading.value = false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
_isLoading.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return SizedBox.square(
|
|
|
|
dimension: widget.size,
|
|
|
|
child: DecoratedBox(
|
2023-10-12 22:09:37 +00:00
|
|
|
decoration:
|
|
|
|
const BoxDecoration(shape: BoxShape.circle, color: Colors.white),
|
2023-09-26 00:06:59 +00:00
|
|
|
child: Center(
|
|
|
|
child: ValueListenableBuilder<bool>(
|
|
|
|
valueListenable: _isLoading,
|
|
|
|
child: InkWell(
|
|
|
|
onTap: _onTap,
|
|
|
|
child: Icon(
|
|
|
|
Icons.play_arrow,
|
|
|
|
color: Colors.black,
|
|
|
|
size: widget.size / 1.5,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
builder: (context, isLoading, child) => isLoading
|
|
|
|
? SizedBox.square(
|
|
|
|
dimension: widget.size / 2,
|
2023-10-12 22:09:37 +00:00
|
|
|
child: const CircularProgressIndicator(
|
2023-09-26 00:06:59 +00:00
|
|
|
strokeWidth: 2.0,
|
|
|
|
color: Colors.black,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: child!),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class SmartTrackListTile extends StatefulWidget {
|
2023-07-29 02:17:26 +00:00
|
|
|
final SmartTrackList? smartTrackList;
|
2023-09-26 00:06:59 +00:00
|
|
|
final FutureOr<void> Function()? onTap;
|
2023-07-29 02:17:26 +00:00
|
|
|
final void Function()? onHold;
|
2023-09-26 00:06:59 +00:00
|
|
|
final double size;
|
|
|
|
|
|
|
|
const SmartTrackListTile(this.smartTrackList,
|
2023-10-12 22:09:37 +00:00
|
|
|
{super.key, this.onHold, this.onTap, this.size = 128.0});
|
2023-09-26 00:06:59 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
State<SmartTrackListTile> createState() => _SmartTrackListTileState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _SmartTrackListTileState extends State<SmartTrackListTile> {
|
|
|
|
final _isLoading = ValueNotifier<bool>(false);
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
_isLoading.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
void _onTap() {
|
|
|
|
final future = widget.onTap?.call();
|
|
|
|
if (future is Future) {
|
|
|
|
_isLoading.value = true;
|
|
|
|
future.whenComplete(() => _isLoading.value = false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget buildTrackTileCover(List<DeezerImageDetails> covers) {
|
|
|
|
if (covers.length == 4) {
|
|
|
|
return ClipRRect(
|
|
|
|
borderRadius: const BorderRadius.all(Radius.circular(4.0)),
|
|
|
|
child: SizedBox.square(
|
|
|
|
dimension: widget.size,
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Row(children: [
|
|
|
|
...[covers[0], covers[1]].map((e) => CachedImage(
|
|
|
|
url: e.thumb,
|
|
|
|
))
|
|
|
|
]),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Row(children: [
|
|
|
|
...[covers[2], covers[3]].map((e) => CachedImage(
|
|
|
|
url: e.thumb,
|
|
|
|
))
|
|
|
|
]),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
// return GridView(
|
|
|
|
// gridDelegate:
|
|
|
|
// SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2),
|
|
|
|
// primary: false,
|
|
|
|
// physics: NeverScrollableScrollPhysics(),
|
|
|
|
// children: [...covers.map((e) => CachedImage(url: e.thumb))],
|
|
|
|
// );
|
|
|
|
}
|
|
|
|
return CachedImage(
|
|
|
|
width: widget.size,
|
|
|
|
height: widget.size,
|
|
|
|
url: covers[0].full,
|
|
|
|
rounded: widget.smartTrackList?.id != 'flow',
|
|
|
|
circular: widget.smartTrackList?.id == 'flow',
|
|
|
|
);
|
|
|
|
}
|
2023-07-29 02:17:26 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return InkWell(
|
2023-09-26 00:06:59 +00:00
|
|
|
onTap: _onTap,
|
|
|
|
onLongPress: widget.onHold,
|
2023-07-29 02:17:26 +00:00
|
|
|
child: Column(
|
2023-09-26 00:06:59 +00:00
|
|
|
mainAxisSize: MainAxisSize.min,
|
2023-07-29 02:17:26 +00:00
|
|
|
children: <Widget>[
|
|
|
|
Padding(
|
2023-10-12 22:09:37 +00:00
|
|
|
padding: const EdgeInsets.all(8.0),
|
2023-09-26 00:06:59 +00:00
|
|
|
child: SizedBox.square(
|
|
|
|
dimension: widget.size,
|
2023-07-29 02:17:26 +00:00
|
|
|
child: Stack(
|
|
|
|
children: [
|
2023-09-26 00:06:59 +00:00
|
|
|
buildTrackTileCover(widget.smartTrackList!.cover!),
|
|
|
|
if (widget.smartTrackList?.id != 'flow')
|
|
|
|
Padding(
|
2023-10-12 22:09:37 +00:00
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
horizontal: 8.0, vertical: 6.0),
|
2023-07-29 02:17:26 +00:00
|
|
|
child: Text(
|
2023-09-26 00:06:59 +00:00
|
|
|
widget.smartTrackList!.title!,
|
|
|
|
maxLines: 1,
|
2023-07-29 02:17:26 +00:00
|
|
|
overflow: TextOverflow.ellipsis,
|
2023-10-12 22:09:37 +00:00
|
|
|
style: const TextStyle(
|
2023-09-26 00:06:59 +00:00
|
|
|
fontSize: 16.0,
|
2023-07-29 02:17:26 +00:00
|
|
|
shadows: [
|
|
|
|
Shadow(
|
|
|
|
offset: Offset(1, 1),
|
|
|
|
blurRadius: 2,
|
|
|
|
color: Colors.black)
|
|
|
|
],
|
|
|
|
color: Colors.white),
|
|
|
|
),
|
|
|
|
),
|
2023-09-26 00:06:59 +00:00
|
|
|
Center(
|
|
|
|
child: SizedBox.square(
|
|
|
|
dimension: 32.0,
|
|
|
|
child: DecoratedBox(
|
2023-10-12 22:09:37 +00:00
|
|
|
decoration: const BoxDecoration(
|
2023-09-26 00:06:59 +00:00
|
|
|
shape: BoxShape.circle, color: Colors.white),
|
|
|
|
child: Center(
|
|
|
|
child: ValueListenableBuilder<bool>(
|
|
|
|
valueListenable: _isLoading,
|
|
|
|
builder: (context, isLoading, _) {
|
2023-10-12 22:09:37 +00:00
|
|
|
if (isLoading) {
|
2023-09-26 00:06:59 +00:00
|
|
|
return const SizedBox.square(
|
|
|
|
dimension: 16.0,
|
|
|
|
child: CircularProgressIndicator(
|
|
|
|
color: Colors.black,
|
|
|
|
strokeWidth: 2.0,
|
|
|
|
));
|
2023-10-12 22:09:37 +00:00
|
|
|
}
|
2023-09-26 00:06:59 +00:00
|
|
|
return const Icon(
|
|
|
|
Icons.play_arrow,
|
|
|
|
color: Colors.black,
|
|
|
|
size: 24.0,
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
))),
|
2023-07-29 02:17:26 +00:00
|
|
|
],
|
2023-09-26 00:06:59 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2023-07-29 02:17:26 +00:00
|
|
|
SizedBox(
|
2023-09-26 00:06:59 +00:00
|
|
|
width: widget.size,
|
2023-07-29 02:17:26 +00:00
|
|
|
child: Text(
|
2023-09-26 00:06:59 +00:00
|
|
|
widget.smartTrackList!.subtitle!,
|
2023-07-29 02:17:26 +00:00
|
|
|
maxLines: 3,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
2023-10-12 22:09:37 +00:00
|
|
|
style: const TextStyle(fontSize: 14.0),
|
2023-07-29 02:17:26 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 8.0)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class AlbumCard extends StatelessWidget {
|
2023-09-26 00:06:59 +00:00
|
|
|
final Album album;
|
|
|
|
final void Function()? onTap;
|
|
|
|
final void Function()? onHold;
|
2023-07-29 02:17:26 +00:00
|
|
|
|
2023-10-12 22:09:37 +00:00
|
|
|
const AlbumCard(this.album, {super.key, this.onTap, this.onHold});
|
2023-07-29 02:17:26 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-09-26 00:06:59 +00:00
|
|
|
return InkWell(
|
|
|
|
onTap: onTap,
|
|
|
|
onLongPress: onHold,
|
2023-07-29 02:17:26 +00:00
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Padding(
|
2023-09-26 00:06:59 +00:00
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
child: Stack(
|
|
|
|
children: [
|
|
|
|
CachedImage(
|
|
|
|
width: 128.0,
|
|
|
|
height: 128.0,
|
2023-10-08 10:53:22 +00:00
|
|
|
url: album.art!.thumb,
|
2023-09-26 00:06:59 +00:00
|
|
|
rounded: true),
|
|
|
|
Positioned(
|
2023-10-12 22:09:37 +00:00
|
|
|
bottom: 8.0,
|
|
|
|
left: 8.0,
|
2023-09-26 00:06:59 +00:00
|
|
|
child: PlayItemButton(
|
|
|
|
onTap: () async {
|
|
|
|
final fullAlbum = await deezerAPI.album(album.id);
|
|
|
|
await playerHelper.playFromAlbum(fullAlbum);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
2023-07-29 02:17:26 +00:00
|
|
|
),
|
2023-09-26 00:06:59 +00:00
|
|
|
SizedBox(
|
2023-07-29 02:17:26 +00:00
|
|
|
width: 144.0,
|
|
|
|
child: Text(
|
2023-10-08 10:53:22 +00:00
|
|
|
album.title!,
|
2023-07-29 02:17:26 +00:00
|
|
|
maxLines: 1,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
2023-10-12 22:09:37 +00:00
|
|
|
style: const TextStyle(fontSize: 14.0),
|
2023-07-29 02:17:26 +00:00
|
|
|
),
|
|
|
|
),
|
2023-09-26 00:06:59 +00:00
|
|
|
const SizedBox(height: 4.0),
|
|
|
|
SizedBox(
|
2023-07-29 02:17:26 +00:00
|
|
|
width: 144.0,
|
|
|
|
child: Text(
|
2023-10-08 10:53:22 +00:00
|
|
|
album.artistString,
|
2023-07-29 02:17:26 +00:00
|
|
|
maxLines: 1,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12.0,
|
|
|
|
color: (Theme.of(context).brightness == Brightness.light)
|
|
|
|
? Colors.grey[800]
|
|
|
|
: Colors.white70),
|
|
|
|
),
|
|
|
|
),
|
2023-09-26 00:06:59 +00:00
|
|
|
const SizedBox(height: 8.0)
|
2023-07-29 02:17:26 +00:00
|
|
|
],
|
|
|
|
),
|
2023-09-26 00:06:59 +00:00
|
|
|
);
|
2023-07-29 02:17:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ChannelTile extends StatelessWidget {
|
2023-09-26 00:06:59 +00:00
|
|
|
final DeezerChannel channel;
|
2023-07-29 02:17:26 +00:00
|
|
|
final Function? onTap;
|
2023-10-12 22:09:37 +00:00
|
|
|
const ChannelTile(this.channel, {super.key, this.onTap});
|
2023-07-29 02:17:26 +00:00
|
|
|
|
|
|
|
Color _textColor() {
|
2023-09-26 00:06:59 +00:00
|
|
|
double luminance = channel.backgroundColor.computeLuminance();
|
2023-07-29 02:17:26 +00:00
|
|
|
return (luminance > 0.5) ? Colors.black : Colors.white;
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-09-26 00:06:59 +00:00
|
|
|
final Widget child;
|
|
|
|
if (channel.logo != null) {
|
|
|
|
child = Padding(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
child: CachedNetworkImage(
|
|
|
|
cacheKey: channel.logo!.md5,
|
|
|
|
height: 52.0,
|
|
|
|
imageUrl:
|
|
|
|
channel.logo!.size(52, 0, num: 100, id: 'none', format: 'png')),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
child = Text(
|
|
|
|
channel.title!,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
maxLines: 2,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 18.0,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: channel.picture == null ? _textColor() : Colors.white),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return SizedBox(
|
|
|
|
width: 150,
|
|
|
|
height: 75,
|
|
|
|
child: DecoratedBox(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: const BorderRadius.all(Radius.circular(4.0)),
|
|
|
|
color: channel.picture == null ? channel.backgroundColor : null,
|
|
|
|
image: channel.picture == null
|
|
|
|
? null
|
|
|
|
: DecorationImage(
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
image: CachedNetworkImageProvider(
|
|
|
|
channel.picture!.size(134, 264),
|
|
|
|
cacheKey: channel.picture!.md5))),
|
|
|
|
child: Material(
|
|
|
|
color: Colors.transparent,
|
|
|
|
clipBehavior: Clip.hardEdge,
|
|
|
|
borderRadius: const BorderRadius.all(Radius.circular(4.0)),
|
2023-07-29 02:17:26 +00:00
|
|
|
child: InkWell(
|
2023-10-12 22:09:37 +00:00
|
|
|
focusColor: Colors.black45, // give better visibility
|
|
|
|
onTap: onTap as void Function()?,
|
2023-09-26 00:06:59 +00:00
|
|
|
child: Center(child: child)),
|
|
|
|
),
|
|
|
|
),
|
2023-07-29 02:17:26 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ShowCard extends StatelessWidget {
|
|
|
|
final Show? show;
|
2023-10-12 22:09:37 +00:00
|
|
|
final VoidCallback? onTap;
|
|
|
|
final VoidCallback? onHold;
|
2023-07-29 02:17:26 +00:00
|
|
|
|
2023-10-12 22:09:37 +00:00
|
|
|
const ShowCard(this.show, {super.key, this.onTap, this.onHold});
|
2023-07-29 02:17:26 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-10-12 22:09:37 +00:00
|
|
|
return InkWell(
|
|
|
|
onTap: onTap,
|
|
|
|
onLongPress: onHold,
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
child: CachedImage(
|
|
|
|
url: show!.art!.thumb,
|
|
|
|
width: 128.0,
|
|
|
|
height: 128.0,
|
|
|
|
rounded: true,
|
2023-07-29 02:17:26 +00:00
|
|
|
),
|
2023-10-12 22:09:37 +00:00
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
width: 144.0,
|
|
|
|
child: Text(
|
|
|
|
show!.name!,
|
|
|
|
maxLines: 1,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: const TextStyle(fontSize: 14.0),
|
2023-07-29 02:17:26 +00:00
|
|
|
),
|
2023-10-12 22:09:37 +00:00
|
|
|
),
|
|
|
|
],
|
2023-07-29 02:17:26 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ShowTile extends StatelessWidget {
|
|
|
|
final Show show;
|
|
|
|
final Function? onTap;
|
|
|
|
final Function? onHold;
|
|
|
|
|
2023-10-12 22:09:37 +00:00
|
|
|
const ShowTile(this.show, {super.key, this.onTap, this.onHold});
|
2023-07-29 02:17:26 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ListTile(
|
|
|
|
title: Text(
|
|
|
|
show.name!,
|
|
|
|
maxLines: 1,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
),
|
|
|
|
subtitle: Text(
|
|
|
|
show.description!,
|
|
|
|
maxLines: 1,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
),
|
|
|
|
onTap: onTap as void Function()?,
|
|
|
|
onLongPress: onHold as void Function()?,
|
|
|
|
leading: CachedImage(
|
|
|
|
url: show.art!.thumb,
|
|
|
|
width: 48,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ShowEpisodeTile extends StatelessWidget {
|
|
|
|
final ShowEpisode episode;
|
|
|
|
final Function? onTap;
|
|
|
|
final Function? onHold;
|
|
|
|
final Widget? trailing;
|
|
|
|
|
2023-10-12 22:09:37 +00:00
|
|
|
const ShowEpisodeTile(this.episode,
|
|
|
|
{super.key, this.onTap, this.onHold, this.trailing});
|
2023-07-29 02:17:26 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return InkWell(
|
|
|
|
onLongPress: onHold as void Function()?,
|
|
|
|
onTap: onTap as void Function()?,
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
ListTile(
|
|
|
|
title: Text(episode.title!, maxLines: 2),
|
|
|
|
trailing: trailing,
|
|
|
|
),
|
|
|
|
Padding(
|
2023-10-12 22:09:37 +00:00
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
2023-07-29 02:17:26 +00:00
|
|
|
child: Text(
|
|
|
|
episode.description!,
|
|
|
|
maxLines: 2,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.textTheme
|
|
|
|
.titleMedium!
|
|
|
|
.color!
|
|
|
|
.withOpacity(0.9)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Padding(
|
2023-10-12 22:09:37 +00:00
|
|
|
padding: const EdgeInsets.fromLTRB(16, 8.0, 0, 0),
|
2023-07-29 02:17:26 +00:00
|
|
|
child: Row(
|
|
|
|
mainAxisSize: MainAxisSize.max,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
'${episode.publishedDate} | ${episode.durationString}',
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12.0,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: Theme.of(context)
|
|
|
|
.textTheme
|
|
|
|
.titleMedium!
|
|
|
|
.color!
|
|
|
|
.withOpacity(0.6)),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2023-10-12 22:09:37 +00:00
|
|
|
const Divider(),
|
2023-07-29 02:17:26 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|