Component({
  props: {
    checked: {
      type: Boolean,
      default: false
    },
    onChange: {
      type: Function,
      default: () => {}
    }
  },
  data: {
    mChecked: false
  },
  methods: {
    change() {
      this.setData({
        mChecked: !this.data.mChecked
      })
      this.props.onChange(this.data.mChecked)
    }
  },
  rootEvents: {
    onReady() {
      this.setData({
        mChecked: this.props.checked
      })
    }
  }
})
