package com.adealink.weparty.module.order.util

import androidx.appcompat.widget.AppCompatTextView
import com.adealink.frame.aab.util.getCompatColor
import com.adealink.frame.aab.util.getCompatString
import com.adealink.weparty.R
import com.adealink.weparty.module.order.data.OrderStatus


fun getUserOrderStatusText(
    status: OrderStatus?,
    isRefundApply: Boolean? //是否处于申请退款中
): String? {
    if (isRefundApply == true) {
        return getCompatString(R.string.user_order_status_refund_under_review_desc)
    }
    return when (status) {
        OrderStatus.CREATE_ORDER -> {
            getCompatString(R.string.user_order_status_create_order_desc)
        }

        OrderStatus.WAIT_FOR_ACCEPT -> {
            getCompatString(R.string.user_order_status_wait_accept_desc)
        }

        OrderStatus.PLAYMATE_ACCEPT -> {
            getCompatString(R.string.user_order_status_accept_desc)
        }

        OrderStatus.PLAYMATE_IN_SERVICE -> {
            getCompatString(R.string.user_order_status_in_service_desc)
        }

        OrderStatus.PLAYMATE_END_SERVICE -> {
            getCompatString(R.string.user_order_status_end_service_desc)
        }

        OrderStatus.PLAYMATE_REFUSE -> {
            getCompatString(R.string.user_order_status_playmate_refuse_desc)
        }

        OrderStatus.COMPLETE -> {
            getCompatString(R.string.user_order_status_complete_desc)
        }

        OrderStatus.USER_REFUND -> {
            getCompatString(R.string.user_order_status_user_refund_desc)
        }

        OrderStatus.USER_CANCEL -> {
            getCompatString(R.string.user_order_status_user_cancel_desc)
        }

        null -> {
            null
        }
    }
}

fun getUserOrderStatusIcon(
    status: OrderStatus?,
    isRefundApply: Boolean? //是否处于申请退款中
): Int {
    if (isRefundApply == true) {
        return R.drawable.common_order_status_refund_ic
    }
    return when (status) {
        OrderStatus.CREATE_ORDER -> {
            R.drawable.common_order_status_create_ic
        }

        OrderStatus.WAIT_FOR_ACCEPT -> {
            R.drawable.common_order_status_wait_accept_ic
        }

        OrderStatus.PLAYMATE_ACCEPT -> {
            R.drawable.common_order_status_accept_ic
        }

        OrderStatus.PLAYMATE_IN_SERVICE -> {
            R.drawable.common_order_status_in_service_ic
        }

        OrderStatus.PLAYMATE_END_SERVICE -> {
            R.drawable.common_order_status_end_service_ic
        }

        OrderStatus.PLAYMATE_REFUSE -> {
            R.drawable.common_order_status_cancel_ic
        }

        OrderStatus.COMPLETE -> {
            R.drawable.common_order_status_complete_ic
        }

        OrderStatus.USER_REFUND -> {
            R.drawable.common_order_status_refund_complete_ic
        }

        OrderStatus.USER_CANCEL -> {
            R.drawable.common_order_status_cancel_ic
        }

        null -> {
            0
        }
    }
}

fun getPlaymateOrderStatusText(
    status: OrderStatus?,
    isRefundApply: Boolean? //是否处于申请退款中
): String? {
    if (isRefundApply == true) {
        return getCompatString(R.string.user_order_status_refund_under_review_desc)
    }
    return when (status) {
        OrderStatus.CREATE_ORDER -> {
            getCompatString(R.string.user_order_status_create_order_desc)
        }

        OrderStatus.WAIT_FOR_ACCEPT -> {
            getCompatString(R.string.user_order_status_wait_accept_desc)
        }

        OrderStatus.PLAYMATE_ACCEPT -> {
            getCompatString(R.string.user_order_status_accept_desc)
        }

        OrderStatus.PLAYMATE_IN_SERVICE -> {
            getCompatString(R.string.user_order_status_in_service_desc)
        }

        OrderStatus.PLAYMATE_END_SERVICE -> {
            getCompatString(R.string.user_order_status_end_service_desc)
        }

        OrderStatus.PLAYMATE_REFUSE -> {
            getCompatString(R.string.user_order_status_playmate_refuse_desc)
        }

        OrderStatus.COMPLETE -> {
            getCompatString(R.string.user_order_status_complete_desc)
        }

        OrderStatus.USER_REFUND -> {
            getCompatString(R.string.user_order_status_user_refund_desc)
        }

        OrderStatus.USER_CANCEL -> {
            getCompatString(R.string.user_order_status_user_cancel_desc)
        }

        null -> {
            null
        }
    }
}

