package com.casic.dcms.ui;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;

import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.casic.dcms.R;
import com.casic.dcms.adapter.SubViewPagerAdapter;
import com.casic.dcms.base.BaseActivity;
import com.casic.dcms.ui.fragment.check.CaseCheckFragment;
import com.casic.dcms.ui.fragment.check.CaseCheckedFragment;
import com.casic.dcms.utils.Constant;
import com.google.android.material.tabs.TabLayout;
import com.qmuiteam.qmui.widget.QMUITopBarLayout;

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

import butterknife.BindView;

/**
 * @author : Pengxh
 * @time : 2021/4/16 9:24
 * @email : 290677893@qq.com
 **/
public class CaseCheckActivity extends BaseActivity {

    @BindView(R.id.checkTopLayout)
    QMUITopBarLayout checkTopLayout;
    @BindView(R.id.checkTabLayout)
    TabLayout checkTabLayout;
    @BindView(R.id.checkViewPager)
    ViewPager checkViewPager;

    private Context context = this;

    @Override
    public int initLayoutView() {
        return R.layout.activity_case_check;
    }

    @Override
    protected void setupTopBarLayout() {
        checkTopLayout.setTitle("案卷核查").setTextColor(ContextCompat.getColor(this, R.color.white));
        checkTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor));
        checkTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    public void initData() {
        List<Fragment> fragmentList = new ArrayList<>();
        fragmentList.add(new CaseCheckFragment());
        fragmentList.add(new CaseCheckedFragment());
        SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), Constant.CASE_PAGE_TITLES, fragmentList);
        checkViewPager.setAdapter(adapter);
        //绑定TabLayout
        checkTabLayout.setupWithViewPager(checkViewPager);
        LinearLayout linearLayout = (LinearLayout) checkTabLayout.getChildAt(0);
        linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
        linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical));
    }

    @Override
    public void initEvent() {

    }
}
