package com.quansu.heifengwuliu.activity

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.MBTabActivity
import com.quansu.heifengwuliu.databinding.ActivityAccountBinding
import com.quansu.heifengwuliu.fragment.AccountAnalysisFragment
import com.quansu.heifengwuliu.fragment.AccountBillFragment
import com.ysnows.base.base.BRepository
import com.ysnows.base.base.BViewModel

class AccountActivity : MBTabActivity<BViewModel<BRepository>, ActivityAccountBinding>() {


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


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

    override fun getPageItem(position: Int): Fragment {
        return if (position == 1) {
            AccountAnalysisFragment()
        } else AccountBillFragment()
    }

    override fun getPageCount(): Int {
        return 2
    }

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

        val component = tabBuilder
                .setText(getString(R.string.bill))
                .build(context())
        val util = tabBuilder
                .setText(getText(R.string.analysis))
                .build(context())

        return arrayOf(component, util)
    }
}