mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
fix: use CustomScrollView for personalized page
This commit is contained in:
parent
88b8785cb8
commit
7d05c40dc0
11
lib/extensions/string.dart
Normal file
11
lib/extensions/string.dart
Normal file
@ -0,0 +1,11 @@
|
||||
import 'package:html_unescape/html_unescape.dart';
|
||||
|
||||
final htmlEscape = HtmlUnescape();
|
||||
|
||||
extension UnescapeHtml on String {
|
||||
String unescapeHtml() => htmlEscape.convert(this);
|
||||
}
|
||||
|
||||
extension NullableUnescapeHtml on String? {
|
||||
String? unescapeHtml() => this == null ? null : htmlEscape.convert(this!);
|
||||
}
|
@ -46,32 +46,47 @@ class PersonalizedPage extends HookConsumerWidget {
|
||||
[newReleases.pages],
|
||||
);
|
||||
|
||||
return ListView(
|
||||
return CustomScrollView(
|
||||
controller: controller,
|
||||
slivers: [
|
||||
SliverList.list(
|
||||
children: [
|
||||
if (!featuredPlaylistsQuery.hasPageData &&
|
||||
!featuredPlaylistsQuery.isLoadingNextPage)
|
||||
const ShimmerCategories()
|
||||
else
|
||||
HorizontalPlaybuttonCardView<PlaylistSimple>(
|
||||
AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
child: !featuredPlaylistsQuery.hasPageData &&
|
||||
!featuredPlaylistsQuery.isLoadingNextPage
|
||||
? const ShimmerCategories()
|
||||
: HorizontalPlaybuttonCardView<PlaylistSimple>(
|
||||
items: playlists.toList(),
|
||||
title: Text(context.l10n.featured),
|
||||
isLoadingNextPage: featuredPlaylistsQuery.isLoadingNextPage,
|
||||
isLoadingNextPage:
|
||||
featuredPlaylistsQuery.isLoadingNextPage,
|
||||
hasNextPage: featuredPlaylistsQuery.hasNextPage,
|
||||
onFetchMore: featuredPlaylistsQuery.fetchNext,
|
||||
),
|
||||
if (auth != null &&
|
||||
newReleases.hasPageData &&
|
||||
),
|
||||
if (auth != null)
|
||||
AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
child: newReleases.hasPageData &&
|
||||
userArtistsQuery.hasData &&
|
||||
!newReleases.isLoadingNextPage)
|
||||
HorizontalPlaybuttonCardView<Album>(
|
||||
!newReleases.isLoadingNextPage
|
||||
? HorizontalPlaybuttonCardView<Album>(
|
||||
items: albums,
|
||||
title: Text(context.l10n.new_releases),
|
||||
isLoadingNextPage: newReleases.isLoadingNextPage,
|
||||
hasNextPage: newReleases.hasNextPage,
|
||||
onFetchMore: newReleases.fetchNext,
|
||||
)
|
||||
: const ShimmerCategories(),
|
||||
),
|
||||
...?madeForUser.data?["content"]?["items"]?.map((item) {
|
||||
],
|
||||
),
|
||||
SliverSafeArea(
|
||||
sliver: SliverList.builder(
|
||||
itemCount: madeForUser.data?["content"]?["items"]?.length ?? 0,
|
||||
itemBuilder: (context, index) {
|
||||
final item = madeForUser.data?["content"]?["items"]?[index];
|
||||
final playlists = item["content"]?["items"]
|
||||
?.where((itemL2) => itemL2["type"] == "playlist")
|
||||
.map((itemL2) => PlaylistSimple.fromJson(itemL2))
|
||||
@ -86,7 +101,9 @@ class PersonalizedPage extends HookConsumerWidget {
|
||||
isLoadingNextPage: false,
|
||||
onFetchMore: () {},
|
||||
);
|
||||
})
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import 'package:spotube/services/sourced_track/models/source_info.dart';
|
||||
import 'package:spotube/services/sourced_track/models/source_map.dart';
|
||||
import 'package:spotube/services/sourced_track/sourced_track.dart';
|
||||
import 'package:jiosaavn/jiosaavn.dart';
|
||||
import 'package:spotube/extensions/string.dart';
|
||||
|
||||
final jiosaavnClient = JioSaavnClient();
|
||||
|
||||
@ -74,14 +75,14 @@ class JioSaavnSourcedTrack extends SourcedTrack {
|
||||
result.primaryArtists,
|
||||
if (result.featuredArtists.isNotEmpty) ", ",
|
||||
result.featuredArtists
|
||||
].join("").replaceAll("&", "&"),
|
||||
].join("").unescapeHtml(),
|
||||
artistUrl:
|
||||
"https://www.jiosaavn.com/artist/${result.primaryArtistsId.split(",").firstOrNull ?? ""}",
|
||||
duration: Duration(seconds: int.parse(result.duration)),
|
||||
id: result.id,
|
||||
pageUrl: result.url,
|
||||
thumbnail: result.image?.last.link ?? "",
|
||||
title: result.name!,
|
||||
title: result.name!.unescapeHtml(),
|
||||
album: result.album.name,
|
||||
),
|
||||
source: SourceMap(
|
||||
@ -115,10 +116,12 @@ class JioSaavnSourcedTrack extends SourcedTrack {
|
||||
return results
|
||||
.where(
|
||||
(s) {
|
||||
final sameName = s.name?.replaceAll("&", "&") == track.name;
|
||||
final artistNames =
|
||||
"${s.primaryArtists}${s.featuredArtists.isNotEmpty ? ", " : ""}${s.featuredArtists}"
|
||||
.replaceAll("&", "&");
|
||||
final sameName = s.name?.unescapeHtml() == track.name;
|
||||
final artistNames = [
|
||||
s.primaryArtists,
|
||||
if (s.featuredArtists.isNotEmpty) ", ",
|
||||
s.featuredArtists
|
||||
].join("").unescapeHtml();
|
||||
final sameArtists = artistNames.split(", ").any(
|
||||
(artist) =>
|
||||
trackArtistNames?.any((ar) => artist == ar) ?? false,
|
||||
|
@ -1058,6 +1058,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.15.4"
|
||||
html_unescape:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: html_unescape
|
||||
sha256: "15362d7a18f19d7b742ef8dcb811f5fd2a2df98db9f80ea393c075189e0b61e3"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
http:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -118,6 +118,7 @@ dependencies:
|
||||
dart_discord_rpc:
|
||||
git:
|
||||
url: https://github.com/Tommypop2/dart_discord_rpc.git
|
||||
html_unescape: ^2.0.0
|
||||
|
||||
dev_dependencies:
|
||||
build_runner: ^2.3.2
|
||||
|
Loading…
Reference in New Issue
Block a user