Files
pipelines/app/lib/features/runs/actions/decision_option_row.dart
T
alan e43cc867f9 Sheets, decision options, usage, settings and artifact errors: review r2 batches H and L
Shared AppSheetHeader (title + Done) for the Runs filter/sort and Needs you
sheets; Runs filter single-choice groups as check rows and statuses in
sentence case; Cupertino decision options as a check list; run action sheet
titled with the run; usage page without the duplicate title and with honest
empty states; Settings Reconnect wording, compact notifications row and a
tinted Cupertino Save workspace; friendly artifact preview failures with
Retry.
2026-10-31 12:13:34 +00:00

110 lines
3.3 KiB
Dart

import 'package:flutter/cupertino.dart';
/// One option row in the Cupertino decision prompt, keyed by the option.
ValueKey<String> decisionOptionKey(String option) =>
ValueKey<String>('human-decision-option-$option');
/// One choice of the Cupertino decision prompt: a check-list row.
///
/// The option reads as text in the label colour, not as a blue link, with its
/// target underneath in the secondary colour. An empty circle marks an
/// unpicked row and a filled check circle the picked one, so the choice is
/// visible before Confirm. The whole row is the tap target; semantics report
/// it as a selectable member of one exclusive group. A null [onTap] (while
/// sending) dims the row.
class DecisionOptionRow extends StatelessWidget {
const DecisionOptionRow({
super.key,
required this.label,
required this.selected,
required this.onTap,
this.target,
this.divider = false,
});
final String label;
final String? target;
final bool selected;
final bool divider;
final VoidCallback? onTap;
@override
Widget build(BuildContext context) {
final theme = CupertinoTheme.of(context);
final enabled = onTap != null;
final labelColor = enabled
? CupertinoColors.label.resolveFrom(context)
: CupertinoColors.tertiaryLabel.resolveFrom(context);
final mark = selected
? Icon(
CupertinoIcons.checkmark_circle_fill,
color: enabled
? theme.primaryColor
: CupertinoColors.tertiaryLabel.resolveFrom(context),
)
: Icon(
CupertinoIcons.circle,
color: CupertinoColors.tertiaryLabel.resolveFrom(context),
);
final row = Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: Row(
children: [
mark,
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
label,
textAlign: TextAlign.start,
style: theme.textTheme.textStyle.copyWith(
color: labelColor,
fontWeight: selected ? FontWeight.w600 : null,
),
),
if (target case final target?)
Text(
target,
textAlign: TextAlign.start,
style: theme.textTheme.textStyle.copyWith(
fontSize: 13,
color: CupertinoColors.secondaryLabel.resolveFrom(
context,
),
),
),
],
),
),
],
),
);
return Semantics(
inMutuallyExclusiveGroup: true,
selected: selected,
checked: selected,
button: true,
enabled: enabled,
child: DecoratedBox(
decoration: BoxDecoration(
border: divider
? Border(
top: BorderSide(
color: CupertinoColors.separator.resolveFrom(context),
width: 0,
),
)
: null,
),
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: onTap,
child: row,
),
),
);
}
}