/*
package com.ys.bdtp.adm.mvvm.ui.examine

import android.annotation.SuppressLint
import android.webkit.*
import android.widget.Toast
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Divider
import androidx.compose.material.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.viewinterop.AndroidView
import com.google.gson.Gson
import com.ys.bdtp.adm.mvvm.model.vo.FunctionEndBlockModel
import com.ys.bdtp.adm.mvvm.model.vo.PageParam
import com.ys.bdtp.adm.mvvm.model.vo.SetFloorPathModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch


@Composable
@SuppressLint("SetJavaScriptEnabled", "JavascriptInterface")
fun ModelExamineScreen() {
    val context = LocalContext.current
    val gson = Gson()
    var firstInit = false

    val webViewChromeClient = object : WebChromeClient() {
        override fun onProgressChanged(view: WebView?, newProgress: Int) {
            super.onProgressChanged(view, newProgress)
        }
    }
    val rcs = rememberCoroutineScope()

    class Js(val webView: WebView) {

        @JavascriptInterface
        fun MeshClick(meshObject: String) {
            rcs.launch {
                Toast.makeText(context, "选中了ID:${meshObject}", Toast.LENGTH_LONG).show()
//
            }
        }

        @JavascriptInterface
        fun FunctionEndBlock(name: String) {
            val nameObject = gson.fromJson(name, FunctionEndBlockModel::class.java)
            when (nameObject.Name) {
                "OpenPage" -> {
                    rcs.launch(Dispatchers.Main) {
                        webView.loadUrl("javascript:OpenTestData()")
                    }
//                rcs.launch(Dispatchers.Main) { viewModel.getFloorSpace() }
                }
                "SetSpaceData" -> {
//                if (isLastSpace) {
                    rcs.launch(Dispatchers.Main) {
                        val model = SetFloorPathModel("Pj9909990002", "Pj99099900022fcaba5e46b611ec821df544d04bf03aB3", -13.8)
                        webView.loadUrl("javascript:SetFloorPath('${gson.toJson(model)}')")
                    }
//                }
                }
                "SetFloorPath" -> {
//                    rcs.launch(Dispatchers.Main) {
//                        webView?.loadUrl("javascript:LoadAllModelWithFloor()")
//                    }
                }
                "OpenTestData" -> {
                    rcs.launch(Dispatchers.Main) {
                        webView.loadUrl("javascript:LoadAllModelWithFloor()")
                    }
                }
            }
        }
    }

    val webView by remember {
        mutableStateOf(WebView(context).apply {
            webViewClient = object : WebViewClient() {
                //兼容低版本
                override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
                    view.loadUrl(url)
                    return true
                }

                override fun onPageFinished(view: WebView, url: String) {
                    super.onPageFinished(view, url)
                    if (view.progress == 100 && !firstInit) {
                        firstInit = true
//                viewModel.getFloorSpace()
                        val pageParam = PageParam()
                        val param = PageParam.Param()
                        param.PageType = "1"
                        pageParam.Param = param
                        loadUrl("javascript:OpenPage('${gson.toJson(pageParam)}')")
                    }
                }
            }
            webChromeClient = webViewChromeClient
            settings.javaScriptEnabled = true
            settings.javaScriptCanOpenWindowsAutomatically = true
            settings.domStorageEnabled = true
            settings.loadsImagesAutomatically = true
            settings.mediaPlaybackRequiresUserGesture = false
            addJavascriptInterface(Js(this), "android")
            settings.defaultTextEncodingName = "utf-8"
            settings.builtInZoomControls = true
            settings.layoutAlgorithm = WebSettings.LayoutAlgorithm.SINGLE_COLUMN
            // 是否启动概述模式浏览界面，当页面宽度超过WebView显示宽度时，缩小页面适应WebView。默认false
            settings.loadWithOverviewMode = true
            settings.databaseEnabled = true
            settings.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
            WebView.setWebContentsDebuggingEnabled(true)
//                    loadUrl("https://www.baidu.com/")
            loadUrl("http://60.205.177.43:8000/APP/")
        })
    }


    Row(
        modifier = Modifier.fillMaxWidth()
            .background(Color.White),
        verticalAlignment = Alignment.CenterVertically
    ) {

        Column(modifier = Modifier.fillMaxHeight().width(270.dp).verticalScroll(rememberScrollState())) {
            for (i in 0..9) {
                Text(
                    text = "$i 层",
                    modifier = Modifier.height(40.dp).fillMaxWidth().padding(60.dp, 9.dp, 0.dp, 9.dp),
                    color = Color(0XFF1F2429),
                    fontSize = 14.sp
                )
            }
        }

        Divider(modifier = Modifier.width(1.dp).fillMaxHeight().background(Color(0XFFEFF0F1)))


        Box(modifier = Modifier.fillMaxWidth().fillMaxHeight()) {
            AndroidView(modifier = Modifier.fillMaxWidth().fillMaxHeight(), factory = { ctx ->
                webView
            })

            Column(
                modifier = Modifier.padding(0.dp, 40.dp, 30.dp, 0.dp).background(
                    color = Color.Black,
                    shape = RoundedCornerShape(4.dp)
                )
                    .align(Alignment.TopEnd).width(40.dp)
            ) {
                Spacer(modifier = Modifier.size(20.dp))
                Text(
                    text = "2D",
                    color = Color(0XFFFFFFFF),
                    fontSize = 14.sp,
                    modifier = Modifier.padding(4.dp).fillMaxWidth(),
                    textAlign = TextAlign.Center
                )

                Spacer(modifier = Modifier.size(12.dp))

                Text(
                    text = "3D",
                    color = Color(0XFFFFFFFF),
                    fontSize = 14.sp,
                    modifier = Modifier.padding(4.dp).fillMaxWidth().background(
                        color = Color(0XFF0091FF),
                        shape = RoundedCornerShape(4.dp)
                    ).height(28.dp).padding(4.dp),
                    textAlign = TextAlign.Center
                )
                Spacer(modifier = Modifier.size(20.dp))
            }

            Column(
                modifier = Modifier.padding(0.dp, 170.dp, 30.dp, 0.dp).background(
                    color = Color.Black,
                    shape = RoundedCornerShape(4.dp)
                )
                    .align(Alignment.TopEnd).width(40.dp)
            ) {
                Spacer(modifier = Modifier.size(20.dp))

                Column {
                    Image(
                        painter = painterResource(id = com.ys.bdtp.adm.R.drawable.icon_compass),
                        modifier = Modifier.size(30.dp).align(Alignment.CenterHorizontally),
                        contentDescription = null
                    )
                    Text(
                        text = "指南",
                        color = Color(0XFFFFFFFF),
                        fontSize = 12.sp,
                        modifier = Modifier.padding(4.dp).fillMaxWidth(),
                        textAlign = TextAlign.Center
                    )
                }
                Spacer(modifier = Modifier.size(12.dp))
                Column {
                    Image(
                        painter = painterResource(id = com.ys.bdtp.adm.R.drawable.icon_vertical),
                        modifier = Modifier.size(30.dp).align(Alignment.CenterHorizontally),
                        contentDescription = null
                    )
                    Text(
                        text = "俯视",
                        color = Color(0XFFFFFFFF),
                        fontSize = 12.sp,
                        modifier = Modifier.padding(4.dp).fillMaxWidth(),
                        textAlign = TextAlign.Center
                    )
                }
                Spacer(modifier = Modifier.size(12.dp))
                Column {
                    Image(
                        painter = painterResource(id = com.ys.bdtp.adm.R.drawable.icon_degree),
                        modifier = Modifier.size(30.dp).align(Alignment.CenterHorizontally),
                        contentDescription = null
                    )
                    Text(
                        text = "45度",
                        color = Color(0XFFFFFFFF),
                        fontSize = 12.sp,
                        modifier = Modifier.padding(4.dp).fillMaxWidth(),
                        textAlign = TextAlign.Center
                    )
                }
                Spacer(modifier = Modifier.size(12.dp))
                Column {
                    Image(
                        painter = painterResource(id = com.ys.bdtp.adm.R.drawable.icon_lock),
                        modifier = Modifier.size(30.dp).align(Alignment.CenterHorizontally),
                        contentDescription = null
                    )
                    Text(
                        text = "锁定\n视角",
                        color = Color(0XFFFFFFFF),
                        fontSize = 12.sp,
                        modifier = Modifier.padding(4.dp).fillMaxWidth(),
                        textAlign = TextAlign.Center
                    )
                }
                Spacer(modifier = Modifier.size(12.dp))
                Column {
                    Image(
                        painter = painterResource(id = com.ys.bdtp.adm.R.drawable.icon_angle),
                        modifier = Modifier.size(30.dp).align(Alignment.CenterHorizontally),
                        contentDescription = null
                    )
                    Text(
                        text = "第一\n人称",
                        color = Color(0XFFFFFFFF),
                        fontSize = 12.sp,
                        modifier = Modifier.padding(4.dp).fillMaxWidth(),
                        textAlign = TextAlign.Center
                    )
                }
                Spacer(modifier = Modifier.size(20.dp))
            }

        }
    }

}



*/
