package com.zswc.creativity.activity

import android.os.Bundle
import androidx.fragment.app.Fragment
import com.qmuiteam.qmui.widget.tab.QMUITab
import com.qmuiteam.qmui.widget.tab.QMUITabBuilder
import com.ysnows.base.utils.B
import com.zswc.creativity.base.MBTabActivity
import com.zswc.creativity.databinding.ActivityConsignorderListBinding
import com.zswc.creativity.fragment.ConsignOrderListFragment
import com.zswc.creativity.fragment.OrderListFragment
import com.zswc.creativity.vmodel.ConsignOrderVModel

/**
 *寄售订单
 *on 2021/3/15
 */
class ConsignmentOrderActivity : MBTabActivity<ConsignOrderVModel, ActivityConsignorderListBinding>(){


    override fun init(savedInstanceState: Bundle?) {
        super.init(savedInstanceState)


    }

    override fun vmClass(): Class<ConsignOrderVModel> {
        return ConsignOrderVModel::class.java
    }


    override fun createTabs(tabBuilder: QMUITabBuilder): Array<QMUITab> {

        val one = tabBuilder
                .setText("已购买")
                .build(context())
        val two = tabBuilder
                .setText("待支付")
                .build(context())

        val three = tabBuilder
                .setText("已售出")
                .build(context())

        val four = tabBuilder
                .setText("寄售中")
                .build(context())



        return arrayOf(one, two, three, four)
    }

    override fun binding(): ActivityConsignorderListBinding {
       return ActivityConsignorderListBinding.inflate(layoutInflater)
    }

    override fun getPageItem(position: Int): Fragment {
        var ownerFragment = ConsignOrderListFragment()
        when (position) {
            0 -> {

                ownerFragment.arguments = B().putString("state", "")
                        .ok()
                return ownerFragment
            }
            1 -> {

                ownerFragment.arguments = B().putString("state", "0")
                        .ok()
                return ownerFragment

            }
            2 -> {

                ownerFragment.arguments = B().putString("state", "1")
                        .ok()
                return ownerFragment

            }

            3 -> {

                ownerFragment.arguments = B().putString("state", "2")
                        .ok()
                return ownerFragment

            }
            else->{

                ownerFragment.arguments = B().putString("state", "")
                        .ok()
                return ownerFragment
            }

        }
    }

    override fun getPageCount(): Int {
        return 4
    }

    override fun title(): String? {
        return "我的订单"
    }

    override val isRxbus: Boolean
        get() = true
}
