-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Markdown Checkbox Functionality #54
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AdritRao Thank you for taking a look at the issue and addressing a first element here!
I have a few first things that could help as you move forward:
- I would suggest using the GitHub task list syntax to extract checkboxes from the markdown: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#task-lists
- I would suggest that we allow these checkboxes to be translated to either Toggles or a Menu. I would probably prefer a SwiftUI Menu as it can also detail that no selection has been made yet, which might be important if a user needs to either agree or disagree to something.
- We should embed these at the places where they occur in the Markdown. This requires us to basically parse the MD fileline by line, then investigate if one line contains a special syntax we need to interpret (see above or below for possibilities), and then transform this into a specialized element. I would suggest that we create a special data structure for this instead of doing this in a few. This would also make it easier to unit test this:
a. The data structure contains a list of elements that are enums. These can be Markdown text, an agree/disagree selection with a description, or the signature field (keeping it simple for these three for now).
b. You can parse an MD string into this format so it is transformed in our internal representation.
c. This is then used in the Consent Document to basically render this in a ForEach loop that just renders each section one after each other in our VStack/ScrollView.
d. On export, this data is then collected and transferred into an easily parsable representation as noted in Supporting to distinguish multiple consent forms during onboarding via an identifier (#50) #51.
In addition, we should take a look at the GitHub MD syntax on how we might represent additional fields like an initial signature field. I can imagine we can use:
> [!INITIALS]
> Description for the initials field.
Syntax or something similar to how GitHub displays alerts boxes: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts.
I can also see that we only rely on this syntax and also use that for selections:
> [!AGREE]
> Description of the Agree/Disagree field
and
> [!SIGNATURE]
to even inject the signature field at the bottom of the consent document.
Let me know what you think; thank you for taking a deep-dive into all of this!
Thank you for reviewing the PR and for providing these next steps @PSchmiedmayer! I will start working on migrating to the GitHub syntax and using SwiftUI menus. I will also add the functionality for line-by-line parsing to make sure that elements are created and displayed based on the order they appear in the Markdown file. After this, I will add the additional elements such as initials, etc. |
Markdown Checkbox Functionality
♻️ Current situation & Problem
Checkboxes are currently not supported in markdown consent forms for SpeziOnboarding. Adding support for checkbox syntax in MD files can allow for yes/no consent questions in addition to the name and signature.
⚙️ Release Notes
extractMarkdownCB()
). Checkbox questions can be put within square brackets (e.g. [Do you consent to data collection?]).extractMarkdownCB()
also returns a cleaned MD with checkbox syntax removed for PDF exportcheckboxesView
to create checkbox buttons based on the extracted items from MDImageRenderer
to capture snapshot ofcheckboxesView
when user taps 'I Consent'OnboardingConsentMarkdownRenderingView.swift
to allow for QuickLook PDF viewBelow is an image of the UI and PDF export produced from the following MD data:
📝 Code of Conduct & Contributing Guidelines
By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines: