testsAndMisc/focus_owner/lib/status_card_parts.dart
Krzysztof kuhy Rudnicki d9982e53dd Split the focus_owner Dart files under the cap
main.dart 538 -> 130, policy.dart 272 -> 85, enforcement_status_card.dart
268 -> 145, plus both test files.

Every lib split uses part/part of rather than import. The first attempt
used import+export and the analyzer gave 30 errors like "The name
'_Card' isn't a class": Dart privates are visible to the whole LIBRARY,
and a separate file is a separate library unless it is a part.

The test splits separated groups from the testWidgets() calls that had
been initialising the binding implicitly, so four tests failed with
"Binding has not yet been initialized" - both halves now call
ensureInitialized() explicitly.

94 tests passing before and after; flutter analyze reports no issues.
focus_owner/analysis_options.yaml has an uncommitted change from an
earlier session and is deliberately left unstaged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
2026-08-16 20:39:13 +02:00

129 lines
3.6 KiB
Dart

/// The card's list, field and note sub-widgets.
///
/// Split out of enforcement_status_card.dart to keep it under the 250-line cap. A `part`
/// because Dart privates are library-scoped and these widgets are private.
part of 'enforcement_status_card.dart';
/// The hidden apps, each with the rule that hid it.
class _HiddenList extends StatelessWidget {
const _HiddenList({required this.hidden});
final List<HiddenPackage> hidden;
@override
Widget build(BuildContext context) {
return Theme(
data: Theme.of(context).copyWith(dividerColor: Colors.transparent),
child: ExpansionTile(
tilePadding: EdgeInsets.zero,
title: Text(
'Why these ${hidden.length} apps are hidden',
style: const TextStyle(color: kAccent, fontSize: 14),
),
children: [
for (final entry in hidden)
Padding(
padding: const EdgeInsets.only(bottom: 6),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Text(
entry.package,
style: const TextStyle(color: kText, fontSize: 12),
),
),
const SizedBox(width: kGap / 2),
Text(
entry.reason.explanation,
style: TextStyle(
color: entry.reason == HideReason.alwaysBlocked
? kDanger
: kMuted,
fontSize: 12,
),
),
],
),
),
],
),
);
}
}
class _Card extends StatelessWidget {
const _Card({required this.child});
final Widget child;
// A Material rather than a plain decorated box: the hidden-apps
// ExpansionTile paints its ink on the nearest Material ancestor, and a
// DecoratedBox in between swallows the ripple.
@override
Widget build(BuildContext context) => Material(
color: kSurface,
borderRadius: BorderRadius.circular(8),
child: Container(
width: double.infinity,
padding: const EdgeInsets.all(kGap),
child: child,
),
);
}
class _Field extends StatelessWidget {
const _Field({required this.label, required this.value, this.danger = false});
final String label;
final String value;
final bool danger;
@override
Widget build(BuildContext context) => Padding(
padding: const EdgeInsets.only(bottom: 6),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
width: 150,
child: Text(
label,
style: const TextStyle(color: kMuted, fontSize: 13),
),
),
Expanded(
child: Text(
value,
style: TextStyle(
color: danger ? kDanger : kText,
fontSize: 13,
),
),
),
],
),
);
}
class _Note extends StatelessWidget {
const _Note({required this.text, this.danger = false});
final String text;
final bool danger;
@override
Widget build(BuildContext context) => Padding(
padding: const EdgeInsets.only(top: 4, bottom: 6),
child: Text(
text,
style: TextStyle(
color: danger ? kDanger : kWarn,
fontSize: 12,
height: 1.3,
),
),
);
}