package com.atridad.ascently.ui.viewmodel

import android.content.Context
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.atridad.ascently.data.repository.ClimbRepository
import com.atridad.ascently.data.sync.SyncService

class ClimbViewModelFactory(
    private val repository: ClimbRepository,
    private val syncService: SyncService,
    private val context: Context,
) : ViewModelProvider.Factory {

    @Suppress("UNCHECKED_CAST")
    override fun <T : ViewModel> create(modelClass: Class<T>): T {
        if (modelClass.isAssignableFrom(ClimbViewModel::class.java)) {
            return ClimbViewModel(repository, syncService, context) as T
        }
        throw IllegalArgumentException("Unknown ViewModel class")
    }
}
