package com.halo.assistant.fragment.user.auth

import android.os.Bundle
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.gh.gamecenter.common.baselist.ListFragment
import com.gh.gamecenter.common.utils.toColor
import com.gh.gamecenter.common.utils.viewModelProvider
import com.gh.gamecenter.entity.UserAuthEntity

class UserAuthFragment: ListFragment<UserAuthEntity, UserAuthViewModel>() {

    private val mAdapter by lazy {
        UserAuthAdapter(requireContext(), mViewModel)
    }

    private val mViewModel: UserAuthViewModel by lazy { viewModelProvider() }
    override fun provideListAdapter(): UserAuthAdapter = mAdapter

    override fun provideListViewModel(): UserAuthViewModel = mViewModel

    override fun getItemDecoration(): RecyclerView.ItemDecoration? = null

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        mCachedView.setBackgroundColor(com.gh.gamecenter.common.R.color.ui_surface.toColor(requireContext()))
    }

    override fun onDarkModeChanged() {
        super.onDarkModeChanged()
        mCachedView.setBackgroundColor(com.gh.gamecenter.common.R.color.ui_surface.toColor(requireContext()))
        mAdapter.run {
            notifyItemRangeChanged(0, itemCount)
        }
    }
}