Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 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
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ root = true
charset = utf-8
insert_final_newline = true
max_line_length = 120
end_of_line = crlf
end_of_line = crlf

[*.{kt,kts}]
ktlint_function_naming_ignore_when_annotated_with = Composable
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,5 @@ google-services.json
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

*.DS_Store
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ configure<KtlintExtension> {
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")

version = libs.findVersion("ktlint").get().toString()
disabledRules = setOf("filename")
}
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ android.library.defaults.buildfeatures.androidresources=false

# Kotlin
kotlin.code.style=official
kotlin.native.useEmbeddableCompilerJar=true
kotlin.native.ignoreDisabledTargets=true
kotlin.mpp.stability.nowarn=true

Expand Down
31 changes: 17 additions & 14 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
[versions]
agp = "8.11.0"
kotlin = "2.2.0"
agp = "8.12.2"
kotlin = "2.2.21"
mavenPublish = "0.33.0"
composeMultiplatform = "1.8.2"
binaryCompatibilityValidator = "0.18.0"
composeMultiplatform = "1.10.3"
binaryCompatibilityValidator = "0.18.1"
atomicfu = "0.29.0"
ktlint = "0.47.1"
ktlintPlugin = "12.3.0"
ktlint = "1.0.1"
ktlintPlugin = "13.0.0"

coroutines = "1.10.2"
kodein = "7.21.2"
koin-compose = "4.1.0"
kodein = "7.29.0"
koin-compose = "4.1.1"
hilt = "2.56.2"
lifecycle = "2.9.1"
activityCompose = "1.10.1"
rxjava = "3.1.10"
lifecycle = "2.10.0"
activityCompose = "1.12.0"
rxjava = "3.1.12"

androidxKmp-bundle = "1.0.1"
androidxKmp-lifecycle = "2.9.1"
androidxKmp-lifecycle = "2.10.0"

junit = "5.13.2"

