@astryxdesign/native 0.7.5-canary.e9b3f3e → 0.7.5-canary.eb3e539
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apple/Package.swift +1 -1
- package/apple/README.md +1 -0
- package/apple/Sources/Astryx/Avatar/Avatar.spec.md +43 -34
- package/apple/Sources/Astryx/Avatar/Avatar.swift +96 -19
- package/apple/Sources/Astryx/Avatar/AvatarStatusDot.spec.md +162 -0
- package/apple/Sources/Astryx/Avatar/AvatarStatusDot.swift +181 -0
- package/apple/Sources/Astryx/Icon/Icon.spec.md +14 -11
- package/apple/Sources/Astryx/Icon/Icon.swift +8 -3
- package/apple/Sources/Astryx/Localization/AstryxStrings.swift +36 -0
- package/apple/Sources/Astryx/Resources/af.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/ar.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/ca.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/cs.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/da.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/de.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/el.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/en.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/es.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/fi.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/fr.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/he.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/hu.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/it.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/ja.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/ko.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/nb.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/nl.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/pl.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/pt-BR.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/pt-PT.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/ro.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/ru.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/sr.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/sv.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/tr.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/uk.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/vi.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/zh-Hans.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Resources/zh-Hant.lproj/Localizable.strings +15 -0
- package/apple/Sources/Astryx/Theme/Generated/ButterTheme.swift +38 -0
- package/apple/Sources/Astryx/Theme/Generated/ChocolateTheme.swift +42 -4
- package/apple/Sources/Astryx/Theme/Generated/DefaultTheme.swift +39 -1
- package/apple/Sources/Astryx/Theme/Generated/GothicTheme.swift +38 -0
- package/apple/Sources/Astryx/Theme/Generated/MatchaTheme.swift +42 -4
- package/apple/Sources/Astryx/Theme/Generated/NeutralTheme.swift +44 -6
- package/apple/Sources/Astryx/Theme/Generated/StoneTheme.swift +44 -6
- package/apple/Sources/Astryx/Theme/Generated/Tokens.swift +95 -0
- package/apple/Sources/Astryx/Theme/Generated/Y2kTheme.swift +38 -0
- package/apple/Sources/Astryx/Thumbnail/Thumbnail.spec.md +191 -0
- package/apple/Sources/Astryx/Thumbnail/Thumbnail.swift +357 -0
- package/apple/Sources/Astryx/Tooltip/TooltipPresenter.swift +17 -4
- package/apple/Sources/Astryx/Wire/AstryxNodeView.swift +6 -1
- package/apple/Sources/AstryxNative/Generated/AstryxNode.swift +6 -0
- package/apple/Sources/AstryxNative/Generated/Avatar.swift +2 -0
- package/apple/Sources/AstryxNative/Generated/AvatarStatusDot.swift +78 -0
- package/apple/Sources/AstryxNative/Generated/Icon.swift +1 -0
- package/apple/Sources/AstryxNative/Generated/Thumbnail.swift +123 -0
- package/apple/Tests/AstryxTests/AvatarStatusDotTests.swift +255 -0
- package/apple/Tests/AstryxTests/AvatarTests.swift +35 -35
- package/apple/Tests/AstryxTests/IconTests.swift +4 -3
- package/apple/Tests/AstryxTests/ThumbnailTests.swift +204 -0
- package/dist/components/Avatar.d.ts.map +1 -1
- package/dist/components/Avatar.js +2 -1
- package/dist/components/AvatarStatusDot.d.ts +10 -0
- package/dist/components/AvatarStatusDot.d.ts.map +1 -0
- package/dist/components/AvatarStatusDot.js +9 -0
- package/dist/components/Thumbnail.d.ts +10 -0
- package/dist/components/Thumbnail.d.ts.map +1 -0
- package/dist/components/Thumbnail.js +10 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +4 -0
- package/dist/types/android.d.ts +29 -5
- package/dist/types/core.d.ts +18 -1
- package/dist/types/ios.d.ts +29 -5
- package/dist/types/macos.d.ts +29 -5
- package/dist/types/shared.d.ts +29 -5
- package/dist/types/windows.d.ts +29 -5
- package/package.json +3 -3
- package/src/components/Avatar.ts +2 -1
- package/src/components/AvatarStatusDot.ts +20 -0
- package/src/components/Thumbnail.ts +21 -0
- package/src/components/index.ts +4 -0
- package/src/contract/contracts.test.ts +44 -2
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
---
|
|
2
|
+
schema_version: 3
|
|
3
|
+
template_version: 7
|
|
4
|
+
kind: component
|
|
5
|
+
id: component:swift/Thumbnail
|
|
6
|
+
platform_of: component:Thumbnail
|
|
7
|
+
authority: draft
|
|
8
|
+
archive_reason: null
|
|
9
|
+
superseded_by: null
|
|
10
|
+
approved_by: null
|
|
11
|
+
approved_at: null
|
|
12
|
+
owners: [cixzhang]
|
|
13
|
+
review_triggers: [public-api, behavior, layout, theming, accessibility]
|
|
14
|
+
verified_by:
|
|
15
|
+
[
|
|
16
|
+
packages/native/apple/Tests/AstryxTests/ThumbnailTests.swift,
|
|
17
|
+
packages/native/src/contract/contracts.test.ts,
|
|
18
|
+
packages/native/src/theme/swiftIOSStrings.test.ts,
|
|
19
|
+
]
|
|
20
|
+
modules: []
|
|
21
|
+
families: []
|
|
22
|
+
design_specs: []
|
|
23
|
+
architecture: []
|
|
24
|
+
contributing: []
|
|
25
|
+
system_specs: [spec:AST-082, spec:AST-093]
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
# Thumbnail (Swift) component contract
|
|
29
|
+
|
|
30
|
+
## Contract at a glance
|
|
31
|
+
|
|
32
|
+
| Area | Contract |
|
|
33
|
+
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
34
|
+
| Public contract | `Thumbnail(src:, alt:, label:, isLoading:, isDisabled:, showRemoveOn:, onClick:, onRemove:)` and `Thumbnail(_ props: ThumbnailProps)`, a SwiftUI `View` in module `Astryx`. |
|
|
35
|
+
| Behavior | A 64-point square on the theme's neutral plate showing the image, else a placeholder silhouette; a skeleton while loading with no image and an upload look over one; a remove button in the top trailing corner; a tap that opens the thumbnail. |
|
|
36
|
+
| End-user impact | A person attaching images on iPhone sees the same previews as on the web, can open or remove each one, and VoiceOver reads each by its file name and description and announces once when an upload starts. |
|
|
37
|
+
| Builder impact | An app passes the image URL, a label such as a file name, and the actions it supports. A single trailing closure is `onClick`. |
|
|
38
|
+
| Compatibility/readiness | Additive: a new view, generated `ThumbnailProps`, and four of core's messages in the Swift string catalogs. Draft; built and tested on macOS and the iOS Simulator; device captures are attached to the change. |
|
|
39
|
+
| Review checks | Reject a hidden remove button on a touch device, a tap or remove that works while disabled, a tap that works while loading, an unnamed thumbnail, an upload announced on every render, or a color that is not a theme token. |
|
|
40
|
+
| Governing rules | `spec:AST-082` FR3, FR7; `spec:AST-086` FR8; `spec:AST-093` FR1–FR5; the Swift component API, theme environment, and accessibility (X1, X3, X4, X6, X7) records under `packages/native/specs/swift/library/`. |
|
|
41
|
+
|
|
42
|
+
This table is a review projection; the body below is authoritative.
|
|
43
|
+
|
|
44
|
+
## Intent
|
|
45
|
+
|
|
46
|
+
Thumbnail on Apple platforms is core's preview of an image attachment, drawn
|
|
47
|
+
with SwiftUI's own image loading, progress view, and buttons.
|
|
48
|
+
|
|
49
|
+
## Compatibility and migration
|
|
50
|
+
|
|
51
|
+
- Released default preserved: `not yet released`
|
|
52
|
+
- Compatibility class: additive
|
|
53
|
+
- Controlled/uncontrolled behavior: not applicable
|
|
54
|
+
- Migration decision: none
|
|
55
|
+
|
|
56
|
+
Consumer migration instructions belong in consumer docs and release notes.
|
|
57
|
+
|
|
58
|
+
## Ownership boundary
|
|
59
|
+
|
|
60
|
+
**Owns**
|
|
61
|
+
|
|
62
|
+
- The 64-point tile, its image, placeholder, skeleton, and upload look.
|
|
63
|
+
- The remove button, its visibility, and the open tap.
|
|
64
|
+
- The thumbnail's names and its upload announcement.
|
|
65
|
+
|
|
66
|
+
**Does not own / non-goals**
|
|
67
|
+
|
|
68
|
+
- The meaning of the props and the words — owned by `component:Thumbnail` and
|
|
69
|
+
core's message catalogs.
|
|
70
|
+
- Laying out several thumbnails, which belongs to the screen that holds them.
|
|
71
|
+
|
|
72
|
+
## Public concepts
|
|
73
|
+
|
|
74
|
+
| Concept | Closed values or states | Meaning | Availability by variant/orientation/state | Default | Owner | Stability | Invalid-value behavior |
|
|
75
|
+
| ------------ | ------------------------------------ | -------------------------------------------------------------------------- | ----------------------------------------- | -------- | --------------------- | ------------ | ------------------------------------ |
|
|
76
|
+
| picture | image, placeholder, skeleton, upload | what the tile shows | always | — | `component:Thumbnail` | experimental | a failed image shows the placeholder |
|
|
77
|
+
| showRemoveOn | `hover`, `always` | `hover` shows remove under a pointer and always on touch; `always` at rest | with `onRemove` | `hover` | `component:Thumbnail` | experimental | none |
|
|
78
|
+
| name | label and alt, label, alt, fallback | what VoiceOver reads for the thumbnail | always | fallback | `component:Thumbnail` | experimental | blank strings count as absent |
|
|
79
|
+
|
|
80
|
+
## Behavioral and layout contract
|
|
81
|
+
|
|
82
|
+
| ID | Candidate invariant | Basis | Draft review state |
|
|
83
|
+
| --- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | ------------------ |
|
|
84
|
+
| FR1 | The tile MUST be 64 by 64 points, clipped to `radius.element`, on `color.neutral`. It MUST show the image at `src` cropped to fill the tile, with a 1-point `color.border` inset edge on all four sides of the tile; with no `src`, or when the image fails, a 24-point image silhouette in `color.iconSecondary`. | core `Thumbnail` styles | verify |
|
|
85
|
+
| FR2 | `isLoading` with no `src` MUST show a skeleton in `color.skeleton` at 25% opacity; after 1 second it climbs to 92.5% in ten equal held steps over core's default 550 ms medium duration and back, repeating, as core's does, and it rests at 25% under Reduce Motion; under Increase Contrast its color moves 30% toward `color.textPrimary`, as core's does under `prefers-contrast: more`. `isLoading` with a `src` MUST draw `color.overlay` over the image with the platform's small progress view in `color.onDark`, which keeps its size at any text size. | core `Thumbnail`; Swift accessibility X6 | verify |
|
|
86
|
+
| FR3 | With `onRemove`, a 20-point remove button MUST sit `space.s1` from the top trailing corner on `color.overlay` with the shared `close` `Icon` at `xsm` in `color.onDark`, which the theme can remap and which keeps its size at any text size. It is visible at rest with `always` and on touch devices; with `hover` under a pointer, it appears while the pointer is over an enabled thumbnail or while its open or remove button has keyboard focus; a pointer reveals nothing on a disabled thumbnail, as core turns pointer events off there. | core `Thumbnail` `showRemoveOn`; `spec:AST-082` FR3 | verify |
|
|
87
|
+
| FR4 | With `onClick`, not disabled, and not loading, the tile MUST be a SwiftUI `Button` that paints `color.overlayPressed` while pressed. `isDisabled` MUST draw the thumbnail at half opacity and turn off its tap and remove button. The open button while loading or disabled, and the remove button while disabled, MUST stay mounted but inert, so focus on them stays put and VoiceOver reads them dimmed (`spec:AST-085`; Swift accessibility X2); during an upload the remove button stays active, as core's does. | core `Thumbnail` | verify |
|
|
88
|
+
| FR5 | With a `label`, the thumbnail MUST show it through the Astryx tooltip (`architecture:native-swift-library-tooltip`), as core's tooltip wraps the whole thumbnail: not a tab stop itself, keyboard focus on its open or remove button shows the label, and a direct tap opens it while an open action still runs, as the Tooltip by input table below states. A disabled thumbnail shows none, and the label is not a hint, since it is in the thumbnail's name. | core `Thumbnail` `label`; core `Tooltip`; `spec:AST-082` FR3 | verify |
|
|
89
|
+
| FR6 | Both initializers MUST build the same `ThumbnailProps`; a single trailing closure is `onClick`. Base props come through `ThumbnailProps`: with `isHidden` the view draws nothing; `id` becomes the accessibility identifier. | Swift component API A2–A4, A7; `spec:AST-082` FR7 | verify |
|
|
90
|
+
|
|
91
|
+
**Tooltip by input (FR5).** The Astryx tooltip's rules apply; this table
|
|
92
|
+
states Thumbnail's choices.
|
|
93
|
+
|
|
94
|
+
| Input | With a `label` | Disabled, or no `label` |
|
|
95
|
+
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- |
|
|
96
|
+
| Pointer | the bubble shows the label above the tile after 200 ms, stays while the pointer is on it, and a press hides it | nothing |
|
|
97
|
+
| Keyboard focus | the label at once when keyboard focus is on the open or remove button, as focus within core's tooltip wrapper shows it; the thumbnail itself is not a tab stop | nothing |
|
|
98
|
+
| Touch tap | a direct tap opens the bubble with the label, while an open action and an enclosing row still run; another tap on it, or a tap anywhere else, closes it, and that tap still reaches what it lands on | nothing |
|
|
99
|
+
| VoiceOver | the label is read once, in the thumbnail's name; the bubble is hidden and the tap is left alone | nothing |
|
|
100
|
+
|
|
101
|
+
### Allowed variation
|
|
102
|
+
|
|
103
|
+
- **AV1 — Glyphs and spinner.** The placeholder is the SF Symbol `photo.fill`
|
|
104
|
+
and the spinner the platform's progress view.
|
|
105
|
+
|
|
106
|
+
### Representative states
|
|
107
|
+
|
|
108
|
+
| State | Required invariant | Allowed variation |
|
|
109
|
+
| ------------------------------ | --------------------------------------------- | ----------------- |
|
|
110
|
+
| image | the image fills the tile with an inset edge | image content |
|
|
111
|
+
| no image, failed image | the placeholder silhouette | AV1 |
|
|
112
|
+
| loading without and with image | skeleton; upload overlay with a progress view | AV1 |
|
|
113
|
+
| remove, hover and always | visible on touch; at rest with `always` | none |
|
|
114
|
+
| tappable, disabled | a button; dimmed with no tap or remove | none |
|
|
115
|
+
| light and dark, two themes | each theme's colors | none |
|
|
116
|
+
|
|
117
|
+
### Transformation and precedence order
|
|
118
|
+
|
|
119
|
+
- **ORD1 — Picture.** Skeleton (loading, no `src`) → image → placeholder.
|
|
120
|
+
- **ORD2 — Name.** `label — alt` → `label` → `alt` → core's fallback word.
|
|
121
|
+
|
|
122
|
+
### Performance and resources
|
|
123
|
+
|
|
124
|
+
- **PR1 — System loading.** Images load through `AsyncImage` and the system
|
|
125
|
+
URL cache.
|
|
126
|
+
|
|
127
|
+
## Accessibility contract
|
|
128
|
+
|
|
129
|
+
- **AR1 — Named group.** The thumbnail is a container named by ORD2. The image
|
|
130
|
+
reads as its `alt` and is hidden without one (X4). With `onClick` the open
|
|
131
|
+
button covers the image and its name, "Open" with the thumbnail's name,
|
|
132
|
+
stands for it, so VoiceOver does not read the image on its own, as core's
|
|
133
|
+
open button wraps the image and a button's content is presentational.
|
|
134
|
+
- **AR2 — Named actions.** The open button reads "Open" with the name and the
|
|
135
|
+
remove button "Remove" with the name, from core's message catalogs in the
|
|
136
|
+
person's language (X1).
|
|
137
|
+
- **AR3 — Upload announced once.** Each upload start, including one already
|
|
138
|
+
in progress when the thumbnail appears, announces core's "Loading" once, as
|
|
139
|
+
core does; the spinner is hidden (`spec:AST-086` FR8; X3).
|
|
140
|
+
- **AR4 — Targets.** The remove button answers taps across 44 by 44 points
|
|
141
|
+
without moving its drawing (X7).
|
|
142
|
+
- **AR5 — Rendered tree not measured.** Tests assert what the view sets; the
|
|
143
|
+
rendered accessibility tree, the hit region, and the announcement are not
|
|
144
|
+
measured until an app-hosted target exists.
|
|
145
|
+
|
|
146
|
+
## Design relationships
|
|
147
|
+
|
|
148
|
+
| Anatomy or state | Design requirement | Representation authority | Hierarchy role | Component contract |
|
|
149
|
+
| ---------------- | ---------------------------------------- | ------------------------ | -------------- | ------------------ |
|
|
150
|
+
| Image, overlays | Apple Human Interface Guidelines, Images | prescribed by core | supporting | FR1–FR4 |
|
|
151
|
+
|
|
152
|
+
The component implements design requirements without copying their rationale.
|
|
153
|
+
|
|
154
|
+
Platform controls: SwiftUI `AsyncImage` for the image, `ProgressView` for the
|
|
155
|
+
upload spinner, and `Button` for the open tap and remove action
|
|
156
|
+
(`spec:AST-093` FR2). SwiftUI has no thumbnail control, so the tile and its
|
|
157
|
+
overlays are drawn here. Guideline pages: Images, Progress indicators, Buttons,
|
|
158
|
+
and Accessibility in the Apple Human Interface Guidelines.
|
|
159
|
+
|
|
160
|
+
Theme values read: `color.neutral`, `color.border`, `color.iconSecondary`,
|
|
161
|
+
`color.overlay`, `color.onDark`, `color.overlayPressed`, `radius.element`,
|
|
162
|
+
`space.s1`, `color.skeleton`, `color.textPrimary`, the theme's `close` icon, Reduce Motion, and Increase Contrast; and, for the Astryx tooltip's bubble, `color.textPrimary`, `color.backgroundSurface`, `space.s1`, `space.s2`, `radius.container`, and the body text size and weight.
|
|
163
|
+
|
|
164
|
+
## Family and system relationships
|
|
165
|
+
|
|
166
|
+
- `component:Thumbnail` owns the props, the words, and the look; this record
|
|
167
|
+
states only how Swift draws them.
|
|
168
|
+
|
|
169
|
+
## Verification map
|
|
170
|
+
|
|
171
|
+
| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
|
|
172
|
+
| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------- |
|
|
173
|
+
| FR1 | `ThumbnailTests.swift` size, plate, and two-theme renders | no image; default, neutral, butter; the largest text size | a wrong size or a color of its own fails | `audit:swift/Thumbnail/tile` |
|
|
174
|
+
| FR2 | `ThumbnailTests.swift` loading states, skeleton color, contrast mix, and largest-text render | loading with and without `src`; Increase Contrast; the largest text size | a skeleton over an image, no upload look, a wrong skeleton color, or a tile that grows fails | `audit:swift/Thumbnail/loading` |
|
|
175
|
+
| FR3, FR4 | `ThumbnailTests.swift` remove, tap, disabled, and mounted-while-inert tests and render | `always`, `hover`; disabled; loading | a hidden remove on touch or under keyboard focus, a hard-coded remove glyph, or a tap while disabled or loading fails; an open or remove button that unmounts while loading or disabled fails; a pointer that reveals the remove button on a disabled thumbnail fails | `audit:swift/Thumbnail/actions` |
|
|
176
|
+
| FR5 | `TooltipPresenterTests.swift` for each input; `ThumbnailTests.swift` name and focus-within tests | enabled and disabled; blank label | a tooltip on a disabled thumbnail, or none for keyboard focus on its open or remove button, fails; that the tile keeps one structure across a disabled toggle or an upload ending is not measured, since a test cannot see a rebuild | `audit:swift/Thumbnail/tooltip` |
|
|
177
|
+
| FR6 | `ThumbnailTests.swift` initializer, trailing-closure, and hidden tests; `contracts.test.ts` | both initializers; `isHidden` | differing props or a drawn hidden thumbnail fails | `audit:swift/Thumbnail/api` |
|
|
178
|
+
| AR1, AR2 | `ThumbnailTests.swift` name and open-button tests (`hasOpenButton` decides the image's hiding); `swiftIOSStrings.test.ts`; the rendered tree is not measured | label and alt, each alone, neither; with and without `onClick` | a wrong name or a missing catalog message fails | `audit:swift/Thumbnail/a11y` |
|
|
179
|
+
|
|
180
|
+
## Decision log
|
|
181
|
+
|
|
182
|
+
No component-local decision is recorded.
|
|
183
|
+
|
|
184
|
+
## Open questions
|
|
185
|
+
|
|
186
|
+
None.
|
|
187
|
+
|
|
188
|
+
## Content boundary
|
|
189
|
+
|
|
190
|
+
This file does not duplicate consumer prop tables/examples, current audit
|
|
191
|
+
results, implementation steps, or family/system rules. It links to their owners.
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
import AstryxNative
|
|
4
|
+
import SwiftUI
|
|
5
|
+
|
|
6
|
+
/// A square preview of an image attachment (core `Thumbnail`): the image,
|
|
7
|
+
/// a placeholder when there is none or it fails, a loading look, an optional
|
|
8
|
+
/// remove button, and an optional tap to open it.
|
|
9
|
+
///
|
|
10
|
+
/// ```swift
|
|
11
|
+
/// Thumbnail(src: "https://example.com/beach.jpg", alt: "Beach at sunset", label: "beach.jpg")
|
|
12
|
+
/// Thumbnail(src: url, label: "beach.jpg", isLoading: true) // uploading
|
|
13
|
+
/// Thumbnail(src: url, label: "beach.jpg", onClick: { open() }, onRemove: { remove() })
|
|
14
|
+
/// ```
|
|
15
|
+
public struct Thumbnail: View {
|
|
16
|
+
/// The contract the view draws, the same for both initializers.
|
|
17
|
+
public let props: ThumbnailProps
|
|
18
|
+
@Environment(\.astryx) private var astryx
|
|
19
|
+
@Environment(\.accessibilityReduceMotion) private var reduceMotion
|
|
20
|
+
@Environment(\.colorSchemeContrast) private var contrast
|
|
21
|
+
@State private var isHovering = false
|
|
22
|
+
@FocusState private var focusedPart: Part?
|
|
23
|
+
|
|
24
|
+
/// The thumbnail's focusable parts.
|
|
25
|
+
enum Part: Hashable { case open, remove }
|
|
26
|
+
|
|
27
|
+
/// A thumbnail from its labeled props.
|
|
28
|
+
/// - Parameters:
|
|
29
|
+
/// - src: The image URL (core `src`).
|
|
30
|
+
/// - alt: What the image shows; without it the image is decorative (core `alt`).
|
|
31
|
+
/// - label: The thumbnail's name, such as a file name; also its tooltip (core `label`).
|
|
32
|
+
/// - isLoading: A placeholder while there is no image, or an upload look over the image (core `isLoading`).
|
|
33
|
+
/// - isDisabled: Dims the thumbnail and turns off its tap and remove button (core `isDisabled`).
|
|
34
|
+
/// - showRemoveOn: `hover` shows the remove button under a pointer and always on touch; `always` shows it at rest; `nil` is `hover` (core `showRemoveOn`).
|
|
35
|
+
/// - onClick: Makes the thumbnail a button that runs this; a single trailing closure is this (core `onClick`).
|
|
36
|
+
/// - onRemove: Adds a remove button that runs this (core `onRemove`).
|
|
37
|
+
public init(
|
|
38
|
+
src: String? = nil,
|
|
39
|
+
alt: String? = nil,
|
|
40
|
+
label: String? = nil,
|
|
41
|
+
isLoading: Bool? = nil,
|
|
42
|
+
isDisabled: Bool? = nil,
|
|
43
|
+
showRemoveOn: ThumbnailShowRemoveOn? = nil,
|
|
44
|
+
onClick: (() -> Void)? = nil,
|
|
45
|
+
onRemove: (() -> Void)? = nil
|
|
46
|
+
) {
|
|
47
|
+
self.init(
|
|
48
|
+
ThumbnailProps(
|
|
49
|
+
src: src, alt: alt, label: label, onRemove: onRemove, onClick: onClick, isLoading: isLoading,
|
|
50
|
+
isDisabled: isDisabled, showRemoveOn: showRemoveOn))
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/// A thumbnail from its generated contract, for generated and wire-driven callers.
|
|
54
|
+
public init(_ props: ThumbnailProps) {
|
|
55
|
+
self.props = props
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public var body: some View {
|
|
59
|
+
if props.base.isHidden != true {
|
|
60
|
+
ZStack(alignment: .topTrailing) {
|
|
61
|
+
tile
|
|
62
|
+
if hasRemove {
|
|
63
|
+
// Mounted while disabled too, inert, so focus on it stays put and
|
|
64
|
+
// VoiceOver reads it dimmed (AST-085; Swift accessibility X2).
|
|
65
|
+
removeButton
|
|
66
|
+
.disabled(!removes)
|
|
67
|
+
.padding(astryx.tokens.space.s1)
|
|
68
|
+
.opacity(isRemoveVisible ? 1 : 0)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
.frame(width: Thumbnail.side, height: Thumbnail.side)
|
|
72
|
+
.opacity(isDisabled ? 0.5 : 1)
|
|
73
|
+
.onHover { isHovering = $0 }
|
|
74
|
+
// The Astryx tooltip (library/tooltip.spec.md), as core's Thumbnail wraps
|
|
75
|
+
// itself in core's tooltip: not a tab stop, and core's `auto` touch opens
|
|
76
|
+
// it on a tap, since the wrapper is not a control, while an open action
|
|
77
|
+
// still runs. The label is already in the name, so no hint.
|
|
78
|
+
.astryxTooltip(Thumbnail.meaningful(props.label), focus: .inside(focusedPart != nil), isDisabled: isDisabled)
|
|
79
|
+
.accessibilityElement(children: .contain)
|
|
80
|
+
.accessibilityLabel(accessibleName)
|
|
81
|
+
.modifier(ThumbnailIdentifier(id: props.base.id))
|
|
82
|
+
.onChange(of: showUploadOverlay, initial: true) { _, isUploading in
|
|
83
|
+
// AST-086 FR8: each busy start is announced once, in place of the
|
|
84
|
+
// decorative spinner, including one already uploading as the
|
|
85
|
+
// thumbnail appears, as core announces on mount.
|
|
86
|
+
if isUploading {
|
|
87
|
+
AccessibilityNotification.Announcement(AstryxStrings.spinnerLoading).post()
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/// The image area, with a button over it that opens the thumbnail when it
|
|
94
|
+
/// has `onClick`. The button stays mounted while loading or disabled, inert,
|
|
95
|
+
/// so focus on it stays put and VoiceOver reads it dimmed (AST-085; Swift
|
|
96
|
+
/// accessibility X2), and the picture never reloads as those states change.
|
|
97
|
+
/// The button names the tile, so the picture is hidden.
|
|
98
|
+
private var tile: some View {
|
|
99
|
+
picture
|
|
100
|
+
.accessibilityHidden(hasOpenButton)
|
|
101
|
+
.overlay {
|
|
102
|
+
if let onClick = props.onClick {
|
|
103
|
+
SwiftUI.Button(action: onClick) { Color.clear.contentShape(Rectangle()) }
|
|
104
|
+
.buttonStyle(ThumbnailPressStyle(radius: radius, pressed: astryx.tokens.color.overlayPressed))
|
|
105
|
+
.disabled(!isInteractive)
|
|
106
|
+
.focused($focusedPart, equals: .open)
|
|
107
|
+
.accessibilityLabel(openLabel)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private var picture: some View {
|
|
113
|
+
ZStack {
|
|
114
|
+
astryx.tokens.color.neutral
|
|
115
|
+
if showSkeleton {
|
|
116
|
+
ThumbnailSkeleton(color: skeletonColor, isStill: reduceMotion)
|
|
117
|
+
} else if let url = imageURL {
|
|
118
|
+
AsyncImage(url: url) { phase in
|
|
119
|
+
if let image = phase.image {
|
|
120
|
+
image.resizable().scaledToFill()
|
|
121
|
+
// Cropped to the tile first, so the inset edge below follows
|
|
122
|
+
// the tile on all four sides, whatever the photo's shape.
|
|
123
|
+
.frame(width: Thumbnail.side, height: Thumbnail.side)
|
|
124
|
+
.clipped()
|
|
125
|
+
.modifier(ThumbnailImageName(alt: Thumbnail.meaningful(props.alt)))
|
|
126
|
+
.overlay(
|
|
127
|
+
RoundedRectangle(cornerRadius: radius, style: .continuous)
|
|
128
|
+
.strokeBorder(astryx.tokens.color.border, lineWidth: 1)
|
|
129
|
+
)
|
|
130
|
+
} else if phase.error != nil {
|
|
131
|
+
placeholder
|
|
132
|
+
} else {
|
|
133
|
+
Color.clear
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
placeholder
|
|
138
|
+
}
|
|
139
|
+
if showUploadOverlay {
|
|
140
|
+
astryx.tokens.color.overlay
|
|
141
|
+
ProgressView()
|
|
142
|
+
.progressViewStyle(.circular)
|
|
143
|
+
.controlSize(.small)
|
|
144
|
+
// Core's small spinner: it stays inside the fixed-size tile at any
|
|
145
|
+
// text size.
|
|
146
|
+
.dynamicTypeSize(...DynamicTypeSize.large)
|
|
147
|
+
.tint(astryx.tokens.color.onDark)
|
|
148
|
+
.accessibilityHidden(true)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
.frame(width: Thumbnail.side, height: Thumbnail.side)
|
|
152
|
+
.clipShape(RoundedRectangle(cornerRadius: radius, style: .continuous))
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/// An image silhouette in the secondary icon color.
|
|
156
|
+
private var placeholder: some View {
|
|
157
|
+
Image(systemName: "photo.fill")
|
|
158
|
+
.resizable()
|
|
159
|
+
.scaledToFit()
|
|
160
|
+
.frame(width: 24, height: 24)
|
|
161
|
+
.foregroundStyle(astryx.tokens.color.iconSecondary)
|
|
162
|
+
.accessibilityHidden(true)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
private var removeButton: some View {
|
|
166
|
+
SwiftUI.Button(action: { props.onRemove?() }) {
|
|
167
|
+
// Core's remove glyph: the shared `close` icon at `xsm`, which the
|
|
168
|
+
// theme can remap (AST-082 FR17).
|
|
169
|
+
Icon(.close, size: .xsm)
|
|
170
|
+
.foregroundStyle(astryx.tokens.color.onDark)
|
|
171
|
+
// The button keeps its 20-point size at any text size.
|
|
172
|
+
.dynamicTypeSize(.large)
|
|
173
|
+
.frame(width: 20, height: 20)
|
|
174
|
+
.background(
|
|
175
|
+
RoundedRectangle(cornerRadius: max(0, radius - astryx.tokens.space.s1), style: .continuous)
|
|
176
|
+
.fill(astryx.tokens.color.overlay)
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
.buttonStyle(.plain)
|
|
180
|
+
.focused($focusedPart, equals: .remove)
|
|
181
|
+
// A 44 by 44 point target without moving the drawn button (Swift accessibility, X7).
|
|
182
|
+
.contentShape(.interaction, Rectangle().inset(by: -12))
|
|
183
|
+
.accessibilityLabel(removeLabel)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
private var radius: CGFloat { astryx.tokens.radius.element }
|
|
187
|
+
|
|
188
|
+
/// Core's skeleton color; under Increase Contrast it moves 30% toward the
|
|
189
|
+
/// primary text color, as core's does under `prefers-contrast: more`.
|
|
190
|
+
var skeletonColor: Color {
|
|
191
|
+
Thumbnail.skeletonColor(astryx.tokens, increasedContrast: contrast == .increased)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
nonisolated static func skeletonColor(_ tokens: Tokens, increasedContrast: Bool) -> Color {
|
|
195
|
+
guard increasedContrast else { return tokens.color.skeleton }
|
|
196
|
+
return mix(tokens.color.skeleton, tokens.color.textPrimary, by: 0.3)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/// `amount` of `other` mixed into `base`, in sRGB, as CSS `color-mix` does.
|
|
200
|
+
nonisolated static func mix(_ base: Color, _ other: Color, by amount: Double) -> Color {
|
|
201
|
+
let environment = EnvironmentValues()
|
|
202
|
+
let a = base.resolve(in: environment), b = other.resolve(in: environment)
|
|
203
|
+
let t = Float(amount)
|
|
204
|
+
return Color(
|
|
205
|
+
.sRGB,
|
|
206
|
+
red: Double(a.red + (b.red - a.red) * t),
|
|
207
|
+
green: Double(a.green + (b.green - a.green) * t),
|
|
208
|
+
blue: Double(a.blue + (b.blue - a.blue) * t),
|
|
209
|
+
opacity: Double(a.opacity + (b.opacity - a.opacity) * t)
|
|
210
|
+
)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
var isDisabled: Bool { props.isDisabled == true }
|
|
214
|
+
var isLoading: Bool { props.isLoading == true }
|
|
215
|
+
var imageURL: URL? {
|
|
216
|
+
guard let src = props.src, !src.isEmpty else { return nil }
|
|
217
|
+
return URL(string: src)
|
|
218
|
+
}
|
|
219
|
+
/// Loading with no image yet: a skeleton.
|
|
220
|
+
var showSkeleton: Bool { isLoading && props.src == nil }
|
|
221
|
+
/// Loading over an image: the upload look.
|
|
222
|
+
var showUploadOverlay: Bool { isLoading && props.src != nil }
|
|
223
|
+
/// A tap opens the thumbnail unless it is disabled or loading, as core does.
|
|
224
|
+
var isInteractive: Bool { props.onClick != nil && !isDisabled && !isLoading }
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
/// Whether the open button is mounted: whenever there is `onClick`.
|
|
228
|
+
var hasOpenButton: Bool { props.onClick != nil }
|
|
229
|
+
/// Whether the remove button is mounted: whenever there is `onRemove`.
|
|
230
|
+
var hasRemove: Bool { props.onRemove != nil }
|
|
231
|
+
/// Whether the remove button acts: mounted and not disabled.
|
|
232
|
+
var removes: Bool { hasRemove && !isDisabled }
|
|
233
|
+
|
|
234
|
+
/// `hover` shows the remove button under a pointer, while either button
|
|
235
|
+
/// has keyboard focus, and always on touch devices, as core does; `always`
|
|
236
|
+
/// shows it at rest.
|
|
237
|
+
var isRemoveVisible: Bool {
|
|
238
|
+
Thumbnail.isRemoveVisible(
|
|
239
|
+
showRemoveOn: props.showRemoveOn ?? .hover, isTouch: Thumbnail.isTouchDevice, isHovering: isHovering,
|
|
240
|
+
isFocused: focusedPart != nil, isDisabled: isDisabled)
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/// A pointer reveals the remove button only on an enabled thumbnail, as
|
|
244
|
+
/// core turns pointer events off on a disabled one.
|
|
245
|
+
nonisolated static func isRemoveVisible(
|
|
246
|
+
showRemoveOn: ThumbnailShowRemoveOn, isTouch: Bool, isHovering: Bool, isFocused: Bool, isDisabled: Bool = false
|
|
247
|
+
) -> Bool {
|
|
248
|
+
showRemoveOn == .always || isTouch || (isHovering && !isDisabled) || isFocused
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/// The thumbnail's name: label and alt, else either, else core's fallback.
|
|
252
|
+
var accessibleName: String {
|
|
253
|
+
switch (Thumbnail.meaningful(props.label), Thumbnail.meaningful(props.alt)) {
|
|
254
|
+
case let (label?, alt?): "\(label) — \(alt)"
|
|
255
|
+
case let (label?, nil): label
|
|
256
|
+
case let (nil, alt?): alt
|
|
257
|
+
case (nil, nil): AstryxStrings.thumbnailFallbackName
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
var openLabel: String { AstryxStrings.thumbnailOpen(accessibleName) }
|
|
262
|
+
var removeLabel: String { AstryxStrings.thumbnailRemove(accessibleName) }
|
|
263
|
+
|
|
264
|
+
/// Core's thumbnail side in points.
|
|
265
|
+
static var side: CGFloat { 64 }
|
|
266
|
+
|
|
267
|
+
static var isTouchDevice: Bool {
|
|
268
|
+
#if os(iOS)
|
|
269
|
+
true
|
|
270
|
+
#else
|
|
271
|
+
false
|
|
272
|
+
#endif
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
nonisolated static func meaningful(_ value: String?) -> String? {
|
|
276
|
+
guard let value, !value.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else { return nil }
|
|
277
|
+
return value
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/// Core's skeleton while the image has not arrived: `color.skeleton` at 25%
|
|
282
|
+
/// opacity; after a second it climbs to 92.5% in ten equal steps and back,
|
|
283
|
+
/// over and over, as core's does. Still at rest under Reduce Motion.
|
|
284
|
+
struct ThumbnailSkeleton: View {
|
|
285
|
+
let color: Color
|
|
286
|
+
let isStill: Bool
|
|
287
|
+
@State private var appeared = Date()
|
|
288
|
+
|
|
289
|
+
/// Core's resting and brightest opacities.
|
|
290
|
+
nonisolated static var restingOpacity: Double { 0.25 }
|
|
291
|
+
nonisolated static var brightestOpacity: Double { 0.925 }
|
|
292
|
+
/// Core's wait before the pulse starts, so fast loads never flash.
|
|
293
|
+
nonisolated static var delay: Double { 1 }
|
|
294
|
+
/// One way of the pulse: core's default `duration-medium-max`. The Swift
|
|
295
|
+
/// theme carries no motion tokens yet.
|
|
296
|
+
nonisolated static var pulseDuration: Double { 0.55 }
|
|
297
|
+
|
|
298
|
+
var body: some View {
|
|
299
|
+
TimelineView(.animation(paused: isStill)) { context in
|
|
300
|
+
color.opacity(
|
|
301
|
+
isStill ? Self.restingOpacity : Self.opacity(elapsed: context.date.timeIntervalSince(appeared)))
|
|
302
|
+
}
|
|
303
|
+
.onAppear { appeared = Date() }
|
|
304
|
+
.accessibilityHidden(true)
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/// The opacity `elapsed` seconds after the skeleton appears: at rest for
|
|
308
|
+
/// the delay, then core's ten held steps up and back down.
|
|
309
|
+
nonisolated static func opacity(elapsed: Double) -> Double {
|
|
310
|
+
let time = elapsed - delay
|
|
311
|
+
guard time > 0 else { return restingOpacity }
|
|
312
|
+
let phase = time.truncatingRemainder(dividingBy: 2 * pulseDuration) / pulseDuration
|
|
313
|
+
let climb = phase <= 1 ? phase : 2 - phase
|
|
314
|
+
let step = min((climb * 10).rounded(.down), 9)
|
|
315
|
+
return restingOpacity + step * (brightestOpacity - restingOpacity) / 9
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/// Paints the pressed overlay over the picture.
|
|
320
|
+
private struct ThumbnailPressStyle: ButtonStyle {
|
|
321
|
+
let radius: CGFloat
|
|
322
|
+
let pressed: Color
|
|
323
|
+
|
|
324
|
+
func makeBody(configuration: Configuration) -> some View {
|
|
325
|
+
configuration.label
|
|
326
|
+
.overlay(
|
|
327
|
+
RoundedRectangle(cornerRadius: radius, style: .continuous)
|
|
328
|
+
.fill(configuration.isPressed ? pressed : .clear)
|
|
329
|
+
)
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/// The image reads as its `alt`; without one it is decorative.
|
|
334
|
+
private struct ThumbnailImageName: ViewModifier {
|
|
335
|
+
let alt: String?
|
|
336
|
+
|
|
337
|
+
func body(content: Content) -> some View {
|
|
338
|
+
if let alt {
|
|
339
|
+
content.accessibilityLabel(alt)
|
|
340
|
+
} else {
|
|
341
|
+
content.accessibilityHidden(true)
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/// The base `id` becomes the accessibility identifier (AST-082 FR7).
|
|
347
|
+
private struct ThumbnailIdentifier: ViewModifier {
|
|
348
|
+
let id: String?
|
|
349
|
+
|
|
350
|
+
func body(content: Content) -> some View {
|
|
351
|
+
if let id {
|
|
352
|
+
content.accessibilityIdentifier(id)
|
|
353
|
+
} else {
|
|
354
|
+
content
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
@@ -13,6 +13,16 @@ enum TooltipFocus: Equatable, Sendable {
|
|
|
13
13
|
/// The view is made a tab stop so focus can show the tooltip, as core gives
|
|
14
14
|
/// a static element with a tooltip a tab stop.
|
|
15
15
|
case tabStop
|
|
16
|
+
/// The view holds controls that take focus; `true` while one of them has
|
|
17
|
+
/// it. Focus there shows the tooltip, as core's tooltip on a wrapper shows
|
|
18
|
+
/// on focus within it.
|
|
19
|
+
case inside(Bool)
|
|
20
|
+
|
|
21
|
+
/// Whether a control inside the view has focus.
|
|
22
|
+
var isInsideFocused: Bool {
|
|
23
|
+
if case .inside(let focused) = self { return focused }
|
|
24
|
+
return false
|
|
25
|
+
}
|
|
16
26
|
}
|
|
17
27
|
|
|
18
28
|
/// What a direct tap on a touch screen does, as core's `touchTrigger`.
|
|
@@ -206,9 +216,9 @@ struct TooltipPresenter: ViewModifier {
|
|
|
206
216
|
focusIsKeyboard = Self.keyboardFocusHolds(afterHover: inside, holds: focusIsKeyboard)
|
|
207
217
|
update()
|
|
208
218
|
}
|
|
209
|
-
.onChange(of:
|
|
219
|
+
.onChange(of: anyFocused) {
|
|
210
220
|
focusIsKeyboard =
|
|
211
|
-
|
|
221
|
+
anyFocused && Self.isKeyboardFocus(isHovering: isHovering, sincePress: Date().timeIntervalSince(pressedAt))
|
|
212
222
|
update()
|
|
213
223
|
}
|
|
214
224
|
.onChange(of: text) {
|
|
@@ -268,12 +278,15 @@ struct TooltipPresenter: ViewModifier {
|
|
|
268
278
|
isTapShown = false
|
|
269
279
|
}
|
|
270
280
|
|
|
281
|
+
/// Focus on the view itself, or on a control inside it (`inside`).
|
|
282
|
+
private var anyFocused: Bool { isFocused || focus.isInsideFocused }
|
|
283
|
+
|
|
271
284
|
/// Shows the bubble after the delay; hides it after the bridge.
|
|
272
285
|
private func update() {
|
|
273
286
|
pending?.cancel()
|
|
274
|
-
let keyboardFocused = Self.holdsByFocus(isFocused:
|
|
287
|
+
let keyboardFocused = Self.holdsByFocus(isFocused: anyFocused, focusIsKeyboard: focusIsKeyboard)
|
|
275
288
|
let wants = Self.showsBubble(
|
|
276
|
-
hasText: text != nil, isHovering: isHovering, isHoveringBubble: isHoveringBubble, isFocused:
|
|
289
|
+
hasText: text != nil, isHovering: isHovering, isHoveringBubble: isHoveringBubble, isFocused: anyFocused,
|
|
277
290
|
focusIsKeyboard: focusIsKeyboard, focus: focus)
|
|
278
291
|
guard wants != isShown else { return }
|
|
279
292
|
let byFocus = keyboardFocused && focus != .none && !isHovering && !isHoveringBubble
|
|
@@ -19,7 +19,10 @@ public struct AstryxNodeView: View {
|
|
|
19
19
|
case .heading(let heading): Heading(heading.viewProps(send: send))
|
|
20
20
|
case .card(let card): Card(card.viewProps(send: send), children: card.props.children ?? [], send: send)
|
|
21
21
|
case .icon(let icon): Icon(icon.viewProps(send: send))
|
|
22
|
-
case .avatar(let avatar):
|
|
22
|
+
case .avatar(let avatar):
|
|
23
|
+
Avatar(avatar.viewProps(send: send)) { AstryxNodeList(nodes: avatar.props.status ?? [], send: send) }
|
|
24
|
+
case .avatarStatusDot(let dot): AvatarStatusDot(dot.viewProps(send: send))
|
|
25
|
+
case .thumbnail(let thumbnail): Thumbnail(thumbnail.viewProps(send: send))
|
|
23
26
|
default: AstryxUnsupportedNode(component: Self.componentName(node))
|
|
24
27
|
}
|
|
25
28
|
}
|
|
@@ -28,6 +31,7 @@ public struct AstryxNodeView: View {
|
|
|
28
31
|
static func componentName(_ node: AstryxNode) -> String {
|
|
29
32
|
switch node {
|
|
30
33
|
case .avatar: "Avatar"
|
|
34
|
+
case .avatarStatusDot: "AvatarStatusDot"
|
|
31
35
|
case .badge: "Badge"
|
|
32
36
|
case .button: "Button"
|
|
33
37
|
case .card: "Card"
|
|
@@ -39,6 +43,7 @@ public struct AstryxNodeView: View {
|
|
|
39
43
|
case .selector: "Selector"
|
|
40
44
|
case .switch: "Switch"
|
|
41
45
|
case .text: "Text"
|
|
46
|
+
case .thumbnail: "Thumbnail"
|
|
42
47
|
case .textInput: "TextInput"
|
|
43
48
|
case .vStack: "VStack"
|
|
44
49
|
case .unsupported(let component, _): component
|