feat: display app's patch count in appcard

This commit is contained in:
Ushie 2022-12-14 02:12:57 +03:00
parent d78868b462
commit 8d4e4ba6c9
No known key found for this signature in database
GPG key ID: 0EF73F1CA38B2D5F
3 changed files with 29 additions and 8 deletions

View file

@ -92,6 +92,7 @@ class _AppSelectorViewState extends State<AppSelectorView> {
name: app.appName,
pkgName: app.packageName,
icon: app.icon,
patchesCount: model.patchesCount(app.packageName),
onTap: () {
model.selectApp(app);
Navigator.of(context).pop();

View file

@ -15,6 +15,9 @@ class AppSelectorViewModel extends BaseViewModel {
final Toast _toast = locator<Toast>();
final List<ApplicationWithIcon> apps = [];
bool noApps = false;
int patchesCount(String packageName) {
return _patcherAPI.getFilteredPatches(packageName).length;
}
Future<void> initialize() async {
apps.addAll(await _patcherAPI.getFilteredInstalledApps());

View file

@ -6,6 +6,7 @@ class InstalledAppItem extends StatefulWidget {
final String name;
final String pkgName;
final Uint8List icon;
final int patchesCount;
final Function()? onTap;
const InstalledAppItem({
@ -13,6 +14,7 @@ class InstalledAppItem extends StatefulWidget {
required this.name,
required this.pkgName,
required this.icon,
required this.patchesCount,
this.onTap,
}) : super(key: key);
@ -44,6 +46,9 @@ class _InstalledAppItemState extends State<InstalledAppItem> {
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(
widget.name,
@ -54,6 +59,18 @@ class _InstalledAppItemState extends State<InstalledAppItem> {
fontWeight: FontWeight.w500,
),
),
const SizedBox(width: 6),
Text(
widget.patchesCount == 1
? "${widget.patchesCount} patch"
: "${widget.patchesCount} patches",
style: TextStyle(
fontSize: 8,
color: Theme.of(context).colorScheme.secondary,
),
),
],
),
const SizedBox(height: 4),
Text(widget.pkgName),
],