Skip to content

Commit

Permalink
feat: display app's patch count in appcard
Browse files Browse the repository at this point in the history
  • Loading branch information
Ushie committed Dec 13, 2022
1 parent d78868b commit 8d4e4ba
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
1 change: 1 addition & 0 deletions lib/ui/views/app_selector/app_selector_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions lib/ui/views/app_selector/app_selector_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
33 changes: 25 additions & 8 deletions lib/ui/widgets/appSelectorView/installed_app_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ class InstalledAppItem extends StatefulWidget {
final String name;
final String pkgName;
final Uint8List icon;
final int patchesCount;
final Function()? onTap;

const InstalledAppItem({
Key? key,
required this.name,
required this.pkgName,
required this.icon,
required this.patchesCount,
this.onTap,
}) : super(key: key);

Expand Down Expand Up @@ -45,14 +47,29 @@ class _InstalledAppItemState extends State<InstalledAppItem> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
widget.name,
maxLines: 2,
overflow: TextOverflow.visible,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(
widget.name,
maxLines: 2,
overflow: TextOverflow.visible,
style: const TextStyle(
fontSize: 16,
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),
Expand Down

0 comments on commit 8d4e4ba

Please sign in to comment.