From 89ffc02e1ddebeced1305517dac717e15ff76fe3 Mon Sep 17 00:00:00 2001 From: LavaDesu Date: Sun, 13 Apr 2025 01:27:49 +1000 Subject: [PATCH] feat(android): init basic maps --- .gitignore | 2 ++ build.gradle.kts | 8 +++++++- composeApp/build.gradle.kts | 6 ++++++ composeApp/src/androidMain/AndroidManifest.xml | 3 +++ .../lava/banksia/native/maps/Maps.android.kt | 3 ++- .../commonMain/kotlin/moe/lava/banksia/App.kt | 18 ++++++------------ .../moe/lava/banksia/native/maps/Maps.kt | 4 ++-- gradle/libs.versions.toml | 9 ++++++++- 8 files changed, 36 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 7d9c0e4..3bc06b7 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ captures !*.xcodeproj/project.xcworkspace/ !*.xcworkspace/contents.xcworkspacedata **/xcshareddata/WorkspaceSettings.xcsettings + +secrets.properties diff --git a/build.gradle.kts b/build.gradle.kts index 45d8ae7..04f2a07 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,4 +7,10 @@ plugins { alias(libs.plugins.composeCompiler) apply false alias(libs.plugins.kotlinJvm) apply false alias(libs.plugins.kotlinMultiplatform) apply false -} \ No newline at end of file +} + +buildscript { + dependencies { + classpath(libs.secrets.gradle.plugin) + } +} diff --git a/composeApp/build.gradle.kts b/composeApp/build.gradle.kts index 604e9ab..dabf147 100644 --- a/composeApp/build.gradle.kts +++ b/composeApp/build.gradle.kts @@ -7,6 +7,7 @@ plugins { alias(libs.plugins.androidApplication) alias(libs.plugins.composeMultiplatform) alias(libs.plugins.composeCompiler) + alias(libs.plugins.secretsGradle) } kotlin { @@ -33,6 +34,8 @@ kotlin { androidMain.dependencies { implementation(compose.preview) implementation(libs.androidx.activity.compose) + implementation(libs.play.services.maps) + implementation(libs.maps.compose) } commonMain.dependencies { implementation(compose.runtime) @@ -79,3 +82,6 @@ dependencies { debugImplementation(compose.uiTooling) } +secrets { + propertiesFileName = "secrets.properties" +} \ No newline at end of file diff --git a/composeApp/src/androidMain/AndroidManifest.xml b/composeApp/src/androidMain/AndroidManifest.xml index c5db0b1..c6c63da 100644 --- a/composeApp/src/androidMain/AndroidManifest.xml +++ b/composeApp/src/androidMain/AndroidManifest.xml @@ -8,6 +8,9 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@android:style/Theme.Material.Light.NoActionBar"> + ) { - TODO("Not yet implemented") + GoogleMap() } \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/moe/lava/banksia/App.kt b/composeApp/src/commonMain/kotlin/moe/lava/banksia/App.kt index 016a3b3..c716b52 100644 --- a/composeApp/src/commonMain/kotlin/moe/lava/banksia/App.kt +++ b/composeApp/src/commonMain/kotlin/moe/lava/banksia/App.kt @@ -3,9 +3,12 @@ package moe.lava.banksia import androidx.compose.animation.AnimatedVisibility import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.material.BottomSheetScaffold import androidx.compose.material.Button import androidx.compose.material.MaterialTheme +import androidx.compose.material.Scaffold import androidx.compose.material.Text import androidx.compose.runtime.* import androidx.compose.ui.Alignment @@ -15,23 +18,14 @@ import org.jetbrains.compose.ui.tooling.preview.Preview import banksia.composeapp.generated.resources.Res import banksia.composeapp.generated.resources.compose_multiplatform +import moe.lava.banksia.native.maps.Maps @Composable @Preview fun App() { MaterialTheme { - var showContent by remember { mutableStateOf(false) } - Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) { - Button(onClick = { showContent = !showContent }) { - Text("Click me!") - } - AnimatedVisibility(showContent) { - val greeting = remember { Greeting().greet() } - Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) { - Image(painterResource(Res.drawable.compose_multiplatform), null) - Text("Compose: $greeting") - } - } + Scaffold { + Maps(modifier = Modifier.fillMaxSize()) } } } \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/moe/lava/banksia/native/maps/Maps.kt b/composeApp/src/commonMain/kotlin/moe/lava/banksia/native/maps/Maps.kt index 79bd541..101a288 100644 --- a/composeApp/src/commonMain/kotlin/moe/lava/banksia/native/maps/Maps.kt +++ b/composeApp/src/commonMain/kotlin/moe/lava/banksia/native/maps/Maps.kt @@ -7,6 +7,6 @@ data class Marker(val name: String) @Composable expect fun Maps( - modifier: Modifier, - markers: List + modifier: Modifier = Modifier, + markers: List = listOf() ) \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 82583de..2fe6191 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -16,6 +16,9 @@ junit = "4.13.2" kotlin = "2.1.10" ktor = "3.1.1" logback = "1.5.17" +mapsCompose = "6.4.1" +playServicesMaps = "19.1.0" +secretsGradlePlugin = "2.0.1" [libraries] kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } @@ -34,6 +37,9 @@ logback = { module = "ch.qos.logback:logback-classic", version.ref = "logback" } ktor-server-core = { module = "io.ktor:ktor-server-core-jvm", version.ref = "ktor" } ktor-server-netty = { module = "io.ktor:ktor-server-netty-jvm", version.ref = "ktor" } ktor-server-tests = { module = "io.ktor:ktor-server-test-host", version.ref = "ktor" } +maps-compose = { module = "com.google.maps.android:maps-compose", version.ref = "mapsCompose" } +play-services-maps = { module = "com.google.android.gms:play-services-maps", version.ref = "playServicesMaps" } +secrets-gradle-plugin = { module = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin", version.ref = "secretsGradlePlugin" } [plugins] androidApplication = { id = "com.android.application", version.ref = "agp" } @@ -42,4 +48,5 @@ composeMultiplatform = { id = "org.jetbrains.compose", version.ref = "compose-mu composeCompiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } ktor = { id = "io.ktor.plugin", version.ref = "ktor" } -kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } \ No newline at end of file +kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } +secretsGradle = { id = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin" } \ No newline at end of file