From 005ef17f8e66a3800e6268be08fec95e140535fa Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Mon, 11 Jul 2022 09:36:43 +0300 Subject: [PATCH] Move classes to common --- .../sciprog/maps}/GeodeticMapCoordinates.kt | 2 +- .../kotlin/centre/sciprog/maps}/MapViewPoint.kt | 2 +- .../centre/sciprog/maps}/MercatorProjection.kt | 2 +- .../sciprog/maps}/WebMercatorProjection.kt | 2 +- .../centre/sciprog/maps/compose/MapFeature.kt | 1 + .../sciprog/maps/compose/MapTileProvider.kt | 0 .../centre/sciprog/maps/compose/MapView.kt | 16 ++++++++++++++++ src/jvmMain/kotlin/Main.kt | 2 ++ .../maps/compose/{MapView.kt => MapViewJvm.kt} | 10 +++++----- 9 files changed, 28 insertions(+), 9 deletions(-) rename src/{jvmMain/kotlin/centre/sciprog/maps/compose => commonMain/kotlin/centre/sciprog/maps}/GeodeticMapCoordinates.kt (98%) rename src/{jvmMain/kotlin/centre/sciprog/maps/compose => commonMain/kotlin/centre/sciprog/maps}/MapViewPoint.kt (93%) rename src/{jvmMain/kotlin/centre/sciprog/maps/compose => commonMain/kotlin/centre/sciprog/maps}/MercatorProjection.kt (98%) rename src/{jvmMain/kotlin/centre/sciprog/maps/compose => commonMain/kotlin/centre/sciprog/maps}/WebMercatorProjection.kt (98%) rename src/{jvmMain => commonMain}/kotlin/centre/sciprog/maps/compose/MapFeature.kt (96%) rename src/{jvmMain => commonMain}/kotlin/centre/sciprog/maps/compose/MapTileProvider.kt (100%) create mode 100644 src/commonMain/kotlin/centre/sciprog/maps/compose/MapView.kt rename src/jvmMain/kotlin/centre/sciprog/maps/compose/{MapView.kt => MapViewJvm.kt} (96%) diff --git a/src/jvmMain/kotlin/centre/sciprog/maps/compose/GeodeticMapCoordinates.kt b/src/commonMain/kotlin/centre/sciprog/maps/GeodeticMapCoordinates.kt similarity index 98% rename from src/jvmMain/kotlin/centre/sciprog/maps/compose/GeodeticMapCoordinates.kt rename to src/commonMain/kotlin/centre/sciprog/maps/GeodeticMapCoordinates.kt index fe2743e..9f73bc2 100644 --- a/src/jvmMain/kotlin/centre/sciprog/maps/compose/GeodeticMapCoordinates.kt +++ b/src/commonMain/kotlin/centre/sciprog/maps/GeodeticMapCoordinates.kt @@ -1,4 +1,4 @@ -package centre.sciprog.maps.compose +package centre.sciprog.maps import kotlin.math.PI diff --git a/src/jvmMain/kotlin/centre/sciprog/maps/compose/MapViewPoint.kt b/src/commonMain/kotlin/centre/sciprog/maps/MapViewPoint.kt similarity index 93% rename from src/jvmMain/kotlin/centre/sciprog/maps/compose/MapViewPoint.kt rename to src/commonMain/kotlin/centre/sciprog/maps/MapViewPoint.kt index 57d1f7d..3094d1a 100644 --- a/src/jvmMain/kotlin/centre/sciprog/maps/compose/MapViewPoint.kt +++ b/src/commonMain/kotlin/centre/sciprog/maps/MapViewPoint.kt @@ -1,4 +1,4 @@ -package centre.sciprog.maps.compose +package centre.sciprog.maps import kotlin.math.roundToInt diff --git a/src/jvmMain/kotlin/centre/sciprog/maps/compose/MercatorProjection.kt b/src/commonMain/kotlin/centre/sciprog/maps/MercatorProjection.kt similarity index 98% rename from src/jvmMain/kotlin/centre/sciprog/maps/compose/MercatorProjection.kt rename to src/commonMain/kotlin/centre/sciprog/maps/MercatorProjection.kt index 6318370..1221c4a 100644 --- a/src/jvmMain/kotlin/centre/sciprog/maps/compose/MercatorProjection.kt +++ b/src/commonMain/kotlin/centre/sciprog/maps/MercatorProjection.kt @@ -3,7 +3,7 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -package centre.sciprog.maps.compose +package centre.sciprog.maps import kotlin.math.* diff --git a/src/jvmMain/kotlin/centre/sciprog/maps/compose/WebMercatorProjection.kt b/src/commonMain/kotlin/centre/sciprog/maps/WebMercatorProjection.kt similarity index 98% rename from src/jvmMain/kotlin/centre/sciprog/maps/compose/WebMercatorProjection.kt rename to src/commonMain/kotlin/centre/sciprog/maps/WebMercatorProjection.kt index 33479df..a05816a 100644 --- a/src/jvmMain/kotlin/centre/sciprog/maps/compose/WebMercatorProjection.kt +++ b/src/commonMain/kotlin/centre/sciprog/maps/WebMercatorProjection.kt @@ -3,7 +3,7 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -package centre.sciprog.maps.compose +package centre.sciprog.maps import kotlin.math.* diff --git a/src/jvmMain/kotlin/centre/sciprog/maps/compose/MapFeature.kt b/src/commonMain/kotlin/centre/sciprog/maps/compose/MapFeature.kt similarity index 96% rename from src/jvmMain/kotlin/centre/sciprog/maps/compose/MapFeature.kt rename to src/commonMain/kotlin/centre/sciprog/maps/compose/MapFeature.kt index 20284aa..83215f1 100644 --- a/src/jvmMain/kotlin/centre/sciprog/maps/compose/MapFeature.kt +++ b/src/commonMain/kotlin/centre/sciprog/maps/compose/MapFeature.kt @@ -8,6 +8,7 @@ import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.graphics.vector.VectorPainter import androidx.compose.ui.graphics.vector.rememberVectorPainter import androidx.compose.ui.unit.IntSize +import centre.sciprog.maps.GeodeticMapCoordinates //TODO replace zoom range with zoom-based representation change sealed class MapFeature(val zoomRange: IntRange) diff --git a/src/jvmMain/kotlin/centre/sciprog/maps/compose/MapTileProvider.kt b/src/commonMain/kotlin/centre/sciprog/maps/compose/MapTileProvider.kt similarity index 100% rename from src/jvmMain/kotlin/centre/sciprog/maps/compose/MapTileProvider.kt rename to src/commonMain/kotlin/centre/sciprog/maps/compose/MapTileProvider.kt diff --git a/src/commonMain/kotlin/centre/sciprog/maps/compose/MapView.kt b/src/commonMain/kotlin/centre/sciprog/maps/compose/MapView.kt new file mode 100644 index 0000000..53d7c8c --- /dev/null +++ b/src/commonMain/kotlin/centre/sciprog/maps/compose/MapView.kt @@ -0,0 +1,16 @@ +package centre.sciprog.maps.compose + +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import centre.sciprog.maps.GeodeticMapCoordinates +import centre.sciprog.maps.MapViewPoint + +@Composable +expect fun MapView( + initialViewPoint: MapViewPoint, + mapTileProvider: MapTileProvider, + features: Collection = emptyList(), + modifier: Modifier = Modifier.fillMaxSize(), + onClick: (GeodeticMapCoordinates) -> Unit = {}, +) \ No newline at end of file diff --git a/src/jvmMain/kotlin/Main.kt b/src/jvmMain/kotlin/Main.kt index 501fecb..1946886 100644 --- a/src/jvmMain/kotlin/Main.kt +++ b/src/jvmMain/kotlin/Main.kt @@ -8,6 +8,8 @@ import androidx.compose.material.icons.filled.Home import androidx.compose.runtime.* import androidx.compose.ui.window.Window import androidx.compose.ui.window.application +import centre.sciprog.maps.GeodeticMapCoordinates +import centre.sciprog.maps.MapViewPoint import centre.sciprog.maps.compose.* import io.ktor.client.HttpClient import io.ktor.client.engine.cio.CIO diff --git a/src/jvmMain/kotlin/centre/sciprog/maps/compose/MapView.kt b/src/jvmMain/kotlin/centre/sciprog/maps/compose/MapViewJvm.kt similarity index 96% rename from src/jvmMain/kotlin/centre/sciprog/maps/compose/MapView.kt rename to src/jvmMain/kotlin/centre/sciprog/maps/compose/MapViewJvm.kt index 5e507d6..fd6fac9 100644 --- a/src/jvmMain/kotlin/centre/sciprog/maps/compose/MapView.kt +++ b/src/jvmMain/kotlin/centre/sciprog/maps/compose/MapViewJvm.kt @@ -18,11 +18,11 @@ import androidx.compose.ui.input.pointer.PointerEventType import androidx.compose.ui.input.pointer.PointerInputChange import androidx.compose.ui.input.pointer.onPointerEvent import androidx.compose.ui.input.pointer.pointerInput +import centre.sciprog.maps.* import mu.KotlinLogging import org.jetbrains.skia.Font import org.jetbrains.skia.Paint import kotlin.math.pow -import kotlin.math.round import kotlin.math.roundToInt @@ -38,12 +38,12 @@ private val logger = KotlinLogging.logger("MapView") */ @OptIn(ExperimentalComposeUiApi::class) @Composable -fun MapView( +actual fun MapView( initialViewPoint: MapViewPoint, mapTileProvider: MapTileProvider, - features: Collection = emptyList(), - modifier: Modifier = Modifier.fillMaxSize(), - onClick: (GeodeticMapCoordinates) -> Unit = {}, + features: Collection, + modifier: Modifier, + onClick: (GeodeticMapCoordinates) -> Unit, ) { var viewPoint by remember { mutableStateOf(initialViewPoint) }