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:github/github.dart';
|
||||||
import 'package:injectable/injectable.dart';
|
import 'package:injectable/injectable.dart';
|
||||||
|
import 'package:timeago/timeago.dart';
|
||||||
|
|
||||||
@lazySingleton
|
@lazySingleton
|
||||||
class GithubAPI {
|
class GithubAPI {
|
||||||
@ -19,10 +20,10 @@ class GithubAPI {
|
|||||||
return dlurl;
|
return dlurl;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<DateTime?> latestCommitTime(String org, repoName) async {
|
Future<String> latestCommitTime(String org, repoName) async {
|
||||||
var repo = await github.repositories.getRepository(
|
var repo = await github.repositories.getRepository(
|
||||||
RepositorySlug(org, repoName),
|
RepositorySlug(org, repoName),
|
||||||
);
|
);
|
||||||
return repo.pushedAt;
|
return format(repo.pushedAt!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,23 +14,6 @@ class LatestCommitCard extends StatefulWidget {
|
|||||||
|
|
||||||
class _LatestCommitCardState extends State<LatestCommitCard> {
|
class _LatestCommitCardState extends State<LatestCommitCard> {
|
||||||
GithubAPI githubAPI = GithubAPI();
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -57,10 +40,20 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
FutureBuilder<String>(
|
||||||
'$lastPatcherCommit ago',
|
future: githubAPI.latestCommitTime(
|
||||||
style: robotoTextStyle,
|
'revanced',
|
||||||
)
|
'revanced-patcher',
|
||||||
|
),
|
||||||
|
initialData: FlutterI18n.translate(
|
||||||
|
context,
|
||||||
|
'latestCommitCard.loadingLabel',
|
||||||
|
),
|
||||||
|
builder: (context, snapshot) => Text(
|
||||||
|
snapshot.data!,
|
||||||
|
style: robotoTextStyle,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
@ -74,10 +67,20 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
FutureBuilder<String>(
|
||||||
'$lastManagerCommit ago',
|
future: githubAPI.latestCommitTime(
|
||||||
style: robotoTextStyle,
|
'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"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.4.9"
|
version: "0.4.9"
|
||||||
|
timeago:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: timeago
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "3.2.2"
|
||||||
timing:
|
timing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -28,6 +28,7 @@ dependencies:
|
|||||||
stacked: ^2.3.15
|
stacked: ^2.3.15
|
||||||
stacked_generator: ^0.7.14
|
stacked_generator: ^0.7.14
|
||||||
stacked_services: ^0.9.3
|
stacked_services: ^0.9.3
|
||||||
|
timeago: ^3.2.2
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
build_runner: any
|
build_runner: any
|
||||||
|
Loading…
Reference in New Issue
Block a user