react-native-check-box
react-native-check-box copied to clipboard
Indeterminate state
I'm in the process of writing an application which needs check-boxes that may be in the "indeterminate" state.
After some research facebook react issue and experimentation jsfiddle (I've only tested in Chrome & Firefox) my understanding is that:
Checked/unchecked/indeterminate
- Are three states
- Controlled by two bits
- checked [true/false]
- indeterminate [true/false]
Checked: true | Checked: false | |
---|---|---|
Indeterminate: true | indeterminate | indeterminate |
Indeterminate: false | checked | not checked |
Depending on available time, I'm considering a PR which would:
- Add the property "isIndeterminate"
- Add a property "indeterminateImage"
- Update _renderImage() to return this.props.indeterminateImage if isIndetermenate is true, or pass on to genCheckedImage()
- Update genCheckedImage() to render a third image if isIndeterminate is true (overriding the value of 'this.props.isChecked'
- Update defaultProps to include isIndeterminate: false
- Add an image for the indeterminate state.
As far as I can tell, this should do it.
WDYT? Would such a PR be accepted?
In the above, I'd stick to using "genCheckedImage()" as it's currently used.
Currently, it's used, not to "generate the checked image", but rather as a "provide a default image".
I'd go for something like "genDefaultImage( ['checked'|'unchecked'|'indetermined'] )"
https://github.com/jav/react-native-check-box
PR: https://github.com/crazycodeboy/react-native-check-box/pull/33