package com.cooleshow.base.utils;

import android.content.Context;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.cooleshow.base.R;

/**
 * Author by pq, Date on 2022/9/21.
 */
public class MusicSheetUtils {
    public static final String CHARGE_TYPE_FREE = "FREE";
    public static final String CHARGE_TYPE_VIP = "VIP";
    public static final String CHARGE_TYPE_CHARGE = "CHARGE";
    public static void createTag(Context context,ViewGroup viewParent, String chargeType) {
        TextView textView = new TextView(context);
        textView.setWidth(SizeUtils.dp2px(30));
        textView.setHeight(SizeUtils.dp2px(17));
        textView.setTextSize(10);
        textView.setGravity(Gravity.CENTER);
        setTagStyle(context,chargeType, textView);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        if (viewParent.getChildCount() >= 1) {
            params.setMargins(SizeUtils.dp2px(4), 0, 0, 0);
        }
        viewParent.addView(textView, params);
    }

    private static void setTagStyle(Context context,String chargeType, TextView tvTag) {
        if (TextUtils.equals(chargeType, CHARGE_TYPE_FREE)) {
            tvTag.setText("免费");
            tvTag.setTextColor(context.getResources().getColor(com.cooleshow.base.R.color.color_01b84f));
            tvTag.setBackgroundResource(R.drawable.shape_01b84f_border);
            return;
        }
        if (TextUtils.equals(chargeType, CHARGE_TYPE_VIP)) {
            tvTag.setText("会员");
            tvTag.setTextColor(context.getResources().getColor(com.cooleshow.base.R.color.color_cd863e));
            tvTag.setBackgroundResource(R.drawable.shape_cd863e_border);
            return;
        }
        if (TextUtils.equals(chargeType, CHARGE_TYPE_CHARGE)) {
            tvTag.setText("点播");
            tvTag.setTextColor(context.getResources().getColor(com.cooleshow.base.R.color.color_3591ce));
            tvTag.setBackgroundResource(R.drawable.shape_3591ce_border);
        }
    }
}
