package com.wd.workoffice.ui.activity.mes.work;

import android.os.Bundle;
import android.text.TextUtils;

import com.google.android.material.tabs.TabLayout;
import com.wd.workoffice.R;
import com.wd.workoffice.app.WorkToolBarActivity;
import com.wd.workoffice.ui.adapter.VpDataAdapter;

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

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.viewpager.widget.ViewPager;
import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 质量工单详情
 * author : flexible
 * email : lgd19940421@163.com
 * github: https://github.com/FlexibleXd
 **/
public class WorkTaskDetailActivity extends WorkToolBarActivity {

    @BindView(R.id.tl_tab)
    TabLayout tlTab;
    @BindView(R.id.vp_data)
    ViewPager vpData;
    private List<String> tab = new ArrayList<>();
//    {
//            "工单", "计划", "实际情况" ,"故障报告"};

    @Override
    protected void initView() {
        ButterKnife.bind(this);
        tlTab.setupWithViewPager(vpData);
        tlTab.setTabMode(TabLayout.MODE_FIXED);
    }

    @Override
    protected void initData() {
        String plan = getIntent().getStringExtra("plan");
        Bundle bundle = new Bundle();
        bundle.putString("info", getIntent().getStringExtra("info"));
        bundle.putString("plan", plan);
        FragmentManager sfm = getSupportFragmentManager();
        List<Fragment> data = new ArrayList<>();
        WorkTaskPeopleFragment qualityWorkFragment = new WorkTaskPeopleFragment();
        WorkTaskMaterialsFragment qualityWorkPlanFragment = new WorkTaskMaterialsFragment();

        qualityWorkFragment.setArguments(bundle);
        qualityWorkPlanFragment.setArguments(bundle);
        data.add(qualityWorkFragment);
        data.add(qualityWorkPlanFragment);
        tab.add("员工");
        tab.add("物料");
        VpDataAdapter vpFgAdapter = new VpDataAdapter(sfm, data);
        vpData.setAdapter(vpFgAdapter);
        for (int i = 0; i < tab.size(); i++) {
            tlTab.getTabAt(i).setText(tab.get(i));
        }
    }

    @Override
    protected void initEvent() {
    }

    @Override
    protected int layoutId() {
        return R.layout.activity_order;
    }

}
