toolbarItemSemantics

The single accessibility contract for every toolbar item (A11Y-1 / P1-6).

Applied at the leaf composable of each item by NutrientToolbarLayout; producers never call it directly. Centralizing it means a11y review is a one-time design exercise instead of per-PR vigilance, and it matches or exceeds the View toolbar's AppCompatImageButton baseline.

It sets, from item and its state:

  • RoleRole.Switch for a ToolbarItem.Toggle, Role.Button otherwise.

  • contentDescriptionitem.contentDescription (the label TalkBack reads).

  • stateDescription"on"/"off" for a toggle; otherwise "selected", "disabled", "selected and disabled", or unset when the item is in its default state.

  • testTag — derived from item.id via toToolbarTestTag (closes P1-12: customers map per-button R.id Espresso matchers to onNodeWithTag mechanically).

  • disabled() + 38% alpha when not enabled; hidden from accessibility when not visible.

  • an onClick label ("Activate …", or "Open … menu" for a submenu) so TalkBack reads a meaningful action; the actual click is handled by the host composable's clickable.

It's @Composable because the test tag is resolved from the R.id resource name, which needs a Context (LocalContext).

Note: ToolbarItem.Submenu expanded/collapsed announcement is deferred to the popup layer (it depends on transient expansion state not held by ToolbarItem).