package com.isidroid.c23.ui.screen.map._components

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.isidroid.c23.ui.screen.map.MapContract
import com.isidroid.ui.maps.MapsComponent
import com.isidroid.ui.maps.model.MapMarker
import kotlinx.coroutines.flow.StateFlow

@Composable
fun TPMapComponent(
    onEventSent: (event: MapContract.Event) -> Unit,
    lat: Double?,
    lng: Double?,
    mapMarkersStateFlow: StateFlow<List<MapMarker>>,
    modifier: Modifier = Modifier
) {
    if (lat == null || lng == null)
        return

    MapsComponent(
        lat = lat,
        lng = lng,
        mapMarkersStateFlow = mapMarkersStateFlow,
        onCameraMove = { lat1, lng1, radius -> onEventSent(MapContract.Event.CameraMove(lat1, lng1, radius)) },
        clickOnMarker = { onEventSent(MapContract.Event.ClickOnMarker(it)) },
        moveCameraToMyLocation = { onEventSent(MapContract.Event.MoveCameraToMyLocation) },
        modifier = modifier
    )
}