You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When loading views dynamically the client needs to receive a callback when the view loads in order to be able to access the subviews/controls. Setting a different json value for LoadableView does not load it synchronously in-place so there was a race condition to access the load subviews.
The clients can now declare viewDidLoadActionID in LoadableView json and register a callback for that ID to get their action handler called when the loaded view is ready for access.
Copy file name to clipboardExpand all lines: ActionUI/Views/LoadableView.swift
+6-4Lines changed: 6 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,8 @@
7
7
"properties": {
8
8
"url": "https://example.com/view.json", // Optional: String URL to remote JSON or binary plist (http://, https://)
9
9
"filePath": "/path/to/view.json", // Optional: String absolute path to local JSON or binary plist
10
-
"name": "HelloWorld.json" // Optional: String name of JSON or binary plist resource in app bundle
10
+
"name": "HelloWorld.json", // Optional: String name of JSON or binary plist resource in app bundle
11
+
"viewDidLoadActionID": "view.loaded" // Optional: String action triggered once after a new sub-view is loaded. Not re-triggered on SwiftUI body rebuilds for the same source.
11
12
}
12
13
// Note: Requires exactly one of "url", "filePath", or "name" to be valid. Loads JSON or binary plist, determined by .json or .plist extension, parses into ActionUIElementBase using ActionUIModel.loadDescription, and renders ActionUIView. Remote "url" loads asynchronously with ProgressView; local "filePath" or bundle "name" loads synchronously in init. Assumes unique IDs in loaded description to avoid conflicts with existing windowModels. Baseline View properties (padding, hidden, foregroundColor, font, background, frame, opacity, cornerRadius, actionID, disabled) and additional View protocol modifiers are inherited and applied via ActionUIRegistry.shared.applyViewModifiers(to: baseView, properties: element.properties).
13
14
// Note: Invalid sources or unsupported extensions will result in error display. The source (url/filePath/name) is the designated value (valueType: String.self), settable via ActionUIModel.setElementValue, with heuristics: http:// or https:// for URL, file:// or / for filePath, else bundle name.
0 commit comments