Skip to content
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

Add support for empty values in NumberEditor #165

Merged
merged 1 commit into from
Jan 15, 2021

Conversation

achernenko-pp
Copy link
Contributor

@achernenko-pp achernenko-pp commented Jan 14, 2021

What has been done?

This PR enables empty values in ValueFields backed by NumberEditor. The intended use case is being able to express nil values. Internally, empty values are mapped to NSDecimalNumber.notANumber. A proper implementation would require making TextEditor.value optional, but that would be a dramatic change of the API, so while the proposed solution is not ideal, it is much more conservative.

Empty values are enabled using the allowsEmptyValues parameter in the NumberEditor initializer, after which this behavior cannot be changed. This is done to avoid overcomplicating the internal logic in NumberEditor. Besides, it is probably unlikely that the desired behavior for a field will need to change during the lifetime of an editor.

Copy link
Contributor

@CJEkman CJEkman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@achernenko-pp achernenko-pp merged commit 1956958 into master Jan 15, 2021
@achernenko-pp achernenko-pp deleted the numbereditor-empty-values branch January 15, 2021 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants