revanced-manager/lib/ui/widgets/available_updates_card.dart

55 lines
2.1 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
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';
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-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-08-17 18:07:00 +02:00
final GithubAPI githubAPI = GithubAPI();
@override
Widget build(BuildContext context) {
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
? 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
),
),
)
: Container(),
),
],
);
}
}