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.handle.CaseHandledFragment;
import com.casic.dcms.ui.fragment.handle.CaseTodoFragment;
import com.casic.dcms.ui.fragment.handle.OvertimeCaseFragment;
import com.casic.dcms.ui.fragment.handle.UrgentCaseFragment;
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 CaseHandleActivity extends BaseActivity {

    private static final String[] pageTitles = {"超时案卷", "紧急案卷", "待办案卷", "已办案卷"};
    @BindView(R.id.handleTopLayout)
    QMUITopBarLayout handleTopLayout;
    @BindView(R.id.handleTabLayout)
    TabLayout handleTabLayout;
    @BindView(R.id.handleViewPager)
    ViewPager handleViewPager;

    private Context context = this;

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

    @Override
    protected void setupTopBarLayout() {
        handleTopLayout.setTitle("案卷处理").setTextColor(ContextCompat.getColor(this, R.color.white));
        handleTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor));
        handleTopLayout.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 OvertimeCaseFragment());
        fragmentList.add(new UrgentCaseFragment());
        fragmentList.add(new CaseTodoFragment());
        fragmentList.add(new CaseHandledFragment());
        SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), pageTitles, fragmentList);
        handleViewPager.setAdapter(adapter);
        //绑定TabLayout
        handleTabLayout.setupWithViewPager(handleViewPager);
        LinearLayout linearLayout = (LinearLayout) handleTabLayout.getChildAt(0);
        linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
        linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical));
    }

    @Override
    public void initEvent() {

    }
}
