import 'package:flutter/material.dart'; import 'package:ocarina/api/audio/audioplayer_service.dart'; import 'package:ocarina/api/subsonic/album.dart'; import 'package:ocarina/api/subsonic/song.dart'; import 'package:ocarina/api/subsonic/subsonic.dart'; import 'package:ocarina/main.dart'; import 'package:ocarina/widgets/hero_banner.dart'; import 'package:ocarina/widgets/song_row.dart'; import 'package:responsive_sizer/responsive_sizer.dart'; class AlbumView extends StatefulWidget { const AlbumView({required this.album, super.key}); final Album album; @override State createState() => _AlbumViewState(); } class _AlbumViewState extends State { final _songs = []; @override void initState() { super.initState(); loadSongs(); } Future loadSongs() async { _songs ..clear() ..addAll(await SubsonicApiService().getSongList(widget.album.id) ?? []); setState(() {}); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(), body: SizedBox( width: 100.w, height: 100.h, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ HeroBanner( imageUrl: widget.album.coverArtUrl, title: widget.album.name, description: widget.album.artistName, ), SizedBox( height: 65.h, width: 95.w, child: ListView.builder( itemBuilder: (c, i) => InkWell( onTap: () async { AudioPlayerService().song = _songs[i]; playerKey.currentState?.update(); await AudioPlayerService().playFile(); setState(() {}); }, child: SongRow( imageUrl: _songs[i].coverArtUrl, songTitle: _songs[i].title, ), ), itemCount: _songs.length, ), ), ], ), ), ); } }