package com.yidian.shenghuoquan.buserorder.ui.widget

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.databinding.DataBindingUtil
import com.yidian.shenghuoquan.buserorder.R
import com.yidian.shenghuoquan.buserorder.databinding.BorderViewOrderInfoBinding
import com.yidian.shenghuoquan.buserorder.dto.OrderDetailDto
import com.yidian.shenghuoquan.buserorder.manager.OrderStatus
import com.yidian.shenghuoquan.buserorder.viewmodel.OrderInfoViewModel

/**
 * author: yinjiacheng
 * date: 2021/8/22 19:59
 * description: 订单信息
 */
class OrderInfoView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0) :
  ConstraintLayout(context, attrs, defStyle) {

  private val binding =
    DataBindingUtil.inflate<BorderViewOrderInfoBinding>(LayoutInflater.from(getContext()), R.layout.border_view_order_info, this, true)

  /**
   * 设置订单信息
   * @param status 订单状态
   * @param info 订单信息
   */
  fun setOrderInfo(status: OrderStatus?, info: OrderDetailDto) {
    binding.vm = OrderInfoViewModel()
    binding.status = status
    binding.data = info
  }
}
