package com.kdanmobile.kdan_others_library_for_android.dialog;

import android.content.Context;
import android.graphics.Color;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;

import com.afollestad.materialdialogs.MaterialDialog;
import com.kdanmobile.kdan_others_library_for_android.R;

/**
 * Created by Shan on 2017/4/5.
 */

public class ZendeskLoginNotifyDialog {

    public interface ZendeskLoginNotifyDialogInterface {

        void onSignInClick();

        void onGuestVisitClick();
    }

    private MaterialDialog.Builder builder;

    public ZendeskLoginNotifyDialog(Context context, ZendeskLoginNotifyDialogInterface dialogInterface) {
        builder = new MaterialDialog.Builder(context)
                .content(R.string.zendesk_sign_in_notify_message)
                .contentColorRes(R.color.colorSecondaryTextDark)
                .backgroundColor(Color.WHITE)
                .positiveText(R.string.zendesk_sign_in)
                .negativeText(R.string.zendesk_continue_as_guest)
                .positiveColorRes(R.color.colorAccentCloud)
                .negativeColorRes(R.color.colorAccentCloud)
                .onPositive((dialog, which) -> {
                    dialogInterface.onSignInClick();
                })
                .onNegative((dialog, which) -> {
                    dialogInterface.onGuestVisitClick();
                });
    }

    public void setContentColor(@ColorInt int color) {
        builder.contentColor(color);
    }

    public void setContentColorRes(@ColorRes int colorRes) {
        builder.contentColorRes(colorRes);
    }

    public void setBackgroundColor(@ColorInt int color) {
        builder.backgroundColor(color);
    }

    public void setBackgroundColorRes(@ColorRes int colorRes) {
        builder.backgroundColorRes(colorRes);
    }

    public void setButtonColor(@ColorInt int color) {
        builder.positiveColor(color);
        builder.negativeColor(color);
    }

    public void setButtonColorRes(@ColorRes int colorRes) {
        builder.positiveColorRes(colorRes);
        builder.negativeColorRes(colorRes);
    }

    public void show() {
        if (builder != null) {
            builder.show();
        }
    }
}
