package com.img.rabbit.utils

import android.content.Context
import android.content.Intent
import androidx.core.net.toUri
import com.img.rabbit.WebViewActivity

object UrlLinkUtils {
    fun openAgreement(context: Context, title: String, url: String, isExternal:Boolean = false) {
        if(isExternal){
            // 打开服务协议
            Intent(Intent.ACTION_VIEW, url.toUri()).apply {
                addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
            }.let { intent ->
                context.startActivity(intent)
            }
        }else{
            val intent = Intent(context, WebViewActivity::class.java).apply {
                putExtra("url", url)
                putExtra("title", title)
            }
            context.startActivity(intent)
        }
    }
}