feat(flutter): library screen with 5 tabs (Artists/Albums/History/Liked/Hidden)
Models: - history_event.dart (HistoryEvent + HistoryPage envelope) - quarantine_mine.dart (QuarantineMineRow for /api/quarantine/mine) - Renamed Page<T> -> Paged<T> to avoid collision with Material's Page Endpoints: - library_lists.dart: listArtists / listAlbums (paged) - me.dart: history + quarantineMine - likes.dart: extended with listTracks/Albums/Artists (paged) UI: - library_screen.dart: TabBar over 5 tabs - Artists tab: 3-col grid - Albums tab: 2-col grid - History tab: list with relative-time formatting (matches HistoryRow.svelte) - Liked tab: 3 stacked sections (artists scroll-row, albums scroll-row, tracks list) - Hidden tab: list of quarantined tracks with reason pill - /library route + library_music icon on home AppBar First page only for v1 (limit 50). Infinite scroll deferred.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import '../../models/album.dart';
|
||||
import '../../models/artist.dart';
|
||||
import '../../models/page.dart';
|
||||
|
||||
/// Paged library browse endpoints. Distinct from LibraryApi (which
|
||||
/// fetches Home + entity detail) so screens that just need a flat
|
||||
/// list don't drag in detail-page providers.
|
||||
class LibraryListsApi {
|
||||
LibraryListsApi(this._dio);
|
||||
final Dio _dio;
|
||||
|
||||
Future<Paged<ArtistRef>> listArtists({int limit = 50, int offset = 0}) async {
|
||||
final r = await _dio.get<Map<String, dynamic>>(
|
||||
'/api/library/artists',
|
||||
queryParameters: {'limit': limit, 'offset': offset},
|
||||
);
|
||||
return Paged.fromJson(r.data ?? const {}, ArtistRef.fromJson);
|
||||
}
|
||||
|
||||
Future<Paged<AlbumRef>> listAlbums({int limit = 50, int offset = 0}) async {
|
||||
final r = await _dio.get<Map<String, dynamic>>(
|
||||
'/api/library/albums',
|
||||
queryParameters: {'limit': limit, 'offset': offset},
|
||||
);
|
||||
return Paged.fromJson(r.data ?? const {}, AlbumRef.fromJson);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import '../../models/album.dart';
|
||||
import '../../models/artist.dart';
|
||||
import '../../models/page.dart';
|
||||
import '../../models/track.dart';
|
||||
|
||||
enum LikeKind { artist, album, track }
|
||||
|
||||
extension LikeKindPath on LikeKind {
|
||||
@@ -22,6 +27,31 @@ class LikesApi {
|
||||
await _dio.delete<void>('/api/likes/${kind.path}/$id');
|
||||
}
|
||||
|
||||
/// GET /api/likes/tracks?limit=N&offset=N. Paged.
|
||||
Future<Paged<TrackRef>> listTracks({int limit = 50, int offset = 0}) async {
|
||||
final r = await _dio.get<Map<String, dynamic>>(
|
||||
'/api/likes/tracks',
|
||||
queryParameters: {'limit': limit, 'offset': offset},
|
||||
);
|
||||
return Paged.fromJson(r.data ?? const {}, TrackRef.fromJson);
|
||||
}
|
||||
|
||||
Future<Paged<AlbumRef>> listAlbums({int limit = 50, int offset = 0}) async {
|
||||
final r = await _dio.get<Map<String, dynamic>>(
|
||||
'/api/likes/albums',
|
||||
queryParameters: {'limit': limit, 'offset': offset},
|
||||
);
|
||||
return Paged.fromJson(r.data ?? const {}, AlbumRef.fromJson);
|
||||
}
|
||||
|
||||
Future<Paged<ArtistRef>> listArtists({int limit = 50, int offset = 0}) async {
|
||||
final r = await _dio.get<Map<String, dynamic>>(
|
||||
'/api/likes/artists',
|
||||
queryParameters: {'limit': limit, 'offset': offset},
|
||||
);
|
||||
return Paged.fromJson(r.data ?? const {}, ArtistRef.fromJson);
|
||||
}
|
||||
|
||||
/// Returns sets of {artists, albums, tracks} the user has liked.
|
||||
/// Server response keys (verified in internal/api/likes.go
|
||||
/// `likedIDsResponse`): `artist_ids`, `album_ids`, `track_ids`.
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import '../../models/history_event.dart';
|
||||
import '../../models/quarantine_mine.dart';
|
||||
|
||||
/// /api/me/* endpoints — caller-scoped data (history, profile, etc.).
|
||||
class MeApi {
|
||||
MeApi(this._dio);
|
||||
final Dio _dio;
|
||||
|
||||
/// GET /api/me/history. Paginated via offset/limit; server emits
|
||||
/// `{events, has_more}` rather than the standard `Page<T>` envelope.
|
||||
Future<HistoryPage> history({int limit = 50, int offset = 0}) async {
|
||||
final r = await _dio.get<Map<String, dynamic>>(
|
||||
'/api/me/history',
|
||||
queryParameters: {'limit': limit, 'offset': offset},
|
||||
);
|
||||
return HistoryPage.fromJson(r.data ?? const {});
|
||||
}
|
||||
|
||||
/// GET /api/quarantine/mine — flat list (no envelope).
|
||||
Future<List<QuarantineMineRow>> quarantineMine() async {
|
||||
final r = await _dio.get<List<dynamic>>('/api/quarantine/mine');
|
||||
final raw = r.data ?? const [];
|
||||
return raw
|
||||
.map((e) =>
|
||||
QuarantineMineRow.fromJson((e as Map).cast<String, dynamic>()))
|
||||
.toList(growable: false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user