package com.bonait.bnframework.modules.home.fragment;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;

import com.bonait.bnframework.R;
import com.bonait.bnframework.common.base.BaseFragment;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.bonait.bnframework.modules.home.fragment.from.JcsjglActivity;
import com.bonait.bnframework.modules.home.fragment.from.OrderListActivity;
import com.bonait.bnframework.modules.home.fragment.from.SalesStatisticsActivity;
import com.orhanobut.logger.Logger;
import com.qmuiteam.qmui.widget.QMUITopBarLayout;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class DingDanfragment extends BaseFragment {


//    @BindView(R.id.topbar)
//    QMUITopBarLayout mTopBar;//顶部标题
    private Context context;

    public DingDanfragment() {
    }

    @Override
    protected View onCreateView() {
        View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_dingdan, null);
        ButterKnife.bind(this, root);
        return root;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        context = getContext();
        initTopBar();
    }

    /**
     * 初始化TopBar
     */
    private void initTopBar() {
       // mTopBar.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.app_color_theme_4));
//        mTopBar.setTitle("订单管理");
    }

    @OnClick({R.id.ddgl,R.id.xltj})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.xltj://
                skipToActivity(OrderListActivity.class);
                //ConfigName.getInstance().fragmentAdapter.replaceFragment(2,new OrderListActivity());
                break;
            case R.id.ddgl://
                skipToActivity(SalesStatisticsActivity.class);
                break;
        }
    }


    @Override
    public void onDestroy() {
        super.onDestroy();
        Logger.d("第一页销毁");
    }

    /**
     * 当在activity设置viewPager + BottomNavigation + fragment时，
     * 为防止viewPager左滑动切换界面，与fragment左滑返回上一界面冲突引起闪退问题，
     * 必须加上此方法，禁止fragment左滑返回上一界面。
     * <p>
     * 切记！切记！切记！否则会闪退！
     * <p>
     * 当在fragment设置viewPager + BottomNavigation + fragment时，则不会出现这个问题。
     */
    @Override
    protected boolean canDragBack() {
        return false;
    }
}