package com.isidroid.c23.ui.navigation.destinations

import androidx.compose.runtime.Composable
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavController
import com.isidroid.c23.ui.navigation.routeMap
import com.isidroid.c23.ui.screen.render_preview.RenderContract
import com.isidroid.c23.ui.screen.render_preview.RenderPreviewScreen
import com.isidroid.c23.ui.screen.render_preview.RenderViewModel

@Composable
fun RenderScreenDestination(navController: NavController) {
    val viewModel: RenderViewModel = hiltViewModel()

    RenderPreviewScreen(
        state = viewModel.viewState,
        renderResultsFlow = viewModel.renderResultsFlow,
        effectFlow = viewModel.effect,
        onEventSent = { event -> viewModel.setEvent(event) },
        onNavigationRequested = { effect ->
            when (effect) {
                RenderContract.Effect.Navigation.ToBack -> navController.popBackStack()
                RenderContract.Effect.Navigation.ToMap -> navController.navigate(routeMap())
            }
        }
    )
}