Skip to content

feat(ios): style SwiftUI controls instead of wrapping CDS views - #893

Merged
adrienzheng-cb merged 6 commits into
masterfrom
adrien/ios-swiftui-styles
Sep 28, 2026
Merged

adrienzheng-cb merged 6 commits into
masterfrom
adrien/ios-swiftui-styles

Conversation

@adrienzheng-cb

@adrienzheng-cb adrienzheng-cb commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

What changed? Why?

iOS should not re-implement system controls as CDS views. This PR reshapes the experimental (internal) iOS components so SwiftUI owns the primitive and CDS owns the look, and adds agent guidance so future migrations follow the same pattern.

SwiftUI Style / modifier instead of CDS wrapper views

  • Button → SwiftUI Button + .buttonStyle(.cds) and CDSButtonLabel for icon spacing
  • Switch → SwiftUI Toggle + .toggleStyle(.cds)
  • Text → SwiftUI Text + .cdsText
  • ProgressCircle → SwiftUI ProgressView + .progressViewStyle(.cds)

SlideButton stays a CDS view — there is no SwiftUI primitive to restyle. The gallery demos each pattern as its own section. Components remain internal.

swiftui-best-practices skill + AGENTS guidance

  • New .claude/skills/swiftui-best-practices skill (rewrite patterns, "why not a wrapper", RN → iOS map); root AGENTS.md loads it for SwiftUI / RN → iOS work.
  • packages/cds-ios/AGENTS.md links the CDS SwiftUI Best Practices doc and adds:
    • Visual spec is RN, not HIG. Match the React Native component; HIG wins only for OS chrome or where iOS physically can't match.
    • Overlays are CDS views. Components like Alert, Accordion, and Tooltip become CDS views matching RN. The OS .alert shown in the gallery is for contrast only; the CDS Alert will be a CDS view matching the RN modal (doc comments and gallery copy updated accordingly).
    • Whole-app CDS is environment inheritance, not wrapper views. CDSThemeProvider sets environment defaults so plain SwiftUI controls pick up CDS styling.

UI changes

Gallery-only. No product screenshot matrix; exercise on iOS Simulator via yarn nx run ios-gallery:launch.

Testing

How has it been tested?

  • Unit tests
  • Interaction tests
  • Pseudo State tests
  • Manual - Web
  • Manual - Android (Emulator / Device)
  • Manual - iOS (Emulator / Device)

Testing instructions

  1. yarn nx run cds-ios:test
  2. yarn nx run ios-gallery:launch
  3. Scroll to Text, Components, Toggle, Alert, ProgressView
  4. Confirm toggles flip, Show system alert presents a system dialog (contrast reference only), and progress rings spin (plus a determinate ring)

Change management

type=routine
risk=low
impact=sev5

automerge=false

Made with Cursor

Keep Button, Toggle, Text, and ProgressView as SwiftUI primitives and ship CDS
ButtonStyle, ToggleStyle, cdsText, and ProgressViewStyle. Alert stays a system
.alert with no CDS view.

Co-authored-by: Cursor <cursoragent@cursor.com>
@cb-heimdall

cb-heimdall commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Heimdall Review Status

Requirement Status More Info
Reviews ✅ 1/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 1
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1
CODEOWNERS ✅ See below

✅ CODEOWNERS

Code Owner Status Calculation
ui-systems-eng-team ✅ 1/1
Denominator calculation
Additional CODEOWNERS Requirement
Show calculation
Sum 0
0
From CODEOWNERS 1
Sum 1

- Add .claude/skills/swiftui-best-practices (SKILL.md, best-practices and RN->iOS HIG map references, evals)
- Root AGENTS.md: load swiftui-best-practices for SwiftUI / RN->iOS migration work
- cds-ios AGENTS.md: link CDS SwiftUI Best Practices doc; RN is the visual spec, not HIG; whole-app CDS via environment inheritance, not wrapper views
- Alert/ToggleStyle docs and gallery copy: OS .alert is contrast only; CDS Alert will be a CDS view matching the RN modal

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added the root label Sep 28, 2026
adrienzheng-cb and others added 4 commits September 28, 2026 12:21
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
… copy

Co-authored-by: Cursor <cursoragent@cursor.com>
…s doc

Co-authored-by: Cursor <cursoragent@cursor.com>
@adrienzheng-cb
adrienzheng-cb merged commit ac72e0f into master Sep 28, 2026
32 checks passed
@adrienzheng-cb
adrienzheng-cb deleted the adrien/ios-swiftui-styles branch September 28, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants