diff --git a/navigation/build.gradle.kts b/navigation/build.gradle.kts index e858faf..b440af5 100644 --- a/navigation/build.gradle.kts +++ b/navigation/build.gradle.kts @@ -1,6 +1,6 @@ plugins { id(libs.plugins.configurations.compose.multiplatform.get().pluginId) - alias(libs.plugins.kotlin.parcelize) + alias(libs.plugins.kotlinx.serialization) } dependencies { @@ -20,4 +20,6 @@ dependencies { commonMainImplementation(projects.feature.system.domain) commonMainImplementation(projects.feature.system.presentation) + + commonMainImplementation(libs.kotlinx.serialization) } \ No newline at end of file diff --git a/navigation/src/commonMain/kotlin/io/timemates/app/navigation/Navigator.kt b/navigation/src/commonMain/kotlin/io/timemates/app/navigation/Navigator.kt index a02e255..a650b22 100644 --- a/navigation/src/commonMain/kotlin/io/timemates/app/navigation/Navigator.kt +++ b/navigation/src/commonMain/kotlin/io/timemates/app/navigation/Navigator.kt @@ -14,7 +14,8 @@ import com.arkivanov.decompose.extensions.compose.jetbrains.subscribeAsState import com.arkivanov.decompose.router.stack.ChildStack import com.arkivanov.decompose.router.stack.StackNavigationSource import com.arkivanov.decompose.router.stack.childStack -import com.arkivanov.essenty.parcelable.Parcelable +import kotlinx.serialization.KSerializer +import kotlinx.serialization.builtins.nullable val LocalComponentContext: ProvidableCompositionLocal = staticCompositionLocalOf { error("Root component context was not provided") } @@ -25,7 +26,7 @@ fun ProvideComponentContext(componentContext: ComponentContext, content: @Compos } @Composable -inline fun ChildStack( +inline fun ChildStack( source: StackNavigationSource, noinline initialStack: () -> List, modifier: Modifier = Modifier, @@ -66,11 +67,10 @@ fun ChildStack( } @Composable -inline fun rememberChildStack( +inline fun rememberChildStack( source: StackNavigationSource, noinline initialStack: () -> List, key: String = "DefaultChildStack", - handleBackButton: Boolean = false, ): State> { val componentContext = LocalComponentContext.current @@ -78,9 +78,9 @@ inline fun rememberChildStack( componentContext.childStack( source = source, initialStack = initialStack, - key = key, - handleBackButton = handleBackButton, + handleBackButton = true, childFactory = { _, childComponentContext -> childComponentContext }, + serializer = Screen.serializer() as KSerializer, ) }.subscribeAsState() } \ No newline at end of file diff --git a/navigation/src/commonMain/kotlin/io/timemates/app/navigation/Screen.kt b/navigation/src/commonMain/kotlin/io/timemates/app/navigation/Screen.kt index 4903b08..5dac2fe 100644 --- a/navigation/src/commonMain/kotlin/io/timemates/app/navigation/Screen.kt +++ b/navigation/src/commonMain/kotlin/io/timemates/app/navigation/Screen.kt @@ -2,47 +2,49 @@ package io.timemates.app.navigation import com.arkivanov.essenty.parcelable.Parcelable import com.arkivanov.essenty.parcelable.Parcelize +import kotlinx.serialization.Serializable -sealed class Screen : Parcelable { +@Serializable +sealed class Screen { - @Parcelize + @Serializable data object Startup : Screen() { private fun readResolve(): Any = Startup } - @Parcelize + @Serializable data object InitialAuthorizationScreen : Screen() { private fun readResolve(): Any = InitialAuthorizationScreen } - @Parcelize + @Serializable data object StartAuthorization : Screen() { private fun readResolve(): Any = StartAuthorization } - @Parcelize + @Serializable data class AfterStart(val verificationHash: String) : Screen() - @Parcelize + @Serializable data class ConfirmAuthorization(val verificationHash: String) : Screen() - @Parcelize + @Serializable data class NewAccountInfo(val verificationHash: String) : Screen() - @Parcelize + @Serializable data class NewAccount(val verificationHash: String) : Screen() - @Parcelize + @Serializable data object TimersList : Screen() { private fun readResolve(): Any = TimersList } - @Parcelize + @Serializable data object TimerCreation : Screen() { private fun readResolve(): Any = TimerCreation } - @Parcelize + @Serializable data object TimerSettings : Screen() { private fun readResolve(): Any = TimerSettings } diff --git a/platforms/android/build.gradle.kts b/platforms/android/build.gradle.kts index 6a6d5b4..16099ca 100644 --- a/platforms/android/build.gradle.kts +++ b/platforms/android/build.gradle.kts @@ -12,6 +12,12 @@ android { multiDexEnabled = true } + packaging { + resources { + excludes += "/META-INF/{AL2.0,LGPL2.1}" + } + } + compileOptions { sourceCompatibility = JavaVersion.VERSION_19 targetCompatibility = JavaVersion.VERSION_19 diff --git a/platforms/android/src/main/kotlin/io/timemates/app/TimeMatesApplication.kt b/platforms/android/src/main/kotlin/io/timemates/app/TimeMatesApplication.kt index 1b8380e..a754327 100644 --- a/platforms/android/src/main/kotlin/io/timemates/app/TimeMatesApplication.kt +++ b/platforms/android/src/main/kotlin/io/timemates/app/TimeMatesApplication.kt @@ -20,10 +20,8 @@ class TimeMatesApplication : MultiDexApplication() { internal val onAuthFailedChannel: Channel = Channel() } - override fun attachBaseContext(base: Context) { - super.attachBaseContext(base) - MultiDex.install(this) - + override fun onCreate() { + super.onCreate() val (authDriver, usersDriver) = listOf( "authorization" to TimeMatesAuthorizations.Schema, "users" to TimeMatesUsers.Schema, @@ -45,4 +43,9 @@ class TimeMatesApplication : MultiDexApplication() { credentialsStorage, ) } + + override fun attachBaseContext(base: Context) { + super.attachBaseContext(base) + MultiDex.install(this) + } }