package com.cooleshow.teacher.widgets.helper;

import android.text.TextUtils;

import com.cooleshow.teacher.R;
import com.cooleshow.teacher.bean.MineToolMenuBean;

import java.util.ArrayList;

/**
 * Author by pq, Date on 2022/9/8.
 * 用于创建老师端个人中心 常用工具模块
 */
public class MineFragmentToolsHelper {
    public static final String TYPE_MINE_HOME_PAGE = "HOME_PAGE";//我的主页
    public static final String TYPE_MINE_INCOME = "INCOME";//我的收入
    public static final String TYPE_MINE_STYLE = "STYLE";//个人风采
    public static final String TYPE_MINE_GOODS_ORDER = "GOODS_ORDER";//商品订单
    public static final String TYPE_MINE_MUSIC_SHEET = "MUSIC_SHEET";//我的乐谱
    public static final String TYPE_MINE_COURSE = "COURSE";//我的课程
    public static final String TYPE_MINE_COUPON = "COUPON";//我的优惠券
    public static final String TYPE_MINE_UPLOAD_MUSIC_SHEET = "TYPE_MINE_UPLOAD_MUSIC_SHEET";//上传曲谱
    public static final String[] TYPES = new String[]{TYPE_MINE_HOME_PAGE, TYPE_MINE_INCOME,
            TYPE_MINE_STYLE, TYPE_MINE_GOODS_ORDER, TYPE_MINE_COURSE, TYPE_MINE_COUPON,TYPE_MINE_MUSIC_SHEET,TYPE_MINE_UPLOAD_MUSIC_SHEET};
    public static final String[] TITLES = new String[]{"我的主页", "我的收入",
            "个人风采", "商品订单", "我的课程", "我的优惠券","我的乐谱","上传乐谱"};
    public static final int[] ICON_DRAWABLES = new int[]{R.drawable.icon_mine_page, R.drawable.icon_mine_income,
            R.drawable.icon_mine_style, R.drawable.icon_goods_order
            , R.drawable.icon_mine_course, R.drawable.icon_mine_coupon,R.drawable.icon_mine_sheet_music, R.drawable.icon_mine_upload_music_sheet};

    public static ArrayList<MineToolMenuBean> getData(String... filterDatas) {
        ArrayList<MineToolMenuBean> list = new ArrayList<>();
        for (int i = 0; i < TYPES.length; i++) {
            String type = TYPES[i];
            boolean containFilterData = isContainFilterData(type, filterDatas);
            if (containFilterData) {
                continue;
            }
            MineToolMenuBean mineToolMenuBean = new MineToolMenuBean();
            mineToolMenuBean.title = TITLES[i];
            mineToolMenuBean.drawable = ICON_DRAWABLES[i];
            mineToolMenuBean.type = TYPES[i];
            list.add(mineToolMenuBean);
        }
        return list;
    }

    private static boolean isContainFilterData(String target, String... datas) {
        if (datas == null || datas.length == 0) {
            return false;
        }
        for (int i = 0; i < datas.length; i++) {
            String data = datas[i];
            if (TextUtils.equals(data, target)) {
                return true;
            }
        }
        return false;
    }

}
