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

52 lines
2.0 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 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-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(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>(
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: false,
onPressed: () => {},
),
),
)
: Container(),
),
],
);
}
}