mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 16:05:18 +00:00
feat: locale category/genre title
This commit is contained in:
parent
ae820a22f2
commit
88137f01b2
@ -1,20 +1,27 @@
|
|||||||
import 'package:fl_query/fl_query.dart';
|
import 'package:fl_query/fl_query.dart';
|
||||||
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:spotify/spotify.dart';
|
import 'package:spotify/spotify.dart';
|
||||||
|
import 'package:spotube/extensions/context.dart';
|
||||||
import 'package:spotube/hooks/use_spotify_infinite_query.dart';
|
import 'package:spotube/hooks/use_spotify_infinite_query.dart';
|
||||||
|
import 'package:spotube/provider/user_preferences_provider.dart';
|
||||||
|
|
||||||
class CategoryQueries {
|
class CategoryQueries {
|
||||||
const CategoryQueries();
|
const CategoryQueries();
|
||||||
|
|
||||||
InfiniteQuery<Page<Category>, dynamic, int> list(
|
InfiniteQuery<Page<Category>, dynamic, int> list(
|
||||||
WidgetRef ref, String recommendationMarket) {
|
WidgetRef ref,
|
||||||
|
String recommendationMarket,
|
||||||
|
) {
|
||||||
|
ref.watch(userPreferencesProvider.select((s) => s.locale));
|
||||||
|
final locale = useContext().l10n.localeName;
|
||||||
return useSpotifyInfiniteQuery<Page<Category>, dynamic, int>(
|
return useSpotifyInfiniteQuery<Page<Category>, dynamic, int>(
|
||||||
"category-playlists",
|
"category-playlists",
|
||||||
(pageParam, spotify) async {
|
(pageParam, spotify) async {
|
||||||
final categories = await spotify.categories
|
final categories = await spotify.categories
|
||||||
.list(
|
.list(
|
||||||
country: recommendationMarket,
|
country: recommendationMarket,
|
||||||
locale: 'en_US',
|
locale: locale,
|
||||||
)
|
)
|
||||||
.getPage(8, pageParam);
|
.getPage(8, pageParam);
|
||||||
|
|
||||||
@ -35,12 +42,16 @@ class CategoryQueries {
|
|||||||
WidgetRef ref,
|
WidgetRef ref,
|
||||||
String category,
|
String category,
|
||||||
) {
|
) {
|
||||||
|
ref.watch(userPreferencesProvider.select((s) => s.locale));
|
||||||
|
final market = ref
|
||||||
|
.watch(userPreferencesProvider.select((s) => s.recommendationMarket));
|
||||||
|
final locale = useContext().l10n.localeName;
|
||||||
return useSpotifyInfiniteQuery<Page<PlaylistSimple?>, dynamic, int>(
|
return useSpotifyInfiniteQuery<Page<PlaylistSimple?>, dynamic, int>(
|
||||||
"category-playlists/$category",
|
"category-playlists/$category",
|
||||||
(pageParam, spotify) async {
|
(pageParam, spotify) async {
|
||||||
final playlists = await Pages<PlaylistSimple?>(
|
final playlists = await Pages<PlaylistSimple?>(
|
||||||
spotify,
|
spotify,
|
||||||
"v1/browse/categories/$category/playlists?country=US&locale=en_US",
|
"v1/browse/categories/$category/playlists?country=$market&locale=$locale",
|
||||||
(json) => json == null ? null : PlaylistSimple.fromJson(json),
|
(json) => json == null ? null : PlaylistSimple.fromJson(json),
|
||||||
'playlists',
|
'playlists',
|
||||||
(json) => PlaylistsFeatured.fromJson(json),
|
(json) => PlaylistsFeatured.fromJson(json),
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import 'package:fl_query/fl_query.dart';
|
import 'package:fl_query/fl_query.dart';
|
||||||
import 'package:fl_query_hooks/fl_query_hooks.dart';
|
import 'package:fl_query_hooks/fl_query_hooks.dart';
|
||||||
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:spotube/extensions/context.dart';
|
||||||
import 'package:spotube/provider/authentication_provider.dart';
|
import 'package:spotube/provider/authentication_provider.dart';
|
||||||
import 'package:spotube/provider/custom_spotify_endpoint_provider.dart';
|
import 'package:spotube/provider/custom_spotify_endpoint_provider.dart';
|
||||||
import 'package:spotube/provider/user_preferences_provider.dart';
|
import 'package:spotube/provider/user_preferences_provider.dart';
|
||||||
@ -17,9 +19,16 @@ class ViewsQueries {
|
|||||||
final market = ref
|
final market = ref
|
||||||
.watch(userPreferencesProvider.select((s) => s.recommendationMarket));
|
.watch(userPreferencesProvider.select((s) => s.recommendationMarket));
|
||||||
|
|
||||||
|
final locale = useContext().l10n.localeName;
|
||||||
|
|
||||||
return useQuery<Map<String, dynamic>?, dynamic>("views/$view", () {
|
return useQuery<Map<String, dynamic>?, dynamic>("views/$view", () {
|
||||||
if (auth == null) return null;
|
if (auth == null) return null;
|
||||||
return customSpotify.getView(view, market: market, country: market);
|
return customSpotify.getView(
|
||||||
|
view,
|
||||||
|
market: market,
|
||||||
|
country: market,
|
||||||
|
locale: locale,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user