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.urgent.CaseHandledFragment;
import com.casic.dcms.ui.fragment.urgent.CaseTodoFragment;
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 UrgentCaseActivity extends BaseActivity {

    @BindView(R.id.urgentTopLayout)
    QMUITopBarLayout urgentTopLayout;
    @BindView(R.id.urgentTabLayout)
    TabLayout urgentTabLayout;
    @BindView(R.id.urgentViewPager)
    ViewPager urgentViewPager;

    private Context context = this;

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

    @Override
    protected void setupTopBarLayout() {
        urgentTopLayout.setTitle("紧急要件").setTextColor(ContextCompat.getColor(this, R.color.white));
        urgentTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor));
        urgentTopLayout.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 CaseTodoFragment());
        fragmentList.add(new CaseHandledFragment());
        SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), Constant.CASE_PAGE_TITLES, fragmentList);
        urgentViewPager.setAdapter(adapter);
        //绑定TabLayout
        urgentTabLayout.setupWithViewPager(urgentViewPager);
        LinearLayout linearLayout = (LinearLayout) urgentTabLayout.getChildAt(0);
        linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
        linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical));
    }

    @Override
    public void initEvent() {

    }
}
