package com.ym.admodule.widget

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import com.ym.admodule.R
import com.ym.modulecommon.AppliContext
import com.ym.modulecommon.utils.Utils

class ZXSelfRenderingView : FrameLayout {


    constructor(context: Context?) : super(context!!) {
        init()
    }

    constructor(context: Context?, attrs: AttributeSet?) : super(context!!, attrs) {
        init()
    }

    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
        context!!,
        attrs,
        defStyleAttr
    ) {
        init()
    }

    private var zx_ll_container: LinearLayout? = null
    private var zx_tv_title: TextView? = null
    private var zx_iv_img: ImageView? = null
    private var zx_tv_des: TextView? = null

    //初始化
    private fun init() {
        val parent =
            LayoutInflater.from(AppliContext.get()).inflate(R.layout.layout_self_rendering, this)
        zx_ll_container = parent.findViewById<LinearLayout>(R.id.zx_ll_container)
        zx_tv_title = parent.findViewById<TextView>(R.id.zx_tv_title)
        zx_iv_img = parent.findViewById<ImageView>(R.id.zx_iv_img)
        zx_tv_des = parent.findViewById<TextView>(R.id.zx_tv_des)


    }


    fun setConfig(rendConfig: ZXRenderingConfig) {
        zx_tv_title?.textSize = Utils.sp2px(rendConfig.getTitleSize().toFloat()).toFloat()
        zx_tv_title?.textSize = rendConfig.getTitleSize().toFloat()
    }

}