package com.zxhl.main.page.view

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.RelativeLayout
import android.widget.TextView
import com.zxhl.main.R
import kotlinx.android.synthetic.main.view_navigation_bottom.view.*

/**
 * Created by gaoleichao on 2018/12/28
 */
class NavigationBottomView : RelativeLayout {
    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 mUserText: TextView? = null
    private var mVideoText: TextView? = null
    private var mWarehouseText: TextView? = null
    private var mVoiceroomText: TextView? = null

    private var navifationCallback: NavifationCallback? = null

    private fun init() {
        LayoutInflater.from(context).inflate(R.layout.view_navigation_bottom, this)
        id_ll_bottom_user?.setOnClickListener {
            id_view_navigation_bottom_user?.setImageResource(R.drawable.icon_my_click)
            id_view_navigation_bottom_msg?.setImageResource(R.drawable.icon_xiaoxi_default)
            id_view_navigation_bottom_xingzuo?.setImageResource(R.drawable.icon_xingzuo_default)
            id_view_navigation_bottom_shouye?.setImageResource(R.drawable.icon_shouye_default)
//            if(true){
//                JumpUtils.activityJump(RounterBus.getRounter(RounterApi::class.java).getIntentActivityLogin())
//            } else {
//            mVideoText?.setTextColor(resources.getColor(R.color.color_666666))
//            mUserText?.setTextColor(resources.getColor(R.color.color_aa60ff))
//            mWarehouseText?.setTextColor(resources.getColor(R.color.color_666666))
//            mVoiceroomText?.setTextColor(resources.getColor(R.color.color_666666))
//            val voiceDrawable = getResources().getDrawable(R.drawable.icon_xingzuo_default)
//            voiceDrawable.setBounds(
//                0,
//                0,
//                voiceDrawable.getMinimumWidth(),
//                voiceDrawable.getMinimumHeight()
//            )
//            val userDrawable = getResources().getDrawable(R.drawable.icon_my_click_xinzeng)
//            userDrawable.setBounds(
//                0,
//                0,
//                userDrawable.getMinimumWidth(),
//                userDrawable.getMinimumHeight()
//            )
//            val videoDrawable = getResources().getDrawable(R.drawable.icon_shouye_default)
//            videoDrawable.setBounds(
//                0,
//                0,
//                videoDrawable.getMinimumWidth(),
//                videoDrawable.getMinimumHeight()
//            )
//            val warehouseDrawable = getResources().getDrawable(R.drawable.icon_xiaoxi_default)
//            warehouseDrawable.setBounds(
//                0,
//                0,
//                videoDrawable.getMinimumWidth(),
//                videoDrawable.getMinimumHeight()
//            )
//            mVoiceroomText?.setCompoundDrawables(null, voiceDrawable, null, null)
//            mUserText?.setCompoundDrawables(null, userDrawable, null, null)
//            mVideoText?.setCompoundDrawables(null, videoDrawable, null, null)
//            mWarehouseText?.setCompoundDrawables(null, warehouseDrawable, null, null)
            navifationCallback?.onNavigationClick(it.id)
        }
        id_ll_bottom_shouye?.setOnClickListener {
            id_view_navigation_bottom_user?.setImageResource(R.drawable.icon_my_default)
            id_view_navigation_bottom_msg?.setImageResource(R.drawable.icon_xiaoxi_default)
            id_view_navigation_bottom_xingzuo?.setImageResource(R.drawable.icon_xingzuo_default)
            id_view_navigation_bottom_shouye?.setImageResource(R.drawable.icon_shouye_click)
            navifationCallback?.onNavigationClick(it.id)
        }
        id_ll_bottom_xingzuo?.setOnClickListener {
            id_view_navigation_bottom_user?.setImageResource(R.drawable.icon_my_default)
            id_view_navigation_bottom_msg?.setImageResource(R.drawable.icon_xiaoxi_default)
            id_view_navigation_bottom_xingzuo?.setImageResource(R.drawable.icon_xingzuo_click)
            id_view_navigation_bottom_shouye?.setImageResource(R.drawable.icon_shouye_default)
            navifationCallback?.onNavigationClick(it.id)
        }
        id_ll_bottom_msg?.setOnClickListener {
            id_view_navigation_bottom_user?.setImageResource(R.drawable.icon_my_default)
            id_view_navigation_bottom_msg?.setImageResource(R.drawable.icon_xiaoxi_click)
            id_view_navigation_bottom_xingzuo?.setImageResource(R.drawable.icon_xingzuo_default)
            id_view_navigation_bottom_shouye?.setImageResource(R.drawable.icon_shouye_default)
            navifationCallback?.onNavigationClick(it.id)
        }
    }


    fun setNavifationCallback(navifationCallback: NavifationCallback) {
        this.navifationCallback = navifationCallback
    }


    interface NavifationCallback {

        fun onNavigationClick(vId: Int)
    }

}