Repository navigation
feat(native): the Swift theme tints stock controls where the accent stays readable, and sets a single-mode theme's color scheme - #8290
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Visual Regression48 of 502 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 28 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
Changes requested: .astryxTheme(_:) picks light or dark once, where the modifier sits, so a subtree that sets its own color scheme below it keeps the other mode's tint and text colors; plain Text on an AstryxCard inside a dark section of a light butter screen draws at about 1.25:1 (Theme.swift, lines 241-247). Resolving the colors where they are drawn, for example with a ShapeStyle whose resolve(in:) reads environment.colorScheme, plus a test that sets .environment(\.colorScheme, .dark) inside .astryxTheme(.butter), would fix it. The tint and foreground writes themselves are defined only by the draft theme-environment spec, which AST-093 FR6 treats as a spec gap rather than a blocker.
[Automated review]
| let color = (colorScheme == .dark ? theme.dark : theme.light).color | ||
| content | ||
| .tint(color.accent) | ||
| .foregroundStyle(color.textPrimary, color.textSecondary, color.textDisabled) |
There was a problem hiding this comment.
These colors are picked once, from the color scheme where .astryxTheme(_:) sits, and are fixed sRGB values, so a descendant with its own .environment(\.colorScheme, .dark) keeps the light accent and text colors while Astryx components beside it switch to dark tokens: plain Text on butter's dark card is #1D1C11 on #3A2A1F, 1.25:1. Resolving them where they are drawn, for example with a ShapeStyle whose resolve(in:) picks by environment.colorScheme, keeps the two in step; a Pixels test with .environment(\.colorScheme, .dark) inside .astryxTheme(.butter) would cover it.
There was a problem hiding this comment.
Approval recommended: .astryxTheme(_:) now resolves the tint and text colors in the color scheme of the view that draws them, which fixes the earlier dark-section issue, and the new view tests cover it on macOS and the iOS Simulator. The tint and foreground writes follow the draft theme-environment spec (E2, E3, E5); until that record is current, AST-093 FR6 treats them as a spec gap rather than a blocker, so an engineering owner can approve this head once its required checks pass. Worth settling when that record becomes current: several themes' dark accents are near white (butter #FDEE8C, neutral #F1F1F1), where a stock control's own white label or thumb, such as a .borderedProminent button or the iOS switch, would sit at 1.13:1 to 1.18:1 against the tint; a device capture would confirm it.
[Automated review]
f0b5fa0 to
0234a23
Compare
|
/approve-spec 0234a23 |
There was a problem hiding this comment.
Approval recommended: .astryxTheme(_:) now writes SwiftUI's tint and foreground styles from the theme, resolved in the color scheme of the view that draws them, and the new view tests pass on macOS and the iOS Simulator. These writes follow the draft theme-environment record (E2, E3, E5), which an engineering owner approved on this head, so nothing more is needed here once the required checks pass. Worth settling when that record becomes current: what stock controls draw on a pale tint (white on butter's dark accent #FDEE8C is 1.18:1), SwiftUI's palette rendering of multi-layer SF Symbols under a three-level foreground style, and textDisabled as the tertiary level; device captures would confirm the first two.
[Automated review]
0234a23 to
7e826ea
Compare
|
/approve-spec 7e826ea |
There was a problem hiding this comment.
Approval recommended: .astryxTheme(_:) now writes SwiftUI's tint and foreground styles from the theme, resolved in the color scheme of the view that draws them, and the new view tests pass on macOS and the iOS Simulator. No current spec defines these writes yet, so under AST-093 FR6 they are recorded as spec gaps rather than blockers, and nothing more is needed here once the required checks pass. Worth settling when the theme environment record becomes current:
- Gothic is dark-only, so in a light system appearance stock text and tinted controls on system surfaces would draw
#E8F1F6at about 1.14:1 against white. - Stock controls that draw white on the tint would sit at 1.13:1 to 1.18:1 on the pale dark-mode accents of butter, neutral, stone, y2k and Gothic.
- The three-level foreground style switches unstyled multi-layer SF Symbols to palette rendering and makes
textDisabledthe tertiary level.
[Automated review]
7e826ea to
3cab703
Compare
|
/approve-spec 3cab703 |
|
/approve-spec 790635a |
There was a problem hiding this comment.
Changes requested: .astryxTheme(_:) writes Gothic's color scheme through an if let view branch (Theme.swift, lines 293-295), so an app that switches theme at runtime between Gothic and any other theme rebuilds everything inside the modifier and loses its state. Writing the scheme without branching, for example .transformEnvironment(\.colorScheme) { if let mode = theme.singleMode { $0 = mode } }, would fix it.
- Please add a
Pixelstest for a stockLinkand a borderlessButtonunder the theme, because the theme's foreground style is expected to win over the tint for their labels while the description says they take the accent. - The Testing section still describes butter swatch tests, but on this head those tests use the default theme.
[Automated review]
| @ViewBuilder fileprivate func astryxSingleModeScheme(_ scheme: ColorScheme?) -> some View { | ||
| if let scheme { environment(\.colorScheme, scheme) } else { self } | ||
| } |
There was a problem hiding this comment.
This if let makes the modifier's body a conditional view, so Gothic and every two-mode theme give the content different identities; switching theme at runtime between them rebuilds the whole subtree and resets its @State. An inert write keeps one structure for every theme, for example:
.transformEnvironment(\.colorScheme) { if let mode = theme.singleMode { $0 = mode } }
| func body(content: Content) -> some View { | ||
| content | ||
| .tint(AstryxThemeColor(theme: theme, role: .tint)) | ||
| .foregroundStyle(AstryxThemeColor(theme: theme, role: .textPrimary)) |
There was a problem hiding this comment.
This foreground style also reaches the labels of stock Links and borderless Buttons, and an explicit foreground style wins over the tint for them, so they are expected to draw in textPrimary rather than the accent the description promises. A Pixels test of each under .astryxTheme(.default) would settle it.
40f90d1 to
2036b6a
Compare
There was a problem hiding this comment.
Approval of this head waits on one spec decision: E2 of the draft theme environment spec is reworded here (the 3:1 rule for .tint, the primary-only .foregroundStyle, the single-mode colorScheme paragraph and the E2 check row), no current spec states it, and the earlier /approve-spec for the same text names a different head. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so if they are an engineering owner; otherwise please say which part of E2 should change. The code matches that text, and its tests pass on macOS and the iOS Simulator.
- A
Pixelstest of a stockLinkand a borderlessButtonunder the theme would show whether their labels take the accent, as the description says, or the theme's primary text color, which the subtree-wide foreground style is expected to give them. - The Testing section describes butter swatch tests that use the default theme on this head, and the E2 and E5 check rows name a stock
Togglethat those swatch tests do not draw.
[Automated review]
| | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| | E1, E3 | A view test with only `.preferredColorScheme(.dark)` (no other Astryx setting) draws an Astryx component with dark tokens; with `colorSchemeContrast` increased, a Card draws `color.borderEmphasized`. With `legibilityWeight` set to `.bold`, an Astryx Text in butter's registered body face at regular weight resolves to semibold, and at bold to heavy. | | ||
| | E2 | A stock SwiftUI `Toggle` inside `.astryxTheme(.butter)` draws butter's accent; a plain `SwiftUI.Text` inside it draws butter's primary text color. | | ||
| | E2 | A stock SwiftUI `Toggle` inside `.astryxTheme(.butter)` in light draws butter's accent, and in dark, where butter's pale accent fails 3:1 against white, the system tint; a plain `SwiftUI.Text` inside it draws butter's primary text color; under `.astryxTheme(.gothic)` in a light appearance, a stock surface draws dark. | |
There was a problem hiding this comment.
This check names a stock Toggle and a plain SwiftUI.Text under .astryxTheme(.butter), but the tests on this head draw .tint and .primary swatches under .astryxTheme(.default) and check butter's dark fallback as a function (EnvironmentTests.swift:92-119); the E5 row below names a stock Toggle too. Describing the swatch tests here, or attaching simulator captures of the Toggle and Text, would make the check match its evidence.
2036b6a to
96c7c61
Compare
|
Posted by Cindy's agent on her behalf. Decision (Cindy, 2026-10-25): the Swift theme does not affect stock SwiftUI controls except through the tint.
What this PR needs: the code and the E2 record on this head implement exactly that. It merges once CodeBunny and CI are clean and the spec approval is posted on the final head. |
There was a problem hiding this comment.
Approval of this head waits on one spec decision: E2 of the draft theme environment spec is rewritten here (the 3:1 rule for .tint, no foreground style, the single-mode colorScheme paragraph and the amended E2 check row), no current spec states it, and no /approve-spec names this head yet. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner; otherwise please say which part of E2 should change. Worth weighing first: in light mode the 3:1 rule keeps accents that equal or nearly equal body text as the tint (neutral #1B1B1B, stone #25252A, y2k #2D241B, matcha #3E481D), so stock links and borderless buttons read as plain text, as the Neutral capture in the description shows.
- The record's Summary and E1
colorSchemerow still say the system setting drives the mode and that stock controls take the theme's accent, so they need aligning with E2.
[Automated review]
| | `.foregroundStyle(_:_:_:)` (primary, secondary, tertiary) | `color.textPrimary`, `color.textSecondary`, `color.textDisabled` | | ||
| | SwiftUI value | From the theme | | ||
| | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| | `.tint(_:)` | `color.accent`, in a mode where white meets 3:1 against it, because stock controls draw white on their tint; the system tint in any other mode | |
There was a problem hiding this comment.
A stock Link or borderless Button draws its label in this tint, and the 3:1 test measures only white on the accent, so in light mode it keeps neutral #1B1B1B, stone #25252A, y2k #2D241B and matcha #3E481D, which equal or nearly equal body text. The Neutral light capture in the description shows the stock link and borderless button looking like plain text, the outcome the paragraph below gives as its reason for writing no foreground style.
| | Requirement | Check | | ||
| | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| | E1, E3 | A view test with only `.preferredColorScheme(.dark)` (no other Astryx setting) draws an Astryx component with dark tokens; with `colorSchemeContrast` increased, a Card draws `color.borderEmphasized`. With `legibilityWeight` set to `.bold`, an Astryx Text in butter's registered body face at regular weight resolves to semibold, and at bold to heavy. | | ||
| | E2 | A stock SwiftUI `Toggle` inside `.astryxTheme(.butter)` in light draws butter's accent, and in dark, where butter's pale accent fails 3:1 against white, the system tint; a stock `Link` and a borderless `Button` draw their labels in the tint, and a prominent `Button` keeps its white label; under `.astryxTheme(.gothic)` in a light appearance, a stock surface draws dark. | |
There was a problem hiding this comment.
This row names a stock Toggle inside .astryxTheme(.butter) in light and in dark, but the tests draw .tint swatches under .astryxTheme(.default) and check butter's dark fallback as a function (EnvironmentTests.swift:92-99, :135-145), and the description's captures show a Toggle under core and Neutral only. Describing that evidence here, or attaching a butter capture, would make the row match it.
There was a problem hiding this comment.
Approval of this head waits on one spec decision: the rewritten E1 colorScheme row, E2 and E2 check row of the draft theme environment spec (the 3:1 rule for .tint, no foreground style, the single-mode colorScheme) are stated by no current spec, and no /approve-spec names this head yet. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner; otherwise please say which part of E2 should change. Worth weighing first: in light mode the 3:1 rule keeps accents that equal or nearly equal body text as the tint (neutral #1B1B1B, stone #25252A, y2k #2D241B, matcha #3E481D), so stock links and borderless buttons read as plain text, as the Neutral capture in the description shows. The code matches that text, and its tests pass on macOS and the iOS Simulator.
- The title still says the theme sets foreground styles; it now sets only the tint and a single-mode theme's color scheme.
[Automated review]
…accent; dark-section test reads a tint that passes 3:1
…keep their label colors
… tint (decided 2026-10-25); current state
…nderer draws them
f7de15b to
81a4c0e
Compare
There was a problem hiding this comment.
Approval of this head waits on one spec decision: the rewritten E1 colorScheme row, E2 and E2 check row of the draft theme environment spec (the 3:1 rule for .tint, no foreground style, the single-mode colorScheme) are stated by no current spec, and no /approve-spec names this head yet. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner; otherwise please say which part of E2 should change. Worth weighing first: in light mode the 3:1 rule keeps accents that equal or nearly equal body text as the tint (neutral #1B1B1B, stone #25252A, y2k #2D241B, matcha #3E481D), so stock links and borderless buttons read as plain text, as the Neutral capture in the description shows. The code matches that text, and its tests pass on macOS and the iOS Simulator.
[Automated review]
|
/approve-spec 81a4c0e |
What changes for people
Inside
.astryxTheme(_:), SwiftUI's own controls carry the brand only through their tint, wherever it stays readable. A stockToggle,ProgressView,Picker,Link, or borderlessButtontakes the theme's accent in any mode where white reaches 3:1 against it (stock controls draw white on their tint), and the system tint otherwise. A prominent button keeps its white label on that tint. The theme doesn't change stock controls' text colors, so links still look like links and filled buttons stay readable in every theme. A single-mode theme such as Gothic sets its section's color scheme, so stock surfaces inside draw dark on its dark grounds.Decided by cixzhang, 2026-10-25: "Let's not affect Swift controls aside from tint."
What this does
Implements the theme environment spec's E2 (
packages/native/specs/swift/library/theme-environment.md):.astryxTheme(_:)now also writes.tint(_:)fromcolor.accentin a mode where white meets 3:1 against it, else the system tint (WCAG's floor for interface components; the system's own dark blue is about 3.6:1);colorScheme, from its page ground, written without a view branch so switching themes keeps state.The tint resolves where it is drawn, through a
ShapeStylethat reads the color scheme there, so a subtree with its own color scheme gets that mode's tint (E3). An inner.astryxTheme(_:)replaces the outer tint (E5). Without the modifier nothing is written (E4). The theme writes no foreground style: an inherited one overrides stock controls' own label colors, turning links into plain text and prominent labels dark (shown below). The default font stays unset (the spec's open question).Spec change
Theme environment E2: the tint row, the single-mode paragraph, the sentence that the theme affects stock controls only through the tint (with the decision), the E2 check row, and Current state. Measured white-on-accent contrast: default 5.39 light / 3.11 dark; butter 5.24 / 1.18; chocolate 5.88 / 2.32; matcha 9.77 / 1.70; neutral 17.22 / 1.13; stone 15.25 / 1.13; y2k 15.22 / 1.14; gothic 1.14 (single mode).
Captures (AST-093 FR5)
iPhone 16 simulator, iOS 18.5, Xcode 16.4. Stock controls (Link, borderless, bordered, prominent, Toggle, plain Text) under Core (top) and Neutral (bottom). Left to right: the earlier head that also wrote the text color, this change (tint only), and a variant that kept the text color. Built from
8d25940, this change's theme code before the rebase onto main, which changed no theme code.This change alone, light and dark:

Astryx components are unchanged by this (they read the theme directly):

Not measured: the largest text size (tint is independent of text size) and the accessibility tree.
Testing
.tintswatch under the default theme reads its accent in light and the passing dark accent; the theme leaves.primaryexactly as the system draws it; a stockLinkand a borderlessButtondraw their labels in the tint; a.borderedProminentlabel stays white on the tint; a nested.environment(\.colorScheme, .dark)inside a light theme reads the dark tint; an inner theme replaces the tint.swiftc -typecheckof both modules, the tests, and the templates; the Swift tests run in CI on macOS and the iOS Simulator.Every changed file is under
packages/native/.