Skip to content

Commit 73c4625

Browse files
committed
Migrate foundation to KMP
1 parent cd23674 commit 73c4625

13 files changed

Lines changed: 121 additions & 26 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
.externalNativeBuild
44
.cxx
55
*.iml
6+
.idea/artifacts
67
.idea/caches
78
.idea/compiler.xml
89
.idea/deviceManager.xml
@@ -40,3 +41,6 @@ app/src/main/res/raw/changelog.md
4041

4142
# Mustache output
4243
Module.md
44+
45+
# Kotlin Multiplatform
46+
.kotlin/

app/src/main/java/com/orange/ouds/app/ui/ChangeThemeSettingsDialog.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@ package com.orange.ouds.app.ui
1515
import androidx.annotation.StringRes
1616
import androidx.compose.foundation.layout.Arrangement
1717
import androidx.compose.foundation.layout.Column
18-
import androidx.compose.foundation.layout.Row
1918
import androidx.compose.foundation.layout.fillMaxWidth
2019
import androidx.compose.foundation.layout.padding
2120
import androidx.compose.runtime.Composable
2221
import androidx.compose.runtime.getValue
2322
import androidx.compose.runtime.mutableStateOf
2423
import androidx.compose.runtime.saveable.rememberSaveable
2524
import androidx.compose.runtime.setValue
26-
import androidx.compose.ui.Alignment
2725
import androidx.compose.ui.Modifier
2826
import androidx.compose.ui.res.stringResource
2927
import androidx.compose.ui.tooling.preview.PreviewLightDark

app/src/main/java/com/orange/ouds/app/ui/components/ComponentVariantsScreen.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,11 @@ package com.orange.ouds.app.ui.components
1414

1515
import androidx.compose.foundation.clickable
1616
import androidx.compose.foundation.layout.PaddingValues
17-
import androidx.compose.foundation.layout.WindowInsets
18-
import androidx.compose.foundation.layout.WindowInsetsSides
19-
import androidx.compose.foundation.layout.asPaddingValues
20-
import androidx.compose.foundation.layout.consumeWindowInsets
2117
import androidx.compose.foundation.layout.fillMaxWidth
22-
import androidx.compose.foundation.layout.only
2318
import androidx.compose.foundation.layout.padding
24-
import androidx.compose.foundation.layout.statusBars
2519
import androidx.compose.foundation.lazy.LazyColumn
2620
import androidx.compose.foundation.lazy.items
2721
import androidx.compose.material3.Text
28-
import androidx.compose.material3.TopAppBarDefaults
2922
import androidx.compose.runtime.Composable
3023
import androidx.compose.ui.Modifier
3124
import androidx.compose.ui.res.stringResource

