Skip to content

Commit

Permalink
some tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sargunv committed Nov 22, 2024
1 parent 547098c commit 1c3a437
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 28 deletions.
10 changes: 1 addition & 9 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ root = true
end_of_line = lf
insert_final_newline = true

[*.yml]
indent_style = space
indent_size = 2

[*.{kt,kts}]
indent_style = space
indent_size = 2

[*.{swift}]
[*.{yml,json,kt,kts,swift}]
indent_style = space
indent_size = 2
44 changes: 44 additions & 0 deletions .fleet/run.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"configurations": [
{
"name": "iOS-App",
"type": "xcode-app",
"workingDir": "$PROJECT_DIR$",
"buildTarget": {
"project": "iosApp",
"target": "iosApp"
},
"configuration": "Debug"
},
{
"name": "Android-App",
"type": "android-app",
"workingDir": "$PROJECT_DIR$",
"module": "root.demo-app.main"
},
{
"name": "Reformat",
"type": "gradle",
"workingDir": "$PROJECT_DIR$",
"tasks": [
"spotlessApply"
],
},
{
"name": "iOS-Test",
"type": "gradle",
"workingDir": "$PROJECT_DIR$",
"tasks": [
"iosSimulatorArm64Test"
],
},
{
"name": "Android-Test",
"type": "gradle",
"workingDir": "$PROJECT_DIR$",
"tasks": [
"connectedDebugAndroidTest"
],
}
]
}
17 changes: 16 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ subprojects {
spotless {
format("swift") {
target("iosApp/iosApp/**/*.swift")
nativeCmd("swiftFormat","/usr/bin/env", listOf("swift", "format"))
nativeCmd("swiftFormat", "/usr/bin/env", listOf("swift", "format"))
}
}

tasks.register("installGitHooks") {
doLast {
copy {
from("${rootProject.projectDir}/scripts/pre-commit")
into("${rootProject.projectDir}/.git/hooks")
}
}
}

tasks.named("clean") {
doLast {
delete("${rootProject.projectDir}/.git/hooks/pre-commit")
}
}
4 changes: 0 additions & 4 deletions demo-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ kotlin {
add("-Xconsistent-data-class-copy-visibility")
}
}
languageSettings {
optIn("androidx.compose.material3.ExperimentalMaterial3Api")
optIn("org.jetbrains.compose.resources.ExperimentalResourceApi")
}
}

commonMain.dependencies {
Expand Down
6 changes: 1 addition & 5 deletions maplibre-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ kotlin {
add("-Xconsistent-data-class-copy-visibility")
}
}
languageSettings {
optIn("androidx.compose.ui.ExperimentalComposeUiApi")
optIn("kotlinx.cinterop.ExperimentalForeignApi")
optIn("kotlinx.cinterop.BetaInteropApi")
}
languageSettings { optIn("kotlinx.cinterop.ExperimentalForeignApi") }
}

commonMain.dependencies {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package dev.sargunv.maplibrecompose.compose

import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import co.touchlab.kermit.Logger
import dev.sargunv.maplibrecompose.compose.engine.LayerNode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.runtime.setValue
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.viewinterop.UIKitInteropInteractionMode
Expand Down Expand Up @@ -42,6 +43,7 @@ internal actual fun ComposableMapView(
)
}

@OptIn(ExperimentalComposeUiApi::class)
@Composable
internal fun IosMapView(
modifier: Modifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine
import kotlin.time.Duration
import kotlin.time.DurationUnit
import kotlinx.cinterop.BetaInteropApi
import kotlinx.cinterop.CValue
import kotlinx.cinterop.ObjCAction
import kotlinx.cinterop.useContents
Expand Down Expand Up @@ -130,6 +131,7 @@ internal class IosMap(
recognizer.addTarget(target = this, action = sel_registerName(::handleGesture.name + ":"))
}

@OptIn(BetaInteropApi::class)
@ObjCAction
fun handleGesture(sender: UIGestureRecognizer) {
@Suppress("UNCHECKED_CAST") action(sender as T)
Expand Down Expand Up @@ -180,6 +182,7 @@ internal class IosMap(
(uiPadding.calculateTopPadding().value - insetPadding.calculateTopPadding().value)
.toDouble(),
)

MLNOrnamentPositionTopRight ->
CGPointMake(
(uiPadding.calculateRightPadding(layoutDir).value -
Expand All @@ -188,6 +191,7 @@ internal class IosMap(
(uiPadding.calculateTopPadding().value - insetPadding.calculateTopPadding().value)
.toDouble(),
)

MLNOrnamentPositionBottomLeft ->
CGPointMake(
(uiPadding.calculateLeftPadding(layoutDir).value -
Expand All @@ -196,6 +200,7 @@ internal class IosMap(
(uiPadding.calculateBottomPadding().value - insetPadding.calculateBottomPadding().value)
.toDouble(),
)

MLNOrnamentPositionBottomRight ->
CGPointMake(
(uiPadding.calculateRightPadding(layoutDir).value -
Expand All @@ -204,6 +209,7 @@ internal class IosMap(
(uiPadding.calculateBottomPadding().value - insetPadding.calculateBottomPadding().value)
.toDouble(),
)

else -> error("Invalid ornament position")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ import dev.sargunv.maplibrecompose.core.expression.Point
import io.github.dellisd.spatialk.geojson.Feature
import io.github.dellisd.spatialk.geojson.GeoJson
import io.github.dellisd.spatialk.geojson.Position
import kotlinx.cinterop.CValue
import kotlinx.cinterop.addressOf
import kotlinx.cinterop.useContents
import kotlinx.cinterop.usePinned
import kotlinx.cinterop.*
import kotlinx.serialization.json.JsonArray
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonNull
Expand Down Expand Up @@ -115,6 +112,7 @@ private fun normalizeJsonLike(value: Any?): Any? =
blue = value.blue.toDouble(),
alpha = value.alpha.toDouble(),
)

is Insets ->
NSValue.valueWithUIEdgeInsets(
UIEdgeInsetsMake(
Expand All @@ -124,6 +122,7 @@ private fun normalizeJsonLike(value: Any?): Any? =
right = value.right.toDouble(),
)
)

else -> throw IllegalArgumentException("Unsupported type: ${value::class}")
}

Expand Down
7 changes: 7 additions & 0 deletions scripts/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

# Run Spotless
./gradlew -q spotlessApply

# Add any modified files back to the staging area
git add .

0 comments on commit 1c3a437

Please sign in to comment.