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.verify.CaseVerifiedFragment;
import com.casic.dcms.ui.fragment.verify.CaseVerifyFragment;
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;

public class CaseVerifyActivity extends BaseActivity {

    @BindView(R.id.verifyTopLayout)
    QMUITopBarLayout verifyTopLayout;
    @BindView(R.id.verifyTabLayout)
    TabLayout verifyTabLayout;
    @BindView(R.id.verifyViewPager)
    ViewPager verifyViewPager;

    private Context context = this;

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

    @Override
    protected void setupTopBarLayout() {
        verifyTopLayout.setTitle("案卷核实").setTextColor(ContextCompat.getColor(this, R.color.white));
        verifyTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor));
        verifyTopLayout.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 CaseVerifyFragment());
        fragmentList.add(new CaseVerifiedFragment());
        SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), Constant.CASE_PAGE_TITLES, fragmentList);
        verifyViewPager.setAdapter(adapter);
        //绑定TabLayout
        verifyTabLayout.setupWithViewPager(verifyViewPager);
        LinearLayout linearLayout = (LinearLayout) verifyTabLayout.getChildAt(0);
        linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
        linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical));
    }

    @Override
    public void initEvent() {

    }
}
