package com.img.rabbit

import android.annotation.SuppressLint
import android.os.Bundle
import android.webkit.WebView
import android.webkit.WebViewClient
import android.widget.ImageView
import android.widget.TextView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity

class WebViewActivity : AppCompatActivity() {

    @SuppressLint("SetJavaScriptEnabled")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)


        // 启用Edge-to-Edge模式（沉浸模式）
        enableEdgeToEdge()

        setContentView(R.layout.layout_web)

        val webView: WebView = findViewById(R.id.webView)
        val ivWebBreak: ImageView = findViewById(R.id.iv_web_break)
        val ivWebTitle: TextView = findViewById(R.id.iv_web_title)

        val title = intent.getStringExtra("title") ?: ""
        val url = intent.getStringExtra("url") ?: ""

        ivWebBreak.setOnClickListener { finish() }
        ivWebTitle.text = title

        webView.settings.javaScriptEnabled = true
        webView.webViewClient = WebViewClient()
        webView.loadUrl(url)
    }
}