build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import com.orange.ouds.gradle.releaseVersion
1616
plugins {
1717
kotlin("jvm")
1818
alias(libs.plugins.compose.compiler) apply false
19+
alias(libs.plugins.compose.multiplatform) apply false
20+
id(libs.plugins.kotlin.multiplatform.get().pluginId) apply false
1921
id(libs.plugins.firebase.appdistribution.get().pluginId) apply false
2022
alias(libs.plugins.firebase.crashlytics) apply false
2123
alias(libs.plugins.google.services) apply false

foundation/build.gradle.kts

Lines changed: 96 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,105 @@
1111
*/
1212

1313
plugins {
14-
id("library")
1514
alias(libs.plugins.compose.compiler)
15+
alias(libs.plugins.compose.multiplatform)
16+
id(libs.plugins.kotlin.multiplatform.get().pluginId)
17+
id(libs.plugins.android.kotlin.multiplatform.library.get().pluginId)
1618
}
1719

18-
android {
19-
namespace = "com.orange.ouds.foundation"
20+
kotlin {
21+
jvmToolchain(17)
2022

21-
buildFeatures {
22-
compose = true
23+
// Target declarations - add or remove as needed below. These define
24+
// which platforms this KMP module supports.
25+
// See: https://kotlinlang.org/docs/multiplatform-discover-project.html#targets
26+
android {
27+
namespace = "com.orange.ouds.foundation"
28+
compileSdk = libs.versions.androidCompileSdk.get().toInt()
29+
minSdk = libs.versions.androidMinSdk.get().toInt()
30+
31+
withHostTestBuilder {
32+
}
33+
34+
withDeviceTestBuilder {
35+
sourceSetTreeName = "test"
36+
}.configure {
37+
instrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
38+
}
39+
}
40+
41+
// For iOS targets, this is also where you should
42+
// configure native binary output. For more information, see:
43+
// https://kotlinlang.org/docs/multiplatform-build-native-binaries.html#build-xcframeworks
44+
45+
// A step-by-step guide on how to include this library in an XCode
46+
// project can be found here:
47+
// https://developer.android.com/kotlin/multiplatform/migrate
48+
val xcfName = "oudsFoundation"
49+
50+
iosX64 {
51+
binaries.framework {
52+
baseName = xcfName
53+
}
54+
}
55+
56+
iosArm64 {
57+
binaries.framework {
58+
baseName = xcfName
59+
}
2360
}
24-
}
2561

26-
dependencies {
27-
implementation(platform(libs.androidx.compose.bom))
28-
implementation(libs.androidx.compose.ui)
29-
api(libs.androidx.compose.ui.tooling.preview)
30-
}
62+
iosSimulatorArm64 {
63+
binaries.framework {
64+
baseName = xcfName
65+
}
66+
}
67+
68+
// Source set declarations.
69+
// Declaring a target automatically creates a source set with the same name. By default, the
70+
// Kotlin Gradle Plugin creates additional source sets that depend on each other, since it is
71+
// common to share sources between related targets.
72+
// See: https://kotlinlang.org/docs/multiplatform-hierarchy.html
73+
sourceSets {
74+
commonMain {
75+
dependencies {
76+
implementation(libs.kotlin.stdlib)
77+
// Add KMP dependencies here
78+
implementation(libs.compose.ui)
79+
}
80+
}
81+
82+
commonTest {
83+
dependencies {
84+
implementation(libs.kotlin.test)
85+
}
86+
}
87+
88+
androidMain {
89+
dependencies {
90+
// Add Android-specific dependencies here. Note that this source set depends on
91+
// commonMain by default and will correctly pull the Android artifacts of any KMP
92+
// dependencies declared in commonMain.
93+
api(libs.androidx.compose.ui.tooling.preview)
94+
}
95+
}
96+
97+
getByName("androidDeviceTest") {
98+
dependencies {
99+
implementation(libs.androidx.junit)
100+
implementation(libs.androidx.runner)
101+
implementation(libs.core)
102+
}
103+
}
104+
105+
iosMain {
106+
dependencies {
107+
// Add iOS-specific dependencies here. This a source set created by Kotlin Gradle
108+
// Plugin (KGP) that each specific iOS target (e.g., iosX64) depends on as
109+
// part of KMP’s default source set hierarchy. Note that this source set depends
110+
// on common by default and will correctly pull the iOS artifacts of any
111+
// KMP dependencies declared in commonMain.
112+
}
113+
}
114+
}
115+
}
File renamed without changes.

foundation/src/main/java/com/orange/ouds/foundation/ExperimentalOudsApi.kt renamed to foundation/src/commonMain/kotlin/com/orange/ouds/foundation/ExperimentalOudsApi.kt

File renamed without changes.

foundation/src/main/java/com/orange/ouds/foundation/InternalOudsApi.kt renamed to foundation/src/commonMain/kotlin/com/orange/ouds/foundation/InternalOudsApi.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* the text of which is available at https://opensource.org/license/MIT/
88
* or see the "LICENSE" file for more details.
99
*
10-
* Software description: Android library of reusable graphical components
10+
* Software description: Android library of reusable graphical components
1111
*/
1212

1313
package com.orange.ouds.foundation

foundation/src/main/java/com/orange/ouds/foundation/RestrictedOudsApi.kt renamed to foundation/src/commonMain/kotlin/com/orange/ouds/foundation/RestrictedOudsApi.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* the text of which is available at https://opensource.org/license/MIT/
88
* or see the "LICENSE" file for more details.
99
*
10-
* Software description: Android library of reusable graphical components
10+
* Software description: Android library of reusable graphical components
1111
*/
1212

1313
package com.orange.ouds.foundation

foundation/src/main/java/com/orange/ouds/foundation/extensions/StandardExt.kt renamed to foundation/src/commonMain/kotlin/com/orange/ouds/foundation/extensions/StandardExt.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* the text of which is available at https://opensource.org/license/MIT/
88
* or see the "LICENSE" file for more details.
99
*
10-
* Software description: Android library of reusable graphical components
10+
* Software description: Android library of reusable graphical components
1111
*/
1212

1313
package com.orange.ouds.foundation.extensions

0 commit comments

Comments
 (0)