import { StringCaser } from "@/utils/utils"
import { findComponentsByKeyValue, generateComponentId, getComponentViewBindingId } from "./helpers"


export const generateWebViewInteractions = (fragment) => {
    if (findComponentsByKeyValue(fragment, "name", "WebView").length == 0) return "";
    let webviews = findComponentsByKeyValue(fragment, "name", "WebView");

    return ` 
    ${webviews.map((view) => ` 
        binding.${getComponentViewBindingId(view)}.webViewClient = WebViewClient()
        binding.${getComponentViewBindingId(view)}.loadUrl("${view.props.url}")
        binding.${getComponentViewBindingId(view)}.settings.javaScriptEnabled = true
        binding.${getComponentViewBindingId(view)}.settings.setSupportZoom(true)
    `)} `
}

export const generateWebViewImports = (fragment) => {
    if (findComponentsByKeyValue(fragment, "name", "WebView").length > 0) return `import android.webkit.WebViewClient`
    else return ''
} 