From 7d3b219d706232a6f4d05dedc83277278e46e63a Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 1 Oct 2023 11:12:15 +0300 Subject: [PATCH] Move files around --- demo/maps/src/jvmMain/kotlin/Main.kt | 7 ++--- demo/scheme/src/jvmMain/kotlin/Main.kt | 8 +++--- gradle.properties | 6 +++-- maps-kt-compose/build.gradle.kts | 3 ++- .../maps/compose/OsmTileProviderTest.kt | 1 - .../sciprog/maps/compose/canvasControls.kt | 1 + .../sciprog/maps/compose/clickGestures.kt | 27 ++----------------- settings.gradle.kts | 6 ++++- 8 files changed, 22 insertions(+), 37 deletions(-) rename maps-kt-features/src/{jvmMain => commonMain}/kotlin/center/sciprog/maps/compose/canvasControls.kt (99%) rename maps-kt-features/src/{jvmMain => commonMain}/kotlin/center/sciprog/maps/compose/clickGestures.kt (85%) diff --git a/demo/maps/src/jvmMain/kotlin/Main.kt b/demo/maps/src/jvmMain/kotlin/Main.kt index 3bea047..1081d2b 100644 --- a/demo/maps/src/jvmMain/kotlin/Main.kt +++ b/demo/maps/src/jvmMain/kotlin/Main.kt @@ -72,7 +72,7 @@ fun App() { ) { geoJson(javaClass.getResource("/moscow.geo.json")!!) - .modifyAttribute(ColorAttribute, Color.Blue) + .color(Color.Blue) .modifyAttribute(AlphaAttribute, 0.4f) icon(pointOne, Icons.Filled.Home) @@ -153,8 +153,9 @@ fun App() { Color( red = ((gmc.latitude + Angle.piDiv2).degrees * 10 % 1f).toFloat(), green = ((gmc.longitude + Angle.pi).degrees * 10 % 1f).toFloat(), - blue = 0f - ).copy(alpha = 0.3f) + blue = 0f, + alpha = 0.3f + ) } centerCoordinates.filterNotNull().onEach { diff --git a/demo/scheme/src/jvmMain/kotlin/Main.kt b/demo/scheme/src/jvmMain/kotlin/Main.kt index 9aeefae..a74f42d 100644 --- a/demo/scheme/src/jvmMain/kotlin/Main.kt +++ b/demo/scheme/src/jvmMain/kotlin/Main.kt @@ -29,7 +29,7 @@ fun App() { MaterialTheme { val scope = rememberCoroutineScope() - val schemeFeaturesState: FeatureGroup = FeatureGroup.remember(XYCoordinateSpace) { + val features: FeatureGroup = FeatureGroup.remember(XYCoordinateSpace) { background(1600f, 1200f) { painterResource("middle-earth.jpg") } circle(410.52737 to 868.7676).color(Color.Blue) text(410.52737 to 868.7676, "Shire").color(Color.Blue) @@ -53,7 +53,7 @@ fun App() { } val initialViewPoint: ViewPoint = remember { - schemeFeaturesState.getBoundingBox(1f)?.computeViewPoint() ?: XYViewPoint(XY(0f, 0f)) + features.getBoundingBox(1f)?.computeViewPoint() ?: XYViewPoint(XY(0f, 0f)) } var viewPoint: ViewPoint by remember { mutableStateOf(initialViewPoint) } @@ -61,7 +61,7 @@ fun App() { var snapshot: FeatureStateSnapshot? by remember { mutableStateOf(null) } if (snapshot == null) { - snapshot = schemeFeaturesState.snapshot() + snapshot = features.snapshot() } ContextMenuArea( @@ -90,7 +90,7 @@ fun App() { SchemeView( mapState, - schemeFeaturesState, + features, ) } diff --git a/gradle.properties b/gradle.properties index c574f8a..5b599e7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,10 +1,12 @@ kotlin.code.style=official compose.version=1.5.1 -#agp.version=7.4.2 -#android.useAndroidX=true org.jetbrains.compose.experimental.jscanvas.enabled=true +agp.version=8.1.0 +android.useAndroidX=true +android.enableJetifier=true + org.gradle.jvmargs=-Xmx4096m toolsVersion=0.14.9-kotlin-1.9.0 \ No newline at end of file diff --git a/maps-kt-compose/build.gradle.kts b/maps-kt-compose/build.gradle.kts index e6c658d..819ae81 100644 --- a/maps-kt-compose/build.gradle.kts +++ b/maps-kt-compose/build.gradle.kts @@ -1,6 +1,7 @@ plugins { id("space.kscience.gradle.mpp") id("org.jetbrains.compose") +// id("com.android.library") `maven-publish` } @@ -39,4 +40,4 @@ readme { feature( id = "osm", ) { "OpenStreetMap tile provider." } -} \ No newline at end of file +} diff --git a/maps-kt-compose/src/jvmTest/kotlin/center/sciprog/maps/compose/OsmTileProviderTest.kt b/maps-kt-compose/src/jvmTest/kotlin/center/sciprog/maps/compose/OsmTileProviderTest.kt index 4c9049c..1e5a367 100644 --- a/maps-kt-compose/src/jvmTest/kotlin/center/sciprog/maps/compose/OsmTileProviderTest.kt +++ b/maps-kt-compose/src/jvmTest/kotlin/center/sciprog/maps/compose/OsmTileProviderTest.kt @@ -9,7 +9,6 @@ import org.junit.jupiter.api.Test import java.nio.file.Files import kotlin.test.assertFails -@OptIn(ExperimentalCoroutinesApi::class) class OsmTileProviderTest { // @get:Rule // val rule = createComposeRule() diff --git a/maps-kt-features/src/jvmMain/kotlin/center/sciprog/maps/compose/canvasControls.kt b/maps-kt-features/src/commonMain/kotlin/center/sciprog/maps/compose/canvasControls.kt similarity index 99% rename from maps-kt-features/src/jvmMain/kotlin/center/sciprog/maps/compose/canvasControls.kt rename to maps-kt-features/src/commonMain/kotlin/center/sciprog/maps/compose/canvasControls.kt index dddbcb8..747abee 100644 --- a/maps-kt-features/src/jvmMain/kotlin/center/sciprog/maps/compose/canvasControls.kt +++ b/maps-kt-features/src/commonMain/kotlin/center/sciprog/maps/compose/canvasControls.kt @@ -1,5 +1,6 @@ package center.sciprog.maps.compose +import androidx.compose.foundation.gestures.detectTapGestures import androidx.compose.foundation.gestures.drag import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.Offset diff --git a/maps-kt-features/src/jvmMain/kotlin/center/sciprog/maps/compose/clickGestures.kt b/maps-kt-features/src/commonMain/kotlin/center/sciprog/maps/compose/clickGestures.kt similarity index 85% rename from maps-kt-features/src/jvmMain/kotlin/center/sciprog/maps/compose/clickGestures.kt rename to maps-kt-features/src/commonMain/kotlin/center/sciprog/maps/compose/clickGestures.kt index 2939a0d..9f9ada5 100644 --- a/maps-kt-features/src/jvmMain/kotlin/center/sciprog/maps/compose/clickGestures.kt +++ b/maps-kt-features/src/commonMain/kotlin/center/sciprog/maps/compose/clickGestures.kt @@ -26,32 +26,9 @@ public val PointerEvent.position: Offset get() = firstChange.position /** - * Detects tap, double-tap, and long press gestures and calls [onClick], [onDoubleClick], and - * [onLongClick], respectively, when detected. [onPress] is called when the press is detected - * and the [PressGestureScope.tryAwaitRelease] and [PressGestureScope.awaitRelease] can be - * used to detect when pointers have released or the gesture was canceled. - * The first pointer down and final pointer up are consumed, and in the - * case of long press, all changes after the long press is detected are consumed. - * - * Each function parameter receives an [Offset] representing the position relative to the containing - * element. The [Offset] can be outside the actual bounds of the element itself meaning the numbers - * can be negative or larger than the element bounds if the touch target is smaller than the - * [ViewConfiguration.minimumTouchTargetSize]. - * - * When [onDoubleClick] is provided, the tap gesture is detected only after - * the [ViewConfiguration.doubleTapMinTimeMillis] has passed and [onDoubleClick] is called if the - * second tap is started before [ViewConfiguration.doubleTapTimeoutMillis]. If [onDoubleClick] is not - * provided, then [onClick] is called when the pointer up has been received. - * - * After the initial [onPress], if the pointer moves out of the input area, the position change - * is consumed, or another gesture consumes the down or up events, the gestures are considered - * canceled. That means [onDoubleClick], [onLongClick], and [onClick] will not be called after a - * gesture has been canceled. - * - * If the first down event is consumed somewhere else, the entire gesture will be skipped, - * including [onPress]. + * An alternative to [detectTapGestures] with reimplementation of internal logic */ -public suspend fun PointerInputScope.detectClicks( +internal suspend fun PointerInputScope.detectClicks( onDoubleClick: (Density.(PointerEvent) -> Unit)? = null, onLongClick: (Density.(PointerEvent) -> Unit)? = null, onPress: suspend PressGestureScope.(event: PointerEvent) -> Unit = NoPressGesture, diff --git a/settings.gradle.kts b/settings.gradle.kts index afa549e..29d9fec 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -5,6 +5,8 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") pluginManagement { val toolsVersion: String by extra + val composeVersion = extra["compose.version"] as String + val agpVersion = extra["agp.version"] as String repositories { mavenLocal() @@ -18,11 +20,13 @@ pluginManagement { plugins { // id("com.android.application").version(extra["agp.version"] as String) // id("com.android.library").version(extra["agp.version"] as String) - id("org.jetbrains.compose").version(extra["compose.version"] as String) + id("org.jetbrains.compose") version composeVersion id("space.kscience.gradle.project") version toolsVersion id("space.kscience.gradle.mpp") version toolsVersion id("space.kscience.gradle.jvm") version toolsVersion id("space.kscience.gradle.js") version toolsVersion + id("com.android.application") version agpVersion + id("com.android.library") version agpVersion } }