2022-07-31 21:46:27 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2022-08-16 15:06:56 +02:00
|
|
|
import 'package:revanced_manager/app/app.locator.dart';
|
|
|
|
import 'package:revanced_manager/models/patched_application.dart';
|
2022-08-17 18:07:00 +02:00
|
|
|
import 'package:revanced_manager/services/github_api.dart';
|
2022-08-16 15:06:56 +02:00
|
|
|
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
|
2022-08-06 23:35:35 +02:00
|
|
|
import 'package:revanced_manager/ui/widgets/application_item.dart';
|
2022-07-31 21:46:27 +02:00
|
|
|
|
2022-08-01 20:15:55 +02:00
|
|
|
class AvailableUpdatesCard extends StatelessWidget {
|
2022-08-17 18:07:00 +02:00
|
|
|
AvailableUpdatesCard({
|
2022-08-11 22:17:10 +02:00
|
|
|
Key? key,
|
|
|
|
}) : super(key: key);
|
2022-07-31 21:46:27 +02:00
|
|
|
|
2022-08-17 18:07:00 +02:00
|
|
|
final GithubAPI githubAPI = GithubAPI();
|
|
|
|
|
2022-07-31 21:46:27 +02:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-08-16 15:06:56 +02:00
|
|
|
return Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
FutureBuilder<List<PatchedApplication>>(
|
|
|
|
future: locator<HomeViewModel>().getPatchedApps(true),
|
|
|
|
builder: (context, snapshot) =>
|
2022-08-17 18:07:00 +02:00
|
|
|
snapshot.hasData && snapshot.data!.isNotEmpty
|
2022-08-16 15:06:56 +02:00
|
|
|
? ListView.builder(
|
2022-08-17 18:07:00 +02:00
|
|
|
shrinkWrap: true,
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
itemCount: snapshot.data!.length,
|
|
|
|
itemBuilder: (context, index) => FutureBuilder<String>(
|
|
|
|
future: githubAPI.getChangelog(
|
|
|
|
snapshot.data![index],
|
|
|
|
'revanced',
|
|
|
|
'revanced-patches',
|
|
|
|
),
|
|
|
|
initialData: '',
|
|
|
|
builder: (context, snapshot2) => ApplicationItem(
|
|
|
|
icon: snapshot.data![index].icon,
|
|
|
|
name: snapshot.data![index].name,
|
|
|
|
patchDate: snapshot.data![index].patchDate,
|
|
|
|
changelog: snapshot2.data!,
|
|
|
|
isUpdatableApp: true,
|
2022-08-17 19:44:27 +02:00
|
|
|
onPressed: () =>
|
|
|
|
locator<HomeViewModel>().navigateToInstaller(
|
|
|
|
snapshot.data![index],
|
|
|
|
),
|
2022-08-17 18:07:00 +02:00
|
|
|
),
|
2022-08-16 15:06:56 +02:00
|
|
|
),
|
|
|
|
)
|
|
|
|
: Container(),
|
|
|
|
),
|
|
|
|
],
|
2022-07-31 21:46:27 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|