package com.adealink.weparty.commonui.mediapicker.imageselect.viewmodel

import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.adealink.weparty.commonui.mediapicker.imageselect.clip.BitmapViewModel
import com.adealink.weparty.commonui.mediapicker.imageselect.processor.ImageProcessorViewModel

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

    override fun <T : ViewModel> create(modelClass: Class<T>): T {
        return with(modelClass) {
            when {
                isAssignableFrom(BitmapViewModel::class.java) ->
                    BitmapViewModel()
                isAssignableFrom(ImageProcessorViewModel::class.java) ->
                    ImageProcessorViewModel()
                else ->
                    throw IllegalArgumentException("Unknown ViewModel class: ${modelClass.name}")
            } as T
        }
    }

}