Expand All @@ -41,10 +40,14 @@ androidx-lifecycle-livedata = { module = "androidx.lifecycle:lifecycle-livedata-
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activityCompose" }
rxjava = { module = "io.reactivex.rxjava3:rxjava", version.ref = "rxjava" }

androidxKmp-core-bundle = { module = "org.jetbrains.androidx.core:core-bundle", version.ref = "androidxKmp-bundle" }
androidxKmp-animation = { module = "org.jetbrains.compose.animation:animation", version.ref = "composeMultiplatform" }
androidxKmp-lifecycle-runtimeCompose = { module = "org.jetbrains.androidx.lifecycle:lifecycle-runtime-compose", version.ref = "androidxKmp-lifecycle" }
androidxKmp-lifecycle-viewmodel = { module = "org.jetbrains.androidx.lifecycle:lifecycle-viewmodel", version.ref = "androidxKmp-lifecycle" }
androidxKmp-lifecycle-viewmodelCompose = { module = "org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "androidxKmp-lifecycle" }
androidxKmp-material = { module = "org.jetbrains.compose.material:material", version.ref = "composeMultiplatform" }
androidxKmp-runtime = { module = "org.jetbrains.compose.runtime:runtime", version.ref = "composeMultiplatform" }
androidxKmp-runtime-saveable = { module = "org.jetbrains.compose.runtime:runtime-saveable", version.ref = "composeMultiplatform" }
androidxKmp-ui = { module = "org.jetbrains.compose.ui:ui", version.ref = "composeMultiplatform" }

junit-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" }
junit-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit" }
Expand Down
1 change: 1 addition & 0 deletions samples/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ android {
namespace = "cafe.adriel.voyager.sample"
defaultConfig {
applicationId = "cafe.adriel.voyager.sample"
minSdk = 23
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cafe.adriel.voyager.sample.liveDataIntegration

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.currentCompositeKeyHash
import androidx.compose.runtime.currentCompositeKeyHashCode
import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState
import cafe.adriel.voyager.core.model.rememberScreenModel
Expand All @@ -27,7 +27,7 @@ class LiveDataScreen : Screen {
else -> Unit
}

LaunchedEffect(currentCompositeKeyHash) {
LaunchedEffect(currentCompositeKeyHashCode) {
screenModel.getItems()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cafe.adriel.voyager.sample.rxJavaIntegration

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.currentCompositeKeyHash
import androidx.compose.runtime.currentCompositeKeyHashCode
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rxjava3.subscribeAsState
import cafe.adriel.voyager.core.model.rememberScreenModel
Expand All @@ -26,7 +26,7 @@ class RxJavaScreen : Screen {
is RxJavaScreenModel.State.Result -> ListContent(result.items)
}

LaunchedEffect(currentCompositeKeyHash) {
LaunchedEffect(currentCompositeKeyHashCode) {
screenModel.getItems()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cafe.adriel.voyager.sample.screenModel
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.currentCompositeKeyHash
import androidx.compose.runtime.currentCompositeKeyHashCode
import androidx.compose.runtime.getValue
import cafe.adriel.voyager.core.model.rememberScreenModel
import cafe.adriel.voyager.core.screen.Screen
Expand Down Expand Up @@ -31,7 +31,7 @@ data class DetailsScreen(
is DetailsScreenModel.State.Result -> DetailsContent(screenModel, result.item, navigator::pop)
}

LaunchedEffect(currentCompositeKeyHash) {
LaunchedEffect(currentCompositeKeyHashCode) {
screenModel.getItem(index)
}
}
Expand Down
1 change: 1 addition & 0 deletions samples/multi-module/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ android {
namespace = "cafe.adriel.voyager.sample.multimodule"
defaultConfig {
applicationId = "cafe.adriel.voyager.sample.multimodule"
minSdk = 23
}
}

Expand Down
7 changes: 4 additions & 3 deletions samples/multiplatform/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ android {
namespace = "cafe.adriel.voyager.sample.multiplatform"
defaultConfig {
applicationId = "cafe.adriel.voyager.sample.multiplatform"
minSdk = 23
}
}

Expand Down Expand Up @@ -83,9 +84,9 @@ kotlin {
implementation(projects.voyagerCore)
implementation(projects.voyagerNavigator)
implementation(projects.voyagerTransitions)
implementation(compose.runtime)
implementation(compose.ui)
implementation(compose.material)
implementation(libs.androidxKmp.runtime)
implementation(libs.androidxKmp.ui)
implementation(libs.androidxKmp.material)
implementation(libs.coroutines.core)
}
androidMain.dependencies {
Expand Down
4 changes: 2 additions & 2 deletions voyager-bottom-sheet-navigator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ kotlin {
commonMain.dependencies {
api(projects.voyagerCore)
api(projects.voyagerNavigator)
implementation(compose.runtime)
implementation(compose.material)
implementation(libs.androidxKmp.runtime)
implementation(libs.androidxKmp.material)
}
androidMain.dependencies {
implementation(libs.androidx.activity.compose)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ import androidx.activity.compose.BackHandler
import androidx.compose.runtime.Composable

@Composable
internal actual fun BackHandler(enabled: Boolean, onBack: () -> Unit) =
BackHandler(enabled, onBack)
internal actual fun BackHandler(
enabled: Boolean,
onBack: () -> Unit,
) = BackHandler(enabled, onBack)
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,16 @@ public fun BottomSheetNavigator(
animationSpec: AnimationSpec<Float> = ModalBottomSheetDefaults.AnimationSpec,
key: String = compositionUniqueId(),
sheetContent: BottomSheetNavigatorContent = { CurrentScreen() },
content: BottomSheetNavigatorContent
content: BottomSheetNavigatorContent,
) {
var hideBottomSheet: (() -> Unit)? = null
val coroutineScope = rememberCoroutineScope()
val sheetState = rememberModalBottomSheetState(
initialValue = ModalBottomSheetValue.Hidden,
skipHalfExpanded = skipHalfExpanded,
animationSpec = animationSpec
)
val sheetState =
rememberModalBottomSheetState(
initialValue = ModalBottomSheetValue.Hidden,
skipHalfExpanded = skipHalfExpanded,
animationSpec = animationSpec,
)

LaunchedEffect(sheetState, sheetState.currentValue) {
if (sheetState.currentValue == ModalBottomSheetValue.Hidden) {
Expand All @@ -70,9 +71,10 @@ public fun BottomSheetNavigator(
}

Navigator(HiddenBottomSheetScreen, onBackPressed = null, key = key) { navigator ->
val bottomSheetNavigator = remember(navigator, sheetState, coroutineScope) {
BottomSheetNavigator(navigator, sheetState, coroutineScope)
}
val bottomSheetNavigator =
remember(navigator, sheetState, coroutineScope) {
BottomSheetNavigator(navigator, sheetState, coroutineScope)
}

hideBottomSheet = bottomSheetNavigator::hide

Expand All @@ -92,52 +94,52 @@ public fun BottomSheetNavigator(
},
content = {
content(bottomSheetNavigator)
}
},
)
}
}
}

@OptIn(ExperimentalMaterialApi::class)
public class BottomSheetNavigator @InternalVoyagerApi constructor(
private val navigator: Navigator,
private val sheetState: ModalBottomSheetState,
private val coroutineScope: CoroutineScope
) : Stack<Screen> by navigator {
public class BottomSheetNavigator
@InternalVoyagerApi
constructor(
private val navigator: Navigator,
private val sheetState: ModalBottomSheetState,
private val coroutineScope: CoroutineScope,
) : Stack<Screen> by navigator {
public val isVisible: Boolean
get() = sheetState.isVisible

public val isVisible: Boolean
get() = sheetState.isVisible

public fun show(screen: Screen) {
coroutineScope.launch {
replaceAll(screen)
sheetState.show()
public fun show(screen: Screen) {
coroutineScope.launch {
replaceAll(screen)
sheetState.show()
}
}
}

public fun hide() {
coroutineScope.launch {
if (isVisible) {
sheetState.hide()
replaceAll(HiddenBottomSheetScreen)
} else if (sheetState.targetValue == ModalBottomSheetValue.Hidden) {
// Swipe down - sheetState is already hidden here so `isVisible` is false
replaceAll(HiddenBottomSheetScreen)
public fun hide() {
coroutineScope.launch {
if (isVisible) {
sheetState.hide()
replaceAll(HiddenBottomSheetScreen)
} else if (sheetState.targetValue == ModalBottomSheetValue.Hidden) {
// Swipe down - sheetState is already hidden here so `isVisible` is false
replaceAll(HiddenBottomSheetScreen)
}
}
}
}

@Composable
public fun saveableState(
key: String,
content: @Composable () -> Unit
) {
navigator.saveableState(key, content = content)
@Composable
public fun saveableState(
key: String,
content: @Composable () -> Unit,
) {
navigator.saveableState(key, content = content)
}
}
}

private object HiddenBottomSheetScreen : Screen {

@Composable
override fun Content() {
Spacer(modifier = Modifier.height(1.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ import androidx.compose.runtime.Composable
import cafe.adriel.voyager.navigator.bottomSheet.BottomSheetNavigator

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

@ExperimentalMaterialApi
@Composable
internal fun BottomSheetNavigatorBackHandler(
navigator: BottomSheetNavigator,
sheetState: ModalBottomSheetState,
hideOnBackPress: Boolean
hideOnBackPress: Boolean,
) {
BackHandler(enabled = sheetState.isVisible) {
if (navigator.pop().not() && hideOnBackPress) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ package cafe.adriel.voyager.navigator.bottomSheet.internal
import androidx.compose.runtime.Composable

@Composable
internal actual fun BackHandler(enabled: Boolean, onBack: () -> Unit) = Unit
internal actual fun BackHandler(
enabled: Boolean,
onBack: () -> Unit,
) = Unit
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ package cafe.adriel.voyager.navigator.bottomSheet.internal
import androidx.compose.runtime.Composable

@Composable
internal actual fun BackHandler(enabled: Boolean, onBack: () -> Unit) = Unit
internal actual fun BackHandler(
enabled: Boolean,
onBack: () -> Unit,
) = Unit
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ import androidx.compose.runtime.Composable

// TODO: use ios backstack
@Composable
internal actual fun BackHandler(enabled: Boolean, onBack: () -> Unit) = Unit
internal actual fun BackHandler(
enabled: Boolean,
onBack: () -> Unit,
) = Unit
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ package cafe.adriel.voyager.navigator.bottomSheet.internal
import androidx.compose.runtime.Composable

@Composable
internal actual fun BackHandler(enabled: Boolean, onBack: () -> Unit) = Unit
internal actual fun BackHandler(
enabled: Boolean,
onBack: () -> Unit,
) = Unit
4 changes: 2 additions & 2 deletions voyager-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
kotlin {
sourceSets {
commonMain.dependencies {
implementation(compose.runtime)
implementation(compose.runtimeSaveable)
implementation(libs.androidxKmp.runtime)
implementation(libs.androidxKmp.runtime.saveable)
implementation(libs.coroutines.core)
}
commonJvmTest.dependencies {
Expand Down
Loading
Loading