package com.wd.workoffice.ui.activity.bat.order;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;

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 com.wd.workoffice.ui.fg.ProFlowFragment;
import com.wd.workoffice.ui.fg.ProStockFragment;

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 ProFlowActivity extends WorkToolBarActivity {

    @BindView(R.id.tl_tab)
    TabLayout tlTab;
    @BindView(R.id.vp_data)
    ViewPager vpData;
    @BindView(R.id.tv_name)
    TextView tvName;
    private String tab[] = {
            "产品流水", "产品库存"};

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

    @Override
    protected void initData() {
        tvName.setText(String.format("%s(%s)", getIntent().getStringExtra("product"), getIntent().getStringExtra("simpleCode")));
        FragmentManager sfm = getSupportFragmentManager();
        List<Fragment> data = new ArrayList<>();
        ProFlowFragment proFlowFragment = new ProFlowFragment();
        ProStockFragment proStockFragment = new ProStockFragment();
        Bundle bundle = new Bundle();
        bundle.putString("orderItemId", getIntent().getStringExtra("orderItemId"));
//        bundle.putString("productId", getIntent().getStringExtra("productId"));
//        bundle.putString("num", getIntent().getStringExtra("num"));
        bundle.putString("info", getIntent().getStringExtra("info"));
        proFlowFragment.setArguments(bundle);
        proStockFragment.setArguments(bundle);
        data.add(proFlowFragment);
        data.add(proStockFragment);
        VpDataAdapter vpFgAdapter = new VpDataAdapter(sfm, data);
        vpData.setAdapter(vpFgAdapter);
        for (int i = 0; i < tab.length; i++) {
            tlTab.getTabAt(i).setText(tab[i]);
        }
    }

    @Override
    protected void initEvent() {
    }

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

}