fun getPlaymateOrderStatusIcon(
    status: OrderStatus?,
    isRefundApply: Boolean? //是否处于申请退款中
): Int {
    if (isRefundApply == true) {
        return R.drawable.common_order_status_refund_ic
    }
    return when (status) {
        OrderStatus.CREATE_ORDER -> {
            R.drawable.common_order_status_create_ic
        }

        OrderStatus.WAIT_FOR_ACCEPT -> {
            R.drawable.common_order_status_wait_accept_ic
        }

        OrderStatus.PLAYMATE_ACCEPT -> {
            R.drawable.common_order_status_accept_ic
        }

        OrderStatus.PLAYMATE_IN_SERVICE -> {
            R.drawable.common_order_status_in_service_ic
        }

        OrderStatus.PLAYMATE_END_SERVICE -> {
            R.drawable.common_order_status_end_service_ic
        }

        OrderStatus.PLAYMATE_REFUSE -> {
            R.drawable.common_order_status_cancel_ic
        }

        OrderStatus.COMPLETE -> {
            R.drawable.common_order_status_complete_ic
        }

        OrderStatus.USER_REFUND -> {
            R.drawable.common_order_status_refund_complete_ic
        }

        OrderStatus.USER_CANCEL -> {
            R.drawable.common_order_status_cancel_ic
        }

        null -> {
            0
        }
    }
}

fun setUserOrderStatusText(
    textView: AppCompatTextView,
    status: OrderStatus?,
    isRefundApply: Boolean? //是否处于申请退款中
) {
    if (isRefundApply == true) {
        textView.text =
            getCompatString(R.string.user_order_status_refund_under_review_desc)
        textView.setTextColor(getCompatColor(R.color.color_FFF23051))
        return
    }
    when (status) {
        OrderStatus.CREATE_ORDER -> {
            textView.text =
                getCompatString(R.string.user_order_status_create_order_desc)
            textView.setTextColor(getCompatColor(R.color.color_FFFFB836))
        }

        OrderStatus.WAIT_FOR_ACCEPT -> {
            textView.text =
                getCompatString(R.string.user_order_status_wait_accept_desc)
            textView.setTextColor(getCompatColor(R.color.color_FF3FBFBD))
        }

        OrderStatus.PLAYMATE_ACCEPT -> {
            textView.text =
                getCompatString(R.string.user_order_status_accept_desc)
            textView.setTextColor(getCompatColor(R.color.color_FFFFB836))
        }

        OrderStatus.PLAYMATE_IN_SERVICE -> {
            textView.text =
                getCompatString(R.string.user_order_status_in_service_desc)
            textView.setTextColor(getCompatColor(R.color.color_FFFFB836))
        }

        OrderStatus.PLAYMATE_END_SERVICE -> {
            textView.text =
                getCompatString(R.string.user_order_status_end_service_desc)
            textView.setTextColor(getCompatColor(R.color.color_FFFFB836))
        }

        OrderStatus.PLAYMATE_REFUSE -> {
            textView.text =
                getCompatString(R.string.user_order_status_playmate_refuse_desc)
            textView.setTextColor(getCompatColor(R.color.color_FF1D2129))
        }

        OrderStatus.COMPLETE -> {
            textView.text =
                getCompatString(R.string.user_order_status_complete_desc)
            textView.setTextColor(getCompatColor(R.color.color_FF3FBFBD))
        }

        OrderStatus.USER_REFUND -> {
            textView.text =
                getCompatString(R.string.user_order_status_user_refund_desc)
            textView.setTextColor(getCompatColor(R.color.color_FF1D2129))
        }

        OrderStatus.USER_CANCEL -> {
            textView.text =
                getCompatString(R.string.user_order_status_user_cancel_desc)
            textView.setTextColor(getCompatColor(R.color.color_FF1D2129))
        }

        null -> {
            textView.text = null
        }
    }
}