feat(tui-prompts): WIP Add DateTime type #92
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.
This is a work in progress, but I thought this would be a good point to share what I have so far.
The DateTime prompt does most of what I want it to, and the trait changes relating to prompt state should make it easier to add other compound prompts (like a radio button prompt).
That said, working on this demonstrated just how opinionated a prompt that handles date and time has to be.
It may be less of a headache long-term to include the datetime module only in the examples directory, while keeping the code allowing compound state that it's built on.
Please let me know what you think!
What this changes
State traits
Creates a CompoundState, intended as a container to hold the state of multiple child prompts.
Creates a TextualState to hold functionality separate from the container-like CompoundState.
Creates a StateCommon, to hold core functionality shared by all state types.
Validation
is_valid_char)chrono::NaiveDateTime) on marking prompt Status as DonedatetimeModuleDateTimeState, DateTimePrompt, NumericChildState and NumericPrompt
Styling
The datetime prompt has a default display shown when no text is entered.
Example
Adds the
utc_timeexample, which requires thedatetimefeature:The status doesn't do anything.
Remaining issues
I haven't written much documentation or any tests for the new code yet.
Validity
No builtin way of checking semantic validity yet.
This is important where the value of one prompt is related to the value of another, or where there is an external constraint.
Does it need to be builtin? I'm not sure
Status
With validation on submission, there is now the possibility for an "invalid" status. I have made no changes to this, so the Status (or more broadly, how status is considered and handled) needs review.
Adding Style
The
*RenderStyletypes would benefit from more generalisation.Prompt Sizing
I haven't yet done anything to allow for resizing of the DateTimePrompt.