-
Notifications
You must be signed in to change notification settings - Fork 141
Add kmp modules for shareable domain and ui components #3595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1804a77
add kmp module for domain
andreia-ferreira 3ec9ff5
fix code style issues
andreia-ferreira aeb9e84
add ui kmp module
andreia-ferreira 6dc50e7
add composable for QR code
andreia-ferreira 88d0753
add domain module for the LOI report
andreia-ferreira 288ca87
Merge branch 'master' into andreia/3575/create-kmp-modules
andreia-ferreira c14c7c9
apply pr reviews
andreia-ferreira ae3e469
Merge branch 'master' into andreia/3575/create-kmp-modules
andreia-ferreira 418e6ff
Merge branch 'master' into andreia/3575/create-kmp-modules
andreia-ferreira d762443
remove unneeded import
andreia-ferreira File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /* | ||
| * Copyright 2026 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| plugins { | ||
| alias(libs.plugins.kotlin.multiplatform) | ||
| alias(libs.plugins.kotlin.serialization) | ||
| } | ||
|
|
||
| kotlin { | ||
| // We do not add an Android target here because this is a pure domain module. | ||
| // Adding an Android target would require the Android Gradle Plugin (AGP) and SDK configuration, | ||
| // which would couple the domain layer to platform-specific infrastructure. | ||
| // iOS targets are included because Kotlin can compile to iOS without any platform plugin. | ||
| jvm() | ||
| jvmToolchain(libs.versions.jvmToolchainVersion.get().toInt()) | ||
|
|
||
| iosX64() | ||
| iosArm64() | ||
| iosSimulatorArm64() | ||
|
|
||
| sourceSets { | ||
| commonMain { | ||
| dependencies { | ||
| implementation(libs.kotlin.stdlib) | ||
| implementation(libs.kotlinx.serialization.json) | ||
| } | ||
| } | ||
|
|
||
| commonTest { dependencies { implementation(libs.kotlin.test) } } | ||
| } | ||
| } | ||
21 changes: 21 additions & 0 deletions
21
core/domain/src/commonMain/kotlin/org/groundplatform/domain/model/LoiReport.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /* | ||
| * Copyright 2026 Google LLC | ||
andreia-ferreira marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.groundplatform.domain.model | ||
|
|
||
| import kotlinx.serialization.json.JsonObject | ||
|
|
||
| /** Represents the data collected for a specific LOI which can be downloaded and shared */ | ||
| data class LoiReport(val geoJson: JsonObject) | ||
andreia-ferreira marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /* | ||
| * Copyright 2026 Google LLC | ||
andreia-ferreira marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| plugins { | ||
| alias(libs.plugins.kotlin.multiplatform) | ||
| alias(libs.plugins.android.kotlin.multiplatform.library) | ||
| alias(libs.plugins.android.lint) | ||
| alias(libs.plugins.compose.multiplatform) | ||
| alias(libs.plugins.compose.compiler) | ||
| } | ||
|
|
||
| kotlin { | ||
| jvmToolchain(libs.versions.jvmToolchainVersion.get().toInt()) | ||
| androidLibrary { | ||
| namespace = "org.groundplatform.core.ui" | ||
| compileSdk = libs.versions.androidCompileSdk.get().toInt() | ||
| minSdk = libs.versions.androidMinSdk.get().toInt() | ||
| } | ||
|
|
||
| val xcfName = "GroundUiKit" | ||
|
|
||
| listOf(iosX64(), iosArm64(), iosSimulatorArm64()).forEach { | ||
| it.binaries.framework { | ||
| baseName = xcfName | ||
| isStatic = true | ||
| } | ||
| } | ||
|
|
||
| sourceSets { | ||
| commonMain { | ||
| dependencies { | ||
| implementation(libs.compose.runtime) | ||
| implementation(libs.compose.foundation) | ||
| implementation(libs.compose.material3) | ||
| implementation(libs.compose.ui) | ||
| implementation(libs.compose.ui.tooling.preview) | ||
| implementation(libs.compose.components.resources) | ||
| implementation(libs.androidx.lifecycle.runtime.compose) | ||
| implementation(libs.qrose) | ||
| } | ||
| } | ||
|
|
||
| commonTest { dependencies { implementation(libs.kotlin.test) } } | ||
|
|
||
| androidMain { dependencies {} } | ||
|
|
||
| iosMain { dependencies {} } | ||
| } | ||
| } | ||
|
|
||
| dependencies { androidRuntimeClasspath(libs.compose.ui.tooling) } | ||
65 changes: 65 additions & 0 deletions
65
core/ui/src/commonMain/kotlin/org/groundplatform/ui/components/GroundQrCode.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /* | ||
| * Copyright 2026 Google LLC | ||
andreia-ferreira marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.groundplatform.ui.components | ||
|
|
||
| import androidx.compose.foundation.Image | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.material3.MaterialTheme | ||
| import androidx.compose.material3.Surface | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.graphics.painter.Painter | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import io.github.alexzhirkevich.qrose.rememberQrCodePainter | ||
|
|
||
| /** | ||
| * Displays a QR code generated from the given [content] string. | ||
| * | ||
| * The composable is intentionally generic, it accepts any string payload, making it reusable for | ||
| * GeoJSON, URLs, or any other data that fits within QR code capacity limits. | ||
| */ | ||
| @Composable | ||
| fun GroundQrCode( | ||
| modifier: Modifier = Modifier, | ||
| content: String, | ||
| contentDescription: String, | ||
| centerLogoPainter: Painter?, | ||
| ) { | ||
andreia-ferreira marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| val qrcodePainter = | ||
| rememberQrCodePainter(data = content) { | ||
| if (centerLogoPainter != null) { | ||
| logo { painter = centerLogoPainter } | ||
| } | ||
| } | ||
|
|
||
| Image(painter = qrcodePainter, contentDescription = contentDescription, modifier = modifier) | ||
| } | ||
|
|
||
| @Preview | ||
| @Composable | ||
| private fun GroundQrCodePreview() { | ||
| MaterialTheme { | ||
| Surface { | ||
| GroundQrCode( | ||
| modifier = Modifier.padding(16.dp), | ||
| content = "https://www.google.com", | ||
| contentDescription = "Google", | ||
| centerLogoPainter = null, | ||
| ) | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,3 +27,5 @@ plugins { | |
| } | ||
|
|
||
| include ':app', ':e2eTest' | ||
| include ':core:ui' | ||
| include ':core:domain' | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.