package com.guadou.parttimerunalone

import android.content.Intent
import android.os.Bundle
import android.view.View
import com.guadou.lib_baselib.base.activity.BaseVMActivity
import com.guadou.lib_baselib.base.vm.EmptyViewModel
import com.guadou.lib_baselib.utils.CommUtils
import com.guadou.lib_baselib.utils.StatusBarUtils
import com.hongyegroup.cpt_parttime.ui.PartTimeMainFragment

/**
 * 独立运行模块的兼职Fragment的页面载体
 */
class PartTimeMainActivity : BaseVMActivity<EmptyViewModel>() {

    private lateinit var mGroupTabPartTime: View
    private val mPartTimeFragment by lazy { PartTimeMainFragment() }

    companion object {
        fun startInstance() {
            val context = CommUtils.getContext()
            val intent = Intent(context, PartTimeMainActivity::class.java)
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
            context.startActivity(intent)
        }
    }

    override fun getLayoutIdRes(): Int = R.layout.activity_parttime_main

    override fun init(savedInstanceState: Bundle?) {
        StatusBarUtils.immersive(this)
        setStatusBarBlackText()

        initView()
        initFragment()
    }

    private fun initFragment() {
        supportFragmentManager.beginTransaction()
            .add(R.id.main_fragment_container, mPartTimeFragment)
            .commitAllowingStateLoss()
    }

    private fun initView() {
        mGroupTabPartTime = findViewById(R.id.group_tab_parttime)
        mGroupTabPartTime.isSelected = true
    }

    override fun startObserve() {

    }
}