Repository navigation
spec(native): the Swift theme rides on SwiftUI's environment both ways - #8040
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report
|
|
/approve-spec f4bc6be |
There was a problem hiding this comment.
Changes requested: the approved direction stands, but the theme environment record needs four corrections before it merges.
- The Current state section describes a Swift theme modifier and SwiftUI components that
maindoes not have yet; describemainas it is, or land after the implementation and match it (components there already follow Dark Mode without the modifier). - The record builds on the theme generator and component API specs and a Dynamic Type spec that are not on
main; land it after them, cite each by path, and add it to the library index. - E2 already requires the default-font write that OQ1 still asks about, so settle it one way.
- E1 says Bold Text is followed because weights come from system or text-style fonts, but E2 installs the theme's custom body face; say how that face follows
legibilityWeightand add a Bold Text check.
Because a new commit invalidates the current /approve-spec, an engineering owner will need to post it again for the corrected head.
[Automated review]
| - The theme modifier chooses light or dark tokens from `colorScheme` and scales | ||
| text from `dynamicTypeSize`; without the modifier, components use core's | ||
| default light tokens even in dark mode. | ||
| - The modifier writes no SwiftUI value, so stock SwiftUI controls inside an | ||
| Astryx theme keep the system accent and font. | ||
| - No component reacts to Increase Contrast, Reduce Transparency, or Bold Text. |
There was a problem hiding this comment.
On main there is no Swift theme modifier or SwiftUI component yet: packages/native/apple holds the generated props, the wire and the logic host only. The modifier described here is in the open implementation #7981, where components already follow Dark Mode without it (EnvironmentValues.astryx picks the default theme's dark tokens). Describe main as it is, or land after #7981 and match its behavior.
| - Relation: extends AST-093 FR4 and AST-082 FR10, FR11; builds on the Swift | ||
| theme generator spec (the `Theme` and `Tokens` it generates) and the Swift | ||
| component API spec (names). |
There was a problem hiding this comment.
The theme generator and component API specs this line builds on are not on main yet: the generator is #8031 (the unprefixed Theme and Tokens come from #8038, stacked on it) and the component API is #8035. Land after them and cite each by path, and add this file to the library/ index that #8031 introduces. The "library spec on Dynamic Type" on line 27 is not on main or in those pull requests either.
| | `accessibilityReduceMotion` | Movement becomes a cross-fade or no animation | | ||
| | `accessibilityReduceTransparency` | Translucent surfaces become opaque | | ||
| | `layoutDirection` | Leading and trailing follow it | | ||
| | `legibilityWeight` | Bold Text: weights come from system or text-style fonts, so they follow it | |
There was a problem hiding this comment.
With E2's default font, a registered custom body face (butter's Outfit) is neither a system nor a text-style font, so it does not get heavier under Bold Text on its own. Say how the family reader follows legibilityWeight for a custom face, or narrow this row to system faces, and add a Bold Text check to the acceptance table.
| - **OQ1 — Should the theme set the default font for all text in its subtree?** | ||
| It brands stock SwiftUI text, and it also changes text an app draws itself. | ||
| Recommendation: set it, because a theme's typeface is part of its identity | ||
| and an app can still set its own `.font(_:)` on any view. |
There was a problem hiding this comment.
E2 (line 40) already requires the theme to set the default font, and the E2 check on line 67 tests it, so this question is answered there. Either fold this reason into E2 and drop OQ1, or move the font row and its check out of E2 until it is decided.
There was a problem hiding this comment.
Approval waits on an engineering owner's decision: E1–E6 and their acceptance checks in theme-environment.md are new requirements that no current spec states, and the earlier /approve-spec named a head this push replaced. Any engineering owner, the author included, records that decision by commenting /approve-spec <full head SHA> on the head that will merge. Two fixes should land before that head:
- The Bold Text rule says "one weight step heavier" but maps regular to semibold and gives no weight for medium, core's label weight, so spell out every weight and name the expected one in the E1 check.
- The record cites
theme-generator.mdandcomponent-api.md, which are not onmainyet, so rebase onto those specs and add this file to thelibrary/index.
[Automated review]
| | `accessibilityReduceMotion` | Movement becomes a cross-fade or no animation | | ||
| | `accessibilityReduceTransparency` | Translucent surfaces become opaque | | ||
| | `layoutDirection` | Leading and trailing follow it | | ||
| | `legibilityWeight` | Bold Text: system and text-style fonts follow it by themselves; a custom face from the theme's family list is drawn one weight step heavier when it is `.bold` (regular → semibold, semibold → bold, bold → heavy) | |
There was a problem hiding this comment.
Regular → semibold is two steps on SwiftUI's Font.Weight scale (regular, medium, semibold) and on core's weight tokens (400, 500, 600), so "one weight step heavier" and this mapping disagree, and medium (core's --text-label-weight) has no entry. Spelling out the mapping for 400, 500, 600 and 700, and naming in the E1 check on line 66 the weight butter's body and label faces resolve to, would make the rule testable.
| - Relation: extends AST-093 FR4 and AST-082 FR10, FR11; builds on | ||
| `packages/native/specs/swift/library/theme-generator.md` (the `Theme` and | ||
| `Tokens` it generates, and its font family reader) and | ||
| `packages/native/specs/swift/library/component-api.md` (names). |
There was a problem hiding this comment.
|
/approve-spec 609ddaa |
|
/approve-spec 2b5995d |
There was a problem hiding this comment.
Changes requested: E1–E6 are owner-approved on this head, but the record still builds on theme-generator.md and component-api.md, which are not on main yet, so merging it now would leave the Relation line (lines 4–7) pointing at files that do not exist. Once #8031, #8038 and #8035 land, rebase onto them and add this file to the swift/library/ index; that new head needs a fresh /approve-spec <full head SHA> from an engineering owner, which the author can post.
[Automated review]
2b5995d to
fd40bc7
Compare
|
/approve-spec fd40bc7 |
There was a problem hiding this comment.
Changes requested: E1–E6 are owner-approved on this head and the theme generator spec has landed, but the Relation line (lines 4–7) still names Theme and Tokens, which theme-generator.md on main calls AstryxTheme and AstryxTokens, and cites component-api.md, which is not on main yet. Rebase once #8035 and #8038 land, as the description plans, or cite the names main has today; either way the new head needs a fresh /approve-spec <full head SHA> from an engineering owner, which the author can post. While editing, consider a check with a stock Toggle and a plain Text under a subtree's own .environment(\.colorScheme, .dark), since no current check shows E2's tint and foreground styles following E3.
[Automated review]
| - Relation: extends AST-093 FR4 and AST-082 FR10, FR11; builds on | ||
| `packages/native/specs/swift/library/theme-generator.md` (the `Theme` and | ||
| `Tokens` it generates, and its font family reader) and | ||
| `packages/native/specs/swift/library/component-api.md` (names). |
There was a problem hiding this comment.
On main, theme-generator.md generates AstryxTheme and AstryxTokens (G3), and component-api.md does not exist yet; Theme, Tokens and that file arrive with #8038 and #8035, which are still open. Rebase once they land, or cite the names main has today; either way the new head needs a fresh /approve-spec.
|
|
||
| | 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. | |
There was a problem hiding this comment.
This row sets only .preferredColorScheme(.dark), which applies to the whole presentation, so no check shows E2's tint and foreground styles following a subtree's own .environment(\.colorScheme, .dark) as E3 (lines 49–52) says tokens do. A stock Toggle and a plain Text in such a subtree inside a light .astryxTheme(.butter) would cover it.
fd40bc7 to
820b786
Compare
|
/approve-spec 820b786 |
There was a problem hiding this comment.
Approval recommended: an engineering owner approved E1–E6 on this exact head, the record contradicts no current native spec, and the Relation line and library index now resolve on main. Two small, non-blocking suggestions for a later edit:
- Add a check that the theme's tint and foreground styles follow a subtree's own
.environment(\.colorScheme, .dark), as E3 says tokens do, for example a stockToggleand a plainSwiftUI.Textin a dark panel inside a light.astryxTheme(.butter). - Lines 44–46 list backgrounds as having no SwiftUI environment equivalent, but
backgroundStyle(_:)is one, so either state keeping backgrounds Astryx-only as a choice or write it fromcolor.backgroundSurface.
[Automated review]
| | `legibilityWeight` | Bold Text: system and text-style fonts follow it by themselves; a custom face from the theme's family list is drawn heavier when it is `.bold`: ultra light → thin, thin → light, light → regular, regular → semibold, medium → semibold, semibold → bold, bold → heavy, heavy → black, black stays black | | ||
|
|
||
| - **E2 — The theme writes SwiftUI's own values where a native equivalent | ||
| exists.** `.astryxTheme(_:)` sets, for the subtree, in the current mode: |
There was a problem hiding this comment.
Written "in the current mode" where the modifier sits, these values do not follow a descendant's own .environment(\.colorScheme, .dark): that subtree's Astryx components switch to dark tokens (E3) while its stock Toggle keeps the outer accent and a plain Text the outer color.textPrimary. Saying E2's values follow the colour scheme where they are drawn (iOS 17's ShapeStyle.resolve(in:) can do it) keeps the two in step; a check with a stock Toggle and a plain SwiftUI.Text in such a subtree would prove it.
| Whether the theme also sets the default font is OQ1. Theme values with no SwiftUI environment equivalent are read only | ||
| by Astryx components: corner radius, spacing, element heights, borders, and | ||
| backgrounds. Control size has no clean mapping: Astryx sizes are a per- |
There was a problem hiding this comment.
SwiftUI does carry a background style in the environment: backgroundStyle(_:) sets the style that background() and background(in:) fill with. If backgrounds stay Astryx-only, state it as a choice with its reason; or have .astryxTheme(_:) also write backgroundStyle from color.backgroundSurface so a stock background(in:) matches the theme.
Exact decision needed
How an Astryx theme rides on SwiftUI's environment in both directions: settings are read from SwiftUI (color scheme, contrast, text size, motion, transparency, direction, Bold Text) and never duplicated, and the theme writes SwiftUI's own values (tint, foreground styles, default font) so stock controls carry the brand. Draft until the owner approves; nothing is built from it before then.
Existing authority searched
spec:AST-093FR3 (Apple platforms follow the HIG) and FR4 (brand through the theme);spec:AST-082FR10 (native theme) and FR11 (platform controls and settings first).ThemeandTokensthis spec carries; the approved Swift component API spec sets the names.Decision
colorScheme,colorSchemeContrast,dynamicTypeSize,accessibilityReduceMotion,accessibilityReduceTransparency,layoutDirection,legibilityWeight); no Astryx mode API.legibilityWeightby themselves..astryxTheme(_:)writes.tint(accent) and.foregroundStyleprimary/secondary/tertiary (text colors); whether it also sets the default font is OQ1. Radius, spacing, heights, borders, backgrounds and control size have no SwiftUI equivalent and stay Astryx-only.@Entryenvironment value; no singletons.Rejected alternatives
None recorded in the spec.
Landing order
This builds on
packages/native/specs/swift/library/theme-generator.md(#8031, with the unprefixed names from #8038) andpackages/native/specs/swift/library/component-api.md(#8035). It lands after them; thelibrary/index entry is added when it is rebased onto those.Claim scope and non-goals
Typed tokens and the theme files are the theme generator spec. Shipping Astryx's look as SwiftUI style protocols is a separate decision.
Evidence and implementation relationship
One file:
packages/native/specs/swift/library/theme-environment.md.Writing rubric results
Scope
packages/native/.