package com.zj365.mime.act

import com.alibaba.android.arouter.facade.annotation.Route
import com.xty.base.act.IBaseAct
import com.xty.base.vp2.VpAdapter
import com.xty.common.arouter.ARouterUrl
import com.xty.common.arouter.RouteManager
import com.zj365.mime.databinding.ActScoreBinding
import com.zj365.mime.fragment.ScoreDetailFrag
import com.zj365.mime.fragment.ScoreRuleFrag
import com.zj365.mime.weight.WebViewDialog

/**
 * 积分明细
 */
@Route(path = ARouterUrl.SCORE)
class ScoreAct : IBaseAct() {

    val binding by lazy { ActScoreBinding.inflate(layoutInflater) }
    override fun setLayout() = binding.root

    private val listFrag by lazy { listOf(ScoreDetailFrag(), ScoreRuleFrag()) }

    //    var tip =
//        "人的心率在非静息状态下会不断变化，属正常情况！同时，不同心率监测设备采集心率的方法和算法有所不同，同一时间通过不同心率监测装置出现心率数据偏差亦属正常现象。
//        中健三六五心率变异算法会将采集的心率整体变化趋势与不同状态下的正常心率模型对比，请您及时关注心率变化。"
    val tipDialog by lazy {
        WebViewDialog(this, "file:///android_asset/word_rule.html") {
        }
    }

    override fun initView() {
        super.initView()
        statusBar(binding.title.mView)
        binding.title.mTvTitle.text = "积分明细"
        binding.title.mIvBack.setOnClickListener { finish() }
        initVp2()
        binding.mDetailed.isSelected = true
        binding.mDetailed.setOnClickListener {
            it.isSelected = true
            binding.mRule.isSelected = false
            binding.mVp2.currentItem = 0
        }
        binding.mRule.setOnClickListener {
//            binding.mDetailed.isSelected=false
//            it.isSelected=true
//            binding.mVp2.currentItem=1
            RouteManager.goAct(ARouterUrl.SCORE_RULE)

        }
    }

    private fun initVp2() {
        binding.mVp2.isUserInputEnabled = false
        binding.mVp2.adapter = VpAdapter(listFrag, this)
        binding.mVp2.offscreenPageLimit = 2
        binding.mVp2.currentItem = 0
    }

    fun setAllScore(score: String) {
        binding.mTvScore.text = score
    }


}