package com.unis.sxzcl.ui.depot;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.fragment.app.Fragment;

import com.unis.sxzcl.base.BaseFragment;
import com.unis.sxzcl.databinding.FragmentBaseTabPagerBinding;
import com.unis.sxzcl.ui.house.HouseListFragment;
import com.unis.sxzcl.ui.person.PersonListFragment;
import com.unis.sxzcl.widget.TabFragmentPagerAdapter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 包名: com.unis.sxzcl.ui.depot
 * 类名: DepotHomeFragment
 * 作用描述:
 * 创建人: mQ
 * 创建时间: 2020/12/1 15:06
 * 更新人:
 * 更新时间: 2020/12/1 15:06
 * 更新说明:
 * 版本号: 1.0
 */
public class DepotHomeFragment extends BaseFragment<FragmentBaseTabPagerBinding> {

    private List<String> mTabs = Arrays.asList("简介", "仓房", "人员");
    private List<Fragment> mFragments;


    @Override
    protected FragmentBaseTabPagerBinding getViewBinding(LayoutInflater inflater, ViewGroup container) {
        return FragmentBaseTabPagerBinding.inflate(inflater,container,false);
    }

    @Override
    protected void init() {
        Bundle bundle = getArguments();
        String data = bundle.getString("data");

        mBinding.bar.setLeftClickListener(v -> onBack());
        mBinding.bar.setTitle(data);

        initFragment();
        mBinding.tabLayout.setupWithViewPager(mBinding.viewPager);
        TabFragmentPagerAdapter adapter = new TabFragmentPagerAdapter(
                getChildFragmentManager(), mTabs, mFragments);
        mBinding.viewPager.setAdapter(adapter);
        mBinding.viewPager.setOffscreenPageLimit(mFragments.size());
    }

    private void initFragment() {
        mFragments = new ArrayList<>();
        mFragments.add(new DepotDetailFragment());
        mFragments.add(HouseListFragment.newFragmentNoTitle());
        mFragments.add(PersonListFragment.newFragmentNoTitle());
    }

    @Override
    protected void onFirstShow() {

    }
}
