react-native-check-box icon indicating copy to clipboard operation
react-native-check-box copied to clipboard

Indeterminate state

Open jav opened this issue 7 years ago • 3 comments

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?

jav avatar Jul 29 '17 11:07 jav

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'] )"

jav avatar Jul 29 '17 12:07 jav

https://github.com/jav/react-native-check-box

jav avatar Jul 29 '17 12:07 jav

PR: https://github.com/crazycodeboy/react-native-check-box/pull/33

jav avatar Jul 29 '17 13:07 jav