package com.ym.library.widget;

import android.content.Context;
import android.graphics.drawable.Drawable;

import androidx.annotation.DrawableRes;
import androidx.core.content.ContextCompat;

public class BottomNavigationItem {


    private int mIconResource;
    private Drawable mIcon;
    private int mSelectedIconResource;
    private int mId;
    private Drawable mSelectedIcon;
    private String mTitle;
    private boolean isShowDrop;
    private int mTaskIconResource;

    public BottomNavigationItem(int mId, String mTitle, int mIconResource, int mSelectedIconResource, int mTaskIconResource, boolean isShowDrop) {
        this.mIconResource = mIconResource;
        this.mSelectedIconResource = mSelectedIconResource;
        this.mTaskIconResource = mTaskIconResource;
        this.mId = mId;
        this.mTitle = mTitle;
        this.isShowDrop = isShowDrop;
    }

    /**
     * By default library will switch the color of icon provided (in between active and in-active icons)
     * This method is used, if people need to set different icons for active and in-active modes.
     *
     * @param mSelectedIcon in-active drawable icon
     * @return this, to allow builder pattern
     */
    public BottomNavigationItem setSelectedIcon(Drawable mSelectedIcon) {
        if (mSelectedIcon != null) {
            this.mSelectedIcon = mSelectedIcon;
        }
        return this;
    }

    /**
     * By default library will switch the color of icon provided (in between active and in-active icons)
     * This method is used, if people need to set different icons for active and in-active modes.
     *
     * @param mSelectedIconResource resource for the in-active icon.
     * @return this, to allow builder pattern
     */
    public BottomNavigationItem setSelectedIconResource(@DrawableRes int mSelectedIconResource) {
        this.mSelectedIconResource = mSelectedIconResource;
        return this;
    }


    ///////////////////////////////////////////////////////////////////////////
    // Library only access method
    ///////////////////////////////////////////////////////////////////////////

    /**
     * @param context to fetch drawable
     * @return icon drawable
     */
    public Drawable getIcon(Context context) {
        if (this.mIconResource != 0) {
            return ContextCompat.getDrawable(context, this.mIconResource);
        } else {
            return this.mIcon;
        }
    }

    /**
     * @param context to fetch drawable
     * @return SelectedIcon drawable
     */
    public Drawable getSelectedIcon(Context context) {
        if (this.mSelectedIconResource != 0) {
            return ContextCompat.getDrawable(context, this.mSelectedIconResource);
        } else {
            return this.mSelectedIcon;
        }
    }

    public Drawable getTaskIcon(Context context) {
        return ContextCompat.getDrawable(context, this.mTaskIconResource);
    }

    /**
     * @return title string
     */
    public String getTitle() {
        return this.mTitle;
    }


    public int getmId() {
        return mId;
    }

    public boolean isShowDrop() {
        return isShowDrop;
    }

    public void setShowDrop(boolean showDrop) {
        isShowDrop = showDrop;
    }
}
