toAction method
CarpenterActionDescriptor
toAction(
- I input, {
- String? label,
- String? semanticLabel,
- CarpenterIconSource? icon,
- ActionColorRole? colorRole,
- ShortcutActivator? shortcut,
- CarpenterCommandExecutor? executor,
Creates a presentation-only action snapshot for input from the command's current
visibility, availability, execution state, shortcuts, and semantic prominence.
Implementation
CarpenterActionDescriptor toAction(
I input, {
String? label,
String? semanticLabel,
CarpenterIconSource? icon,
ActionColorRole? colorRole,
ShortcutActivator? shortcut,
CarpenterCommandExecutor? executor,
}) {
final current = state.value;
final visible = current.visibility == CarpenterCommandVisibility.visible;
final available =
visible &&
current.enabled &&
current.execution != CarpenterCommandExecution.executing;
return CarpenterActionDescriptor(
id: id,
label: label ?? title,
semanticLabel: semanticLabel,
icon: icon,
colorRole: colorRole ?? _commandColorRole(presentation),
shortcut: shortcut ?? (shortcuts.isEmpty ? null : shortcuts.first),
visible: visible,
disabledReason: available ? null : current.disabledReason,
onInvoke: available
? () {
unawaited(_executeCommandForSurface(this, input, executor));
}
: null,
);
}