feat(flutter): discover screen — search Lidarr + create requests
- models/lidarr.dart (LidarrSearchResult + LidarrRequestKind) - api/endpoints/discover.dart (search + createRequest) - discover/discover_screen.dart with TextField, kind toggle (Artists/Albums), results list with in_library / requested pills - /discover route + explore icon on home AppBar (5 actions now: Library, Playlists, Search, Discover, Settings)
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
/// Mirrors web/src/lib/api/types.ts LidarrSearchResult — one row in
|
||||
/// `/api/lidarr/search` results. `in_library` and `requested` let the
|
||||
/// UI gray out rows the user can't act on (already imported / already
|
||||
/// awaiting review).
|
||||
class LidarrSearchResult {
|
||||
const LidarrSearchResult({
|
||||
required this.mbid,
|
||||
required this.name,
|
||||
required this.secondaryText,
|
||||
required this.imageUrl,
|
||||
required this.artistMbid,
|
||||
required this.albumMbid,
|
||||
required this.inLibrary,
|
||||
required this.requested,
|
||||
});
|
||||
|
||||
final String mbid;
|
||||
final String name;
|
||||
final String secondaryText;
|
||||
final String imageUrl;
|
||||
final String artistMbid;
|
||||
final String albumMbid;
|
||||
final bool inLibrary;
|
||||
final bool requested;
|
||||
|
||||
factory LidarrSearchResult.fromJson(Map<String, dynamic> j) =>
|
||||
LidarrSearchResult(
|
||||
mbid: j['mbid'] as String? ?? '',
|
||||
name: j['name'] as String? ?? '',
|
||||
secondaryText: j['secondary_text'] as String? ?? '',
|
||||
imageUrl: j['image_url'] as String? ?? '',
|
||||
artistMbid: j['artist_mbid'] as String? ?? '',
|
||||
albumMbid: j['album_mbid'] as String? ?? '',
|
||||
inLibrary: j['in_library'] as bool? ?? false,
|
||||
requested: j['requested'] as bool? ?? false,
|
||||
);
|
||||
}
|
||||
|
||||
enum LidarrRequestKind { artist, album, track }
|
||||
|
||||
extension LidarrRequestKindStr on LidarrRequestKind {
|
||||
String get wire => switch (this) {
|
||||
LidarrRequestKind.artist => 'artist',
|
||||
LidarrRequestKind.album => 'album',
|
||||
LidarrRequestKind.track => 'track',
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user