87 lines
2.6 KiB
Dart
87 lines
2.6 KiB
Dart
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(
|
|
imageUrl: widget.artist.artistImageUrl,
|
|
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(
|
|
imageUrl: _albums[n].coverArtUrl,
|
|
title: _albums[n].name,
|
|
heroTag: _albums[n].name,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|