package com.zswc.creativity.fragment

import android.view.LayoutInflater
import android.view.ViewGroup
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.MBTabFragment
import com.zswc.creativity.databinding.FragmentConSaleBinding
import com.zswc.creativity.vmodel.CoSaleVModel

/**
 *on 2022/7/25
 */
class ConSaleFragmet : MBTabFragment<CoSaleVModel, FragmentConSaleBinding>(){


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

    override fun binding(inflater: LayoutInflater, container: ViewGroup?): FragmentConSaleBinding {
        return FragmentConSaleBinding.inflate(layoutInflater)
    }

    override fun getPageItem(position: Int): Fragment {

        var ownerFragment = SaleListFragment()
        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

            }

            4 -> {

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

            }

            5 -> {

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

            }

            else->{

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

        }





//        when (position) {
//            0 -> {
//                var oneFragment = SiteOneFragment()
//                return oneFragment
//            }
//            1 -> {
//                var twoFragment = SiteTwoFragment()
//                return twoFragment
//            }
//            else ->{
//                var oneFragment = SiteOneFragment()
//                return oneFragment
//            }
    }

    override fun getPageCount(): Int {
      return 6
    }

    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())
        val five = tabBuilder
                .setText("国风")
                .build(context())
        val seven = tabBuilder
                .setText("IP授权")
                .build(context())

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

    override fun title(): String? {
        return null
    }
}
