extract SettingsCheckboxTile for settings toggles

This commit is contained in:
2026-07-12 23:41:12 +02:00
parent dfce3e7b5c
commit 4aa31a2e44
5 changed files with 133 additions and 140 deletions
@@ -0,0 +1,42 @@
import 'package:flutter/material.dart';
import '../../../../utils/haptics.dart';
import '../../../../widget/centered_leading.dart';
/// Settings row with a trailing checkbox. Fires [Haptics.selection] before
/// invoking [onChanged] (with the resolved non-null value), so the sections
/// don't repeat that. The leading icon is vertically centered when a [subtitle]
/// is present, matching the surrounding settings styling.
class SettingsCheckboxTile extends StatelessWidget {
final IconData icon;
final String title;
final String? subtitle;
final bool value;
final ValueChanged<bool> onChanged;
const SettingsCheckboxTile({
required this.icon,
required this.title,
required this.value,
required this.onChanged,
this.subtitle,
super.key,
});
@override
Widget build(BuildContext context) {
final leadingIcon = Icon(icon);
return ListTile(
leading: subtitle == null ? leadingIcon : CenteredLeading(leadingIcon),
title: Text(title),
subtitle: subtitle == null ? null : Text(subtitle!),
trailing: Checkbox(
value: value,
onChanged: (e) {
Haptics.selection();
onChanged(e ?? false);
},
),
);
}
}