Skip to content

Commit

Permalink
Merge pull request #99 from leoafarias/feature/github-trending
Browse files Browse the repository at this point in the history
Added github trending and cleaned up packages screen
  • Loading branch information
leoafarias authored Jun 19, 2021
2 parents 01f3462 + 426a5e4 commit 3e9d491
Show file tree
Hide file tree
Showing 26 changed files with 1,107 additions and 669 deletions.
369 changes: 226 additions & 143 deletions lib/generated/intl/messages_de.dart

Large diffs are not rendered by default.

355 changes: 215 additions & 140 deletions lib/generated/intl/messages_en.dart

Large diffs are not rendered by default.

52 changes: 19 additions & 33 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions lib/l10n/intl_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@
"thereWasAnIsssueOpeningSidekick": "Es gab ein Problem beim Öffnen von Sidekick",
"close": "Schließen",
"language": "Sprache",
"gitCacheSubtitle": "Dadurch wird das Haupt-Repository von Flutter für schnellere und kleinere Installationen zwischengespeichert",
"gitCache": "Git Cache",
"analyticsCrashReportSubtitle": "Wenn ein Flutter-Befehl abstürzt, wird versucht, einen Absturzbericht an Google zu senden, damit Google im Laufe der Zeit Verbesserungen an Flutter beisteuern kann",
"flutterSDKGlobalDescription": "Eine Flutter-Sdk-Version muss als global eingestellt werden, um auf die Flutter-Einstellungen zugreifen zu können",
"theCurrentTipoftreeAbsoluteLatestCuttingEdgeBuildUsuallyFunctional": "Der aktuelle Tip-of-Tree, der absolut neueste Cutting Edge Build. Normalerweise funktional, obwohl wir manchmal versehentlich Dinge kaputt machen.",
Expand Down
2 changes: 0 additions & 2 deletions lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@
"thereWasAnIsssueOpeningSidekick": "There was an isssue opening Sidekick",
"close": "Close",
"language": "Language",
"gitCacheSubtitle": "This will cache the main Flutter repository for faster and smaller installs",
"gitCache": "Git Cache",
"analyticsCrashReportSubtitle": "When a flutter command crashes it attempts to send a crash report to Google in order to help Google contribute improvements to Flutter over time",
"flutterSDKGlobalDescription": "A Flutter sdk version neeeds to be set as global in order to access Flutter settings",
"theCurrentTipoftreeAbsoluteLatestCuttingEdgeBuildUsuallyFunctional": "The current tip-of-tree, absolute latest cutting edge build. Usually functional, though sometimes we accidentally break things.",
Expand Down
47 changes: 2 additions & 45 deletions lib/src/modules/common/utils/dependencies.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import 'package:github/github.dart';
import 'package:pub_api_client/pub_api_client.dart';

import '../../packages/package.dto.dart';

final client = PubClient();

final github = GitHub(
auth: Authentication.anonymous(),
);

Map<String, PubPackage> mapPackages;

/// Fetches all packages info from pub.dev
Expand All @@ -35,7 +30,7 @@ List<PubPackage> _getTopValidPackages(
List<PubPackage> packages,
Map<String, int> packagesCount,
) {
const max = 10;
const max = 30;

// Filter to only valid packages
final validPackages = packages.where((dep) => dep.name != null).toList();
Expand Down Expand Up @@ -64,46 +59,9 @@ Future<List<PackageDetail>> _complementPackageInfo(
return await Future.wait(packagesDetail);
}

RepositorySlug _getRepoSlug(String homepage) {
String author;
String repo;

if (homepage != null && homepage.contains('github.com')) {
final uri = Uri.parse(homepage);
final paths = uri.path.split('/');

// Some edge cases there wont be a repo attached to the url
if (paths.length < 3) {
author = null;
repo = null;
} else {
author = paths[1];
repo = paths[2];
}
}

if (author != null && repo != null) {
return RepositorySlug(author, repo);
} else {
return null;
}
}

Future<PackageDetail> _assignInfo(PubPackage package, int count) async {
final score = await client.packageScore(package.name);
final pubspec = package.latestPubspec;
Repository repo;

final repoSlug = _getRepoSlug(pubspec.homepage);
try {
if (repoSlug != null) {
repo = await github.repositories.getRepository(repoSlug);
} else {
repo = null;
}
} on Exception {
repo = null;
}

return PackageDetail(
name: package.name,
description: package.description,
Expand All @@ -113,6 +71,5 @@ Future<PackageDetail> _assignInfo(PubPackage package, int count) async {
changelogUrl: package.changelogUrl,
score: score,
projectsCount: count,
repo: repo,
);
}
3 changes: 3 additions & 0 deletions lib/src/modules/common/utils/helpers.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:io';

import 'package:intl/intl.dart';
import 'package:path/path.dart' as path;
import 'package:path_provider/path_provider.dart';

Expand All @@ -13,6 +14,8 @@ extension StringExtension on String {
}
}

final numberFormatter = NumberFormat('###,###,000');

/// Iterable extension
extension ExtendedIterable<E> on Iterable<E> {
/// Like Iterable<T>.map but callback have index as second argument
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:sidekick/generated/l10n.dart';
import 'package:sidekick/src/modules/packages/flutter_favorite.dto.dart';

import '../../../components/atoms/typography.dart';
import '../../../modules/common/utils/open_link.dart';
import '../../common/molecules/list_tile.dart';
import 'package_score_display.dart';

/// Flutter favorite list item
class FlutterFavoriteListItem extends StatelessWidget {
/// Constructor
const FlutterFavoriteListItem(
this.package, {
Key key,
this.position,
}) : super(key: key);

/// Detail of a package
final FlutterFavorite package;

/// Popular position of package
final int position;

@override
Widget build(BuildContext context) {
return Column(
children: [
SkListTile(
title: Text(package.name),
subtitle: Text(
package.description,
maxLines: 2,
style: Theme.of(context).textTheme.caption,
),
trailing: PackageScoreDisplay(score: package.score),
),
Row(
children: [
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const SizedBox(width: 20),
Caption(package.version),
Spacer(),
Tooltip(
message: S.of(context).details,
child: IconButton(
iconSize: 20,
splashRadius: 20,
icon: const Icon(MdiIcons.informationOutline),
onPressed: () async {
await openLink(package.url);
},
),
),
const SizedBox(width: 10),
const Text('·'),
const SizedBox(width: 10),
Tooltip(
message: S.of(context).changelog,
child: IconButton(
iconSize: 20,
splashRadius: 20,
icon: const Icon(MdiIcons.textBox),
onPressed: () async {
await openLink(package.changelogUrl);
},
),
),
const SizedBox(width: 10),
const Text('·'),
const SizedBox(width: 10),
Tooltip(
message: S.of(context).website,
child: IconButton(
iconSize: 20,
splashRadius: 20,
icon: const Icon(MdiIcons.earth),
onPressed: () async {
await openLink(package.url);
},
),
),
const SizedBox(width: 10),
],
),
)
],
),
],
);
}
}
54 changes: 0 additions & 54 deletions lib/src/modules/packages/components/package_github_info.dart

This file was deleted.

Loading

0 comments on commit 3e9d491

Please sign in to comment.