diff --git a/app/src/main/java/com/github/swent/echo/compose/map/EventLocationSelector.kt b/app/src/main/java/com/github/swent/echo/compose/map/EventLocationSelector.kt index e9b388a57..4d0540424 100644 --- a/app/src/main/java/com/github/swent/echo/compose/map/EventLocationSelector.kt +++ b/app/src/main/java/com/github/swent/echo/compose/map/EventLocationSelector.kt @@ -16,6 +16,12 @@ import org.ramani.compose.Circle import org.ramani.compose.MapLibre import org.ramani.compose.Symbol +/** + * A Composable to select a location on a map. + * + * @param initialLocation The location at which the map must be initialized. + * @param locationCallback The function to call when the selected location changes. + */ @Composable fun LocationSelector( modifier: Modifier = Modifier, @@ -52,6 +58,11 @@ fun LocationSelector( } } +/** + * A Composable to display a location on a mpa. + * + * @param position The location to be displayed. + */ @Composable fun LocationDisplayer( modifier: Modifier = Modifier, diff --git a/app/src/main/java/com/github/swent/echo/compose/map/Map.kt b/app/src/main/java/com/github/swent/echo/compose/map/Map.kt index 2d392d5fd..311263075 100644 --- a/app/src/main/java/com/github/swent/echo/compose/map/Map.kt +++ b/app/src/main/java/com/github/swent/echo/compose/map/Map.kt @@ -18,6 +18,18 @@ import com.mapbox.mapboxsdk.geometry.LatLng val MAP_CENTER = Location("EPFL", 46.5191, 6.5668) const val DEFAULT_ZOOM = 13.0 +/** + * Wrapper around an [AndroidView] to facilitate readability. + * + * @param factory The factory that will product a [View]. + * @param update The function to update said [View]. + * @param events The list of events to be displayed by the map. Whenever this list changes, the + * event markers in the map will be automatically updated to match the list. + * @param callback The function to be called when a marker on the map is clicked on. The [Event] + * corresponding to the marker will be passed as an argument to this function. + * @param withLocation Whether the [View] should display the location of the user. + * @param launchEventCreation A function to enable the [View] to launch event creations. + */ @Composable fun EchoAndroidView( modifier: Modifier = Modifier, @@ -28,6 +40,7 @@ fun EchoAndroidView( withLocation: Boolean, launchEventCreation: (LatLng) -> Unit ) { + // Will change when the map construction is done in order to trigger an update. var trigger by remember { mutableStateOf(false) } AndroidView( modifier = modifier.testTag("mapAndroidView"), diff --git a/app/src/main/java/com/github/swent/echo/compose/map/MapViewProvider.kt b/app/src/main/java/com/github/swent/echo/compose/map/MapViewProvider.kt index 2df9e592d..9120ca900 100644 --- a/app/src/main/java/com/github/swent/echo/compose/map/MapViewProvider.kt +++ b/app/src/main/java/com/github/swent/echo/compose/map/MapViewProvider.kt @@ -10,8 +10,6 @@ import com.mapbox.mapboxsdk.geometry.LatLng * [EchoAndroidView][com.github.swent.echo.compose.map.EchoAndroidView]. The methods `factory` and * `update` directly correspond to the parameters of the same name in an * [EchoAndroidView][com.github.swent.echo.compose.map.EchoAndroidView]. - * - * @author alejandrocalles */ interface MapViewProvider { fun factory( @@ -23,5 +21,11 @@ interface MapViewProvider { fun update(view: T, events: List, callback: (Event) -> Unit, withLocation: Boolean) + /** + * Forces this provider to set the position of its camera according to the given parameters. + * + * @param newPosition The position on which to center the camera. + * @param zoomLevel The level of zoom at which to set the camera. + */ fun setSavedCameraPosition(newPosition: LatLng, zoomLevel: Double) } diff --git a/app/src/main/java/com/github/swent/echo/compose/map/MapViewProviderImpl.kt b/app/src/main/java/com/github/swent/echo/compose/map/MapViewProviderImpl.kt index 367e03120..9bac578db 100644 --- a/app/src/main/java/com/github/swent/echo/compose/map/MapViewProviderImpl.kt +++ b/app/src/main/java/com/github/swent/echo/compose/map/MapViewProviderImpl.kt @@ -17,6 +17,7 @@ import com.mapbox.mapboxsdk.maps.MapView import com.mapbox.mapboxsdk.maps.MapboxMap import com.mapbox.mapboxsdk.maps.Style +/** An implementation of a [MapViewProvider] that produces [MapView]s. */ class MapViewProviderImpl : MapViewProvider { // Stores the last camera position so we can restore it when the map is recreated (i.e. when the @@ -68,7 +69,7 @@ class MapViewProviderImpl : MapViewProvider { locationComponent!!.activateLocationComponent(locationComponentActivationOptions) locationComponent!!.isLocationComponentEnabled = true locationComponent!!.cameraMode = CameraMode.NONE - locationComponent?.lastKnownLocation?.apply { + locationComponent!!.lastKnownLocation?.apply { if (firstRecenter) { firstRecenter = false val pos = LatLng(latitude, longitude)