package com.adealink.weparty.profile.viewmodel

import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.adealink.weparty.profile.edit.viewmodel.EditProfileViewModel
import com.adealink.weparty.profile.relation.viewmodel.FollowViewModel

@Suppress("UNCHECKED_CAST")
class ProfileViewModelFactory : ViewModelProvider.NewInstanceFactory() {

    override fun <T : ViewModel> create(modelClass: Class<T>): T {
        return with(modelClass) {
            when {
                isAssignableFrom(ProfileViewModel::class.java) ->
                    ProfileViewModel()

                isAssignableFrom(EditProfileViewModel::class.java) ->
                    EditProfileViewModel()

                isAssignableFrom(FollowViewModel::class.java) ->
                    FollowViewModel()

                else ->
                    throw IllegalArgumentException("Unknown ViewModel class: ${modelClass.name}")
            } as T
        }
    }

}