mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
feat: fetch real data on the Latest Commit card
This commit is contained in:
parent
3df427dccb
commit
a430537b6f
@ -1,5 +1,6 @@
|
||||
import 'package:github/github.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import 'package:timeago/timeago.dart';
|
||||
|
||||
@lazySingleton
|
||||
class GithubAPI {
|
||||
@ -19,10 +20,10 @@ class GithubAPI {
|
||||
return dlurl;
|
||||
}
|
||||
|
||||
Future<DateTime?> latestCommitTime(String org, repoName) async {
|
||||
Future<String> latestCommitTime(String org, repoName) async {
|
||||
var repo = await github.repositories.getRepository(
|
||||
RepositorySlug(org, repoName),
|
||||
);
|
||||
return repo.pushedAt;
|
||||
return format(repo.pushedAt!);
|
||||
}
|
||||
}
|
||||
|
@ -14,23 +14,6 @@ class LatestCommitCard extends StatefulWidget {
|
||||
|
||||
class _LatestCommitCardState extends State<LatestCommitCard> {
|
||||
GithubAPI githubAPI = GithubAPI();
|
||||
String lastPatcherCommit = 'Loading...';
|
||||
String lastManagerCommit = 'Loading...';
|
||||
|
||||
void latestCommit() async {
|
||||
// lastPatcherCommit =
|
||||
// await githubAPI.latestCommitTime('revanced', 'revanced-patcher');
|
||||
// lastManagerCommit =
|
||||
// await githubAPI.latestCommitTime('revanced', 'revanced-manager');
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
setState(() {
|
||||
latestCommit();
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -57,10 +40,20 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'$lastPatcherCommit ago',
|
||||
style: robotoTextStyle,
|
||||
)
|
||||
FutureBuilder<String>(
|
||||
future: githubAPI.latestCommitTime(
|
||||
'revanced',
|
||||
'revanced-patcher',
|
||||
),
|
||||
initialData: FlutterI18n.translate(
|
||||
context,
|
||||
'latestCommitCard.loadingLabel',
|
||||
),
|
||||
builder: (context, snapshot) => Text(
|
||||
snapshot.data!,
|
||||
style: robotoTextStyle,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
@ -74,10 +67,20 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'$lastManagerCommit ago',
|
||||
style: robotoTextStyle,
|
||||
)
|
||||
FutureBuilder<String>(
|
||||
future: githubAPI.latestCommitTime(
|
||||
'revanced',
|
||||
'revanced-patcher',
|
||||
),
|
||||
initialData: FlutterI18n.translate(
|
||||
context,
|
||||
'latestCommitCard.loadingLabel',
|
||||
),
|
||||
builder: (context, snapshot) => Text(
|
||||
snapshot.data!,
|
||||
style: robotoTextStyle,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
@ -712,6 +712,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.4.9"
|
||||
timeago:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: timeago
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.2.2"
|
||||
timing:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -28,6 +28,7 @@ dependencies:
|
||||
stacked: ^2.3.15
|
||||
stacked_generator: ^0.7.14
|
||||
stacked_services: ^0.9.3
|
||||
timeago: ^3.2.2
|
||||
|
||||
dev_dependencies:
|
||||
build_runner: any
|
||||
|
Loading…
Reference in New Issue
Block a user