Complete SwiftUI Implementation of v0.10 Basic Catalog#729
Draft
sunnypurewal wants to merge 117 commits intogoogle:mainfrom
Draft
Complete SwiftUI Implementation of v0.10 Basic Catalog#729sunnypurewal wants to merge 117 commits intogoogle:mainfrom
sunnypurewal wants to merge 117 commits intogoogle:mainfrom
Conversation
PROMPT: So this is a fresh clone of the A2UI repo, and I've implemented a Swift renderer that I want to contribute back to the project open-source. However, there's no git history because I copied the code from another repo. Can we analyze the code and create 5-10 git commits that document the changes. What info do you need to accomplish this? PROMPT: do it
PROMPT: fix the build error when running swift test
…e test structure PROMPT: can you work on fixing the the tests in this folder `swift test` to run them
…ld error display PROMPT: have you implemented Checkable from the spec?Checkable is on some components like TextField so we can run a function on its value PROMPT: where will the TextFieldView display the message? it shouldn't take over the text field's content. Can we add a small label under the TextFIeld and show the error if it exists in small red text. Also, only have that error label present IF checks.isEmpty==false and the checks fail PROMPT: actually let's not show anymore error messages yet, let me try it out on textfield PROMPT: i manually fixed the build. if you have statements in the Preview, you need to have `return` before the View definition PROMPT: commit
PROMPT: we've added CheckRule and Checkable and implemented the catalog of built-in functions. But do we ever call the check functions? E.g. when the TextField value changes, should we be calling the check functions then? PROMPT: can you add logs for when the checks are run PROMPT: not just if it fails, log when they are about to run, what hte inputs are as well
…ructure - Remove redundant checks from component property structs (TextField, Button, etc.) - Handle checks at the ComponentInstance level as a sibling to component - Update BoundValue to support 'functionCall' wrapper used in templates - Pass instance-level checks to A2UITextFieldView PROMPT: ok so it seems like we should never have added Checks to the TextFieldProperties or any component properties right?
PROMPT: ok so any code you wrote to support my mistake please remove it
…n TextField gallery PROMPT: I want the sample app to be able to configure the Checks run on the TextField. Can we make an enum populating all of the standard catalog functions? PROMPT: use 0_10
PROMPT: note the build error, the #""# needs to be asingle line
…ustom template logic - Update PropertyDefinition to allow optional value and add mapValue closure - Update GalleryComponent to use mapValue in resolvedTemplate - Update ComponentView to handle nil property values and show 'None' in Pickers - Update TextField gallery to support optional validation checks with a 'None' option PROMPT: I'd like PropertyDefinition to allow for a nil value. e.g. PropertyDefinition(key: checkFunctionKey, label: "Check", options: StandardCheckFunction.allCases.map(\.rawValue), value: StandardCheckFunction.email.rawValue) I want Check to be able to be nil so we know not to run any checks
- Created FunctionDemos.swift with several catalog function examples - Added formatDate, formatCurrency, and pluralize demos - Updated StaticComponent.swift with shared components for function previews - Integrated into ContentView and GalleryData PROMPT: i'd like to add a category to the main view called Functions, then I'd like to show all the built-in standard catalog functions, and then when tapped, a way to demo each function's functionality PROMPT: i'd like the UI for the demo to be all in A2UI the same way the component gallery is
- Set showInEditor: false for all DataModelFields in FunctionDemos.swift to rely on A2UI components for input/interaction PROMPT: update all the function gallery components so that they have their DataModelFields have showInEditor: false
PROMPT: now split up FunctionDemos.swift into a file for each component
PROMPT: move A2UIFunctionEvaluator out of Surface into a new folder called Functions/ Then break the file up and make 3 new folders Validation/ Formatting/ and Logical/ and then create a file for each function and put it in the right folder
PROMPT: let's try it
…gument validation to the evaluator PROMPT: but all the function params are optional...let's check to make sure all the arguments exist in the evaluator, then send them into the function. functions should not have optional parameter types
…UI spec for required and optional arguments PROMPT: does the spec say anything about how to handle args to a function call? Right now we are making sure they're all not-nil, but does the spec say to do this? Does the spec say some args can be nil or optional?i ahven't found anything about this, seems like all args have to be tehre PROMPT: ok since the spec defines optional arguments, let's implement the functions to spec
… in Swift renderer. PROMPT: currently the text field shows the error message if checks fail, but I don't think that's a good UI for generic open-source use. If we remove that, is there some way for the user to listen for the output of checks so they can render some other UI element?or I guess they could put another A2UI component in the UI, and it will bind to the check value? I don't htink that's possible actually PROMPT: don't look at other renderers, onlys wift PROMPT: explain what you're doing. are you publishing validation errors after running checks? PROMPT: wait did you remove the automatic checking when the value changes in the textfield and other input views that use checks? PROMPT: can we do both push and pull? When the value of the textfield changes, we should still run the checks and update that _validation virtual path PROMPT: commit
…ths. PROMPT: can we udpate the gallery TextField so that it has a Text component that shows the Check status. e.g. if no checks, just show nothing. if a check is configured (email, or required). show Passed Checks or Failed Checks on the text
…in Swift gallery. PROMPT: can we show the _validation virtual paths when we look at the Data Model JSON int he gallery?
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive Swift renderer for the A2UI protocol, including component views, data models, a parser, and a sample application. The implementation is extensive and well-structured, with good test coverage for an initial version. My review focuses on critical issues like potential crashes from force unwraps and memory leaks from retain cycles, as well as some high and medium-severity issues related to stream parsing, data conversion, and component behavior. Addressing these points will significantly improve the robustness and reliability of the renderer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR implements a SwiftUI renderer of the basic catalog components and functions defined in v0.10. I chose v0.10 because it looks identical to v0.9, which is itself very different from v0.8, so I found no reason to implement the outdated v0.8 and v0.10 seemed like the best choice.
The sample app demonstrates the union of the A2UI elements, the data model, and the rendered SwiftUI for each component. The basic catalog functions are also demonstrated on user input.
Note that this is a full implementation so this PR is gigantic.
google:mainhave been edited.Pre-launch Checklist
If you need help, consider asking for advice on the discussion board.