Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
/buildSrc/build/*
.DS_Store
/build
*/build/
/captures
.externalNativeBuild
.kotlin
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ plugins {
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.compose) apply false
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.compose.multiplatform) apply false
alias(libs.plugins.maven.publish) apply false
alias(libs.plugins.detekt)
signing
Expand Down
24 changes: 23 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ material = "1.12.0"
# Compose
androidxComposeBom = "2025.08.00"

# Compose Multiplatform
composeMultiplatform = "1.6.10"

[libraries]

# Gradle plugins
Expand Down Expand Up @@ -46,13 +49,24 @@ androidx-compose-animation = { group = "androidx.compose.animation", name = "ani
androidx-compose-layout = { group = "androidx.compose.foundation", name = "foundation-layout" }
androidx-compose-runtime = { group = "androidx.compose.runtime", name = "runtime" }

# Compose Multiplatform
compose-mpp-runtime = { group = "org.jetbrains.compose.runtime", name = "runtime", version.ref = "composeMultiplatform" }
compose-mpp-ui = { group = "org.jetbrains.compose.ui", name = "ui", version.ref = "composeMultiplatform" }
compose-mpp-foundation = { group = "org.jetbrains.compose.foundation", name = "foundation", version.ref = "composeMultiplatform" }
compose-mpp-animation = { group = "org.jetbrains.compose.animation", name = "animation", version.ref = "composeMultiplatform" }
compose-mpp-material3 = { group = "org.jetbrains.compose.material3", name = "material3", version.ref = "composeMultiplatform" }

[plugins]
# Build plugins
android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }

# Compose Multiplatform
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
compose-multiplatform = { id = "org.jetbrains.compose", version.ref = "composeMultiplatform" }

# Quality plugins
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detektGradlePlugin" }

Expand All @@ -72,4 +86,12 @@ compose = [
"androidx-compose-material2",
"androidx-compose-animation",
"androidx-compose-layout"
]
]

compose-mpp = [
"compose-mpp-runtime",
"compose-mpp-ui",
"compose-mpp-foundation",
"compose-mpp-animation",
"compose-mpp-material3",
]
66 changes: 66 additions & 0 deletions library-compose-multiplatform/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
plugins {
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.android.library)
alias(libs.plugins.compose.multiplatform)
alias(libs.plugins.kotlin.compose)

id(libs.plugins.conventions.lint.get().pluginId)
}

kotlin {
jvmToolchain(ProjectSettings.Kotlin.JvmToolchainVersion)

// Android target
androidTarget {
compilations.all {
compileTaskProvider.configure {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
}
}
}
}

// iOS target
listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "DonutCompose"
isStatic = true
}
}

sourceSets {
val commonMain by getting {
dependencies {
implementation(libs.bundles.compose.mpp)
}
}

val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
}
}

android {
namespace = "app.futured.donut.cmp"
compileSdk = ProjectSettings.targetSdk

defaultConfig {
minSdk = ProjectSettings.minSdkLibraryCompose
}

testOptions {
targetSdk = ProjectSettings.targetSdk
}

lint {
targetSdk = ProjectSettings.targetSdk
}
}
11 changes: 11 additions & 0 deletions library-compose-multiplatform/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Gradle
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8

# Kotlin
kotlin.code.style=official
kotlin.mpp.androidSourceSetLayoutV2AndroidStyleDirs.nowarn=true
kotlin.mpp.applyDefaultHierarchyTemplate=false

# Android
android.useAndroidX=true
android.nonTransitiveRClass=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package app.futured.donut.cmp

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier

/**
* Simple Hello World composable for testing Compose Multiplatform setup.
* This will work on both Android and iOS.
*/
@Composable
fun HelloWorld() {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
Text(text = "Hello World from Compose Multiplatform! 🍩")
}
}
1 change: 1 addition & 0 deletions sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ android {
dependencies {
implementation(project(":library"))
implementation(project(":library-compose"))
implementation(project(":library-compose-multiplatform"))

implementation(platform(libs.androidx.compose.bom))
implementation(libs.bundles.compose)
Expand Down
4 changes: 4 additions & 0 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
<activity
android:name=".ui.playground.compose.PlaygroundComposeActivity"
android:exported="false"/>

<activity
android:name=".ui.helloworld.HelloWorldActivity"
android:exported="false"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package app.futured.donutsample.ui.helloworld

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ComposeView
import app.futured.donut.cmp.HelloWorld

class HelloWorldActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

val composeView = ComposeView(this)
setContentView(composeView)

composeView.setContent {
MaterialTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colors.background
) {
HelloWorld()
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.appcompat.app.AppCompatActivity
import app.futured.donutsample.R
import app.futured.donutsample.ui.playground.PlaygroundActivity
import app.futured.donutsample.ui.playground.compose.PlaygroundComposeActivity
import app.futured.donutsample.ui.helloworld.HelloWorldActivity

class MainActivity : AppCompatActivity() {

Expand All @@ -21,5 +22,9 @@ class MainActivity : AppCompatActivity() {
findViewById<View>(R.id.compose_sample_button).setOnClickListener {
startActivity(Intent(this, PlaygroundComposeActivity::class.java))
}

findViewById<View>(R.id.helloworld_sample_button).setOnClickListener {
startActivity(Intent(this, HelloWorldActivity::class.java))
}
}
}
13 changes: 12 additions & 1 deletion sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,21 @@
android:id="@+id/compose_sample_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="@string/navigate_to_compose_view"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="@+id/helloworld_sample_button"
app:layout_constraintTop_toBottomOf="@+id/android_view_sample_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

<Button
android:id="@+id/helloworld_sample_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/navigate_to_helloworld"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/compose_sample_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions sample/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@

<string name="navigate_to_android_view">Android View Sample</string>
<string name="navigate_to_compose_view">Jetpack Compose Sample</string>
<string name="navigate_to_helloworld">Hello World CMP</string>
</resources>
12 changes: 8 additions & 4 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
google()
mavenCentral()
gradlePluginPortal()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
}

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
google()
mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
}

rootProject.buildFileName = "build.gradle.kts"

include(":library")
include(":library-compose")
include(":library-compose-multiplatform")
include(":sample")

includeBuild("convention-plugins")
includeBuild("convention-plugins")
Loading