package com.dlc.eboard.ui.notice

import android.os.Bundle
import com.dlc.eboard.LabApp
import com.dlc.eboard.common.CommonUtils
import com.dlc.eboard.databinding.ActivityNoticeBinding
import com.dlc.eboard.ui.common.BaseCountDownActivity
import com.dlc.eboard.ui.common.TabFragmentPagerAdapter
import com.dlc.eboard.ui.widget.NavViewCompat
import com.dlc.eboard.ui.widget.TitleBar

/**
 * 消息通知
 *
 * @author ReiChin_
 */
class NoticeActivity :
    BaseCountDownActivity<ActivityNoticeBinding>() {

    override fun createViewBinding() = ActivityNoticeBinding.inflate(layoutInflater)

    override val mTitleBar: TitleBar by lazy { viewBinding.titleBar }
    override val mNavView: NavViewCompat by lazy { viewBinding.navView }

    override fun initViews(savedInstanceState: Bundle?) {
        super.initViews(savedInstanceState)

        val labConfig = LabApp.sLabConfig
        if (null == labConfig) {
            showToast("暂无实验室信息，即将重新获取")
            CommonUtils.restartApp(this)
            return
        }

        val tabArray = mutableListOf(
            NoticeFragment.newInstance(labConfig.labId),
//            ReformFragment.newInstance(labConfig.labId)
        )

        val adapter = TabFragmentPagerAdapter(supportFragmentManager, tabArray)
        viewBinding.viewPager.adapter = adapter

        viewBinding.messageLabel.setOnClickListener {
            viewBinding.viewPager.currentItem = 0
        }
//        viewBinding.reformLabel.setOnClickListener {
//            viewBinding.viewPager.currentItem = 1
//        }
    }

    override fun enabledBackCountDown() = true

    override fun onNoticeViewClicked() {
    }

}