package com.quansu.heifengwuliu.fragment

import android.view.LayoutInflater
import android.view.View
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.quansu.heifengwuliu.R
import com.quansu.heifengwuliu.base.MBTabFragment
import com.quansu.heifengwuliu.databinding.FragmentWaybillBinding
import com.ysnows.base.base.BRepository
import com.ysnows.base.base.BViewModel
import com.ysnows.base.utils.B

/**
 *Created by shihuiyun
 *on 2020/9/9
 */
class WayBillFragment : MBTabFragment<BViewModel<BRepository>, FragmentWaybillBinding>() {

    override fun initView(view: View?) {
        super.initView(view)
        titleBar?.tvRight?.text = getString(R.string.filter)

    }

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

    override fun title(): String? {
        return getString(R.string.source_information)
    }

    override fun backable(): Boolean {
        return false
    }

    override fun getPageItem(position: Int): Fragment {
        var ownerFragment = OrderListFragment()
        when (position) {
            0 -> {
                ownerFragment.arguments = B().putString("info_state", "0").ok()
                return ownerFragment
            }
            1 -> {
                ownerFragment.arguments = B().putString("info_state", "20").ok()
                return ownerFragment

            }
            2 -> {
                ownerFragment.arguments = B().putString("info_state", "30").ok()
                return ownerFragment

            }
            3 -> {
                ownerFragment.arguments = B().putString("info_state", "40").ok()
                return ownerFragment

            }
            4 -> {
                var ownerFragment = OrderListFragment()
                ownerFragment.arguments = B().putString("info_state", "100").ok()
                return ownerFragment

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

        }
        return OrderListFragment()
    }

    override fun getPageCount(): Int {
        return 5
    }

    override fun createTabs(tabBuilder: QMUITabBuilder): Array<QMUITab> {
        val component = tabBuilder
                .setText(getString(R.string.all))
                .build(context())

        val util = tabBuilder
                .setText(getText(R.string.to_order_receive))
                .build(context())

        val ongoing = tabBuilder
                .setText(getText(R.string.on_going))
                .build(context())

        val canceled = tabBuilder
                .setText(getText(R.string.canceled))
                .build(context())

        val completed = tabBuilder
                .setText(getText(R.string.completed))
                .build(context())

        return arrayOf(component, util, ongoing, canceled, completed)

    }


}
