From 8fbc5e6ce49366572c5dbdad7f10463ea85bb7b1 Mon Sep 17 00:00:00 2001 From: austinried <4966622+austinried@users.noreply.github.com> Date: Sun, 7 May 2023 13:28:15 +0900 Subject: [PATCH] add artist radio --- TODO.md | 2 -- lib/app/pages/artist_page.dart | 26 ++++++++++++++++++++++++++ lib/models/support.dart | 3 ++- lib/models/support.g.dart | 1 + 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/TODO.md b/TODO.md index 956f7f4..21fb73e 100644 --- a/TODO.md +++ b/TODO.md @@ -14,8 +14,6 @@ - [ ] Library list display modes - [ ] Search - [ ] Individual "more" results pages -- [ ] Radio modes - - [ ] Artist - [ ] Now playing gestures - [ ] Swipe bar/album to skip - [ ] Double-tap to seek forward/back (bar only) diff --git a/lib/app/pages/artist_page.dart b/lib/app/pages/artist_page.dart index b48e9e0..eafba27 100644 --- a/lib/app/pages/artist_page.dart +++ b/lib/app/pages/artist_page.dart @@ -1,13 +1,19 @@ import 'dart:math'; import 'package:auto_route/auto_route.dart'; +import 'package:fast_immutable_collections/fast_immutable_collections.dart'; import 'package:flutter/material.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; +import '../../database/database.dart'; +import '../../models/query.dart'; +import '../../models/support.dart'; +import '../../services/audio_service.dart'; import '../../state/music.dart'; import '../../state/settings.dart'; import '../app_router.dart'; +import '../buttons.dart'; import '../images.dart'; import '../items.dart'; @@ -27,6 +33,26 @@ class ArtistPage extends HookConsumerWidget { final albums = ref.watch(albumsByArtistIdProvider(id)); return Scaffold( + floatingActionButton: RadioPlayFab( + onPressed: () => artist.hasValue + ? ref.read(audioControlProvider).playRadio( + context: QueueContextType.artist, + contextId: artist.valueOrNull!.id, + query: ListQuery( + filters: IList([ + FilterWith.equals( + column: 'artist_id', + value: artist.valueOrNull!.id, + ) + ]), + ), + getSongs: (query) => ref + .read(databaseProvider) + .songsList(ref.read(sourceIdProvider), query) + .get(), + ) + : null, + ), body: CustomScrollView( slivers: [ SliverToBoxAdapter( diff --git a/lib/models/support.dart b/lib/models/support.dart index 28c0a4f..b9c022d 100644 --- a/lib/models/support.dart +++ b/lib/models/support.dart @@ -68,7 +68,8 @@ enum QueueContextType { album('album'), playlist('playlist'), library('library'), - genre('genre'); + genre('genre'), + artist('artist'); const QueueContextType(this.value); final String value; diff --git a/lib/models/support.g.dart b/lib/models/support.g.dart index 7e2b532..e0dbf0e 100644 --- a/lib/models/support.g.dart +++ b/lib/models/support.g.dart @@ -28,6 +28,7 @@ const _$QueueContextTypeEnumMap = { QueueContextType.playlist: 'playlist', QueueContextType.library: 'library', QueueContextType.genre: 'genre', + QueueContextType.artist: 'artist', }; _$_MediaItemData _$$_MediaItemDataFromJson(Map json) =>