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';
|
|
|
|
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
|
2022-09-05 04:32:36 +02:00
|
|
|
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-11 22:17:10 +02:00
|
|
|
const LatestCommitCard({
|
2023-11-11 13:07:32 +01:00
|
|
|
super.key,
|
2023-08-03 22:23:56 +02:00
|
|
|
required this.model,
|
|
|
|
required this.parentContext,
|
2023-11-11 13:07:32 +01:00
|
|
|
});
|
2023-08-03 22:23:56 +02:00
|
|
|
final HomeViewModel model;
|
|
|
|
final BuildContext parentContext;
|
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-09-11 03:01:06 +02:00
|
|
|
final HomeViewModel model = locator<HomeViewModel>();
|
2022-08-01 20:06:27 +02:00
|
|
|
|
2022-07-31 21:46:27 +02:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-04-18 09:57:26 +02:00
|
|
|
return Column(
|
|
|
|
children: [
|
|
|
|
// ReVanced Manager
|
|
|
|
CustomCard(
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
2022-09-02 15:35:25 +02:00
|
|
|
children: <Widget>[
|
2023-08-03 23:38:38 +02:00
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
const Text('ReVanced Manager'),
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
Row(
|
|
|
|
children: <Widget>[
|
|
|
|
FutureBuilder<String?>(
|
|
|
|
future: model.getLatestManagerReleaseTime(),
|
|
|
|
builder: (context, snapshot) => snapshot.hasData &&
|
|
|
|
snapshot.data!.isNotEmpty
|
|
|
|
? I18nText(
|
|
|
|
'latestCommitCard.timeagoLabel',
|
|
|
|
translationParams: {'time': snapshot.data!},
|
|
|
|
)
|
|
|
|
: I18nText('latestCommitCard.loadingLabel'),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-08-13 11:56:30 +02:00
|
|
|
),
|
2023-04-18 09:57:26 +02:00
|
|
|
FutureBuilder<bool>(
|
2023-04-29 21:09:42 +02:00
|
|
|
future: model.hasManagerUpdates(),
|
2023-04-18 09:57:26 +02:00
|
|
|
initialData: false,
|
2024-01-25 18:20:34 +01:00
|
|
|
builder: (context, snapshot) => FilledButton(
|
|
|
|
onPressed: () => widget.model.showUpdateConfirmationDialog(
|
|
|
|
widget.parentContext,
|
|
|
|
false,
|
|
|
|
!snapshot.data!,
|
2022-08-16 19:49:46 +02:00
|
|
|
),
|
2024-01-25 18:20:34 +01:00
|
|
|
child: (snapshot.hasData && !snapshot.data!)
|
|
|
|
? I18nText('showChangelogButton')
|
|
|
|
: I18nText('showUpdateButton'),
|
2023-04-18 09:57:26 +02:00
|
|
|
),
|
2022-08-01 10:38:22 +02:00
|
|
|
),
|
2022-07-31 21:46:27 +02:00
|
|
|
],
|
|
|
|
),
|
2023-04-18 09:57:26 +02:00
|
|
|
),
|
|
|
|
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
|
2023-10-15 11:56:02 +02:00
|
|
|
// Patches
|
2023-04-18 09:57:26 +02:00
|
|
|
CustomCard(
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: <Widget>[
|
2023-08-03 23:38:38 +02:00
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
2024-01-25 18:20:34 +01:00
|
|
|
const Text('ReVanced Patches'),
|
2023-08-03 23:38:38 +02:00
|
|
|
const SizedBox(height: 4),
|
|
|
|
Row(
|
|
|
|
children: <Widget>[
|
|
|
|
FutureBuilder<String?>(
|
|
|
|
future: model.getLatestPatchesReleaseTime(),
|
|
|
|
builder: (context, snapshot) => Text(
|
|
|
|
snapshot.hasData && snapshot.data!.isNotEmpty
|
|
|
|
? FlutterI18n.translate(
|
|
|
|
context,
|
|
|
|
'latestCommitCard.timeagoLabel',
|
|
|
|
translationParams: {'time': snapshot.data!},
|
|
|
|
)
|
|
|
|
: FlutterI18n.translate(
|
|
|
|
context,
|
|
|
|
'latestCommitCard.loadingLabel',
|
|
|
|
),
|
|
|
|
),
|
2023-04-18 09:57:26 +02:00
|
|
|
),
|
2023-08-03 23:38:38 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-08-18 18:32:58 +02:00
|
|
|
),
|
2023-04-18 09:57:26 +02:00
|
|
|
FutureBuilder<bool>(
|
2024-01-25 18:20:34 +01:00
|
|
|
future: model.hasPatchesUpdates(),
|
2023-04-18 09:57:26 +02:00
|
|
|
initialData: false,
|
2024-01-25 18:20:34 +01:00
|
|
|
builder: (context, snapshot) => FilledButton(
|
|
|
|
onPressed: () => widget.model.showUpdateConfirmationDialog(
|
|
|
|
widget.parentContext,
|
|
|
|
true,
|
|
|
|
!snapshot.data!,
|
2023-04-18 09:57:26 +02:00
|
|
|
),
|
2024-01-25 18:20:34 +01:00
|
|
|
child: (snapshot.hasData && !snapshot.data!)
|
|
|
|
? I18nText('showChangelogButton')
|
|
|
|
: I18nText('showUpdateButton'),
|
2023-04-18 09:57:26 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
2022-08-01 10:38:22 +02:00
|
|
|
),
|
2023-04-18 09:57:26 +02:00
|
|
|
),
|
|
|
|
],
|
2022-07-31 21:46:27 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|