package com.base.scanqrclear.bean

import com.base.scanqrclear.bean.FunctionUIBean.Companion.KEY_INSTAGRAM

data class InstagramUIBean(
    val username: String? = null,
) : ScanBean(KEY_INSTAGRAM) {

    companion object {

        fun createInstagramUIBean(qrCodeValue: String): InstagramUIBean {
            val split = qrCodeValue.split("=")
            val username = if (split.size == 2) split[1] else ""
            return InstagramUIBean(username)
        }

        fun isInstagramQR(qrCodeValue: String): Boolean {
            return qrCodeValue.startsWith("instagram://")
        }

        //   instagram://user?username=www.baidu.com
        //    instagram://user?username=123456
        fun InstagramUIBean.createInstagramQrString(): String {
            return "instagram://user?username=$username"
        }

    }
}