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.ActivityOrderListBinding
import com.zswc.creativity.fragment.OrderListFragment
import com.zswc.creativity.vmodel.OrderVModel

/**
 *我的订单
 *on 2021/3/15
 */
class MyOrderActivity : MBTabActivity<OrderVModel, ActivityOrderListBinding>(){


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


    }

    override fun vmClass(): Class<OrderVModel> {
        return OrderVModel::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( two, three, four)
    }

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

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

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

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

            }
            2 -> {

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

            }


            else->{

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

        }
    }

    override fun getPageCount(): Int {
        return 3
    }

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

    override val isRxbus: Boolean
        get() = true
}
