From 7c9ed1b913f8c33980ebe8a38236f567039632e5 Mon Sep 17 00:00:00 2001 From: Hemant KArya <65885023+HemantKArya@users.noreply.github.com> Date: Fri, 15 Mar 2024 17:24:55 +0530 Subject: [PATCH] billboard trending on home page --- .../Saavn/cubit/saavn_repository_cubit.dart | 17 +++++++++++++++-- lib/repository/Saavn/saavn_api.dart | 1 - lib/screens/widgets/carousal_widget.dart | 2 +- lib/screens/widgets/tabList_widget.dart | 10 ++++++---- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/lib/repository/Saavn/cubit/saavn_repository_cubit.dart b/lib/repository/Saavn/cubit/saavn_repository_cubit.dart index 35d4668..c7c5d97 100644 --- a/lib/repository/Saavn/cubit/saavn_repository_cubit.dart +++ b/lib/repository/Saavn/cubit/saavn_repository_cubit.dart @@ -1,4 +1,5 @@ import 'dart:developer'; +import 'package:Bloomee/plugins/billboard_charts.dart'; import 'package:bloc/bloc.dart'; import 'package:easy_debounce/easy_debounce.dart'; import 'package:rxdart/rxdart.dart'; @@ -30,12 +31,24 @@ class SaavnRepositoryCubit extends Cubit { Future fetchTopResultsfromSaavn() async { emit(state); final trends = await saavnAPI.getTopSearches(); + final billboardIndia = + await getBillboardChart(url: BillboardChartLinks.INDIA_SONGS); List trendings = []; - for (int i = 0; i < trends.length; i++) { + try { + for (int i = 0; i < trends.length; i++) { + final trendingResults = await saavnAPI.fetchSongSearchResults( + searchQuery: + "${billboardIndia[i]["title"]} by ${billboardIndia[i]["label"]}", + count: 1); + + trendings += + fromSaavnSongMapList2MediaItemList(trendingResults["songs"]); + } + } catch (e) { final trendingResults = await saavnAPI.fetchSongSearchResults( - searchQuery: trends[i], count: 2); + searchQuery: trends[0], count: 1); trendings += fromSaavnSongMapList2MediaItemList(trendingResults["songs"]); } diff --git a/lib/repository/Saavn/saavn_api.dart b/lib/repository/Saavn/saavn_api.dart index 84e71a6..254aeeb 100644 --- a/lib/repository/Saavn/saavn_api.dart +++ b/lib/repository/Saavn/saavn_api.dart @@ -2,7 +2,6 @@ import 'dart:convert'; import 'dart:developer'; import 'package:http/http.dart'; import 'package:Bloomee/repository/Saavn/format.dart'; -import 'package:logging/logging.dart'; class SaavnAPI { Map headers = {}; diff --git a/lib/screens/widgets/carousal_widget.dart b/lib/screens/widgets/carousal_widget.dart index a917c0d..81d568b 100644 --- a/lib/screens/widgets/carousal_widget.dart +++ b/lib/screens/widgets/carousal_widget.dart @@ -36,7 +36,7 @@ class _CaraouselWidgetState extends State { child: Row( children: [ Text( - "Trendings", + "Featured", style: Default_Theme.secondoryTextStyle.merge( const TextStyle( color: Default_Theme.primaryColor1, diff --git a/lib/screens/widgets/tabList_widget.dart b/lib/screens/widgets/tabList_widget.dart index 7ce2559..a5b15b3 100644 --- a/lib/screens/widgets/tabList_widget.dart +++ b/lib/screens/widgets/tabList_widget.dart @@ -66,7 +66,7 @@ class _TabSongListWidgetState extends State child: Padding( padding: const EdgeInsets.only(left: 10, right: 10), child: Text( - "Liked", + "Trending", style: Default_Theme.secondoryTextStyle.merge( const TextStyle( color: Default_Theme.primaryColor1, @@ -114,9 +114,11 @@ class SongListWidget extends StatelessWidget { child: Padding( padding: EdgeInsets.only(right: 70), child: SizedBox( - height: 100, - width: 100, - child: CircularProgressIndicator()), + height: 60, + width: 60, + child: CircularProgressIndicator( + color: Default_Theme.accentColor2, + )), ), ); } else {