2024-05-23 19:14:08 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:ocarina/api/subsonic/album.dart';
|
|
|
|
import 'package:ocarina/api/subsonic/artist.dart';
|
|
|
|
import 'package:ocarina/api/subsonic/subsonic.dart';
|
|
|
|
import 'package:ocarina/views/album_view.dart';
|
|
|
|
import 'package:ocarina/widgets/hero_banner.dart';
|
|
|
|
import 'package:ocarina/widgets/image_cover.dart';
|
|
|
|
import 'package:responsive_sizer/responsive_sizer.dart';
|
|
|
|
|
|
|
|
class ArtistView extends StatefulWidget {
|
|
|
|
const ArtistView({required this.artist, super.key});
|
|
|
|
final Artist artist;
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<ArtistView> createState() => _ArtistViewState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ArtistViewState extends State<ArtistView> {
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
loadArtistAlbums();
|
|
|
|
}
|
|
|
|
|
|
|
|
final _albums = <Album>[];
|
|
|
|
|
|
|
|
Future<void> loadArtistAlbums() async {
|
|
|
|
_albums
|
|
|
|
..clear()
|
|
|
|
..addAll(await SubsonicApiService().getAlbumList(widget.artist.id) ?? []);
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
),
|
|
|
|
body: SingleChildScrollView(
|
|
|
|
child: SizedBox(
|
|
|
|
width: 100.w,
|
|
|
|
height: 100.h,
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
HeroBanner(
|
2024-05-28 18:54:05 +02:00
|
|
|
cacheKey: widget.artist.coverArtId,
|
|
|
|
imageUrl: widget.artist.coverArtUrl,
|
2024-05-23 19:14:08 +02:00
|
|
|
title: widget.artist.name,
|
|
|
|
description: "This could be a cool description soon",
|
|
|
|
heroTag: widget.artist.name,
|
|
|
|
),
|
|
|
|
Center(
|
|
|
|
child: SizedBox(
|
|
|
|
height: 70.h,
|
|
|
|
width: 95.w,
|
|
|
|
child: Wrap(
|
|
|
|
alignment: WrapAlignment.spaceBetween,
|
|
|
|
children: List<Widget>.generate(
|
|
|
|
_albums.length,
|
|
|
|
(n) => InkWell(
|
|
|
|
onTap: () async {
|
|
|
|
await Navigator.of(context).push(
|
|
|
|
MaterialPageRoute<void>(
|
|
|
|
builder: (c) => AlbumView(
|
|
|
|
album: _albums[n],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
child: ImageCover(
|
2024-05-28 18:54:05 +02:00
|
|
|
cacheKey: _albums[n].coverArtId,
|
2024-05-23 19:14:08 +02:00
|
|
|
imageUrl: _albums[n].coverArtUrl,
|
|
|
|
title: _albums[n].name,
|
|
|
|
heroTag: _albums[n].name,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|