Repository navigation
feat(menu-item): label the toggle and add a row action - #63
Conversation
A toggle accessory was exposed as an unlabelled Toggle, and a row that both opens an explainer and carries a switch could not keep them apart: wrapping the row in a Button merged the switch into it. The switch is now labelled with the row title, and MenuItem(…, action:) makes the icon and text one button while the accessory stays its own element. The existing initializer is unchanged. Fixes #56 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
romchornyi-pitcrew
left a comment
There was a problem hiding this comment.
Verdict: approve
No blockers or majors. Reviewed at 20fb607.
| Level | Verdict |
|---|---|
| 1 · Idea | ✅ Fixes #56: an unlabelled switch, and a row that cannot keep its explainer and its switch apart |
| 2 · Architecture | ✅ An additive overload. The old initializer and every caller are unchanged |
| 3 · Completeness | ✅ Docs and a preview are included. The app-side follow-up (dropping the dashwallet-ios#1282 workaround) is named |
| 4 · Code | ✅ Clean |
Checked
- Without
actionthe body is the sameleading/central/Spacersequence as before, so existing rows render identically. CI "Snapshot tests" and "Before / After" pass with the old references. - With
actionthe button is disabled with the row (.disabled(!isEnabled)), and.contentShape(Rectangle())keeps the whole text area tappable, including the spacer. MenuItem(title:)without an action still resolves to the old initializer, becauseactionhas no default in the overload. A trailing closure picks the new one.SwitchViewgets.accessibilityLabel(Text(title)). That fits the toggle-row convention: the switch is the row's setting.
Recommendations (non-blocking)
- Snapshot of the new variant.
MenuItemSnapshotTestshas no row withaction. One case (toggle + action, enabled and disabled) would pin the "same layout, only wrapped in a plain button" claim and the disabled styling inside a disabledButton. - Two elements with the same leading name. With
action, the button reads "Advanced mode, Tap to learn more" and the switch reads "Advanced mode". For Voice Control both answer to "tap Advanced mode", so it falls back to numbered disambiguation. It is still separable, which is the point of #56. Consider an.accessibilityHinton the button, or let the host pass a distinct label for the explainer. - Device check. "Not yet checked with VoiceOver on a device" is fair for a library change. Please carry it into the app follow-up's test notes so it is not lost.
🤖 Reviewed with Claude Code
Issue being fixed or feature implemented
Fixes #56. A
MenuItemtoggle accessory was exposed to assistive technologies as an unlabelledToggle, and a row that both opens an explainer and carries a switch could not keep the two apart: wrapping the row in aButtonmerged the switch into it. dashwallet-ios works around this in Settings (dashpay/dashwallet-ios#1282: the whole row is the switch, the explainer is a "Learn more" custom action that Voice Control does not list).What was done?
.toggleaccessory: theSwitchViewgets.accessibilityLabel(Text(title)), so it reads as the row's setting.MenuItem(…, action:)initializer andactionproperty. With an action, the icon and text are oneButton(plain style, disabled with the row) and the accessory stays a separate element. Without one the row behaves as before.docs/lists-and-rows.mddocuments the action and the toggle label.How Has This Been Tested?
swift build,.github/scripts/conventions.sh.Before / After
Rows without
actionrender exactly as before; withactionthe layout is the sameHStack, only wrapped in a plain button. The toggle label is not drawn.Breaking Changes
None. The previous initializer keeps its signature.
Checklist:
🤖 Generated with Claude Code
Summary by CodeRabbit