Skip to content

Commit

Permalink
Make alerting_apps.dart screen easier to toggle apps
Browse files Browse the repository at this point in the history
Having to target a tiny switch on each list item isn't very ergonomic;
right handed users have to scrunch their hands to be able to access them
and left handled users have to stretch their hands to be able to access them.

Making the entire list delegate toggleable fixes this.
  • Loading branch information
pontaoski committed May 26, 2021
1 parent 7f302fb commit 9060406
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
9 changes: 7 additions & 2 deletions lib/ui/common/components/cobble_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,20 @@ class CobbleTile extends StatelessWidget {
ImageProvider? leading,
required String title,
String? subtitle,
required Widget child,
required void Function(bool)? onChanged,
required bool enabled,
}) =>
CobbleTile._(
key: key,
padding: EdgeInsets.symmetric(vertical: 16, horizontal: 12),
leading: _leadingToWidget(leading, size: 48),
title: title,
subtitle: subtitle,
trailing: child,
trailing: Switch(
value: enabled,
onChanged: onChanged,
),
onTap: () => onChanged!(!enabled),
);

@override
Expand Down
29 changes: 13 additions & 16 deletions lib/ui/screens/alerting_apps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,19 @@ class AlertingApps extends HookWidget implements CobbleScreen {
: tr.alertingApps.mutedToday(
muted: random.nextInt(8).toString(),
),
child: Switch(
value: app.enabled,
onChanged: (value) async {
var mutedPkgList =
mutedPackages.data?.value ?? [];
if (value) {
mutedPkgList.removeWhere(
(element) => element == app.packageId);
} else {
print(app.packageId);
mutedPkgList.add(app.packageId);
}
await preferences.data?.value
.setNotificationsMutedPackages(mutedPkgList);
},
),
enabled: app.enabled,
onChanged: (value) async {
var mutedPkgList = mutedPackages.data?.value ?? [];
if (value) {
mutedPkgList.removeWhere(
(element) => element == app.packageId);
} else {
print(app.packageId);
mutedPkgList.add(app.packageId);
}
await preferences.data?.value
.setNotificationsMutedPackages(mutedPkgList);
},
),
)
.toList(),
Expand Down

0 comments on commit 9060406

Please sign in to comment.