package com.quansu.heifengwuliu.activity

import android.appwidget.AppWidgetManager
import android.content.Intent
import android.os.Bundle
import com.hwangjr.rxbus.annotation.Subscribe
import com.hwangjr.rxbus.annotation.Tag
import com.qmuiteam.qmui.kotlin.onClick
import com.quansu.heifengwuliu.R
import com.quansu.heifengwuliu.base.MBActivity
import com.quansu.heifengwuliu.config.ConfigMMKV
import com.quansu.heifengwuliu.config.ConfigRx
import com.quansu.heifengwuliu.databinding.ActivityPrivateCenterBinding
import com.quansu.heifengwuliu.repository.UserInfoRepository
import com.quansu.heifengwuliu.vmodel.PrivateCenterVModel
import com.ysnows.base.base.BRepository
import com.ysnows.base.ccretrofit.CCRetrofit
import com.ysnows.base.route.IApp
import com.ysnows.base.utils.MMKVManager

class PrivateCenterActivity : MBActivity<PrivateCenterVModel, ActivityPrivateCenterBinding>() {

    override fun title(): String? {
        return "个人中心"
    }

    override fun initCreate(savedInstanceState: Bundle?) {
        super.initCreate(savedInstanceState)
        sendBroadcast(Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE))


        if (MMKVManager.instance().decodeBool(ConfigMMKV.FIRST_OPEN, true)) {
            single(SplashActivity::class.java)
        }

    }


    override fun listeners() {
        super.listeners()

        binding.laySettings.onClick {
//            CCRetrofit.instance()
//                    .with(this)
//                    .create(IApp::class.java)
//                    .settings()
//                    .subscribe()
        }

        binding.layNote.onClick {
//            CCRetrofit.instance()
//                    .with(this)
//                    .create(IApp::class.java)
//                    .todoList()
//                    .subscribe()
        }

        binding.layAb.onClick {
            toast(R.string.developing)
        }
    }

    override fun binding(): ActivityPrivateCenterBinding {
        return ActivityPrivateCenterBinding.inflate(layoutInflater)
    }

    override val isRxbus: Boolean
        get() = true

    override fun backable(): Boolean {
        return false
    }

    override fun vmClass(): Class<PrivateCenterVModel> {
        return PrivateCenterVModel::class.java
    }

    @Subscribe(tags = [Tag(ConfigRx.LOGIN)])
    fun logout(from: String) {
        vm.firstReq()
    }

    override fun createRepository(): BRepository {
        return UserInfoRepository()
    }


}
