spotube/lib/components/shared/links/artist_link.dart
Kingkor Roy Tirtho 82307bc030
feat: personalized stats based on local music history (#1522)
* feat: add playback history provider

* feat: implement recently played section

* refactor: use route names

* feat: add stats summary and top tracks/artists/albums

* feat: add top date based filtering

* feat: add stream money calculation

* refactor: place search in mobile navbar and settings in home appbar

* feat: add individual minutes and streams page

* feat(stats): add individual minutes and streams page

* chore: default period to 1 month

* feat: add text to explain user how hypothetical fees are calculated

* chore: ensure usage of route names instead of direct paths

* cd: add cache key

* cd: remove media_kit_event_loop from git
2024-06-01 11:40:01 +06:00

62 lines
1.9 KiB
Dart

import 'package:flutter/widgets.dart';
import 'package:spotify/spotify.dart';
import 'package:spotube/components/shared/links/anchor_button.dart';
import 'package:spotube/pages/artist/artist.dart';
import 'package:spotube/utils/service_utils.dart';
class ArtistLink extends StatelessWidget {
final List<ArtistSimple> artists;
final WrapCrossAlignment crossAxisAlignment;
final WrapAlignment mainAxisAlignment;
final TextStyle textStyle;
final void Function(String route)? onRouteChange;
const ArtistLink({
super.key,
required this.artists,
this.crossAxisAlignment = WrapCrossAlignment.center,
this.mainAxisAlignment = WrapAlignment.center,
this.textStyle = const TextStyle(),
this.onRouteChange,
});
@override
Widget build(BuildContext context) {
return Wrap(
crossAxisAlignment: crossAxisAlignment,
alignment: mainAxisAlignment,
children: artists
.asMap()
.entries
.map(
(artist) => Builder(builder: (context) {
if (artist.value.name == null) {
return Text("Spotify", style: textStyle);
}
return AnchorButton(
(artist.key != artists.length - 1)
? "${artist.value.name}, "
: artist.value.name!,
onTap: () {
if (onRouteChange != null) {
onRouteChange?.call("/artist/${artist.value.id}");
} else {
ServiceUtils.pushNamed(
context,
ArtistPage.name,
pathParameters: {
"id": artist.value.id!,
},
);
}
},
overflow: TextOverflow.ellipsis,
style: textStyle,
);
}),
)
.toList(),
);
}
}