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

56 lines
2.2 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'package:revanced_manager/app/app.locator.dart';
2022-08-18 16:33:33 +02:00
import 'package:revanced_manager/constants.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 InstalledAppsCard extends StatelessWidget {
2022-08-17 18:07:00 +02:00
InstalledAppsCard({
2022-08-11 22:17:10 +02:00
Key? key,
}) : super(key: key);
2022-08-18 16:33:33 +02:00
final GithubAPI _githubAPI = GithubAPI();
2022-08-17 18:07:00 +02:00
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
FutureBuilder<List<PatchedApplication>>(
future: locator<HomeViewModel>().getPatchedApps(false),
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>(
2022-08-18 16:33:33 +02:00
future: _githubAPI.getChangelog(
2022-08-17 18:07:00 +02:00
snapshot.data![index],
2022-08-18 16:33:33 +02:00
ghOrg,
patchesRepo,
2022-08-17 18:07:00 +02:00
),
initialData: '',
builder: (context, snapshot2) => ApplicationItem(
icon: snapshot.data![index].icon,
name: snapshot.data![index].name,
patchDate: snapshot.data![index].patchDate,
changelog: snapshot2.data!,
isUpdatableApp: false,
2022-08-17 19:44:27 +02:00
onPressed: () =>
locator<HomeViewModel>().navigateToInstaller(
snapshot.data![index],
),
2022-08-17 18:07:00 +02:00
),
),
)
: Container(),
),
],
);
}
}