package eu.gaudian.translator.view.dictionary

import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import eu.gaudian.translator.utils.findActivity
import eu.gaudian.translator.viewmodel.DictionaryViewModel
import eu.gaudian.translator.viewmodel.LanguageViewModel

@Composable
fun DictionaryScreen(
    navController: NavController,
    onEntryClick: (eu.gaudian.translator.model.DictionaryEntry) -> Unit = {},
    onNavigateToOptions: () -> Unit
) {
    val activity = LocalContext.current.findActivity()
    val dictionaryViewModel: DictionaryViewModel = hiltViewModel(viewModelStoreOwner = activity)
    val languageViewModel: LanguageViewModel = hiltViewModel(viewModelStoreOwner = activity)


    // Use the new refactored component
    DictionaryScreenContent(
        navController = navController,
        onEntryClick = onEntryClick,
        dictionaryViewModel = dictionaryViewModel,
        languageViewModel = languageViewModel,
        onNavigateToOptions = onNavigateToOptions
    )
}

@Preview
@Composable
fun DictionaryScreenPreview() {

    DictionaryScreen(
        navController = rememberNavController(),
        onEntryClick = {},
        onNavigateToOptions = {}
    )
}