import TyComponent from '../common/component'

TyComponent({
  /**
   * 组件的属性列表
   */
  properties: {

    type: {
      type: String,
      value: 'danger'
    },
    message: {
      type: String
    },
    duration: {
      type: Number,
      value: 3000
    },
    selector: {
      type: String,
      value: 'ht-notify'
    },
    color: {
      type: String,
      value: '#fff'
    },
    background: {
      type: String
    },
    safeAreaInsetTop: {
      type: Boolean,
      value: false
    }
  },

  /**
   * 组件的初始数据
   */
  data: {},

  /**
   * 组件的方法列表
   */
  methods: {

    show() {
      const notify = this.selectComponent('.ht-notify-inner')
      let { onClick, onOpened, onClose} = this.data
      notify.setData({
        onClick,
        onOpened,
        onClose
      })
      if (notify && notify.show) {
        notify.show()
      }
    },
    hide() {
      const notify = this.selectComponent('.ht-notify-inner')
      if (notify && notify.hide) {
        notify.hide()
      }
    },
    // onTap(event) {
    //   const { onClick } = this.data
    //   if (onClick) {
    //     onClick(event.detail)
    //   }
    // },
    // handleClose({
    //   detail
    // }) {
    //   this.triggerEvent('close', detail)
    // },
    // handleClick({
    //   detail
    // }) {
    //   this.triggerEvent('click', detail)
    // },
    // handleOpen({
    //   detail
    // }) {
    //   this.triggerEvent('open', detail)
    // },
  }
})
