Skip to content

Commit

Permalink
Migrate to compose multiplatform
Browse files Browse the repository at this point in the history
  • Loading branch information
w2sv committed Jun 24, 2024
1 parent dda946d commit f271341
Show file tree
Hide file tree
Showing 140 changed files with 90 additions and 66 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.compose.compiler) apply false
alias(libs.plugins.compose) apply false
alias(libs.plugins.kover) apply false
}
5 changes: 0 additions & 5 deletions composed-permissions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ android {
compose = true
buildConfig = false
}
publishing {
singleVariant("release") {
withSourcesJar()
}
}
}

publishing {
Expand Down
121 changes: 72 additions & 49 deletions composed/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,48 @@
plugins {
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.android.library)
alias(libs.plugins.kover)
// alias(libs.plugins.kover)
alias(libs.plugins.compose)
alias(libs.plugins.kotlin.compose.compiler)
`maven-publish`
}

kotlin {
jvmToolchain(17)
applyDefaultHierarchyTemplate()
androidTarget {
publishLibraryVariants("release")
// publishAllLibraryVariants()
}
jvm()
macosX64()
macosArm64()

listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64(),
)
.forEach { target ->
target.binaries.framework {
baseName = "composed"
}
}

sourceSets {
commonMain.dependencies {
implementation(compose.material3)
implementation(compose.ui)
implementation(libs.jetbrains.androidx.lifecycle)
implementation(libs.androidx.annotation)
implementation(libs.androidx.core.ktx)
}
commonTest.dependencies {
implementation(kotlin("test"))
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.uiTest)
}
}
}

android {
Expand Down Expand Up @@ -43,55 +78,43 @@ android {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
publishing {
singleVariant("release") {
withSourcesJar()
}
dependencies {
lintChecks(libs.compose.lint.checks)
testImplementation(libs.androidx.compose.ui.test.junit4.android)
testImplementation(libs.roboelectric)
}
}

tasks.withType(Test::class.java) {
android.sourceSets.getByName("main").res.srcDir("src/test/res")
}

publishing {
publications {
register<MavenPublication>("release") {
groupId = "com.w2sv.composed"
artifactId = "composed"
version = version.toString()
pom {
developers {
developer {
id.set("w2sv")
name.set("Janek Zangenberg")
}
}
description.set("Generic utils for development with Jetpack Compose.")
url.set("https://github.com/w2sv/Composed")
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
}

afterEvaluate {
from(components["release"])
}
}
tasks.withType(Test::class.java) {
android.sourceSets.getByName("main").res.srcDir("src/androidUnitTest/res")
}
}

dependencies {
implementation(libs.compose.ui)
implementation(libs.compose.ui.tooling)
implementation(libs.compose.material3)
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.annotation)
lintChecks(libs.compose.lint.checks)
testImplementation(libs.junit)
testImplementation(libs.roboelectric)
testImplementation(libs.androidx.ui.test.junit4.android)
}
//publishing {
// publications {
// register<MavenPublication>("release") {
// groupId = "com.w2sv.composed"
// artifactId = "composed"
// version = version.toString()
// pom {
// developers {
// developer {
// id.set("w2sv")
// name.set("Janek Zangenberg")
// }
// }
// description.set("Generic utils for development with Jetpack Compose.")
// url.set("https://github.com/w2sv/Composed")
// licenses {
// license {
// name.set("The Apache Software License, Version 2.0")
// url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
// }
// }
// }
//
// afterEvaluate {
// from(components["release"])
// }
// }
// }
//}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.w2sv.composed

import android.annotation.SuppressLint
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
Expand All @@ -12,7 +11,6 @@ import kotlinx.coroutines.flow.collectLatest
/**
* Collect from [flow] and emit values into [collector], whilst relaunching the collection upon [flow], [key1] or [key2] changing.
*/
@SuppressLint("ComposeParameterOrder")
@Composable
fun <T> CollectFromFlow(
flow: Flow<T>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.w2sv.composed

import android.annotation.SuppressLint
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
Expand All @@ -17,7 +16,7 @@ import androidx.compose.ui.Modifier
*/
@Composable
fun <T> InterElementDividedColumn(
@SuppressLint("ComposeUnstableCollections") elements: List<T>,
elements: List<T>,
makeElement: @Composable ColumnScope.(T) -> Unit,
modifier: Modifier = Modifier,
makeDivider: @Composable ColumnScope.() -> Unit = { HorizontalDivider() },
Expand All @@ -43,7 +42,7 @@ fun <T> InterElementDividedColumn(
*/
@Composable
fun <T> InterElementDividedRow(
@SuppressLint("ComposeUnstableCollections") elements: List<T>,
elements: List<T>,
makeElement: @Composable RowScope.(T) -> Unit,
modifier: Modifier = Modifier,
makeDivider: @Composable RowScope.() -> Unit = { VerticalDivider() },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.w2sv.composed.extensions

import org.junit.Assert.assertEquals
import org.junit.Test
import kotlin.test.Test
import kotlin.test.assertEquals

class MapKtTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import junit.framework.TestCase.assertEquals
import org.junit.Test
import kotlin.test.Test
import kotlin.test.assertEquals

class ModifierKtTest {

Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ android.enableJetifier=true
# https://developer.android.com/studio/releases/gradle-plugin#4.1-nontransitive-r-class
android.nonTransitiveRClass=true

kotlin.native.ignoreDisabledTargets=true
kotlin.code.style=official

org.jetbrains.compose.experimental.macos.enabled=true

# Removes uneccessary default build features
android.defaults.buildfeatures.aidl=false
android.defaults.buildfeatures.buildconfig=false
Expand Down
10 changes: 7 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ compileSdk = "34"
kotlin = "2.0.0"
agp = "8.3.2"
kover = "0.7.6"
compose-multiplatform = "1.6.11"

compose-ui = "1.6.8"
compose-material3 = "1.2.1"
androidx-core-ktx = "1.13.1"
androidx-annotation = "1.8.0"
google-accompanist-permissions = "0.34.0"
lifecycle = "2.8.0"
compose-lint-checks = "1.3.1"
junit = "4.13.2"
uiTestJunit4Android = "1.6.8"
Expand All @@ -23,15 +25,17 @@ compose-material3 = { module = "androidx.compose.material3:material3", version.r
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidx-core-ktx" }
androidx-annotation = { module = "androidx.annotation:annotation", version.ref = "androidx-annotation" }
google-accompanist-permissions = { module = "com.google.accompanist:accompanist-permissions", version.ref = "google-accompanist-permissions" }

jetbrains-androidx-lifecycle = { module = "org.jetbrains.androidx.lifecycle:lifecycle-runtime", version.ref = "lifecycle" }
compose-lint-checks = { module = "com.slack.lint.compose:compose-lint-checks", version.ref = "compose-lint-checks" }

junit = { module = "junit:junit", version.ref = "junit" }
androidx-ui-test-junit4-android = { group = "androidx.compose.ui", name = "ui-test-junit4-android", version.ref = "uiTestJunit4Android" }
androidx-compose-ui-test-junit4-android = { group = "androidx.compose.ui", name = "ui-test-junit4-android", version.ref = "uiTestJunit4Android" }
roboelectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" }

[plugins]
compose = { id = "org.jetbrains.compose", version.ref = "compose-multiplatform" }
android-library = { id = "com.android.library", version.ref = "agp" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlin-compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }

0 comments on commit f271341

Please sign in to comment.