package com.unis.sxzcl.ui.basic;

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.widget.TabFragmentPagerAdapter;

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

/**
 * 包名: com.unis.sxzcl.ui.basic
 * 类名: BasicFragment
 * 作用描述:
 * 创建人: mQ
 * 创建时间: 2020/12/9 17:36
 * 更新人:
 * 更新时间: 2020/12/9 17:36
 * 更新说明:
 * 版本号: 1.0
 */
public class BasicFragment extends BaseFragment<FragmentBaseTabPagerBinding> {

//    private List<String> mTabs = Arrays.asList("人员结构", "政策制度");
    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() {
        mBinding.bar.setTitle("基本信息")
                .setLeftClickListener(v -> onBack());

        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 PersonFrameFragment());
//        mFragments.add(new PolicyListFragment());
    }

    @Override
    protected void onFirstShow() {

    }
}
