package com.swago.room.anchor

import com.swago.baseswago.PersonDataDFragment
import com.swago.baseswago.baseroom.IRoomInfo
import com.swago.room.base.BaseComFragment
import com.swago.room.databinding.FragmentBaseComBinding
import com.swago.room.gift.GiftDialog
import com.swago.room.inter.IFooter
import com.swago.room.inter.IHeader
import com.swago.room.widget.AnchorFooterView
import com.swago.room.widget.ComHeaderView

/**
 *@date 2021/10/9 11:35
 *description:
 */
class AnchorRoomFragment : BaseComFragment<FragmentBaseComBinding>() {

    private var footerView : AnchorFooterView? = null

    override fun initOther() {
        super.initOther()
    }

    override fun initLiveData() {
        super.initLiveData()
        footerView = iFooter as AnchorFooterView
        footerView?.openSendMsgDialog = {
            openSendMessageDialog()
        }

        footerView?.openMessageFun = {
            openMessageListDialog()
        }

        footerView?.openGameFun = {
            openGameDialog()
        }


        (iHeader as ComHeaderView).showUserInfo = {
            PersonDataDFragment.newInstance(it, isAnchor = true, inRoom = true)
                .apply {
                    this.openGiftDialog = {nickName, userId ->
                        GiftDialog.newInstance(
                            nickName,
                            userId
                        ).show(parentFragmentManager, "GiftDialog")
                    }
                }.show(childFragmentManager,"PersonDataDFragment")
        }

    }


    override fun changeRoom(iRoomInfo: IRoomInfo) {
    }

    override fun leaveRoom(iRoomInfo: IRoomInfo) {
        super.leaveRoom(iRoomInfo)
    }

    override fun joinedRoom(iRoomInfo: IRoomInfo) {
        super.joinedRoom(iRoomInfo)
    }

    override fun endRoom(iRoomInfo: IRoomInfo?) {
    }

    override fun closeRoomed() {
        super.closeRoomed()
    }

    fun setFooterGameIcon(b: Boolean) {
        footerView?.setGameIcon(b)
    }

    override val iHeader: IHeader by lazy {
        ComHeaderView(requireContext())
    }
    override val iFooter: IFooter by lazy {
        AnchorFooterView(requireContext())
    }
}