Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/lib/frontend/handlers/landing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Future<shelf.Response> indexLandingHandler(shelf.Request request) async {
mostPopularPackages: topPackages.mostPopular(),
topFlutterPackages: topPackages.topFlutter(),
topDartPackages: topPackages.topDart(),
trendingPackages: topPackages.trending(),
topPoWVideos: youtubeBackend.getTopPackageOfWeekVideos(count: 4),
);
}
Expand Down
2 changes: 2 additions & 0 deletions app/lib/frontend/templates/landing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ String renderLandingPage({
List<PackageView>? mostPopularPackages,
List<PackageView>? topFlutterPackages,
List<PackageView>? topDartPackages,
List<PackageView>? trendingPackages,
List<PkgOfWeekVideo>? topPoWVideos,
}) {
final content = landingPageNode(
ffPackages: ffPackages,
mostPopularPackages: mostPopularPackages,
topFlutterPackages: topFlutterPackages,
topDartPackages: topDartPackages,
trendingPackages: trendingPackages,
topPoWVideos: topPoWVideos,
);
return renderLayoutPage(
Expand Down
20 changes: 19 additions & 1 deletion app/lib/frontend/templates/views/landing/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import 'package:_pub_shared/search/search_form.dart';
import 'package:_pub_shared/search/tags.dart';
import 'package:pub_dev/frontend/request_context.dart';

import '../../../../package/models.dart';
import '../../../../service/youtube/backend.dart';
Expand All @@ -20,6 +21,7 @@ d.Node landingPageNode({
List<PackageView>? mostPopularPackages,
List<PackageView>? topFlutterPackages,
List<PackageView>? topDartPackages,
List<PackageView>? trendingPackages,
List<PkgOfWeekVideo>? topPoWVideos,
}) {
return d.fragment([
Expand All @@ -34,7 +36,23 @@ d.Node landingPageNode({
viewAllEvent: 'landing-flutter-favorites-view-all',
viewAllTitle: 'Search Flutter Favorites packages',
),
if (_isNotEmptyList(mostPopularPackages))
if (requestContext.experimentalFlags.showTrending &&
_isNotEmptyList(trendingPackages))
_block(
shortId: 'mp',
image: d.Image.decorative(
src: staticUrls.getAssetUrl('/static/img/landing-01.webp'),
width: 351,
height: 240,
),
title: 'Trending packages',
info: d.text('Some of the packages trending in the last 30 days'),
content: miniListNode('most-trending', trendingPackages!),
viewAllUrl: urls.listingByTrending(),
viewAllEvent: 'landing-trending-view-all',
viewAllTitle: 'Search trending packages',
)
else if (_isNotEmptyList(mostPopularPackages))
_block(
shortId: 'mp',
image: d.Image.decorative(
Expand Down
6 changes: 6 additions & 0 deletions app/lib/search/top_packages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class TopPackages {
);
final _mostPopular =
_cachedValue('top-packages-most-popular', order: SearchOrder.downloads);
final _trending =
_cachedValue('top-packages-trending', order: SearchOrder.trending);
final _topDart = _cachedValue('top-packages-top-dart', query: SdkTag.sdkDart);
final _topFlutter =
_cachedValue('top-packages-top-flutter', query: SdkTag.sdkFlutter);
Expand Down Expand Up @@ -89,6 +91,10 @@ class TopPackages {
return _randomSelection(_topFlutter, 6);
}

List<PackageView> trending() {
return _randomSelection(_trending, 6);
}

List<PackageView> _randomSelection(
CachedValue<List<PackageView>> cachedValue, int count) {
if (!cachedValue.isAvailable) {
Expand Down
3 changes: 3 additions & 0 deletions app/lib/shared/urls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ String searchUrl({
String listingByDownloadCounts() =>
SearchForm(order: SearchOrder.downloads).toSearchLink();

String listingByTrending() =>
SearchForm(order: SearchOrder.trending).toSearchLink();

String dartSdkMainUrl(String version) {
final isDev = version.contains('dev');
final channel = isDev ? 'dev' : 'stable';
Expand Down