2022-07-31 21:46:27 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2022-08-07 01:37:12 +02:00
|
|
|
import 'package:flutter_i18n/flutter_i18n.dart';
|
2022-08-18 18:32:58 +02:00
|
|
|
import 'package:revanced_manager/app/app.locator.dart';
|
2022-08-06 23:35:35 +02:00
|
|
|
import 'package:revanced_manager/services/github_api.dart';
|
|
|
|
import 'package:revanced_manager/constants.dart';
|
2022-08-18 18:32:58 +02:00
|
|
|
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
|
2022-09-05 04:32:36 +02:00
|
|
|
import 'package:revanced_manager/ui/widgets/installerView/custom_material_button.dart';
|
|
|
|
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
|
2022-07-31 21:46:27 +02:00
|
|
|
|
2022-08-01 20:15:55 +02:00
|
|
|
class LatestCommitCard extends StatefulWidget {
|
2022-08-18 16:33:33 +02:00
|
|
|
final Function() onPressed;
|
2022-09-01 12:16:14 +02:00
|
|
|
|
2022-08-11 22:17:10 +02:00
|
|
|
const LatestCommitCard({
|
|
|
|
Key? key,
|
2022-08-18 16:33:33 +02:00
|
|
|
required this.onPressed,
|
2022-08-11 22:17:10 +02:00
|
|
|
}) : super(key: key);
|
2022-07-31 21:46:27 +02:00
|
|
|
|
2022-08-01 20:06:27 +02:00
|
|
|
@override
|
2022-08-01 20:15:55 +02:00
|
|
|
State<LatestCommitCard> createState() => _LatestCommitCardState();
|
2022-08-01 20:06:27 +02:00
|
|
|
}
|
|
|
|
|
2022-08-01 20:15:55 +02:00
|
|
|
class _LatestCommitCardState extends State<LatestCommitCard> {
|
2022-08-18 16:33:33 +02:00
|
|
|
final GithubAPI _githubAPI = GithubAPI();
|
2022-08-01 20:06:27 +02:00
|
|
|
|
2022-07-31 21:46:27 +02:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-09-05 04:32:36 +02:00
|
|
|
return CustomCard(
|
2022-07-31 21:46:27 +02:00
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
2022-09-02 15:35:25 +02:00
|
|
|
children: <Widget>[
|
2022-07-31 21:46:27 +02:00
|
|
|
Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
2022-09-02 15:35:25 +02:00
|
|
|
children: <Widget>[
|
2022-08-16 19:49:46 +02:00
|
|
|
Row(
|
2022-09-02 15:35:25 +02:00
|
|
|
children: <Widget>[
|
2022-08-16 19:49:46 +02:00
|
|
|
I18nText(
|
|
|
|
'latestCommitCard.patcherLabel',
|
2022-09-05 04:32:36 +02:00
|
|
|
child: const Text(
|
2022-08-16 19:49:46 +02:00
|
|
|
'',
|
2022-09-05 04:32:36 +02:00
|
|
|
style: TextStyle(fontWeight: FontWeight.bold),
|
2022-08-16 19:49:46 +02:00
|
|
|
),
|
2022-08-01 10:38:22 +02:00
|
|
|
),
|
2022-08-16 19:49:46 +02:00
|
|
|
FutureBuilder<String>(
|
2022-08-18 16:33:33 +02:00
|
|
|
future: _githubAPI.latestCommitTime(ghOrg, patcherRepo),
|
2022-08-16 19:49:46 +02:00
|
|
|
builder: (context, snapshot) => Text(
|
2022-08-17 14:48:56 +02:00
|
|
|
snapshot.hasData && snapshot.data!.isNotEmpty
|
2022-08-17 14:25:08 +02:00
|
|
|
? FlutterI18n.translate(
|
|
|
|
context,
|
|
|
|
'latestCommitCard.timeagoLabel',
|
|
|
|
translationParams: {'time': snapshot.data!},
|
|
|
|
)
|
2022-08-17 14:18:08 +02:00
|
|
|
: FlutterI18n.translate(
|
|
|
|
context,
|
|
|
|
'latestCommitCard.loadingLabel',
|
|
|
|
),
|
2022-08-16 19:49:46 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
2022-08-13 11:56:30 +02:00
|
|
|
),
|
|
|
|
const SizedBox(height: 8),
|
2022-08-16 19:49:46 +02:00
|
|
|
Row(
|
2022-09-02 15:35:25 +02:00
|
|
|
children: <Widget>[
|
2022-08-16 19:49:46 +02:00
|
|
|
I18nText(
|
|
|
|
'latestCommitCard.managerLabel',
|
2022-09-05 04:32:36 +02:00
|
|
|
child: const Text(
|
2022-08-16 19:49:46 +02:00
|
|
|
'',
|
2022-09-05 04:32:36 +02:00
|
|
|
style: TextStyle(fontWeight: FontWeight.bold),
|
2022-08-16 19:49:46 +02:00
|
|
|
),
|
2022-08-08 00:40:31 +02:00
|
|
|
),
|
2022-08-16 19:49:46 +02:00
|
|
|
FutureBuilder<String>(
|
2022-08-18 16:33:33 +02:00
|
|
|
future: _githubAPI.latestCommitTime(ghOrg, managerRepo),
|
2022-09-05 04:32:36 +02:00
|
|
|
builder: (context, snapshot) =>
|
|
|
|
snapshot.hasData && snapshot.data!.isNotEmpty
|
|
|
|
? I18nText(
|
|
|
|
'latestCommitCard.timeagoLabel',
|
|
|
|
translationParams: {'time': snapshot.data!},
|
|
|
|
)
|
|
|
|
: I18nText('latestCommitCard.loadingLabel'),
|
2022-08-16 19:49:46 +02:00
|
|
|
),
|
|
|
|
],
|
2022-08-01 10:38:22 +02:00
|
|
|
),
|
2022-07-31 21:46:27 +02:00
|
|
|
],
|
|
|
|
),
|
2022-08-18 18:32:58 +02:00
|
|
|
FutureBuilder<bool>(
|
|
|
|
future: locator<HomeViewModel>().hasManagerUpdates(),
|
|
|
|
initialData: false,
|
|
|
|
builder: (context, snapshot) => Opacity(
|
2022-09-05 16:31:22 +02:00
|
|
|
opacity: snapshot.hasData && snapshot.data! ? 1.0 : 0.5,
|
2022-09-05 04:32:36 +02:00
|
|
|
child: CustomMaterialButton(
|
|
|
|
isExpanded: false,
|
|
|
|
label: I18nText('latestCommitCard.updateButton'),
|
2022-08-18 18:32:58 +02:00
|
|
|
onPressed: snapshot.hasData && snapshot.data!
|
|
|
|
? widget.onPressed
|
|
|
|
: () => {},
|
|
|
|
),
|
2022-08-07 01:37:12 +02:00
|
|
|
),
|
2022-08-01 10:38:22 +02:00
|
|
|
),
|
2022-07-31 21:46:27 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|