package com.sheep.gamegroup.model.entity;

import android.support.annotation.IntDef;
import android.support.annotation.LayoutRes;
import android.support.annotation.StringRes;
import android.view.Gravity;
import android.view.View;

import com.sheep.jiuyan.samllsheep.R;
import com.sheep.jiuyan.samllsheep.SheepApp;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by realicing on 2018/6/6.
 * realicing@sina.com
 */
public class DialogConfig {
    private String msg;
    private int msgIndent;//缩进字符数
    private String title;
    private String btnLeftText;
    private View.OnClickListener btnLeftOnClickListener;
    private String btnRightText;
    private View.OnClickListener btnRightOnClickListener;
    private View.OnClickListener btnCloseOnClickListener;
    private String msgMore;
    private int msgMoreColor;//颜色资源
    private String tip;
    private boolean cancelable = true;//默认可以取消对话框，并显示close图标
    private boolean isFinish;
    private boolean btnLeftNotDissDialog;
    private int msgGravity;

    private Map<String, String> colorMsgMap = new HashMap<>();

    public boolean isFinish() {
        return isFinish;
    }

    public DialogConfig setFinish(boolean finish) {
        isFinish = finish;
        return this;
    }

    public String getMsg() {
        return msg;
    }

    public DialogConfig setMsg(String msg) {
        this.msg = msg;
        return this;
    }
    public DialogConfig setMsg(@StringRes int msgRes) {
        this.msg = SheepApp.getInstance().getString(msgRes);
        return this;
    }
    public DialogConfig setMsgColor(String colorMsg, String color) {
        colorMsgMap.put(colorMsg, color);
        return this;
    }

    public Map<String, String> getColorMsgMap() {
        return colorMsgMap;
    }

    public DialogConfig setMsgIndent(int msgIndent) {
        this.msgIndent = msgIndent;
        return this;
    }

    public int getMsgIndent() {
        return msgIndent;
    }

    public String getTitle() {
        return title;
    }

    public DialogConfig setTitle(String title) {
        this.title = title;
        return this;
    }

    public String getBtnLeftText() {
        return btnLeftText;
    }

    public DialogConfig setBtnLeftText(String btnLeftText) {
        this.btnLeftText = btnLeftText;
        return this;
    }

    public View.OnClickListener getBtnLeftOnClickListener() {
        return btnLeftOnClickListener;
    }

    public DialogConfig setBtnLeftOnClickListener(View.OnClickListener btnLeftOnClickListener) {
        this.btnLeftOnClickListener = btnLeftOnClickListener;
        return this;
    }

    public String getBtnRightText() {
        return btnRightText;
    }

    public DialogConfig setBtnRightText(String btnRightText) {
        this.btnRightText = btnRightText;
        return this;
    }

    public View.OnClickListener getBtnCloseOnClickListener() {
        return btnCloseOnClickListener;
    }

    public DialogConfig setBtnCloseOnClickListener(View.OnClickListener btnCloseOnClickListener) {
        this.btnCloseOnClickListener = btnCloseOnClickListener;
        return this;
    }

    public void setColorMsgMap(Map<String, String> colorMsgMap) {
        this.colorMsgMap = colorMsgMap;
    }

    public View.OnClickListener getBtnRightOnClickListener() {
        return btnRightOnClickListener;
    }

    public DialogConfig setBtnRightOnClickListener(View.OnClickListener btnRightOnClickListener) {
        this.btnRightOnClickListener = btnRightOnClickListener;
        return this;
    }

    public String getMsgMore() {
        return msgMore;
    }

    public DialogConfig setMsgMore(String msgMore) {
        this.msgMore = msgMore;
        return this;
    }
    public DialogConfig setMsgMoreColor(int msgMoreColor) {
        this.msgMoreColor = msgMoreColor;
        return this;
    }

    public int getMsgMoreColor() {
        return msgMoreColor;
    }

    public String getTip() {
        return tip;
    }

    public DialogConfig setTip(String tip) {
        this.tip = tip;
        return this;
    }

    public boolean isCancelable() {
        return cancelable;
    }

    public DialogConfig setCancelable(boolean cancelable) {
        this.cancelable = cancelable;
        return this;
    }

    public int getMsgGravity() {
        return msgGravity;
    }

    @IntDef({Gravity.START, Gravity.END, Gravity.CENTER, Gravity.TOP, Gravity.BOTTOM, Gravity.NO_GRAVITY})
    @Retention(RetentionPolicy.SOURCE)
    public @interface GRAVITY {
    }
    public DialogConfig setMsgGravity(@GRAVITY int msgGravity) {
        this.msgGravity = msgGravity;
        return this;
    }
    public static final int THEME_DEFAULT = 0;
    public static final int THEME_PURPLE = 1;
    private int theme = THEME_DEFAULT;
    @IntDef({THEME_DEFAULT, THEME_PURPLE})
    @Retention(RetentionPolicy.SOURCE)
    public @interface THEME {
    }
    public DialogConfig setTheme(@THEME int theme) {
        this.theme = theme;
        return this;
    }

    public int getTheme() {
        return theme;
    }

    public boolean isBtnLeftNotDissDialog() {
        return btnLeftNotDissDialog;
    }
    public DialogConfig setBtnLeftNotDissDialog(boolean btnLeftNotDissDialog) {
        this.btnLeftNotDissDialog = btnLeftNotDissDialog;
        return this;
    }
    private int layoutId = R.layout.x_msg_dialog;
    public int getLayoutId() {
        return layoutId;
    }
    public DialogConfig setLayoutId(@LayoutRes int layoutId) {
        this.layoutId = layoutId;
        return this;
    }
    private int parentLayoutId = R.layout.dialog_parent;
    public int getParentLayoutId() {
        return parentLayoutId;
    }
    public DialogConfig setParentLayoutId(@LayoutRes int parentLayoutId) {
        this.parentLayoutId = parentLayoutId;
        return this;
    }
}
