Skip to content

Commit

Permalink
Add filters
Browse files Browse the repository at this point in the history
  • Loading branch information
samolego committed Sep 18, 2023
1 parent 805413c commit ea0d3c8
Show file tree
Hide file tree
Showing 6 changed files with 531 additions and 167 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
59 changes: 22 additions & 37 deletions lib/components/tiles.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:canta/util/app_info.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:mobx/mobx.dart';

class UninstalledAppTile extends ListTile {
final String packageName;
Expand Down Expand Up @@ -33,30 +32,19 @@ class UninstalledAppTile extends ListTile {
}
}

class BoolWrap {
@observable
bool _value;

BoolWrap(this._value);

@action
void setValue(bool value) => _value = value;

bool get value => _value;
}

class InstalledAppTile extends StatefulWidget {
final AppInfo appInfo;
final Function(bool?) onCheck;
final bool Function() isSelected;
final BoolWrap visible;

const InstalledAppTile({
super.key,
required this.appInfo,
required this.onCheck,
required this.isSelected,
required this.visible,
required bool visible,
});

@override
Expand All @@ -67,31 +55,28 @@ class _InstalledAppTileState extends State<InstalledAppTile> {
@override
Widget build(BuildContext context) {
return Observer(builder: (context) {
return Visibility(
visible: widget.visible.value,
child: ListTile(
leading: Image.memory(widget.appInfo.icon),
title: Text(widget.appInfo.name),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(widget.appInfo.packageName),
if (widget.appInfo.isSystemApp)
Badge(
label: Row(
children: const [
Icon(Icons.android),
Text("System"),
],
),
backgroundColor: Colors.redAccent,
return ListTile(
leading: Image.memory(widget.appInfo.icon),
title: Text(widget.appInfo.name),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(widget.appInfo.packageName),
if (widget.appInfo.isSystemApp)
const Badge(
label: Row(
children: [
Icon(Icons.android),
Text("System"),
],
),
],
),
trailing: Checkbox(
value: widget.isSelected(),
onChanged: (value) => widget.onCheck(value),
),
backgroundColor: Colors.redAccent,
),
],
),
trailing: Checkbox(
value: widget.isSelected(),
onChanged: (value) => widget.onCheck(value),
),
);
});
Expand Down
Loading

0 comments on commit ea0d3c8

Please sign in to comment.