Skip to content

[ARCtic-conf] AccessibilitySnapshotPreviews with SwiftUI support#312

Draft
RoyalPineapple wants to merge 22 commits intomainfrom
ARCtic-conf
Draft

[ARCtic-conf] AccessibilitySnapshotPreviews with SwiftUI support#312
RoyalPineapple wants to merge 22 commits intomainfrom
ARCtic-conf

Conversation

@RoyalPineapple
Copy link
Copy Markdown
Collaborator

Summary

  • Introduces new AccessibilitySnapshotPreviews framework providing SwiftUI-based accessibility visualization
  • Implements layout engine for rendering accessibility annotations with enhanced visual design
  • Adds comprehensive demo apps and test infrastructure for SwiftUI previews

Test plan

  • All snapshot tests pass for AccessibilitySnapshotPreviews demo apps
  • CI pipeline executes successfully with updated configuration
  • Generated reference images match across iOS versions

@RoyalPineapple RoyalPineapple marked this pull request as draft February 5, 2026 17:28
@RoyalPineapple RoyalPineapple changed the title Add AccessibilitySnapshotPreviews framework with SwiftUI support [ARCtic-conf] Add AccessibilitySnapshotPreviews framework with SwiftUI support Feb 10, 2026
@RoyalPineapple RoyalPineapple force-pushed the ARCtic-conf branch 4 times, most recently from 8f07bc2 to 9f431c2 Compare February 10, 2026 18:03
RoyalPineapple and others added 19 commits February 11, 2026 17:33
New types:
- `AccessibilityRenderer` enum (.uikit, .swiftui) for selecting render backend
- `ColorPalette` with .legacy and .modern presets, unified UIColor/SwiftUI Color API
- `LegendLayoutMetrics` shared layout constants for UIKit and SwiftUI renderers
- `AccessibilitySnapshotBaseView` abstract base class for snapshot views

Changes to existing Core files:
- `AccessibilitySnapshotConfiguration` defaults to empty color array (palette handles fallback)
- `OverlayView` accepts separate fill/stroke colors from palette
- `LegendView` accepts fill color from palette
- `AccessibilitySnapshotView` uses ColorPalette for color management
- Deprecate `MarkerColors.defaultColors` in favor of `ColorPalette.legacy`

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Complete SwiftUI-based accessibility snapshot renderer:

View Components:
- `SwiftUIAccessibilitySnapshotView` - Main container for SwiftUI content
- `SwiftUIAccessibilitySnapshotContainerView` - UIKit wrapper for hosting
- `ElementView` - Overlay marker and shape rendering
- `ActivationPointView` - Crosshairs for activation points
- `DescriptionView` / `HintView` - Text content display

Legend Components:
- `SwiftUILegendView` - Multi-column legend layout
- `LegendEntryView` - Individual legend entry with marker and content
- `TraitsView` - Unspoken traits as pills (incl. supportsZoom)
- `CustomActionsView` / `CustomContentView` / `CustomRotorsView`
- `UserInputLabelsView` - Voice Control input labels

Layout Primitives:
- `PillFlowLayout` - Horizontal flow with wrapping
- `ColumnWrapLayout` - Multi-column balanced layout

Styling:
- `SwiftUIDesignTokens` - Centralized styling constants

Parser:
- Add `rotorResultLimit` support for custom rotor parsing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
FBSnapshotTestCase extensions:
- Add `renderer` parameter to `SnapshotVerifyAccessibility` functions
- Default to `.uikit` for backwards compatibility
- SwiftUI views can now specify `.swiftui` renderer
- Update `markerColors` defaults to use ColorPalette

SnapshotTesting extensions:
- Add `renderer` parameter to accessibility snapshot strategies
- Maintain existing API with default UIKit renderer

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Package.swift:
- Add SwiftUI_Experimental library target
- Add SwiftUI_Experimental dependency to iOSSnapshotTestCase

Example/Project.swift (Tuist):
- Add SwiftUI_Experimental framework target
- Add SwiftUIExperimentalDemo app target (iOS 18.0+)
- Add SwiftUIExperimentalTests test target (iOS 18.0+)
- Add SwiftUIExperimentalDemo scheme with test action
- FBSnapshotTestCase_Accessibility depends on SwiftUI_Experimental
- AccessibilitySnapshotDemo depends on SwiftUI_Experimental

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
SwiftUIExperimentalDemo app:
- BasicAccessibilityDemo - Labels, values, hints, adjustable elements
- FormElementsDemo - Buttons, toggles, sliders, pickers, text fields
- CustomActionsDemo - Custom accessibility actions
- ContainersDemo - Data tables, list/landmark containers
- RotorsDemo - Custom accessibility rotors with search
- ColorPaletteDemo - Modern/legacy palette comparison
- InputLabelsDemo - Voice Control input labels
- SortPriorityDemo - Accessibility sort priority

SwiftUIExperimentalTests:
- SwiftUIExperimentalTestCase - Base class with device validation
- SwiftUIRendererTests - Snapshot tests for all demo views

AccessibilitySnapshotDemo:
- UnspokenTraitsDemoView - SwiftUI view showing unspoken traits

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Reference images for SwiftUIExperimentalTests on:
- iOS 18.5 (402x874 @3x)
- iOS 26.2 (402x874 @3x)

Tests covered:
- testBasicAccessibilityDemo
- testContainersDemo
- testCustomActionsDemo
- testCustomRotorsDemo
- testInputLabelsDemo
- testSortPriorityDemo

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Rename AccessibilityRenderer enum to LayoutEngine
- Rename renderer: parameter to layoutEngine: in public APIs
- Rename cleanUpPreviousOverlays() to cleanup()
- Rename createOverlays(with:) to render(data:)
- Remove verbose AI-style comments

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This completes the 2x2 matrix of layout engines × comparison libraries:

|                    | FBSnapshotTestCase | SnapshotTesting |
|--------------------|-------------------|-----------------|
| UIKit Layout       | ✅ Works          | ✅ Works        |
| SwiftUI Layout     | ✅ Works          | ✅ Works (NEW)  |

Changes:
- Add SwiftUI_Experimental dependency to AccessibilitySnapshot target
- Add layoutEngine parameter to .accessibilityImage() strategy
- Make LayoutEngine.default mutable for global configuration
- Consolidate SwiftUI Experimental demos from 7 to 4
- Lower SwiftUI_Experimental to iOS 16.0

Usage:
```swift
// Per-test override
assertSnapshot(of: view, as: .accessibilityImage(layoutEngine: .swiftui))

// Global default
LayoutEngine.default = .swiftui
assertSnapshot(of: view, as: .accessibilityImage())
```

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Cherry-picked from RoyalPineapple/swiftui-ui-iteration.
Changed availability from iOS 18 to iOS 16 to match project requirements.
Removed 26.0.1 test device config (not used in CI).

Original commit: effd1dc
- Rename module: SwiftUI_Experimental → AccessibilitySnapshotPreviews
- Rename demo app: SwiftUIExperimentalDemo → AccessibilitySnapshotPreviewsDemo
- Rename tests: SwiftUIExperimentalTests → AccessibilitySnapshotPreviewsTests
- Update Package.swift and Project.swift
- Update all imports
Update reference images with new test class naming and correct iOS 26.2
screen size (440x956 for iPhone 16 Pro Max).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@RoyalPineapple RoyalPineapple changed the title [ARCtic-conf] Add AccessibilitySnapshotPreviews framework with SwiftUI support [ARCtic-conf] AccessibilitySnapshotPreviews with SwiftUI support Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants