Skip to content
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

Multiplatform Voyager #33

Merged
merged 7 commits into from
Dec 16, 2021
Merged
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
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ org.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8
android.useAndroidX=true
android.enableJetifier=true
kotlin.code.style=official
kotlin.mpp.enableGranularSourceSetsMetadata=true

# Maven
GROUP=cafe.adriel.voyager
Expand Down
4 changes: 3 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
plugin-android = "7.0.3"
plugin-ktlint = "10.2.0"
plugin-maven = "0.18.0"
plugin-multiplatform-compose = "1.0.0"

kotlin = "1.5.31"
kodein = "7.8.0"
Expand All @@ -21,6 +22,7 @@ plugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.
plugin-ktlint = { module = "org.jlleitschuh.gradle:ktlint-gradle", version.ref = "plugin-ktlint" }
plugin-maven = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "plugin-maven" }
plugin-hilt = { module = "com.google.dagger:hilt-android-gradle-plugin", version.ref = "hilt" }
plugin-multiplatform-compose = { module = "org.jetbrains.compose:compose-gradle-plugin", version.ref = "plugin-multiplatform-compose" }

leakCanary = { module = "com.squareup.leakcanary:leakcanary-android", version.ref = "leakCanary" }
kodein = { module = "org.kodein.di:kodein-di-framework-compose", version.ref = "kodein" }
Expand All @@ -47,4 +49,4 @@ junit-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref
junit-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit" }

[bundles]
plugins = ["plugin-android", "plugin-ktlint", "plugin-maven", "plugin-kotlin", "plugin-hilt"]
plugins = ["plugin-android", "plugin-ktlint", "plugin-maven", "plugin-kotlin", "plugin-hilt", "plugin-multiplatform-compose"]
20 changes: 0 additions & 20 deletions voyager-core/build.gradle

This file was deleted.

61 changes: 61 additions & 0 deletions voyager-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
plugins {
kotlin("multiplatform")
id("com.android.library")
id("org.jetbrains.compose")
id("com.vanniktech.maven.publish")
}

kotlin {
explicitApi()

android {
publishAllLibraryVariants()
}
jvm("desktop")

sourceSets {
/* Source sets structure
common
├─ jvm
├─ android
├─ desktop
*/
val commonMain by getting
val jvmMain by creating {
dependsOn(commonMain)
dependencies {
implementation(compose.runtime)
implementation(compose.ui)
}
}
val desktopMain by getting {
dependsOn(jvmMain)
}
val androidMain by getting {
dependsOn(jvmMain)
}
val commonTest by getting
val jvmTest by creating {
dependsOn(commonTest)
}
val desktopTest by getting {
dependsOn(jvmTest)
}
val androidTest by getting {
dependsOn(jvmTest)
dependencies {
implementation(libs.junit.api)
runtimeOnly(libs.junit.engine)
}
}
}
}

android {
compileSdk = 31
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdk = 21
targetSdk = 31
}
}
23 changes: 0 additions & 23 deletions voyager-navigator/build.gradle

This file was deleted.

61 changes: 61 additions & 0 deletions voyager-navigator/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
plugins {
kotlin("multiplatform")
id("com.android.library")
id("org.jetbrains.compose")
id("com.vanniktech.maven.publish")
}

kotlin {
explicitApi()

android {
publishAllLibraryVariants()
}
jvm("desktop")

sourceSets {
/* Source sets structure
common
├─ jvm
├─ android
├─ desktop
*/
val commonMain by getting
val jvmMain by creating {
dependsOn(commonMain)
dependencies {
api(projects.voyagerCore)
implementation(compose.runtime)
implementation(compose.ui)
}
}
val desktopMain by getting {
dependsOn(jvmMain)
}
val androidMain by getting {
dependsOn(jvmMain)
dependencies {
implementation(libs.compose.activity)
}
}
val commonTest by getting
val jvmTest by creating {
dependsOn(commonTest)
}
val desktopTest by getting {
dependsOn(jvmTest)
}
val androidTest by getting {
dependsOn(jvmTest)
}
}
}

android {
compileSdk = 31
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdk = 21
targetSdk = 31
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package cafe.adriel.voyager.navigator.internal

import androidx.activity.compose.BackHandler
import androidx.compose.runtime.Composable

@Composable
internal actual fun BackHandler(enabled: Boolean, onBack: () -> Unit) = BackHandler(enabled, onBack)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package cafe.adriel.voyager.navigator.internal

import androidx.compose.runtime.Composable

@Composable
internal actual fun BackHandler(enabled: Boolean, onBack: () -> Unit) {
println("Not implemented yet!")
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package cafe.adriel.voyager.navigator.internal

import androidx.activity.compose.BackHandler
import androidx.compose.runtime.Composable
import cafe.adriel.voyager.navigator.Navigator
import cafe.adriel.voyager.navigator.OnBackPressed

@Composable
internal expect fun BackHandler(enabled: Boolean = true, onBack: () -> Unit)

@Composable
internal fun NavigatorBackHandler(
navigator: Navigator,
Expand Down