package com.base.scanqr.bean

//smsto:17780524024:问问嗯嗯嗯
data class MessageUIBean(
    var smsto: String = "",
    var msg: String = ""
) : ScanBean(FunctionUIBean.KEY_MESSAGE) {
    companion object {
        fun isMessageQR(qrCodeValue: String): Boolean {

            if (qrCodeValue.startsWith("smsto:")) {
                return true
            }
            return false
        }

        fun createMessageQrString(bean: MessageUIBean): String {
            val qrContent = StringBuilder()
            qrContent.append("smsto:").append(bean.smsto).append(":").append(bean.msg)
            return qrContent.toString()
        }

        fun createMessageBean(qrCodeValue: String): MessageUIBean {
            val messageUIBean = MessageUIBean()
            val split = qrCodeValue.split(":")
            kotlin.runCatching {
                messageUIBean.smsto = split[1]
                messageUIBean.msg = split[2]
            }
            return messageUIBean
        }
    }
}
