mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-20 21:52:18 +01:00
Four lib files and the 536-line UI flow test, into seven new files. Only Flutter's generated windows/runner/win32_window.cpp remains, and editing that would be undone by regeneration. All four lib splits used part/part of first time, applying the rule learned in focus_owner. models.dart needed a hand fix: it has a `library;` directive, which must precede any `part`. 60 tests passing before and after. flutter analyze reports the same 4 pre-existing infos as a detached worktree at HEAD - which is how I caught that an intermediate run's 7 issues were 3 of my own. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
140 lines
4.0 KiB
Dart
140 lines
4.0 KiB
Dart
/// Person and group tile widgets.
|
|
///
|
|
/// Split out of people_screen.dart to keep it under the 250-line cap. A `part`
|
|
/// because Dart privates are library-scoped.
|
|
|
|
part of 'people_screen.dart';
|
|
|
|
class _PersonTile extends StatelessWidget {
|
|
const _PersonTile({required this.person});
|
|
final Person person;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final state = context.read<AppState>();
|
|
return ListTile(
|
|
leading: CircleAvatar(
|
|
child: Text(
|
|
person.name.isEmpty ? '?' : person.name.substring(0, 1).toUpperCase(),
|
|
),
|
|
),
|
|
title: Text(person.name),
|
|
subtitle: Wrap(
|
|
spacing: 6,
|
|
children: [
|
|
for (final g in state.groups.where(
|
|
(g) => g.memberIds.contains(person.id),
|
|
))
|
|
Chip(
|
|
label: Text(g.name, style: const TextStyle(fontSize: 11)),
|
|
visualDensity: VisualDensity.compact,
|
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
),
|
|
],
|
|
),
|
|
trailing: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Tooltip(
|
|
message: 'Drinks alcohol',
|
|
child: Switch(
|
|
value: person.drinks,
|
|
onChanged: (v) => state.mutate(() => person.drinks = v),
|
|
),
|
|
),
|
|
IconButton(
|
|
icon: const Icon(Icons.delete_outline),
|
|
onPressed: () => _confirmRemove(context, state),
|
|
),
|
|
],
|
|
),
|
|
onTap: () => _editMembership(context, state),
|
|
);
|
|
}
|
|
|
|
Future<void> _confirmRemove(BuildContext context, AppState state) async {
|
|
final ok = await showDialog<bool>(
|
|
context: context,
|
|
builder: (c) => AlertDialog(
|
|
title: Text('Remove ${person.name}?'),
|
|
content: const Text(
|
|
'They will be removed from all receipts and item assignments.',
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(c, false),
|
|
child: const Text('Cancel'),
|
|
),
|
|
FilledButton(
|
|
onPressed: () => Navigator.pop(c, true),
|
|
child: const Text('Remove'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
if (ok == true) state.removePerson(person);
|
|
}
|
|
|
|
Future<void> _editMembership(BuildContext context, AppState state) async {
|
|
if (state.groups.isEmpty) return;
|
|
await showModalBottomSheet<void>(
|
|
context: context,
|
|
builder: (c) => StatefulBuilder(
|
|
builder: (c, setState) => SafeArea(
|
|
child: ListView(
|
|
shrinkWrap: true,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Text(
|
|
'${person.name} — groups',
|
|
style: Theme.of(c).textTheme.titleMedium,
|
|
),
|
|
),
|
|
for (final g in state.groups)
|
|
CheckboxListTile(
|
|
title: Text(g.name),
|
|
value: g.memberIds.contains(person.id),
|
|
onChanged: (v) {
|
|
state.mutate(() {
|
|
if (v == true) {
|
|
g.memberIds.add(person.id);
|
|
} else {
|
|
g.memberIds.remove(person.id);
|
|
}
|
|
});
|
|
setState(() {});
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _GroupTile extends StatelessWidget {
|
|
const _GroupTile({required this.group});
|
|
final Group group;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final state = context.read<AppState>();
|
|
final names = state.people
|
|
.where((p) => group.memberIds.contains(p.id))
|
|
.map((p) => p.name)
|
|
.join(', ');
|
|
return ListTile(
|
|
leading: const Icon(Icons.label_outline),
|
|
title: Text(group.name),
|
|
subtitle:
|
|
Text(names.isEmpty ? 'No members — tap a person to add' : names),
|
|
trailing: IconButton(
|
|
icon: const Icon(Icons.delete_outline),
|
|
onPressed: () => state.removeGroup(group),
|
|
),
|
|
);
|
|
}
|
|
}
|