From 7486f64ea91466c9b5da36b20d4cd83d54f79677 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Fri, 12 May 2023 17:26:26 +0100 Subject: [PATCH 01/94] created multiplatform-common utility library to hold sharable Parcelable implementations --- settings.gradle.kts | 1 + utils/multiplatform-common/build.gradle.kts | 33 +++++++++++++++++++ .../utils/multiplatform_common/Parcelize.kt | 7 ++++ .../utils/multiplatform_common/Parcelable.kt | 11 +++++++ .../utils/multiplatform_common/Parcelable.kt | 8 +++++ .../utils/multiplatform_common/Parcelable.kt | 8 +++++ 6 files changed, 68 insertions(+) create mode 100644 utils/multiplatform-common/build.gradle.kts create mode 100644 utils/multiplatform-common/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelize.kt create mode 100644 utils/multiplatform-common/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelable.kt create mode 100644 utils/multiplatform-common/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelable.kt create mode 100644 utils/multiplatform-common/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelable.kt diff --git a/settings.gradle.kts b/settings.gradle.kts index 76637e278..d10a07c35 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -51,6 +51,7 @@ include( ":utils:testing-ui", ":utils:testing-ui-activity", ":utils:testing-unit-common", + ":utils:multiplatform-common", ) // do not remove this. Otherwise all multiplatform modules will produce clashing artifacts diff --git a/utils/multiplatform-common/build.gradle.kts b/utils/multiplatform-common/build.gradle.kts new file mode 100644 index 000000000..df14d0dbe --- /dev/null +++ b/utils/multiplatform-common/build.gradle.kts @@ -0,0 +1,33 @@ +plugins { + kotlin("multiplatform") + kotlin("plugin.serialization") + id("com.android.library") + id("kotlin-parcelize") + id("appyx-publish-multiplatform") +} + +kotlin { + android { + publishLibraryVariants("release") + } + jvm("desktop") { + compilations.all { + kotlinOptions.jvmTarget = libs.versions.jvmTarget.get() + } + } + js(IR) { + // Adding moduleName as a workaround for this issue: https://youtrack.jetbrains.com/issue/KT-51942 + moduleName = "appyx-utils-multiplatform-common" + browser() + } + sourceSets { + val commonMain by getting { + dependencies { + implementation(libs.kotlinx.serialization.json) + } + } + val androidMain by getting + val desktopMain by getting + val jsMain by getting + } +} diff --git a/utils/multiplatform-common/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelize.kt b/utils/multiplatform-common/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelize.kt new file mode 100644 index 000000000..29fd128db --- /dev/null +++ b/utils/multiplatform-common/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelize.kt @@ -0,0 +1,7 @@ +package com.bumble.appyx.utils.multiplatform_common + +actual typealias Parcelize = kotlinx.parcelize.Parcelize + +actual typealias Parcelable = android.os.Parcelable + +actual typealias RawValue = kotlinx.parcelize.RawValue diff --git a/utils/multiplatform-common/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelable.kt b/utils/multiplatform-common/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelable.kt new file mode 100644 index 000000000..cff50c3a8 --- /dev/null +++ b/utils/multiplatform-common/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelable.kt @@ -0,0 +1,11 @@ +package com.bumble.appyx.utils.multiplatform_common + +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.BINARY) +expect annotation class Parcelize() + +@Target(AnnotationTarget.TYPE) +@Retention(AnnotationRetention.BINARY) +expect annotation class RawValue() + +expect interface Parcelable \ No newline at end of file diff --git a/utils/multiplatform-common/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelable.kt b/utils/multiplatform-common/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelable.kt new file mode 100644 index 000000000..8d2422ac6 --- /dev/null +++ b/utils/multiplatform-common/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelable.kt @@ -0,0 +1,8 @@ +package com.bumble.appyx.utils.multiplatform_common + +actual annotation class Parcelize + +actual interface Parcelable + +@Target(AnnotationTarget.TYPE) +actual annotation class RawValue \ No newline at end of file diff --git a/utils/multiplatform-common/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelable.kt b/utils/multiplatform-common/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelable.kt new file mode 100644 index 000000000..8d2422ac6 --- /dev/null +++ b/utils/multiplatform-common/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelable.kt @@ -0,0 +1,8 @@ +package com.bumble.appyx.utils.multiplatform_common + +actual annotation class Parcelize + +actual interface Parcelable + +@Target(AnnotationTarget.TYPE) +actual annotation class RawValue \ No newline at end of file From 7c7893be9779eb01850c574e3be22378aae28fae Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Fri, 12 May 2023 17:58:35 +0100 Subject: [PATCH 02/94] removed Parcelize implementation from interactions module and replaced with new utilities module --- .../appyx/components/backstack/BackStackModel.kt | 4 ++-- .../appyx/components/backstack/operation/NewRoot.kt | 8 ++++---- .../bumble/appyx/components/backstack/operation/Pop.kt | 2 +- .../appyx/components/backstack/operation/Push.kt | 4 ++-- .../appyx/components/backstack/operation/Replace.kt | 8 ++++---- .../bumble/appyx/components/demos/cards/CardsModel.kt | 6 +++--- .../appyx/components/demos/cards/operation/VoteLike.kt | 6 +++--- .../appyx/components/demos/cards/operation/VotePass.kt | 4 ++-- .../appyx/components/demos/promoter/PromoterModel.kt | 4 ++-- .../components/demos/promoter/operation/AddFirst.kt | 8 ++++---- .../components/internal/testdrive/TestDriveModel.kt | 4 ++-- .../components/internal/testdrive/operation/MoveTo.kt | 2 +- .../components/internal/testdrive/operation/Next.kt | 2 +- .../appyx/components/spotlight/SpotlightModel.kt | 6 +++--- .../appyx/components/spotlight/operation/Activate.kt | 2 +- .../appyx/components/spotlight/operation/First.kt | 2 +- .../appyx/components/spotlight/operation/Last.kt | 2 +- .../appyx/components/spotlight/operation/Next.kt | 6 +++--- .../appyx/components/spotlight/operation/Previous.kt | 2 +- .../components/spotlight/operation/UpdateElements.kt | 4 ++-- appyx-interactions/common/build.gradle.kts | 1 + .../kotlin/com/bumble/appyx/interactions/platform.kt | 6 ------ .../com/bumble/appyx/interactions/core/Element.kt | 6 +++--- .../core/model/transition/BaseTransitionModel.kt | 6 ++++-- .../interactions/core/model/transition/Operation.kt | 4 ++-- .../appyx/interactions/permanent/PermanentModel.kt | 4 ++-- .../interactions/permanent/operation/AddUnique.kt | 4 ++-- .../kotlin/com/bumble/appyx/interactions/platform.kt | 10 ---------- .../appyx/interactions/core/TestTransitionModel.kt | 6 +++--- .../kotlin/com/bumble/appyx/interactions/platform.kt | 7 ------- .../kotlin/com/bumble/appyx/interactions/platform.kt | 7 ------- utils/multiplatform-common/build.gradle.kts | 10 ++++++++++ 32 files changed, 70 insertions(+), 87 deletions(-) diff --git a/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/BackStackModel.kt b/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/BackStackModel.kt index 8f45d1386..b2ec53a5d 100644 --- a/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/BackStackModel.kt +++ b/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/BackStackModel.kt @@ -1,13 +1,13 @@ package com.bumble.appyx.components.backstack import com.bumble.appyx.components.backstack.BackStackModel.State -import com.bumble.appyx.interactions.Parcelable -import com.bumble.appyx.interactions.Parcelize import com.bumble.appyx.interactions.core.Element import com.bumble.appyx.interactions.core.Elements import com.bumble.appyx.interactions.core.asElement import com.bumble.appyx.interactions.core.model.transition.BaseTransitionModel import com.bumble.appyx.interactions.core.state.SavedStateMap +import com.bumble.appyx.utils.multiplatform_common.Parcelable +import com.bumble.appyx.utils.multiplatform_common.Parcelize class BackStackModel( initialTargets: List, diff --git a/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/NewRoot.kt b/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/NewRoot.kt index b6372beff..61ee661bd 100644 --- a/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/NewRoot.kt +++ b/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/NewRoot.kt @@ -1,13 +1,13 @@ package com.bumble.appyx.components.backstack.operation import androidx.compose.animation.core.AnimationSpec -import com.bumble.appyx.interactions.Parcelize -import com.bumble.appyx.interactions.RawValue +import com.bumble.appyx.components.backstack.BackStack +import com.bumble.appyx.components.backstack.BackStackModel import com.bumble.appyx.interactions.core.asElement import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation -import com.bumble.appyx.components.backstack.BackStack -import com.bumble.appyx.components.backstack.BackStackModel +import com.bumble.appyx.utils.multiplatform_common.Parcelize +import com.bumble.appyx.utils.multiplatform_common.RawValue /** * Operation: diff --git a/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/Pop.kt b/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/Pop.kt index bc7c2b622..8ed398cf2 100644 --- a/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/Pop.kt +++ b/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/Pop.kt @@ -3,9 +3,9 @@ package com.bumble.appyx.components.backstack.operation import androidx.compose.animation.core.AnimationSpec import com.bumble.appyx.components.backstack.BackStack import com.bumble.appyx.components.backstack.BackStackModel.State -import com.bumble.appyx.interactions.Parcelize import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation +import com.bumble.appyx.utils.multiplatform_common.Parcelize /** * Operation: diff --git a/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/Push.kt b/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/Push.kt index 78c897131..109bd6f82 100644 --- a/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/Push.kt +++ b/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/Push.kt @@ -3,11 +3,11 @@ package com.bumble.appyx.components.backstack.operation import androidx.compose.animation.core.AnimationSpec import com.bumble.appyx.components.backstack.BackStack import com.bumble.appyx.components.backstack.BackStackModel -import com.bumble.appyx.interactions.Parcelize -import com.bumble.appyx.interactions.RawValue import com.bumble.appyx.interactions.core.asElement import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation +import com.bumble.appyx.utils.multiplatform_common.Parcelize +import com.bumble.appyx.utils.multiplatform_common.RawValue /** * Operation: diff --git a/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/Replace.kt b/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/Replace.kt index 921b3463f..663f138d2 100644 --- a/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/Replace.kt +++ b/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/Replace.kt @@ -1,13 +1,13 @@ package com.bumble.appyx.components.backstack.operation import androidx.compose.animation.core.AnimationSpec -import com.bumble.appyx.interactions.Parcelize -import com.bumble.appyx.interactions.RawValue +import com.bumble.appyx.components.backstack.BackStack +import com.bumble.appyx.components.backstack.BackStackModel.State import com.bumble.appyx.interactions.core.asElement import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation -import com.bumble.appyx.components.backstack.BackStack -import com.bumble.appyx.components.backstack.BackStackModel.State +import com.bumble.appyx.utils.multiplatform_common.Parcelize +import com.bumble.appyx.utils.multiplatform_common.RawValue /** diff --git a/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/CardsModel.kt b/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/CardsModel.kt index 5e97e3a61..bdea7d276 100644 --- a/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/CardsModel.kt +++ b/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/CardsModel.kt @@ -3,13 +3,13 @@ package com.bumble.appyx.components.demos.cards import com.bumble.appyx.components.demos.cards.CardsModel.State.Card.InvisibleCard.Queued import com.bumble.appyx.components.demos.cards.CardsModel.State.Card.VisibleCard.BottomCard import com.bumble.appyx.components.demos.cards.CardsModel.State.Card.VisibleCard.TopCard -import com.bumble.appyx.interactions.Parcelable -import com.bumble.appyx.interactions.Parcelize -import com.bumble.appyx.interactions.RawValue import com.bumble.appyx.interactions.core.Element import com.bumble.appyx.interactions.core.asElement import com.bumble.appyx.interactions.core.model.transition.BaseTransitionModel import com.bumble.appyx.interactions.core.state.SavedStateMap +import com.bumble.appyx.utils.multiplatform_common.Parcelable +import com.bumble.appyx.utils.multiplatform_common.Parcelize +import com.bumble.appyx.utils.multiplatform_common.RawValue class CardsModel( initialItems: List = listOf(), diff --git a/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/operation/VoteLike.kt b/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/operation/VoteLike.kt index 0c66fa3c6..648aa83d0 100644 --- a/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/operation/VoteLike.kt +++ b/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/operation/VoteLike.kt @@ -1,17 +1,17 @@ package com.bumble.appyx.components.demos.cards.operation -import com.bumble.appyx.interactions.Parcelize -import com.bumble.appyx.interactions.core.model.transition.Operation import com.bumble.appyx.components.demos.cards.CardsModel import com.bumble.appyx.components.demos.cards.CardsModel.State.Card.InvisibleCard.VotedCard.VOTED_CARD_STATE.LIKED import com.bumble.appyx.components.demos.cards.CardsModel.State.Card.VisibleCard.BottomCard import com.bumble.appyx.components.demos.cards.CardsModel.State.Card.VisibleCard.TopCard import com.bumble.appyx.components.demos.cards.CardsModel.State.Card.VisibleCard.TopCard.TOP_CARD_STATE.STANDARD +import com.bumble.appyx.interactions.core.model.transition.Operation +import com.bumble.appyx.utils.multiplatform_common.Parcelize @Parcelize class VoteLike( override val mode: Operation.Mode = Operation.Mode.KEYFRAME -): TopCardOperation() { +) : TopCardOperation() { override fun createTargetState(fromState: CardsModel.State): CardsModel.State { val votedCards = fromState.votedCards diff --git a/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/operation/VotePass.kt b/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/operation/VotePass.kt index 09af8a3a8..e65c9f516 100644 --- a/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/operation/VotePass.kt +++ b/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/operation/VotePass.kt @@ -1,9 +1,9 @@ package com.bumble.appyx.components.demos.cards.operation -import com.bumble.appyx.interactions.Parcelize -import com.bumble.appyx.interactions.core.model.transition.Operation import com.bumble.appyx.components.demos.cards.CardsModel import com.bumble.appyx.components.demos.cards.CardsModel.State.Card.InvisibleCard.VotedCard.VOTED_CARD_STATE.PASSED +import com.bumble.appyx.interactions.core.model.transition.Operation +import com.bumble.appyx.utils.multiplatform_common.Parcelize @Parcelize class VotePass( diff --git a/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/promoter/PromoterModel.kt b/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/promoter/PromoterModel.kt index 6b831a1bc..3ea897f23 100644 --- a/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/promoter/PromoterModel.kt +++ b/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/promoter/PromoterModel.kt @@ -1,11 +1,11 @@ package com.bumble.appyx.components.demos.promoter import com.bumble.appyx.components.demos.promoter.PromoterModel.State.ElementState.DESTROYED -import com.bumble.appyx.interactions.Parcelable -import com.bumble.appyx.interactions.Parcelize import com.bumble.appyx.interactions.core.Element import com.bumble.appyx.interactions.core.model.transition.BaseTransitionModel import com.bumble.appyx.interactions.core.state.SavedStateMap +import com.bumble.appyx.utils.multiplatform_common.Parcelable +import com.bumble.appyx.utils.multiplatform_common.Parcelize class PromoterModel( savedStateMap: SavedStateMap?, diff --git a/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/promoter/operation/AddFirst.kt b/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/promoter/operation/AddFirst.kt index 3da9c27f0..61b7e78d2 100644 --- a/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/promoter/operation/AddFirst.kt +++ b/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/promoter/operation/AddFirst.kt @@ -1,13 +1,13 @@ package com.bumble.appyx.components.demos.promoter.operation import androidx.compose.animation.core.AnimationSpec -import com.bumble.appyx.interactions.Parcelize -import com.bumble.appyx.interactions.RawValue +import com.bumble.appyx.components.demos.promoter.Promoter +import com.bumble.appyx.components.demos.promoter.PromoterModel import com.bumble.appyx.interactions.core.asElement import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation -import com.bumble.appyx.components.demos.promoter.Promoter -import com.bumble.appyx.components.demos.promoter.PromoterModel +import com.bumble.appyx.utils.multiplatform_common.Parcelize +import com.bumble.appyx.utils.multiplatform_common.RawValue @Parcelize data class AddFirst( diff --git a/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/TestDriveModel.kt b/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/TestDriveModel.kt index c32304567..2397e6b04 100644 --- a/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/TestDriveModel.kt +++ b/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/TestDriveModel.kt @@ -1,12 +1,12 @@ package com.bumble.appyx.components.internal.testdrive import com.bumble.appyx.components.internal.testdrive.TestDriveModel.State.ElementState.A -import com.bumble.appyx.interactions.Parcelable -import com.bumble.appyx.interactions.Parcelize import com.bumble.appyx.interactions.core.Element import com.bumble.appyx.interactions.core.asElement import com.bumble.appyx.interactions.core.model.transition.BaseTransitionModel import com.bumble.appyx.interactions.core.state.SavedStateMap +import com.bumble.appyx.utils.multiplatform_common.Parcelable +import com.bumble.appyx.utils.multiplatform_common.Parcelize class TestDriveModel( val element: InteractionTarget, diff --git a/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/operation/MoveTo.kt b/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/operation/MoveTo.kt index 463a82280..dee89cd11 100644 --- a/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/operation/MoveTo.kt +++ b/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/operation/MoveTo.kt @@ -3,9 +3,9 @@ package com.bumble.appyx.components.internal.testdrive.operation import androidx.compose.animation.core.AnimationSpec import com.bumble.appyx.components.internal.testdrive.TestDrive import com.bumble.appyx.components.internal.testdrive.TestDriveModel -import com.bumble.appyx.interactions.Parcelize import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation +import com.bumble.appyx.utils.multiplatform_common.Parcelize @Parcelize data class MoveTo( diff --git a/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/operation/Next.kt b/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/operation/Next.kt index f9d1f6520..000cf07af 100644 --- a/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/operation/Next.kt +++ b/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/operation/Next.kt @@ -3,9 +3,9 @@ package com.bumble.appyx.components.internal.testdrive.operation import androidx.compose.animation.core.AnimationSpec import com.bumble.appyx.components.internal.testdrive.TestDrive import com.bumble.appyx.components.internal.testdrive.TestDriveModel -import com.bumble.appyx.interactions.Parcelize import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation +import com.bumble.appyx.utils.multiplatform_common.Parcelize @Parcelize data class Next( diff --git a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/SpotlightModel.kt b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/SpotlightModel.kt index e95829c8c..f46d19ec4 100644 --- a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/SpotlightModel.kt +++ b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/SpotlightModel.kt @@ -3,13 +3,13 @@ package com.bumble.appyx.components.spotlight import com.bumble.appyx.components.spotlight.SpotlightModel.State import com.bumble.appyx.components.spotlight.SpotlightModel.State.ElementState.DESTROYED import com.bumble.appyx.components.spotlight.SpotlightModel.State.ElementState.STANDARD -import com.bumble.appyx.interactions.Parcelable -import com.bumble.appyx.interactions.Parcelize -import com.bumble.appyx.interactions.RawValue import com.bumble.appyx.interactions.core.Element import com.bumble.appyx.interactions.core.asElement import com.bumble.appyx.interactions.core.model.transition.BaseTransitionModel import com.bumble.appyx.interactions.core.state.SavedStateMap +import com.bumble.appyx.utils.multiplatform_common.Parcelable +import com.bumble.appyx.utils.multiplatform_common.Parcelize +import com.bumble.appyx.utils.multiplatform_common.RawValue class SpotlightModel( items: List, diff --git a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Activate.kt b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Activate.kt index 846c9b4ec..e38babae5 100644 --- a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Activate.kt +++ b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Activate.kt @@ -3,9 +3,9 @@ package com.bumble.appyx.components.spotlight.operation import androidx.compose.animation.core.AnimationSpec import com.bumble.appyx.components.spotlight.Spotlight import com.bumble.appyx.components.spotlight.SpotlightModel -import com.bumble.appyx.interactions.Parcelize import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation +import com.bumble.appyx.utils.multiplatform_common.Parcelize @Parcelize class Activate( diff --git a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/First.kt b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/First.kt index d153cb7d9..d4b926edf 100644 --- a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/First.kt +++ b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/First.kt @@ -3,9 +3,9 @@ package com.bumble.appyx.components.spotlight.operation import androidx.compose.animation.core.AnimationSpec import com.bumble.appyx.components.spotlight.Spotlight import com.bumble.appyx.components.spotlight.SpotlightModel -import com.bumble.appyx.interactions.Parcelize import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation +import com.bumble.appyx.utils.multiplatform_common.Parcelize @Parcelize diff --git a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Last.kt b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Last.kt index 6cb614dbf..20cfeb7f6 100644 --- a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Last.kt +++ b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Last.kt @@ -3,9 +3,9 @@ package com.bumble.appyx.components.spotlight.operation import androidx.compose.animation.core.AnimationSpec import com.bumble.appyx.components.spotlight.Spotlight import com.bumble.appyx.components.spotlight.SpotlightModel -import com.bumble.appyx.interactions.Parcelize import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation +import com.bumble.appyx.utils.multiplatform_common.Parcelize @Parcelize diff --git a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Next.kt b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Next.kt index 3f7941236..e6c2dee67 100644 --- a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Next.kt +++ b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Next.kt @@ -1,11 +1,11 @@ package com.bumble.appyx.components.spotlight.operation import androidx.compose.animation.core.AnimationSpec -import com.bumble.appyx.interactions.Parcelize -import com.bumble.appyx.interactions.core.model.transition.BaseOperation -import com.bumble.appyx.interactions.core.model.transition.Operation import com.bumble.appyx.components.spotlight.Spotlight import com.bumble.appyx.components.spotlight.SpotlightModel +import com.bumble.appyx.interactions.core.model.transition.BaseOperation +import com.bumble.appyx.interactions.core.model.transition.Operation +import com.bumble.appyx.utils.multiplatform_common.Parcelize @Parcelize class Next( diff --git a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Previous.kt b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Previous.kt index 8ece17b80..7b3ee5681 100644 --- a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Previous.kt +++ b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Previous.kt @@ -3,9 +3,9 @@ package com.bumble.appyx.components.spotlight.operation import androidx.compose.animation.core.AnimationSpec import com.bumble.appyx.components.spotlight.Spotlight import com.bumble.appyx.components.spotlight.SpotlightModel -import com.bumble.appyx.interactions.Parcelize import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation +import com.bumble.appyx.utils.multiplatform_common.Parcelize @Parcelize diff --git a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/UpdateElements.kt b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/UpdateElements.kt index 4e6f55a4e..5cbdb70b3 100644 --- a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/UpdateElements.kt +++ b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/UpdateElements.kt @@ -6,11 +6,11 @@ import com.bumble.appyx.components.spotlight.SpotlightModel import com.bumble.appyx.components.spotlight.SpotlightModel.State.ElementState.CREATED import com.bumble.appyx.components.spotlight.SpotlightModel.State.ElementState.DESTROYED import com.bumble.appyx.components.spotlight.SpotlightModel.State.ElementState.STANDARD -import com.bumble.appyx.interactions.Parcelize -import com.bumble.appyx.interactions.RawValue import com.bumble.appyx.interactions.core.asElement import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation +import com.bumble.appyx.utils.multiplatform_common.Parcelize +import com.bumble.appyx.utils.multiplatform_common.RawValue @Parcelize // TODO cleanup SpotlightModel.State.positions if a position doesn't contain more elements diff --git a/appyx-interactions/common/build.gradle.kts b/appyx-interactions/common/build.gradle.kts index dfccb580d..40d59dd8e 100644 --- a/appyx-interactions/common/build.gradle.kts +++ b/appyx-interactions/common/build.gradle.kts @@ -27,6 +27,7 @@ kotlin { api(compose.runtime) api(compose.foundation) api(compose.material) + api(project(":utils:multiplatform-common")) implementation(libs.kotlinx.serialization.json) } } diff --git a/appyx-interactions/common/src/androidMain/kotlin/com/bumble/appyx/interactions/platform.kt b/appyx-interactions/common/src/androidMain/kotlin/com/bumble/appyx/interactions/platform.kt index 4a7eb0600..2c93e9884 100644 --- a/appyx-interactions/common/src/androidMain/kotlin/com/bumble/appyx/interactions/platform.kt +++ b/appyx-interactions/common/src/androidMain/kotlin/com/bumble/appyx/interactions/platform.kt @@ -3,9 +3,3 @@ package com.bumble.appyx.interactions actual fun getPlatformName(): String { return "Android" } - -actual typealias Parcelize = kotlinx.parcelize.Parcelize - -actual typealias Parcelable = android.os.Parcelable - -actual typealias RawValue = kotlinx.parcelize.RawValue diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/Element.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/Element.kt index 0e9dd34e5..62f1c83da 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/Element.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/Element.kt @@ -2,10 +2,10 @@ package com.bumble.appyx.interactions.core import androidx.compose.runtime.Immutable -import com.bumble.appyx.interactions.Parcelable -import com.bumble.appyx.interactions.Parcelize -import com.bumble.appyx.interactions.RawValue import com.bumble.appyx.interactions.UUID +import com.bumble.appyx.utils.multiplatform_common.Parcelable +import com.bumble.appyx.utils.multiplatform_common.Parcelize +import com.bumble.appyx.utils.multiplatform_common.RawValue @Parcelize @Immutable diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/transition/BaseTransitionModel.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/transition/BaseTransitionModel.kt index 0b61abcc4..8f7d9bae6 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/transition/BaseTransitionModel.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/transition/BaseTransitionModel.kt @@ -1,13 +1,15 @@ package com.bumble.appyx.interactions.core.model.transition import com.bumble.appyx.interactions.AppyxLogger -import com.bumble.appyx.interactions.Parcelable import com.bumble.appyx.interactions.core.Element -import com.bumble.appyx.interactions.core.model.transition.Operation.Mode.* +import com.bumble.appyx.interactions.core.model.transition.Operation.Mode.GEOMETRY +import com.bumble.appyx.interactions.core.model.transition.Operation.Mode.IMMEDIATE +import com.bumble.appyx.interactions.core.model.transition.Operation.Mode.KEYFRAME import com.bumble.appyx.interactions.core.model.transition.TransitionModel.Output import com.bumble.appyx.interactions.core.model.transition.TransitionModel.SettleDirection import com.bumble.appyx.interactions.core.state.MutableSavedStateMap import com.bumble.appyx.interactions.core.state.SavedStateMap +import com.bumble.appyx.utils.multiplatform_common.Parcelable import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableStateFlow diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/transition/Operation.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/transition/Operation.kt index 96bd848f5..46db09996 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/transition/Operation.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/transition/Operation.kt @@ -1,7 +1,7 @@ package com.bumble.appyx.interactions.core.model.transition -import com.bumble.appyx.interactions.Parcelable -import com.bumble.appyx.interactions.Parcelize +import com.bumble.appyx.utils.multiplatform_common.Parcelable +import com.bumble.appyx.utils.multiplatform_common.Parcelize interface Operation : Parcelable { diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/permanent/PermanentModel.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/permanent/PermanentModel.kt index a7c369128..5b76a4195 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/permanent/PermanentModel.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/permanent/PermanentModel.kt @@ -1,13 +1,13 @@ package com.bumble.appyx.interactions.permanent -import com.bumble.appyx.interactions.Parcelable -import com.bumble.appyx.interactions.Parcelize import com.bumble.appyx.interactions.core.Element import com.bumble.appyx.interactions.core.Elements import com.bumble.appyx.interactions.core.asElement import com.bumble.appyx.interactions.core.model.transition.BaseTransitionModel import com.bumble.appyx.interactions.core.state.SavedStateMap import com.bumble.appyx.interactions.permanent.PermanentModel.State +import com.bumble.appyx.utils.multiplatform_common.Parcelable +import com.bumble.appyx.utils.multiplatform_common.Parcelize class PermanentModel( savedStateMap: SavedStateMap?, diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/permanent/operation/AddUnique.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/permanent/operation/AddUnique.kt index 87a39b865..d4ea9976c 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/permanent/operation/AddUnique.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/permanent/operation/AddUnique.kt @@ -1,12 +1,12 @@ package com.bumble.appyx.interactions.permanent.operation -import com.bumble.appyx.interactions.Parcelize -import com.bumble.appyx.interactions.RawValue import com.bumble.appyx.interactions.core.asElement import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation import com.bumble.appyx.interactions.permanent.PermanentInteractionModel import com.bumble.appyx.interactions.permanent.PermanentModel +import com.bumble.appyx.utils.multiplatform_common.Parcelize +import com.bumble.appyx.utils.multiplatform_common.RawValue @Parcelize data class AddUnique( diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/platform.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/platform.kt index 7e1a1e822..65a503653 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/platform.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/platform.kt @@ -1,13 +1,3 @@ package com.bumble.appyx.interactions expect fun getPlatformName(): String - -@Target(AnnotationTarget.CLASS) -@Retention(AnnotationRetention.BINARY) -expect annotation class Parcelize() - -@Target(AnnotationTarget.TYPE) -@Retention(AnnotationRetention.BINARY) -expect annotation class RawValue() - -expect interface Parcelable diff --git a/appyx-interactions/common/src/commonTest/kotlin/com/bumble/appyx/interactions/core/TestTransitionModel.kt b/appyx-interactions/common/src/commonTest/kotlin/com/bumble/appyx/interactions/core/TestTransitionModel.kt index 25961575a..83a626afc 100644 --- a/appyx-interactions/common/src/commonTest/kotlin/com/bumble/appyx/interactions/core/TestTransitionModel.kt +++ b/appyx-interactions/common/src/commonTest/kotlin/com/bumble/appyx/interactions/core/TestTransitionModel.kt @@ -1,12 +1,12 @@ package com.bumble.appyx.interactions.core -import com.bumble.appyx.interactions.Parcelable -import com.bumble.appyx.interactions.Parcelize -import com.bumble.appyx.interactions.RawValue import com.bumble.appyx.interactions.core.TestTransitionModel.State import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.BaseTransitionModel import com.bumble.appyx.interactions.core.model.transition.Operation +import com.bumble.appyx.utils.multiplatform_common.Parcelable +import com.bumble.appyx.utils.multiplatform_common.Parcelize +import com.bumble.appyx.utils.multiplatform_common.RawValue class TestTransitionModel( initialElements: List, diff --git a/appyx-interactions/common/src/desktopMain/kotlin/com/bumble/appyx/interactions/platform.kt b/appyx-interactions/common/src/desktopMain/kotlin/com/bumble/appyx/interactions/platform.kt index ff714fd38..bfc6087d1 100644 --- a/appyx-interactions/common/src/desktopMain/kotlin/com/bumble/appyx/interactions/platform.kt +++ b/appyx-interactions/common/src/desktopMain/kotlin/com/bumble/appyx/interactions/platform.kt @@ -3,10 +3,3 @@ package com.bumble.appyx.interactions actual fun getPlatformName(): String { return "Desktop" } - -actual annotation class Parcelize - -actual interface Parcelable - -@Target(AnnotationTarget.TYPE) -actual annotation class RawValue diff --git a/appyx-interactions/common/src/jsMain/kotlin/com/bumble/appyx/interactions/platform.kt b/appyx-interactions/common/src/jsMain/kotlin/com/bumble/appyx/interactions/platform.kt index 2236aaf2b..b66bfb4e3 100644 --- a/appyx-interactions/common/src/jsMain/kotlin/com/bumble/appyx/interactions/platform.kt +++ b/appyx-interactions/common/src/jsMain/kotlin/com/bumble/appyx/interactions/platform.kt @@ -1,10 +1,3 @@ package com.bumble.appyx.interactions actual fun getPlatformName(): String = "Web" - -actual annotation class Parcelize - -actual interface Parcelable - -@Target(AnnotationTarget.TYPE) -actual annotation class RawValue diff --git a/utils/multiplatform-common/build.gradle.kts b/utils/multiplatform-common/build.gradle.kts index df14d0dbe..476aa6867 100644 --- a/utils/multiplatform-common/build.gradle.kts +++ b/utils/multiplatform-common/build.gradle.kts @@ -31,3 +31,13 @@ kotlin { val jsMain by getting } } + +android { + namespace = "com.bumble.appyx.utils.multiplatform_common" + compileSdk = libs.versions.androidCompileSdk.get().toInt() + sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") + defaultConfig { + minSdk = libs.versions.androidMinSdk.get().toInt() + targetSdk = libs.versions.androidTargetSdk.get().toInt() + } +} From 6ac3040be2ee142309c27045ec4a96a556f48d42 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Mon, 15 May 2023 13:12:40 +0100 Subject: [PATCH 03/94] renamed multiplatform package --- .../com/bumble/appyx/components/backstack/BackStackModel.kt | 4 ++-- .../bumble/appyx/components/backstack/operation/NewRoot.kt | 4 ++-- .../com/bumble/appyx/components/backstack/operation/Pop.kt | 2 +- .../com/bumble/appyx/components/backstack/operation/Push.kt | 4 ++-- .../bumble/appyx/components/backstack/operation/Replace.kt | 4 ++-- .../com/bumble/appyx/components/demos/cards/CardsModel.kt | 6 +++--- .../appyx/components/demos/cards/operation/VoteLike.kt | 2 +- .../appyx/components/demos/cards/operation/VotePass.kt | 2 +- .../bumble/appyx/components/demos/promoter/PromoterModel.kt | 4 ++-- .../appyx/components/demos/promoter/operation/AddFirst.kt | 4 ++-- .../appyx/components/internal/testdrive/TestDriveModel.kt | 4 ++-- .../appyx/components/internal/testdrive/operation/MoveTo.kt | 2 +- .../appyx/components/internal/testdrive/operation/Next.kt | 2 +- .../com/bumble/appyx/components/spotlight/SpotlightModel.kt | 6 +++--- .../bumble/appyx/components/spotlight/operation/Activate.kt | 2 +- .../bumble/appyx/components/spotlight/operation/First.kt | 2 +- .../com/bumble/appyx/components/spotlight/operation/Last.kt | 2 +- .../com/bumble/appyx/components/spotlight/operation/Next.kt | 2 +- .../bumble/appyx/components/spotlight/operation/Previous.kt | 2 +- .../appyx/components/spotlight/operation/UpdateElements.kt | 4 ++-- .../kotlin/com/bumble/appyx/interactions/core/Element.kt | 6 +++--- .../core/model/transition/BaseTransitionModel.kt | 2 +- .../appyx/interactions/core/model/transition/Operation.kt | 4 ++-- .../bumble/appyx/interactions/permanent/PermanentModel.kt | 4 ++-- .../appyx/interactions/permanent/operation/AddUnique.kt | 4 ++-- .../bumble/appyx/interactions/core/TestTransitionModel.kt | 6 +++--- .../{multiplatform_common => multiplatform}/Parcelize.kt | 2 +- .../{multiplatform_common => multiplatform}/Parcelable.kt | 2 +- .../{multiplatform_common => multiplatform}/Parcelable.kt | 2 +- .../{multiplatform_common => multiplatform}/Parcelable.kt | 2 +- 30 files changed, 49 insertions(+), 49 deletions(-) rename utils/multiplatform-common/src/androidMain/kotlin/com/bumble/appyx/utils/{multiplatform_common => multiplatform}/Parcelize.kt (76%) rename utils/multiplatform-common/src/commonMain/kotlin/com/bumble/appyx/utils/{multiplatform_common => multiplatform}/Parcelable.kt (82%) rename utils/multiplatform-common/src/desktopMain/kotlin/com/bumble/appyx/utils/{multiplatform_common => multiplatform}/Parcelable.kt (71%) rename utils/multiplatform-common/src/jsMain/kotlin/com/bumble/appyx/utils/{multiplatform_common => multiplatform}/Parcelable.kt (71%) diff --git a/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/BackStackModel.kt b/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/BackStackModel.kt index b2ec53a5d..3658ae672 100644 --- a/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/BackStackModel.kt +++ b/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/BackStackModel.kt @@ -6,8 +6,8 @@ import com.bumble.appyx.interactions.core.Elements import com.bumble.appyx.interactions.core.asElement import com.bumble.appyx.interactions.core.model.transition.BaseTransitionModel import com.bumble.appyx.interactions.core.state.SavedStateMap -import com.bumble.appyx.utils.multiplatform_common.Parcelable -import com.bumble.appyx.utils.multiplatform_common.Parcelize +import com.bumble.appyx.utils.multiplatform.Parcelable +import com.bumble.appyx.utils.multiplatform.Parcelize class BackStackModel( initialTargets: List, diff --git a/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/NewRoot.kt b/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/NewRoot.kt index 61ee661bd..853b5385f 100644 --- a/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/NewRoot.kt +++ b/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/NewRoot.kt @@ -6,8 +6,8 @@ import com.bumble.appyx.components.backstack.BackStackModel import com.bumble.appyx.interactions.core.asElement import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation -import com.bumble.appyx.utils.multiplatform_common.Parcelize -import com.bumble.appyx.utils.multiplatform_common.RawValue +import com.bumble.appyx.utils.multiplatform.Parcelize +import com.bumble.appyx.utils.multiplatform.RawValue /** * Operation: diff --git a/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/Pop.kt b/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/Pop.kt index 8ed398cf2..c54fbcb02 100644 --- a/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/Pop.kt +++ b/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/Pop.kt @@ -5,7 +5,7 @@ import com.bumble.appyx.components.backstack.BackStack import com.bumble.appyx.components.backstack.BackStackModel.State import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation -import com.bumble.appyx.utils.multiplatform_common.Parcelize +import com.bumble.appyx.utils.multiplatform.Parcelize /** * Operation: diff --git a/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/Push.kt b/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/Push.kt index 109bd6f82..fe239169c 100644 --- a/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/Push.kt +++ b/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/Push.kt @@ -6,8 +6,8 @@ import com.bumble.appyx.components.backstack.BackStackModel import com.bumble.appyx.interactions.core.asElement import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation -import com.bumble.appyx.utils.multiplatform_common.Parcelize -import com.bumble.appyx.utils.multiplatform_common.RawValue +import com.bumble.appyx.utils.multiplatform.Parcelize +import com.bumble.appyx.utils.multiplatform.RawValue /** * Operation: diff --git a/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/Replace.kt b/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/Replace.kt index 663f138d2..1af7a50da 100644 --- a/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/Replace.kt +++ b/appyx-components/backstack/common/src/commonMain/kotlin/com/bumble/appyx/components/backstack/operation/Replace.kt @@ -6,8 +6,8 @@ import com.bumble.appyx.components.backstack.BackStackModel.State import com.bumble.appyx.interactions.core.asElement import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation -import com.bumble.appyx.utils.multiplatform_common.Parcelize -import com.bumble.appyx.utils.multiplatform_common.RawValue +import com.bumble.appyx.utils.multiplatform.Parcelize +import com.bumble.appyx.utils.multiplatform.RawValue /** diff --git a/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/CardsModel.kt b/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/CardsModel.kt index bdea7d276..a0f2f2c85 100644 --- a/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/CardsModel.kt +++ b/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/CardsModel.kt @@ -7,9 +7,9 @@ import com.bumble.appyx.interactions.core.Element import com.bumble.appyx.interactions.core.asElement import com.bumble.appyx.interactions.core.model.transition.BaseTransitionModel import com.bumble.appyx.interactions.core.state.SavedStateMap -import com.bumble.appyx.utils.multiplatform_common.Parcelable -import com.bumble.appyx.utils.multiplatform_common.Parcelize -import com.bumble.appyx.utils.multiplatform_common.RawValue +import com.bumble.appyx.utils.multiplatform.Parcelable +import com.bumble.appyx.utils.multiplatform.Parcelize +import com.bumble.appyx.utils.multiplatform.RawValue class CardsModel( initialItems: List = listOf(), diff --git a/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/operation/VoteLike.kt b/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/operation/VoteLike.kt index 648aa83d0..6f291cf30 100644 --- a/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/operation/VoteLike.kt +++ b/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/operation/VoteLike.kt @@ -6,7 +6,7 @@ import com.bumble.appyx.components.demos.cards.CardsModel.State.Card.VisibleCard import com.bumble.appyx.components.demos.cards.CardsModel.State.Card.VisibleCard.TopCard import com.bumble.appyx.components.demos.cards.CardsModel.State.Card.VisibleCard.TopCard.TOP_CARD_STATE.STANDARD import com.bumble.appyx.interactions.core.model.transition.Operation -import com.bumble.appyx.utils.multiplatform_common.Parcelize +import com.bumble.appyx.utils.multiplatform.Parcelize @Parcelize class VoteLike( diff --git a/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/operation/VotePass.kt b/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/operation/VotePass.kt index e65c9f516..678f6e5a4 100644 --- a/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/operation/VotePass.kt +++ b/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/operation/VotePass.kt @@ -3,7 +3,7 @@ package com.bumble.appyx.components.demos.cards.operation import com.bumble.appyx.components.demos.cards.CardsModel import com.bumble.appyx.components.demos.cards.CardsModel.State.Card.InvisibleCard.VotedCard.VOTED_CARD_STATE.PASSED import com.bumble.appyx.interactions.core.model.transition.Operation -import com.bumble.appyx.utils.multiplatform_common.Parcelize +import com.bumble.appyx.utils.multiplatform.Parcelize @Parcelize class VotePass( diff --git a/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/promoter/PromoterModel.kt b/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/promoter/PromoterModel.kt index 3ea897f23..12426bc45 100644 --- a/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/promoter/PromoterModel.kt +++ b/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/promoter/PromoterModel.kt @@ -4,8 +4,8 @@ import com.bumble.appyx.components.demos.promoter.PromoterModel.State.ElementSta import com.bumble.appyx.interactions.core.Element import com.bumble.appyx.interactions.core.model.transition.BaseTransitionModel import com.bumble.appyx.interactions.core.state.SavedStateMap -import com.bumble.appyx.utils.multiplatform_common.Parcelable -import com.bumble.appyx.utils.multiplatform_common.Parcelize +import com.bumble.appyx.utils.multiplatform.Parcelable +import com.bumble.appyx.utils.multiplatform.Parcelize class PromoterModel( savedStateMap: SavedStateMap?, diff --git a/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/promoter/operation/AddFirst.kt b/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/promoter/operation/AddFirst.kt index 61b7e78d2..2778d364d 100644 --- a/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/promoter/operation/AddFirst.kt +++ b/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/promoter/operation/AddFirst.kt @@ -6,8 +6,8 @@ import com.bumble.appyx.components.demos.promoter.PromoterModel import com.bumble.appyx.interactions.core.asElement import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation -import com.bumble.appyx.utils.multiplatform_common.Parcelize -import com.bumble.appyx.utils.multiplatform_common.RawValue +import com.bumble.appyx.utils.multiplatform.Parcelize +import com.bumble.appyx.utils.multiplatform.RawValue @Parcelize data class AddFirst( diff --git a/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/TestDriveModel.kt b/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/TestDriveModel.kt index 2397e6b04..baced4d6f 100644 --- a/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/TestDriveModel.kt +++ b/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/TestDriveModel.kt @@ -5,8 +5,8 @@ import com.bumble.appyx.interactions.core.Element import com.bumble.appyx.interactions.core.asElement import com.bumble.appyx.interactions.core.model.transition.BaseTransitionModel import com.bumble.appyx.interactions.core.state.SavedStateMap -import com.bumble.appyx.utils.multiplatform_common.Parcelable -import com.bumble.appyx.utils.multiplatform_common.Parcelize +import com.bumble.appyx.utils.multiplatform.Parcelable +import com.bumble.appyx.utils.multiplatform.Parcelize class TestDriveModel( val element: InteractionTarget, diff --git a/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/operation/MoveTo.kt b/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/operation/MoveTo.kt index dee89cd11..3d3ac4f92 100644 --- a/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/operation/MoveTo.kt +++ b/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/operation/MoveTo.kt @@ -5,7 +5,7 @@ import com.bumble.appyx.components.internal.testdrive.TestDrive import com.bumble.appyx.components.internal.testdrive.TestDriveModel import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation -import com.bumble.appyx.utils.multiplatform_common.Parcelize +import com.bumble.appyx.utils.multiplatform.Parcelize @Parcelize data class MoveTo( diff --git a/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/operation/Next.kt b/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/operation/Next.kt index 000cf07af..a49e8596d 100644 --- a/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/operation/Next.kt +++ b/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/operation/Next.kt @@ -5,7 +5,7 @@ import com.bumble.appyx.components.internal.testdrive.TestDrive import com.bumble.appyx.components.internal.testdrive.TestDriveModel import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation -import com.bumble.appyx.utils.multiplatform_common.Parcelize +import com.bumble.appyx.utils.multiplatform.Parcelize @Parcelize data class Next( diff --git a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/SpotlightModel.kt b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/SpotlightModel.kt index f46d19ec4..0b87ae04a 100644 --- a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/SpotlightModel.kt +++ b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/SpotlightModel.kt @@ -7,9 +7,9 @@ import com.bumble.appyx.interactions.core.Element import com.bumble.appyx.interactions.core.asElement import com.bumble.appyx.interactions.core.model.transition.BaseTransitionModel import com.bumble.appyx.interactions.core.state.SavedStateMap -import com.bumble.appyx.utils.multiplatform_common.Parcelable -import com.bumble.appyx.utils.multiplatform_common.Parcelize -import com.bumble.appyx.utils.multiplatform_common.RawValue +import com.bumble.appyx.utils.multiplatform.Parcelable +import com.bumble.appyx.utils.multiplatform.Parcelize +import com.bumble.appyx.utils.multiplatform.RawValue class SpotlightModel( items: List, diff --git a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Activate.kt b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Activate.kt index e38babae5..a24edf2dd 100644 --- a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Activate.kt +++ b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Activate.kt @@ -5,7 +5,7 @@ import com.bumble.appyx.components.spotlight.Spotlight import com.bumble.appyx.components.spotlight.SpotlightModel import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation -import com.bumble.appyx.utils.multiplatform_common.Parcelize +import com.bumble.appyx.utils.multiplatform.Parcelize @Parcelize class Activate( diff --git a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/First.kt b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/First.kt index d4b926edf..a552b99a8 100644 --- a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/First.kt +++ b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/First.kt @@ -5,7 +5,7 @@ import com.bumble.appyx.components.spotlight.Spotlight import com.bumble.appyx.components.spotlight.SpotlightModel import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation -import com.bumble.appyx.utils.multiplatform_common.Parcelize +import com.bumble.appyx.utils.multiplatform.Parcelize @Parcelize diff --git a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Last.kt b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Last.kt index 20cfeb7f6..072355d57 100644 --- a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Last.kt +++ b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Last.kt @@ -5,7 +5,7 @@ import com.bumble.appyx.components.spotlight.Spotlight import com.bumble.appyx.components.spotlight.SpotlightModel import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation -import com.bumble.appyx.utils.multiplatform_common.Parcelize +import com.bumble.appyx.utils.multiplatform.Parcelize @Parcelize diff --git a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Next.kt b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Next.kt index e6c2dee67..4348fc9f4 100644 --- a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Next.kt +++ b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Next.kt @@ -5,7 +5,7 @@ import com.bumble.appyx.components.spotlight.Spotlight import com.bumble.appyx.components.spotlight.SpotlightModel import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation -import com.bumble.appyx.utils.multiplatform_common.Parcelize +import com.bumble.appyx.utils.multiplatform.Parcelize @Parcelize class Next( diff --git a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Previous.kt b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Previous.kt index 7b3ee5681..7a428386a 100644 --- a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Previous.kt +++ b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/Previous.kt @@ -5,7 +5,7 @@ import com.bumble.appyx.components.spotlight.Spotlight import com.bumble.appyx.components.spotlight.SpotlightModel import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation -import com.bumble.appyx.utils.multiplatform_common.Parcelize +import com.bumble.appyx.utils.multiplatform.Parcelize @Parcelize diff --git a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/UpdateElements.kt b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/UpdateElements.kt index 5cbdb70b3..89136666a 100644 --- a/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/UpdateElements.kt +++ b/appyx-components/spotlight/common/src/commonMain/kotlin/com/bumble/appyx/components/spotlight/operation/UpdateElements.kt @@ -9,8 +9,8 @@ import com.bumble.appyx.components.spotlight.SpotlightModel.State.ElementState.S import com.bumble.appyx.interactions.core.asElement import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation -import com.bumble.appyx.utils.multiplatform_common.Parcelize -import com.bumble.appyx.utils.multiplatform_common.RawValue +import com.bumble.appyx.utils.multiplatform.Parcelize +import com.bumble.appyx.utils.multiplatform.RawValue @Parcelize // TODO cleanup SpotlightModel.State.positions if a position doesn't contain more elements diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/Element.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/Element.kt index 62f1c83da..2bc89c617 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/Element.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/Element.kt @@ -3,9 +3,9 @@ package com.bumble.appyx.interactions.core import androidx.compose.runtime.Immutable import com.bumble.appyx.interactions.UUID -import com.bumble.appyx.utils.multiplatform_common.Parcelable -import com.bumble.appyx.utils.multiplatform_common.Parcelize -import com.bumble.appyx.utils.multiplatform_common.RawValue +import com.bumble.appyx.utils.multiplatform.Parcelable +import com.bumble.appyx.utils.multiplatform.Parcelize +import com.bumble.appyx.utils.multiplatform.RawValue @Parcelize @Immutable diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/transition/BaseTransitionModel.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/transition/BaseTransitionModel.kt index 8f7d9bae6..319abb9be 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/transition/BaseTransitionModel.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/transition/BaseTransitionModel.kt @@ -9,7 +9,7 @@ import com.bumble.appyx.interactions.core.model.transition.TransitionModel.Outpu import com.bumble.appyx.interactions.core.model.transition.TransitionModel.SettleDirection import com.bumble.appyx.interactions.core.state.MutableSavedStateMap import com.bumble.appyx.interactions.core.state.SavedStateMap -import com.bumble.appyx.utils.multiplatform_common.Parcelable +import com.bumble.appyx.utils.multiplatform.Parcelable import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableStateFlow diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/transition/Operation.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/transition/Operation.kt index 46db09996..21d3233e5 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/transition/Operation.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/transition/Operation.kt @@ -1,7 +1,7 @@ package com.bumble.appyx.interactions.core.model.transition -import com.bumble.appyx.utils.multiplatform_common.Parcelable -import com.bumble.appyx.utils.multiplatform_common.Parcelize +import com.bumble.appyx.utils.multiplatform.Parcelable +import com.bumble.appyx.utils.multiplatform.Parcelize interface Operation : Parcelable { diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/permanent/PermanentModel.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/permanent/PermanentModel.kt index 5b76a4195..4e61e6c56 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/permanent/PermanentModel.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/permanent/PermanentModel.kt @@ -6,8 +6,8 @@ import com.bumble.appyx.interactions.core.asElement import com.bumble.appyx.interactions.core.model.transition.BaseTransitionModel import com.bumble.appyx.interactions.core.state.SavedStateMap import com.bumble.appyx.interactions.permanent.PermanentModel.State -import com.bumble.appyx.utils.multiplatform_common.Parcelable -import com.bumble.appyx.utils.multiplatform_common.Parcelize +import com.bumble.appyx.utils.multiplatform.Parcelable +import com.bumble.appyx.utils.multiplatform.Parcelize class PermanentModel( savedStateMap: SavedStateMap?, diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/permanent/operation/AddUnique.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/permanent/operation/AddUnique.kt index d4ea9976c..f005c6fe0 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/permanent/operation/AddUnique.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/permanent/operation/AddUnique.kt @@ -5,8 +5,8 @@ import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.Operation import com.bumble.appyx.interactions.permanent.PermanentInteractionModel import com.bumble.appyx.interactions.permanent.PermanentModel -import com.bumble.appyx.utils.multiplatform_common.Parcelize -import com.bumble.appyx.utils.multiplatform_common.RawValue +import com.bumble.appyx.utils.multiplatform.Parcelize +import com.bumble.appyx.utils.multiplatform.RawValue @Parcelize data class AddUnique( diff --git a/appyx-interactions/common/src/commonTest/kotlin/com/bumble/appyx/interactions/core/TestTransitionModel.kt b/appyx-interactions/common/src/commonTest/kotlin/com/bumble/appyx/interactions/core/TestTransitionModel.kt index 83a626afc..212afae28 100644 --- a/appyx-interactions/common/src/commonTest/kotlin/com/bumble/appyx/interactions/core/TestTransitionModel.kt +++ b/appyx-interactions/common/src/commonTest/kotlin/com/bumble/appyx/interactions/core/TestTransitionModel.kt @@ -4,9 +4,9 @@ import com.bumble.appyx.interactions.core.TestTransitionModel.State import com.bumble.appyx.interactions.core.model.transition.BaseOperation import com.bumble.appyx.interactions.core.model.transition.BaseTransitionModel import com.bumble.appyx.interactions.core.model.transition.Operation -import com.bumble.appyx.utils.multiplatform_common.Parcelable -import com.bumble.appyx.utils.multiplatform_common.Parcelize -import com.bumble.appyx.utils.multiplatform_common.RawValue +import com.bumble.appyx.utils.multiplatform.Parcelable +import com.bumble.appyx.utils.multiplatform.Parcelize +import com.bumble.appyx.utils.multiplatform.RawValue class TestTransitionModel( initialElements: List, diff --git a/utils/multiplatform-common/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelize.kt b/utils/multiplatform-common/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelize.kt similarity index 76% rename from utils/multiplatform-common/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelize.kt rename to utils/multiplatform-common/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelize.kt index 29fd128db..9111e8bbb 100644 --- a/utils/multiplatform-common/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelize.kt +++ b/utils/multiplatform-common/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelize.kt @@ -1,4 +1,4 @@ -package com.bumble.appyx.utils.multiplatform_common +package com.bumble.appyx.utils.multiplatform actual typealias Parcelize = kotlinx.parcelize.Parcelize diff --git a/utils/multiplatform-common/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelable.kt b/utils/multiplatform-common/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt similarity index 82% rename from utils/multiplatform-common/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelable.kt rename to utils/multiplatform-common/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt index cff50c3a8..9448a1f45 100644 --- a/utils/multiplatform-common/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelable.kt +++ b/utils/multiplatform-common/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt @@ -1,4 +1,4 @@ -package com.bumble.appyx.utils.multiplatform_common +package com.bumble.appyx.utils.multiplatform @Target(AnnotationTarget.CLASS) @Retention(AnnotationRetention.BINARY) diff --git a/utils/multiplatform-common/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelable.kt b/utils/multiplatform-common/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt similarity index 71% rename from utils/multiplatform-common/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelable.kt rename to utils/multiplatform-common/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt index 8d2422ac6..a260e76be 100644 --- a/utils/multiplatform-common/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelable.kt +++ b/utils/multiplatform-common/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt @@ -1,4 +1,4 @@ -package com.bumble.appyx.utils.multiplatform_common +package com.bumble.appyx.utils.multiplatform actual annotation class Parcelize diff --git a/utils/multiplatform-common/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelable.kt b/utils/multiplatform-common/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt similarity index 71% rename from utils/multiplatform-common/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelable.kt rename to utils/multiplatform-common/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt index 8d2422ac6..a260e76be 100644 --- a/utils/multiplatform-common/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform_common/Parcelable.kt +++ b/utils/multiplatform-common/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt @@ -1,4 +1,4 @@ -package com.bumble.appyx.utils.multiplatform_common +package com.bumble.appyx.utils.multiplatform actual annotation class Parcelize From 4f7da384f66adc3707856a13388178f070ee9d3d Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Mon, 15 May 2023 13:48:49 +0100 Subject: [PATCH 04/94] renamed multiplatform module --- appyx-interactions/common/build.gradle.kts | 2 +- settings.gradle.kts | 2 +- .../{multiplatform-common => multiplatform}/build.gradle.kts | 4 ++-- .../kotlin/com/bumble/appyx/utils/multiplatform/Parcelize.kt | 0 .../kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt | 0 .../kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt | 0 .../kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt | 0 7 files changed, 4 insertions(+), 4 deletions(-) rename utils/{multiplatform-common => multiplatform}/build.gradle.kts (90%) rename utils/{multiplatform-common => multiplatform}/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelize.kt (100%) rename utils/{multiplatform-common => multiplatform}/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt (100%) rename utils/{multiplatform-common => multiplatform}/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt (100%) rename utils/{multiplatform-common => multiplatform}/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt (100%) diff --git a/appyx-interactions/common/build.gradle.kts b/appyx-interactions/common/build.gradle.kts index 40d59dd8e..3d63d4526 100644 --- a/appyx-interactions/common/build.gradle.kts +++ b/appyx-interactions/common/build.gradle.kts @@ -27,7 +27,7 @@ kotlin { api(compose.runtime) api(compose.foundation) api(compose.material) - api(project(":utils:multiplatform-common")) + api(project(":utils:multiplatform")) implementation(libs.kotlinx.serialization.json) } } diff --git a/settings.gradle.kts b/settings.gradle.kts index d10a07c35..ac537dbe7 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -51,7 +51,7 @@ include( ":utils:testing-ui", ":utils:testing-ui-activity", ":utils:testing-unit-common", - ":utils:multiplatform-common", + ":utils:multiplatform", ) // do not remove this. Otherwise all multiplatform modules will produce clashing artifacts diff --git a/utils/multiplatform-common/build.gradle.kts b/utils/multiplatform/build.gradle.kts similarity index 90% rename from utils/multiplatform-common/build.gradle.kts rename to utils/multiplatform/build.gradle.kts index 476aa6867..aa56778d4 100644 --- a/utils/multiplatform-common/build.gradle.kts +++ b/utils/multiplatform/build.gradle.kts @@ -17,7 +17,7 @@ kotlin { } js(IR) { // Adding moduleName as a workaround for this issue: https://youtrack.jetbrains.com/issue/KT-51942 - moduleName = "appyx-utils-multiplatform-common" + moduleName = "appyx-utils-multiplatform" browser() } sourceSets { @@ -33,7 +33,7 @@ kotlin { } android { - namespace = "com.bumble.appyx.utils.multiplatform_common" + namespace = "com.bumble.appyx.utils.multiplatform" compileSdk = libs.versions.androidCompileSdk.get().toInt() sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") defaultConfig { diff --git a/utils/multiplatform-common/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelize.kt b/utils/multiplatform/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelize.kt similarity index 100% rename from utils/multiplatform-common/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelize.kt rename to utils/multiplatform/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelize.kt diff --git a/utils/multiplatform-common/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt b/utils/multiplatform/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt similarity index 100% rename from utils/multiplatform-common/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt rename to utils/multiplatform/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt diff --git a/utils/multiplatform-common/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt b/utils/multiplatform/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt similarity index 100% rename from utils/multiplatform-common/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt rename to utils/multiplatform/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt diff --git a/utils/multiplatform-common/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt b/utils/multiplatform/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt similarity index 100% rename from utils/multiplatform-common/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt rename to utils/multiplatform/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform/Parcelable.kt From 9c70cca15118ed3263625ddd3adff599c39dcb87 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Tue, 16 May 2023 13:53:42 +0100 Subject: [PATCH 05/94] initial refactoring of appyx-navigation module into a multiplatform-supporting configuration --- .../{ => android}/build.gradle.kts | 6 +- .../src/androidTest/AndroidManifest.xml | 2 +- .../appyx/navigation/AppyxTestScenario.kt | 0 .../navigation/InternalAppyxTestActivity.kt | 0 .../navigation/node/PermanentChildTest.kt | 0 .../src/main/AndroidManifest.xml | 0 .../com/bumble/appyx/navigation/Appyx.kt | 0 .../com/bumble/appyx/navigation/FlowExt.kt | 0 .../appyx/navigation/builder/Builder.kt | 0 .../appyx/navigation/builder/SimpleBuilder.kt | 0 .../appyx/navigation/children/ChildAware.kt | 0 .../children/ChildAwareCallbackInfo.kt | 0 .../navigation/children/ChildAwareExt.kt | 0 .../navigation/children/ChildAwareImpl.kt | 0 .../navigation/children/ChildCallback.kt | 0 .../appyx/navigation/children/ChildEntry.kt | 0 .../navigation/children/ChildEntryExt.kt | 0 .../navigation/children/ChildEntryMap.kt | 0 .../children/ChildNodeCreationManager.kt | 0 .../clienthelper/interactor/Interactor.kt | 0 .../navigation/collections/ImmutableList.kt | 0 .../appyx/navigation/composable/Child.kt | 0 .../navigation/composable/ChildRenderer.kt | 0 .../appyx/navigation/composable/Children.kt | 0 .../navigation/integration/NodeFactory.kt | 0 .../appyx/navigation/integration/NodeHost.kt | 0 .../ActivityIntegrationPoint.kt | 0 .../integrationpoint/IntegrationPoint.kt | 0 .../IntegrationPointProvider.kt | 0 .../integrationpoint/IntegrationPointStub.kt | 0 .../integrationpoint/LocalIntegrationPoint.kt | 0 .../integrationpoint/NodeActivity.kt | 0 .../integrationpoint/NodeComponentActivity.kt | 0 .../activitystarter/ActivityBoundary.kt | 0 .../activitystarter/ActivityResultHandler.kt | 0 .../activitystarter/ActivityStarter.kt | 0 .../activitystarter/ActivityStarterHost.kt | 0 .../CanProvideActivityStarter.kt | 0 .../PermissionRequestBoundary.kt | 0 .../PermissionRequestResultHandler.kt | 0 .../PermissionRequester.kt | 0 .../PermissionRequesterHost.kt | 0 .../RequestCodeBasedEventStream.kt | 0 .../RequestCodeBasedEventStreamImpl.kt | 0 .../requestcode/RequestCodeClient.kt | 0 .../requestcode/RequestCodeDoesntFitInMask.kt | 0 .../requestcode/RequestCodeRegistry.kt | 0 .../lifecycle/ChildNodeLifecycleManager.kt | 0 .../navigation/lifecycle/LifecycleExt.kt | 0 .../navigation/lifecycle/LifecycleLogger.kt | 0 .../lifecycle/MinimumCombinedLifecycle.kt | 0 .../navigation/lifecycle/NodeLifecycle.kt | 0 .../navigation/lifecycle/NodeLifecycleImpl.kt | 0 .../appyx/navigation/modality/AncestryInfo.kt | 0 .../appyx/navigation/modality/BuildContext.kt | 2 +- .../appyx/navigation/navigation/Resolver.kt | 0 .../upnavigation/UpNavigationHandler.kt | 0 .../appyx/navigation/node/ComposableNode.kt | 0 .../appyx/navigation/node/EmptyNodeViews.kt | 0 .../bumble/appyx/navigation/node/LocalNode.kt | 0 .../com/bumble/appyx/navigation/node/Node.kt | 0 .../bumble/appyx/navigation/node/NodeExt.kt | 0 .../bumble/appyx/navigation/node/NodeView.kt | 0 .../appyx/navigation/node/ParentNode.kt | 0 .../appyx/navigation/node/ParentNodeExt.kt | 0 .../appyx/navigation/node/ParentNodeView.kt | 0 .../appyx/navigation/node/ViewFactory.kt | 0 .../appyx/navigation/plugin/NodeAwareImpl.kt | 0 .../bumble/appyx/navigation/plugin/Plugins.kt | 0 .../appyx/navigation/state/SavedStateMap.kt | 0 .../navigation/store/RetainedInstanceStore.kt | 0 .../store/RetainedInstanceStoreExt.kt | 0 .../store/RetainedInstanceStoreImpl.kt | 0 .../store/RetainedInstanceStoreTest.kt | 0 appyx-navigation/common/.gitignore | 1 + appyx-navigation/common/build.gradle.kts | 84 +++++++++++++++++++ appyx-navigation/desktop/build.gradle.kts | 22 +++++ demos/appyx-navigation/build.gradle.kts | 2 +- demos/navigation-compose/build.gradle.kts | 2 +- settings.gradle.kts | 4 +- utils/interop-ribs/build.gradle.kts | 2 +- utils/interop-rx2/build.gradle.kts | 2 +- .../rx2/plugin/DisposeOnDestroyTest.kt | 1 - utils/interop-rx3/build.gradle.kts | 2 +- utils/testing-ui-activity/build.gradle.kts | 3 +- utils/testing-ui/build.gradle.kts | 2 +- .../testing/ui/rules/AppyxActivityTestRule.kt | 1 - .../testing/ui/rules/AppyxViewTestRule.kt | 1 - utils/testing-unit-common/build.gradle.kts | 2 +- 89 files changed, 124 insertions(+), 17 deletions(-) rename appyx-navigation/{ => android}/build.gradle.kts (94%) rename appyx-navigation/{ => android}/src/androidTest/AndroidManifest.xml (83%) rename appyx-navigation/{ => android}/src/androidTest/kotlin/com/bumble/appyx/navigation/AppyxTestScenario.kt (100%) rename appyx-navigation/{ => android}/src/androidTest/kotlin/com/bumble/appyx/navigation/InternalAppyxTestActivity.kt (100%) rename appyx-navigation/{ => android}/src/androidTest/kotlin/com/bumble/appyx/navigation/node/PermanentChildTest.kt (100%) rename appyx-navigation/{ => android}/src/main/AndroidManifest.xml (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/Appyx.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/FlowExt.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/builder/Builder.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/builder/SimpleBuilder.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/children/ChildAware.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/children/ChildAwareCallbackInfo.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/children/ChildAwareExt.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/children/ChildCallback.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/children/ChildEntry.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/children/ChildEntryExt.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/children/ChildEntryMap.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/children/ChildNodeCreationManager.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/clienthelper/interactor/Interactor.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/collections/ImmutableList.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/composable/Child.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/composable/ChildRenderer.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/composable/Children.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/integration/NodeFactory.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/ActivityIntegrationPoint.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPoint.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPointProvider.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPointStub.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/LocalIntegrationPoint.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/NodeActivity.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/NodeComponentActivity.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityBoundary.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityResultHandler.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityStarter.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityStarterHost.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/CanProvideActivityStarter.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequestBoundary.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequestResultHandler.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequester.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequesterHost.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeBasedEventStream.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeBasedEventStreamImpl.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeClient.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeDoesntFitInMask.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeRegistry.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/lifecycle/ChildNodeLifecycleManager.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleExt.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycle.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/modality/AncestryInfo.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/modality/BuildContext.kt (98%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/navigation/Resolver.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/navigation/upnavigation/UpNavigationHandler.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/node/ComposableNode.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/node/EmptyNodeViews.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/node/LocalNode.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/node/Node.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/node/NodeExt.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/node/NodeView.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/node/ParentNodeExt.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/node/ParentNodeView.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/node/ViewFactory.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/plugin/NodeAwareImpl.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/state/SavedStateMap.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStore.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreExt.kt (100%) rename appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreImpl.kt (100%) rename appyx-navigation/{ => android}/src/test/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreTest.kt (100%) create mode 100644 appyx-navigation/common/.gitignore create mode 100644 appyx-navigation/common/build.gradle.kts create mode 100644 appyx-navigation/desktop/build.gradle.kts diff --git a/appyx-navigation/build.gradle.kts b/appyx-navigation/android/build.gradle.kts similarity index 94% rename from appyx-navigation/build.gradle.kts rename to appyx-navigation/android/build.gradle.kts index dc98d1748..d13d8c9fb 100644 --- a/appyx-navigation/build.gradle.kts +++ b/appyx-navigation/android/build.gradle.kts @@ -8,9 +8,8 @@ plugins { } android { - namespace = "com.bumble.appyx.navigation" + namespace = "com.bumble.appyx.navigation.android" compileSdk = libs.versions.androidCompileSdk.get().toInt() - defaultConfig { minSdk = libs.versions.androidMinSdk.get().toInt() targetSdk = libs.versions.androidTargetSdk.get().toInt() @@ -37,14 +36,15 @@ dependencies { api(composeBom) api(project(":utils:customisations")) api(project(":appyx-interactions:appyx-interactions")) + api(project(":appyx-navigation:common")) api(libs.kotlin.coroutines.android) api(libs.androidx.lifecycle.common) + api(libs.compose.runtime) api(libs.compose.ui.tooling) api(libs.compose.ui.ui) api(libs.androidx.appcompat) - implementation(composeBom) implementation(libs.compose.animation.core) implementation(libs.androidx.activity.compose) implementation(libs.androidx.lifecycle.java8) diff --git a/appyx-navigation/src/androidTest/AndroidManifest.xml b/appyx-navigation/android/src/androidTest/AndroidManifest.xml similarity index 83% rename from appyx-navigation/src/androidTest/AndroidManifest.xml rename to appyx-navigation/android/src/androidTest/AndroidManifest.xml index 307495589..f404c9c82 100644 --- a/appyx-navigation/src/androidTest/AndroidManifest.xml +++ b/appyx-navigation/android/src/androidTest/AndroidManifest.xml @@ -4,7 +4,7 @@ Date: Tue, 16 May 2023 14:06:05 +0100 Subject: [PATCH 06/94] moved code from android module to common multiplatform module - this breaks all android dependencies within --- .../src/main => common/src/androidMain}/AndroidManifest.xml | 0 .../src/commonMain}/kotlin/com/bumble/appyx/navigation/Appyx.kt | 0 .../src/commonMain}/kotlin/com/bumble/appyx/navigation/FlowExt.kt | 0 .../kotlin/com/bumble/appyx/navigation/builder/Builder.kt | 0 .../kotlin/com/bumble/appyx/navigation/builder/SimpleBuilder.kt | 0 .../kotlin/com/bumble/appyx/navigation/children/ChildAware.kt | 0 .../bumble/appyx/navigation/children/ChildAwareCallbackInfo.kt | 0 .../kotlin/com/bumble/appyx/navigation/children/ChildAwareExt.kt | 0 .../kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt | 0 .../kotlin/com/bumble/appyx/navigation/children/ChildCallback.kt | 0 .../kotlin/com/bumble/appyx/navigation/children/ChildEntry.kt | 0 .../kotlin/com/bumble/appyx/navigation/children/ChildEntryExt.kt | 0 .../kotlin/com/bumble/appyx/navigation/children/ChildEntryMap.kt | 0 .../bumble/appyx/navigation/children/ChildNodeCreationManager.kt | 0 .../bumble/appyx/navigation/clienthelper/interactor/Interactor.kt | 0 .../com/bumble/appyx/navigation/collections/ImmutableList.kt | 0 .../kotlin/com/bumble/appyx/navigation/composable/Child.kt | 0 .../com/bumble/appyx/navigation/composable/ChildRenderer.kt | 0 .../kotlin/com/bumble/appyx/navigation/composable/Children.kt | 0 .../kotlin/com/bumble/appyx/navigation/integration/NodeFactory.kt | 0 .../kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt | 0 .../appyx/navigation/integrationpoint/ActivityIntegrationPoint.kt | 0 .../bumble/appyx/navigation/integrationpoint/IntegrationPoint.kt | 0 .../appyx/navigation/integrationpoint/IntegrationPointProvider.kt | 0 .../appyx/navigation/integrationpoint/IntegrationPointStub.kt | 0 .../appyx/navigation/integrationpoint/LocalIntegrationPoint.kt | 0 .../com/bumble/appyx/navigation/integrationpoint/NodeActivity.kt | 0 .../appyx/navigation/integrationpoint/NodeComponentActivity.kt | 0 .../integrationpoint/activitystarter/ActivityBoundary.kt | 0 .../integrationpoint/activitystarter/ActivityResultHandler.kt | 0 .../integrationpoint/activitystarter/ActivityStarter.kt | 0 .../integrationpoint/activitystarter/ActivityStarterHost.kt | 0 .../integrationpoint/activitystarter/CanProvideActivityStarter.kt | 0 .../permissionrequester/PermissionRequestBoundary.kt | 0 .../permissionrequester/PermissionRequestResultHandler.kt | 0 .../integrationpoint/permissionrequester/PermissionRequester.kt | 0 .../permissionrequester/PermissionRequesterHost.kt | 0 .../integrationpoint/requestcode/RequestCodeBasedEventStream.kt | 0 .../requestcode/RequestCodeBasedEventStreamImpl.kt | 0 .../navigation/integrationpoint/requestcode/RequestCodeClient.kt | 0 .../integrationpoint/requestcode/RequestCodeDoesntFitInMask.kt | 0 .../integrationpoint/requestcode/RequestCodeRegistry.kt | 0 .../appyx/navigation/lifecycle/ChildNodeLifecycleManager.kt | 0 .../kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleExt.kt | 0 .../com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt | 0 .../bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt | 0 .../kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycle.kt | 0 .../com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt | 0 .../kotlin/com/bumble/appyx/navigation/modality/AncestryInfo.kt | 0 .../kotlin/com/bumble/appyx/navigation/modality/BuildContext.kt | 0 .../kotlin/com/bumble/appyx/navigation/navigation/Resolver.kt | 0 .../navigation/navigation/upnavigation/UpNavigationHandler.kt | 0 .../kotlin/com/bumble/appyx/navigation/node/ComposableNode.kt | 0 .../kotlin/com/bumble/appyx/navigation/node/EmptyNodeViews.kt | 0 .../kotlin/com/bumble/appyx/navigation/node/LocalNode.kt | 0 .../commonMain}/kotlin/com/bumble/appyx/navigation/node/Node.kt | 0 .../kotlin/com/bumble/appyx/navigation/node/NodeExt.kt | 0 .../kotlin/com/bumble/appyx/navigation/node/NodeView.kt | 0 .../kotlin/com/bumble/appyx/navigation/node/ParentNode.kt | 0 .../kotlin/com/bumble/appyx/navigation/node/ParentNodeExt.kt | 0 .../kotlin/com/bumble/appyx/navigation/node/ParentNodeView.kt | 0 .../kotlin/com/bumble/appyx/navigation/node/ViewFactory.kt | 0 .../kotlin/com/bumble/appyx/navigation/plugin/NodeAwareImpl.kt | 0 .../kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt | 0 .../kotlin/com/bumble/appyx/navigation/state/SavedStateMap.kt | 0 .../com/bumble/appyx/navigation/store/RetainedInstanceStore.kt | 0 .../com/bumble/appyx/navigation/store/RetainedInstanceStoreExt.kt | 0 .../bumble/appyx/navigation/store/RetainedInstanceStoreImpl.kt | 0 68 files changed, 0 insertions(+), 0 deletions(-) rename appyx-navigation/{android/src/main => common/src/androidMain}/AndroidManifest.xml (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/Appyx.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/FlowExt.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/builder/Builder.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/builder/SimpleBuilder.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/children/ChildAware.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/children/ChildAwareCallbackInfo.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/children/ChildAwareExt.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/children/ChildCallback.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/children/ChildEntry.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/children/ChildEntryExt.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/children/ChildEntryMap.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/children/ChildNodeCreationManager.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/clienthelper/interactor/Interactor.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/collections/ImmutableList.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/composable/Child.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/composable/ChildRenderer.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/composable/Children.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/integration/NodeFactory.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/integrationpoint/ActivityIntegrationPoint.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPoint.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPointProvider.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPointStub.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/integrationpoint/LocalIntegrationPoint.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/integrationpoint/NodeActivity.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/integrationpoint/NodeComponentActivity.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityBoundary.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityResultHandler.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityStarter.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityStarterHost.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/CanProvideActivityStarter.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequestBoundary.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequestResultHandler.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequester.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequesterHost.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeBasedEventStream.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeBasedEventStreamImpl.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeClient.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeDoesntFitInMask.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeRegistry.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/lifecycle/ChildNodeLifecycleManager.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleExt.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycle.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/modality/AncestryInfo.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/modality/BuildContext.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/navigation/Resolver.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/navigation/upnavigation/UpNavigationHandler.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/node/ComposableNode.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/node/EmptyNodeViews.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/node/LocalNode.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/node/Node.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/node/NodeExt.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/node/NodeView.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/node/ParentNodeExt.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/node/ParentNodeView.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/node/ViewFactory.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/plugin/NodeAwareImpl.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/state/SavedStateMap.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStore.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreExt.kt (100%) rename appyx-navigation/{android/src/main => common/src/commonMain}/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreImpl.kt (100%) diff --git a/appyx-navigation/android/src/main/AndroidManifest.xml b/appyx-navigation/common/src/androidMain/AndroidManifest.xml similarity index 100% rename from appyx-navigation/android/src/main/AndroidManifest.xml rename to appyx-navigation/common/src/androidMain/AndroidManifest.xml diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/Appyx.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/Appyx.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/Appyx.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/Appyx.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/FlowExt.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/FlowExt.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/FlowExt.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/FlowExt.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/builder/Builder.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/builder/Builder.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/builder/Builder.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/builder/Builder.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/builder/SimpleBuilder.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/builder/SimpleBuilder.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/builder/SimpleBuilder.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/builder/SimpleBuilder.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/children/ChildAware.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAware.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/children/ChildAware.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAware.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/children/ChildAwareCallbackInfo.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareCallbackInfo.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/children/ChildAwareCallbackInfo.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareCallbackInfo.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/children/ChildAwareExt.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareExt.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/children/ChildAwareExt.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareExt.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/children/ChildCallback.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildCallback.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/children/ChildCallback.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildCallback.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/children/ChildEntry.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildEntry.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/children/ChildEntry.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildEntry.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/children/ChildEntryExt.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildEntryExt.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/children/ChildEntryExt.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildEntryExt.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/children/ChildEntryMap.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildEntryMap.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/children/ChildEntryMap.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildEntryMap.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/children/ChildNodeCreationManager.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildNodeCreationManager.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/children/ChildNodeCreationManager.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildNodeCreationManager.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/clienthelper/interactor/Interactor.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/clienthelper/interactor/Interactor.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/clienthelper/interactor/Interactor.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/clienthelper/interactor/Interactor.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/collections/ImmutableList.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/collections/ImmutableList.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/collections/ImmutableList.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/collections/ImmutableList.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/composable/Child.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/Child.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/composable/Child.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/Child.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/composable/ChildRenderer.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/ChildRenderer.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/composable/ChildRenderer.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/ChildRenderer.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/composable/Children.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/Children.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/composable/Children.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/Children.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integration/NodeFactory.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeFactory.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integration/NodeFactory.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeFactory.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/ActivityIntegrationPoint.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/ActivityIntegrationPoint.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/ActivityIntegrationPoint.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/ActivityIntegrationPoint.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPoint.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPoint.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPoint.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPoint.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPointProvider.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPointProvider.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPointProvider.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPointProvider.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPointStub.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPointStub.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPointStub.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPointStub.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/LocalIntegrationPoint.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/LocalIntegrationPoint.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/LocalIntegrationPoint.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/LocalIntegrationPoint.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/NodeActivity.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/NodeActivity.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/NodeActivity.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/NodeActivity.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/NodeComponentActivity.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/NodeComponentActivity.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/NodeComponentActivity.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/NodeComponentActivity.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityBoundary.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityBoundary.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityBoundary.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityBoundary.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityResultHandler.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityResultHandler.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityResultHandler.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityResultHandler.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityStarter.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityStarter.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityStarter.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityStarter.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityStarterHost.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityStarterHost.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityStarterHost.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityStarterHost.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/CanProvideActivityStarter.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/CanProvideActivityStarter.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/CanProvideActivityStarter.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/CanProvideActivityStarter.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequestBoundary.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequestBoundary.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequestBoundary.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequestBoundary.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequestResultHandler.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequestResultHandler.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequestResultHandler.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequestResultHandler.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequester.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequester.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequester.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequester.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequesterHost.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequesterHost.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequesterHost.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequesterHost.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeBasedEventStream.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeBasedEventStream.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeBasedEventStream.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeBasedEventStream.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeBasedEventStreamImpl.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeBasedEventStreamImpl.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeBasedEventStreamImpl.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeBasedEventStreamImpl.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeClient.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeClient.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeClient.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeClient.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeDoesntFitInMask.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeDoesntFitInMask.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeDoesntFitInMask.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeDoesntFitInMask.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeRegistry.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeRegistry.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeRegistry.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeRegistry.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/lifecycle/ChildNodeLifecycleManager.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/ChildNodeLifecycleManager.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/lifecycle/ChildNodeLifecycleManager.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/ChildNodeLifecycleManager.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleExt.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleExt.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleExt.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleExt.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycle.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycle.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycle.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycle.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/modality/AncestryInfo.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/modality/AncestryInfo.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/modality/AncestryInfo.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/modality/AncestryInfo.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/modality/BuildContext.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/modality/BuildContext.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/modality/BuildContext.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/modality/BuildContext.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/navigation/Resolver.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/navigation/Resolver.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/navigation/Resolver.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/navigation/Resolver.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/navigation/upnavigation/UpNavigationHandler.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/navigation/upnavigation/UpNavigationHandler.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/navigation/upnavigation/UpNavigationHandler.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/navigation/upnavigation/UpNavigationHandler.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/ComposableNode.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ComposableNode.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/ComposableNode.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ComposableNode.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/EmptyNodeViews.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/EmptyNodeViews.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/EmptyNodeViews.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/EmptyNodeViews.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/LocalNode.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/LocalNode.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/LocalNode.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/LocalNode.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/Node.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/Node.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/NodeExt.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/NodeExt.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/NodeExt.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/NodeExt.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/NodeView.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/NodeView.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/NodeView.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/NodeView.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/ParentNodeExt.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNodeExt.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/ParentNodeExt.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNodeExt.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/ParentNodeView.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNodeView.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/ParentNodeView.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNodeView.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/ViewFactory.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ViewFactory.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/ViewFactory.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ViewFactory.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/plugin/NodeAwareImpl.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/NodeAwareImpl.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/plugin/NodeAwareImpl.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/NodeAwareImpl.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/state/SavedStateMap.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/state/SavedStateMap.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/state/SavedStateMap.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/state/SavedStateMap.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStore.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStore.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStore.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStore.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreExt.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreExt.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreExt.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreExt.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreImpl.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreImpl.kt similarity index 100% rename from appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreImpl.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreImpl.kt From d0e4ae58126fab7bdf98215dfb084971937415d2 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Tue, 16 May 2023 14:06:28 +0100 Subject: [PATCH 07/94] declared common platform interfaces --- .../appyx/navigation/platform/Lifecycle.kt | 30 +++++++++ .../navigation/platform/LifecycleObserver.kt | 63 +++++++++++++++++++ .../navigation/platform/LifecycleOwner.kt | 10 +++ .../navigation/platform/LifecycleRegistry.kt | 7 +++ .../navigation/platform/OnBackPressed.kt | 14 +++++ .../appyx/navigation/platform/PlatformDeps.kt | 7 +++ 6 files changed, 131 insertions(+) create mode 100644 appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/Lifecycle.kt create mode 100644 appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleObserver.kt create mode 100644 appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleOwner.kt create mode 100644 appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt create mode 100644 appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/OnBackPressed.kt create mode 100644 appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformDeps.kt diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/Lifecycle.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/Lifecycle.kt new file mode 100644 index 000000000..26b29cd9f --- /dev/null +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/Lifecycle.kt @@ -0,0 +1,30 @@ +package com.bumble.appyx.navigation.platform + +import kotlinx.coroutines.CoroutineScope + +interface Lifecycle { + var currentState: State + + val coroutineScope: CoroutineScope + + fun addObserver(observer: LifecycleObserver) + + fun removeObserver(observer: LifecycleObserver) + + enum class State { + INITIALIZED, + CREATED, + RESUMED, + DESTROYED, + } + + enum class Event { + ON_CREATE, + ON_START, + ON_RESUME, + ON_PAUSE, + ON_STOP, + ON_DESTROY, + ON_ANY, + } +} diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleObserver.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleObserver.kt new file mode 100644 index 000000000..9c68e21fd --- /dev/null +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleObserver.kt @@ -0,0 +1,63 @@ +package com.bumble.appyx.navigation.platform + +/** + * Ported from Androidx.lifecycle + * + * Marks a class as a LifecycleObserver. Don't use this interface directly. Instead implement either DefaultLifecycleObserver or LifecycleEventObserver to be notified about lifecycle events. + * See Also: + * Lifecycle - for samples and usage patterns. + */ +interface LifecycleObserver { +} + +interface FullLifecycleObserver : LifecycleObserver { + fun onCreate(owner: LifecycleOwner) + fun onStart(owner: LifecycleOwner) + fun onResume(owner: LifecycleOwner) + fun onPause(owner: LifecycleOwner) + fun onStop(owner: LifecycleOwner) + fun onDestroy(owner: LifecycleOwner) +} + +/** + * Ported from Androidx.lifecycle + * + * Callback interface for listening to LifecycleOwner state changes. + * If a class implements both this interface and LifecycleEventObserver, then methods of + * DefaultLifecycleObserver will be called first, and then followed by the call of + * LifecycleEventObserver.onStateChanged(LifecycleOwner, Lifecycle.Event) + * + * If a class implements this interface and in the same time uses OnLifecycleEvent, + * then annotations will be ignored. + */ +interface DefaultLifecycleObserver : FullLifecycleObserver { + override fun onCreate(owner: LifecycleOwner) {} + override fun onStart(owner: LifecycleOwner) {} + override fun onResume(owner: LifecycleOwner) {} + override fun onPause(owner: LifecycleOwner) {} + override fun onStop(owner: LifecycleOwner) {} + override fun onDestroy(owner: LifecycleOwner) {} +} + +/** + * Class that can receive any lifecycle change and dispatch it to the receiver. + * + * + * If a class implements both this interface and + * [DefaultLifecycleObserver], then + * methods of `DefaultLifecycleObserver` will be called first, and then followed by the call + * of [LifecycleEventObserver.onStateChanged] + * + * + * If a class implements this interface and in the same time uses [OnLifecycleEvent], then + * annotations will be ignored. + */ +fun interface LifecycleEventObserver : LifecycleObserver { + /** + * Called when a state transition event happens. + * + * @param source The source of the event + * @param event The event + */ + fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) +} diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleOwner.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleOwner.kt new file mode 100644 index 000000000..e4efc2325 --- /dev/null +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleOwner.kt @@ -0,0 +1,10 @@ +package com.bumble.appyx.navigation.platform + +import kotlinx.coroutines.CoroutineScope + +interface LifecycleOwner { + val lifecycle: Lifecycle + val lifecycleScope: CoroutineScope +} + +interface LocalLifecycleOwnerProvider : () -> LifecycleOwner diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt new file mode 100644 index 000000000..62ea99f6e --- /dev/null +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt @@ -0,0 +1,7 @@ +package com.bumble.appyx.navigation.platform + +interface LifecycleRegistry : Lifecycle { + fun setCurrentState(state: Lifecycle.State) +} + +interface LifecycleRegistryProvider : (LifecycleOwner) -> LifecycleRegistry diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/OnBackPressed.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/OnBackPressed.kt new file mode 100644 index 000000000..ed50a1b6d --- /dev/null +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/OnBackPressed.kt @@ -0,0 +1,14 @@ +package com.bumble.appyx.navigation.platform + +abstract class OnBackPressedCallback(var isEnabled: Boolean) { + + abstract fun handleOnBackPressed() + + open fun remove() {} +} + +interface OnBackPressedDispatcher { + fun addCallback(lifecycleOwner: LifecycleOwner, callback: OnBackPressedCallback) +} + +interface OnBackPressedDispatcherProvider : () -> OnBackPressedDispatcher? diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformDeps.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformDeps.kt new file mode 100644 index 000000000..d76561618 --- /dev/null +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformDeps.kt @@ -0,0 +1,7 @@ +package com.bumble.appyx.navigation.platform + +interface PlatformDeps { + val lifecycleRegistryProvider: LifecycleRegistryProvider + val onBackPressedDispatcherProvider: OnBackPressedDispatcherProvider + val localLifecycleOwnerProvider: LocalLifecycleOwnerProvider +} From ce2a498d079b9251e65caf0168fc01f8728a0094 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Wed, 17 May 2023 17:22:01 +0100 Subject: [PATCH 08/94] made customizations a multiplatform module --- appyx-navigation/common/build.gradle.kts | 2 ++ utils/customisations/build.gradle.kts | 22 ++++++++++++++----- .../MutableNodeCustomisationDirectory.kt | 0 .../utils/customisations/NodeCustomisation.kt | 0 .../NodeCustomisationDirectory.kt | 0 .../NodeCustomisationDirectoryImpl.kt | 0 6 files changed, 18 insertions(+), 6 deletions(-) rename utils/customisations/src/{main => commonMain}/kotlin/com/bumble/appyx/utils/customisations/MutableNodeCustomisationDirectory.kt (100%) rename utils/customisations/src/{main => commonMain}/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisation.kt (100%) rename utils/customisations/src/{main => commonMain}/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectory.kt (100%) rename utils/customisations/src/{main => commonMain}/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt (100%) diff --git a/appyx-navigation/common/build.gradle.kts b/appyx-navigation/common/build.gradle.kts index 4eb5185c3..739ecceb6 100644 --- a/appyx-navigation/common/build.gradle.kts +++ b/appyx-navigation/common/build.gradle.kts @@ -27,6 +27,8 @@ kotlin { api(compose.material) api(project(":utils:multiplatform")) implementation(libs.kotlinx.serialization.json) + implementation(project(":utils:customisations")) + implementation(project(":appyx-interactions:appyx-interactions")) } } val commonTest by getting { diff --git a/utils/customisations/build.gradle.kts b/utils/customisations/build.gradle.kts index e2ef08b79..e1a802079 100644 --- a/utils/customisations/build.gradle.kts +++ b/utils/customisations/build.gradle.kts @@ -1,7 +1,6 @@ plugins { - id("java-library") - id("kotlin") - id("appyx-publish-java") + kotlin("multiplatform") + id("appyx-publish-multiplatform") id("appyx-detekt") } @@ -9,7 +8,18 @@ publishingPlugin { artifactId = "utils-customisations" } -java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 +kotlin { + jvm { + compilations.all { + kotlinOptions.jvmTarget = libs.versions.jvmTarget.get() + } + } + js(IR) { + // Adding moduleName as a workaround for this issue: https://youtrack.jetbrains.com/issue/KT-51942 + moduleName = "appyx-utils-customisation" + browser() + } + sourceSets { + val commonMain by getting + } } diff --git a/utils/customisations/src/main/kotlin/com/bumble/appyx/utils/customisations/MutableNodeCustomisationDirectory.kt b/utils/customisations/src/commonMain/kotlin/com/bumble/appyx/utils/customisations/MutableNodeCustomisationDirectory.kt similarity index 100% rename from utils/customisations/src/main/kotlin/com/bumble/appyx/utils/customisations/MutableNodeCustomisationDirectory.kt rename to utils/customisations/src/commonMain/kotlin/com/bumble/appyx/utils/customisations/MutableNodeCustomisationDirectory.kt diff --git a/utils/customisations/src/main/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisation.kt b/utils/customisations/src/commonMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisation.kt similarity index 100% rename from utils/customisations/src/main/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisation.kt rename to utils/customisations/src/commonMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisation.kt diff --git a/utils/customisations/src/main/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectory.kt b/utils/customisations/src/commonMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectory.kt similarity index 100% rename from utils/customisations/src/main/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectory.kt rename to utils/customisations/src/commonMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectory.kt diff --git a/utils/customisations/src/main/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt b/utils/customisations/src/commonMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt similarity index 100% rename from utils/customisations/src/main/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt rename to utils/customisations/src/commonMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt From 9f95ed2b2bc079b038729b5a49e6e320b6825ec4 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Wed, 17 May 2023 17:24:14 +0100 Subject: [PATCH 09/94] refactored handling of IntegrationPoint, removing android specific concerns to Android-only code --- .../ActivityIntegrationPoint.kt | 9 ++++--- .../AndroidIntegrationPoint.kt | 26 +++++++++++++++++++ .../integrationpoint/IntegrationPointStub.kt | 0 .../integrationpoint/LocalIntegrationPoint.kt | 0 .../integrationpoint/NodeActivity.kt | 0 .../integrationpoint/NodeComponentActivity.kt | 0 .../activitystarter/ActivityBoundary.kt | 0 .../activitystarter/ActivityResultHandler.kt | 0 .../activitystarter/ActivityStarter.kt | 0 .../activitystarter/ActivityStarterHost.kt | 0 .../CanProvideActivityStarter.kt | 0 .../PermissionRequestBoundary.kt | 0 .../PermissionRequestResultHandler.kt | 0 .../PermissionRequester.kt | 0 .../PermissionRequesterHost.kt | 0 .../RequestCodeBasedEventStream.kt | 0 .../RequestCodeBasedEventStreamImpl.kt | 0 .../requestcode/RequestCodeClient.kt | 0 .../requestcode/RequestCodeDoesntFitInMask.kt | 0 .../requestcode/RequestCodeRegistry.kt | 0 .../integrationpoint/IntegrationPoint.kt | 18 +------------ 21 files changed, 33 insertions(+), 20 deletions(-) rename appyx-navigation/{common/src/commonMain => android/src/main}/kotlin/com/bumble/appyx/navigation/integrationpoint/ActivityIntegrationPoint.kt (89%) create mode 100644 appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/AndroidIntegrationPoint.kt rename appyx-navigation/{common/src/commonMain => android/src/main}/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPointStub.kt (100%) rename appyx-navigation/{common/src/commonMain => android/src/main}/kotlin/com/bumble/appyx/navigation/integrationpoint/LocalIntegrationPoint.kt (100%) rename appyx-navigation/{common/src/commonMain => android/src/main}/kotlin/com/bumble/appyx/navigation/integrationpoint/NodeActivity.kt (100%) rename appyx-navigation/{common/src/commonMain => android/src/main}/kotlin/com/bumble/appyx/navigation/integrationpoint/NodeComponentActivity.kt (100%) rename appyx-navigation/{common/src/commonMain => android/src/main}/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityBoundary.kt (100%) rename appyx-navigation/{common/src/commonMain => android/src/main}/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityResultHandler.kt (100%) rename appyx-navigation/{common/src/commonMain => android/src/main}/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityStarter.kt (100%) rename appyx-navigation/{common/src/commonMain => android/src/main}/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityStarterHost.kt (100%) rename appyx-navigation/{common/src/commonMain => android/src/main}/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/CanProvideActivityStarter.kt (100%) rename appyx-navigation/{common/src/commonMain => android/src/main}/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequestBoundary.kt (100%) rename appyx-navigation/{common/src/commonMain => android/src/main}/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequestResultHandler.kt (100%) rename appyx-navigation/{common/src/commonMain => android/src/main}/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequester.kt (100%) rename appyx-navigation/{common/src/commonMain => android/src/main}/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequesterHost.kt (100%) rename appyx-navigation/{common/src/commonMain => android/src/main}/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeBasedEventStream.kt (100%) rename appyx-navigation/{common/src/commonMain => android/src/main}/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeBasedEventStreamImpl.kt (100%) rename appyx-navigation/{common/src/commonMain => android/src/main}/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeClient.kt (100%) rename appyx-navigation/{common/src/commonMain => android/src/main}/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeDoesntFitInMask.kt (100%) rename appyx-navigation/{common/src/commonMain => android/src/main}/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeRegistry.kt (100%) diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/ActivityIntegrationPoint.kt b/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/ActivityIntegrationPoint.kt similarity index 89% rename from appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/ActivityIntegrationPoint.kt rename to appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/ActivityIntegrationPoint.kt index db010ad99..f44c51a1c 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/ActivityIntegrationPoint.kt +++ b/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/ActivityIntegrationPoint.kt @@ -13,7 +13,7 @@ import com.bumble.appyx.navigation.integrationpoint.permissionrequester.Permissi open class ActivityIntegrationPoint( private val activity: Activity, savedInstanceState: Bundle?, -) : IntegrationPoint(savedInstanceState = savedInstanceState) { +) : AndroidIntegrationPoint(savedInstanceState = savedInstanceState) { private val activityBoundary = ActivityBoundary(activity, requestCodeRegistry) private val permissionRequestBoundary = PermissionRequestBoundary(activity, requestCodeRegistry) @@ -51,7 +51,7 @@ open class ActivityIntegrationPoint( } companion object { - fun getIntegrationPoint(context: Context): IntegrationPoint { + fun getIntegrationPoint(context: Context): AndroidIntegrationPoint { val activity = context.findActivity() checkNotNull(activity) { "Could not find an activity from the context: $context" @@ -61,7 +61,10 @@ open class ActivityIntegrationPoint( "Activity ${activity::class.qualifiedName} does not implement IntegrationPointProvider" ) - return integrationPointProvider.appyxIntegrationPoint + return integrationPointProvider.appyxIntegrationPoint as? AndroidIntegrationPoint + ?: error( + "Activity ${activity::class.qualifiedName} does not provide AndroidIntegrationPoint" + ) } @Suppress("UNCHECKED_CAST") diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/AndroidIntegrationPoint.kt b/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/AndroidIntegrationPoint.kt new file mode 100644 index 000000000..c6c88f790 --- /dev/null +++ b/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/AndroidIntegrationPoint.kt @@ -0,0 +1,26 @@ +package com.bumble.appyx.navigation.integrationpoint + +import android.os.Bundle +import androidx.compose.runtime.Stable +import com.bumble.appyx.navigation.integrationpoint.activitystarter.ActivityStarter +import com.bumble.appyx.navigation.integrationpoint.permissionrequester.PermissionRequester +import com.bumble.appyx.navigation.integrationpoint.requestcode.RequestCodeRegistry + +@Stable +abstract class AndroidIntegrationPoint( + protected val savedInstanceState: Bundle? +) : IntegrationPoint() { + + protected val requestCodeRegistry = + RequestCodeRegistry( + savedInstanceState + ) + + abstract val activityStarter: ActivityStarter + + abstract val permissionRequester: PermissionRequester + + fun onSaveInstanceState(outState: Bundle) { + requestCodeRegistry.onSaveInstanceState(outState) + } +} diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPointStub.kt b/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPointStub.kt similarity index 100% rename from appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPointStub.kt rename to appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPointStub.kt diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/LocalIntegrationPoint.kt b/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/LocalIntegrationPoint.kt similarity index 100% rename from appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/LocalIntegrationPoint.kt rename to appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/LocalIntegrationPoint.kt diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/NodeActivity.kt b/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/NodeActivity.kt similarity index 100% rename from appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/NodeActivity.kt rename to appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/NodeActivity.kt diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/NodeComponentActivity.kt b/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/NodeComponentActivity.kt similarity index 100% rename from appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/NodeComponentActivity.kt rename to appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/NodeComponentActivity.kt diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityBoundary.kt b/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityBoundary.kt similarity index 100% rename from appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityBoundary.kt rename to appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityBoundary.kt diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityResultHandler.kt b/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityResultHandler.kt similarity index 100% rename from appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityResultHandler.kt rename to appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityResultHandler.kt diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityStarter.kt b/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityStarter.kt similarity index 100% rename from appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityStarter.kt rename to appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityStarter.kt diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityStarterHost.kt b/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityStarterHost.kt similarity index 100% rename from appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityStarterHost.kt rename to appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/ActivityStarterHost.kt diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/CanProvideActivityStarter.kt b/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/CanProvideActivityStarter.kt similarity index 100% rename from appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/CanProvideActivityStarter.kt rename to appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/activitystarter/CanProvideActivityStarter.kt diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequestBoundary.kt b/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequestBoundary.kt similarity index 100% rename from appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequestBoundary.kt rename to appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequestBoundary.kt diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequestResultHandler.kt b/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequestResultHandler.kt similarity index 100% rename from appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequestResultHandler.kt rename to appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequestResultHandler.kt diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequester.kt b/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequester.kt similarity index 100% rename from appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequester.kt rename to appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequester.kt diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequesterHost.kt b/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequesterHost.kt similarity index 100% rename from appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequesterHost.kt rename to appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/permissionrequester/PermissionRequesterHost.kt diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeBasedEventStream.kt b/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeBasedEventStream.kt similarity index 100% rename from appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeBasedEventStream.kt rename to appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeBasedEventStream.kt diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeBasedEventStreamImpl.kt b/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeBasedEventStreamImpl.kt similarity index 100% rename from appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeBasedEventStreamImpl.kt rename to appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeBasedEventStreamImpl.kt diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeClient.kt b/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeClient.kt similarity index 100% rename from appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeClient.kt rename to appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeClient.kt diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeDoesntFitInMask.kt b/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeDoesntFitInMask.kt similarity index 100% rename from appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeDoesntFitInMask.kt rename to appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeDoesntFitInMask.kt diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeRegistry.kt b/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeRegistry.kt similarity index 100% rename from appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeRegistry.kt rename to appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/requestcode/RequestCodeRegistry.kt diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPoint.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPoint.kt index cdce57eca..615cfbaff 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPoint.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPoint.kt @@ -1,28 +1,12 @@ package com.bumble.appyx.navigation.integrationpoint -import android.os.Bundle import androidx.compose.runtime.Stable -import com.bumble.appyx.navigation.integrationpoint.activitystarter.ActivityStarter -import com.bumble.appyx.navigation.integrationpoint.permissionrequester.PermissionRequester -import com.bumble.appyx.navigation.integrationpoint.requestcode.RequestCodeRegistry import com.bumble.appyx.navigation.navigation.upnavigation.UpNavigationHandler @Stable -abstract class IntegrationPoint( - protected val savedInstanceState: Bundle? -) : UpNavigationHandler { - - protected val requestCodeRegistry = RequestCodeRegistry(savedInstanceState) - - abstract val activityStarter: ActivityStarter - - abstract val permissionRequester: PermissionRequester +abstract class IntegrationPoint : UpNavigationHandler { abstract val isChangingConfigurations: Boolean - fun onSaveInstanceState(outState: Bundle) { - requestCodeRegistry.onSaveInstanceState(outState) - } - abstract fun onRootFinished() } From 372af071a33bfeaa2a1f81eab543647973a60170 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Wed, 17 May 2023 17:30:10 +0100 Subject: [PATCH 10/94] updated imports --- .../appyx/navigation/children/ChildAwareCallbackInfo.kt | 2 +- .../bumble/appyx/navigation/children/ChildAwareImpl.kt | 7 +++---- .../bumble/appyx/navigation/children/ChildCallback.kt | 2 +- .../navigation/children/ChildNodeCreationManager.kt | 1 - .../com/bumble/appyx/navigation/integration/NodeHost.kt | 6 +++--- .../navigation/lifecycle/ChildNodeLifecycleManager.kt | 4 ++-- .../bumble/appyx/navigation/lifecycle/LifecycleExt.kt | 8 ++++---- .../bumble/appyx/navigation/lifecycle/LifecycleLogger.kt | 4 ++-- .../navigation/lifecycle/MinimumCombinedLifecycle.kt | 9 +++++---- .../bumble/appyx/navigation/lifecycle/NodeLifecycle.kt | 4 ++-- .../appyx/navigation/lifecycle/NodeLifecycleImpl.kt | 6 +++--- .../kotlin/com/bumble/appyx/navigation/node/Node.kt | 7 +++---- .../com/bumble/appyx/navigation/node/ParentNode.kt | 4 +--- .../kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt | 4 ++-- 14 files changed, 32 insertions(+), 36 deletions(-) diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareCallbackInfo.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareCallbackInfo.kt index 0728fcc63..9e4e6af10 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareCallbackInfo.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareCallbackInfo.kt @@ -1,9 +1,9 @@ package com.bumble.appyx.navigation.children -import androidx.lifecycle.Lifecycle import com.bumble.appyx.navigation.lifecycle.MinimumCombinedLifecycle import com.bumble.appyx.navigation.lifecycle.isDestroyed import com.bumble.appyx.navigation.node.Node +import com.bumble.appyx.navigation.platform.Lifecycle import kotlin.reflect.KClass import kotlin.reflect.cast import kotlin.reflect.safeCast diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt index d38d70562..0798ae0a8 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt @@ -1,13 +1,12 @@ package com.bumble.appyx.navigation.children -import androidx.lifecycle.DefaultLifecycleObserver -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.coroutineScope import com.bumble.appyx.interactions.core.Element import com.bumble.appyx.navigation.lifecycle.isDestroyed import com.bumble.appyx.navigation.node.Node import com.bumble.appyx.navigation.node.ParentNode +import com.bumble.appyx.navigation.platform.DefaultLifecycleObserver +import com.bumble.appyx.navigation.platform.Lifecycle +import com.bumble.appyx.navigation.platform.LifecycleOwner import com.bumble.appyx.navigation.withPrevious import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.MutableStateFlow diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildCallback.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildCallback.kt index 8662e553f..8afaee8bd 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildCallback.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildCallback.kt @@ -1,6 +1,6 @@ package com.bumble.appyx.navigation.children -import androidx.lifecycle.Lifecycle +import com.bumble.appyx.navigation.platform.Lifecycle typealias ChildrenCallback = (commonLifecycle: Lifecycle, child1: T1, child2: T2) -> Unit diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildNodeCreationManager.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildNodeCreationManager.kt index 435616100..da89a52ee 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildNodeCreationManager.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildNodeCreationManager.kt @@ -1,6 +1,5 @@ package com.bumble.appyx.navigation.children -import androidx.lifecycle.coroutineScope import com.bumble.appyx.interactions.core.Element import com.bumble.appyx.interactions.core.state.MutableSavedStateMap import com.bumble.appyx.navigation.modality.AncestryInfo diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt index 5e8b4cc1e..22e644f37 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt @@ -9,13 +9,13 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.saveable.mapSaver import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalLifecycleOwner -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleEventObserver import com.bumble.appyx.navigation.integrationpoint.IntegrationPoint import com.bumble.appyx.navigation.modality.BuildContext import com.bumble.appyx.navigation.node.Node import com.bumble.appyx.navigation.node.build +import com.bumble.appyx.navigation.platform.Lifecycle +import com.bumble.appyx.navigation.platform.LifecycleEventObserver +import com.bumble.appyx.navigation.platform.LocalLifecycleOwnerProvider import com.bumble.appyx.navigation.state.SavedStateMap import com.bumble.appyx.utils.customisations.NodeCustomisationDirectory import com.bumble.appyx.utils.customisations.NodeCustomisationDirectoryImpl diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/ChildNodeLifecycleManager.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/ChildNodeLifecycleManager.kt index 9a207a833..6dce1641a 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/ChildNodeLifecycleManager.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/ChildNodeLifecycleManager.kt @@ -1,11 +1,11 @@ package com.bumble.appyx.navigation.lifecycle -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleRegistry import com.bumble.appyx.interactions.core.model.InteractionModel import com.bumble.appyx.navigation.children.ChildEntry import com.bumble.appyx.navigation.children.ChildEntryMap import com.bumble.appyx.navigation.children.nodeOrNull +import com.bumble.appyx.navigation.platform.Lifecycle +import com.bumble.appyx.navigation.platform.LifecycleRegistry import com.bumble.appyx.navigation.withPrevious import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.MutableStateFlow diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleExt.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleExt.kt index 6a14d3404..52115257e 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleExt.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleExt.kt @@ -1,9 +1,9 @@ package com.bumble.appyx.navigation.lifecycle -import androidx.lifecycle.DefaultLifecycleObserver -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleEventObserver -import androidx.lifecycle.LifecycleOwner +import com.bumble.appyx.navigation.platform.DefaultLifecycleObserver +import com.bumble.appyx.navigation.platform.Lifecycle +import com.bumble.appyx.navigation.platform.LifecycleEventObserver +import com.bumble.appyx.navigation.platform.LifecycleOwner import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt index 0d596587c..e43e503d1 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt @@ -1,8 +1,8 @@ package com.bumble.appyx.navigation.lifecycle import android.util.Log -import androidx.lifecycle.DefaultLifecycleObserver -import androidx.lifecycle.LifecycleOwner +import com.bumble.appyx.navigation.platform.DefaultLifecycleObserver +import com.bumble.appyx.navigation.platform.LifecycleOwner internal object LifecycleLogger : DefaultLifecycleObserver { diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt index cc527467a..361a4526c 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt @@ -1,9 +1,10 @@ package com.bumble.appyx.navigation.lifecycle -import androidx.lifecycle.DefaultLifecycleObserver -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.LifecycleRegistry +import com.bumble.appyx.navigation.platform.DefaultLifecycleObserver +import com.bumble.appyx.navigation.platform.Lifecycle +import com.bumble.appyx.navigation.platform.LifecycleOwner +import com.bumble.appyx.navigation.platform.LifecycleRegistry + /** * Combines multiple lifecycles and provides a minimum of their states. diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycle.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycle.kt index e99a45e43..a709dc8c2 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycle.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycle.kt @@ -1,7 +1,7 @@ package com.bumble.appyx.navigation.lifecycle -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleOwner +import com.bumble.appyx.navigation.platform.Lifecycle +import com.bumble.appyx.navigation.platform.LifecycleOwner interface NodeLifecycle : LifecycleOwner { diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt index ff34136a4..e61f152ff 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt @@ -1,8 +1,8 @@ package com.bumble.appyx.navigation.lifecycle -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.LifecycleRegistry +import com.bumble.appyx.navigation.platform.Lifecycle +import com.bumble.appyx.navigation.platform.LifecycleOwner +import com.bumble.appyx.navigation.platform.LifecycleRegistry internal class NodeLifecycleImpl(owner: LifecycleOwner) : NodeLifecycle { diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt index 9f2b34992..96b6f3655 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt @@ -8,10 +8,6 @@ import androidx.compose.runtime.Stable import androidx.compose.runtime.saveable.SaverScope import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalLifecycleOwner -import androidx.lifecycle.DefaultLifecycleObserver -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.lifecycleScope import com.bumble.appyx.interactions.core.plugin.Plugin import com.bumble.appyx.interactions.core.plugin.SavesInstanceState import com.bumble.appyx.interactions.core.state.MutableSavedStateMap @@ -26,6 +22,9 @@ import com.bumble.appyx.navigation.lifecycle.NodeLifecycle import com.bumble.appyx.navigation.lifecycle.NodeLifecycleImpl import com.bumble.appyx.navigation.modality.AncestryInfo import com.bumble.appyx.navigation.modality.BuildContext +import com.bumble.appyx.navigation.platform.DefaultLifecycleObserver +import com.bumble.appyx.navigation.platform.Lifecycle +import com.bumble.appyx.navigation.platform.LifecycleOwner import com.bumble.appyx.navigation.plugin.Destroyable import com.bumble.appyx.navigation.plugin.NodeLifecycleAware import com.bumble.appyx.navigation.plugin.NodeReadyObserver diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt index 3ff350146..b00b4c0d2 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt @@ -1,6 +1,5 @@ package com.bumble.appyx.navigation.node -import androidx.activity.compose.BackHandler import androidx.annotation.CallSuper import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -10,8 +9,6 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.lifecycleScope import com.bumble.appyx.interactions.core.Element import com.bumble.appyx.interactions.core.model.InteractionModel import com.bumble.appyx.interactions.core.model.plus @@ -35,6 +32,7 @@ import com.bumble.appyx.navigation.lifecycle.ChildNodeLifecycleManager import com.bumble.appyx.navigation.mapState import com.bumble.appyx.navigation.modality.BuildContext import com.bumble.appyx.navigation.navigation.Resolver +import com.bumble.appyx.navigation.platform.Lifecycle import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.launch diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt index 0c731f1d5..e2ad1eb31 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt @@ -1,9 +1,9 @@ package com.bumble.appyx.navigation.plugin -import androidx.activity.OnBackPressedCallback -import androidx.lifecycle.Lifecycle import com.bumble.appyx.interactions.core.plugin.Plugin import com.bumble.appyx.navigation.node.Node +import com.bumble.appyx.navigation.platform.Lifecycle +import com.bumble.appyx.navigation.platform.OnBackPressedCallback inline fun Node.plugins(): List

= this.plugins.filterIsInstance(P::class.java) From c2b568d4926e75df725b333ba3fde7f9a6c89f34 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Wed, 17 May 2023 17:43:12 +0100 Subject: [PATCH 11/94] addressed class references --- .../com/bumble/appyx/navigation/children/ChildEntry.kt | 6 ++++-- .../kotlin/com/bumble/appyx/navigation/node/ParentNode.kt | 2 +- .../kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildEntry.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildEntry.kt index fa27bead5..22fa83b92 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildEntry.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildEntry.kt @@ -9,13 +9,15 @@ sealed class ChildEntry { abstract val key: Element override fun equals(other: Any?): Boolean = - other?.javaClass == javaClass && (other as? ChildEntry<*>)?.key == key + other != null + && other::class == this::class + && (other as? ChildEntry<*>)?.key == key override fun hashCode(): Int = key.hashCode() override fun toString(): String = - "$key@${javaClass.simpleName}" + "$key@${this::class.simpleName}" /** All public APIs should return this type of child which is ready to work with. */ class Initialized( diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt index b00b4c0d2..a5f370a9a 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt @@ -168,7 +168,7 @@ abstract class ParentNode( waitForChildAttached() } checkNotNull(result) { - "Expected child of type [${T::class.java}] was not found after executing action. " + + "Expected child of type [${T::class}] was not found after executing action. " + "Check that your action actually results in the expected child." } } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt index e2ad1eb31..61aafa808 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt @@ -6,7 +6,7 @@ import com.bumble.appyx.navigation.platform.Lifecycle import com.bumble.appyx.navigation.platform.OnBackPressedCallback inline fun Node.plugins(): List

= - this.plugins.filterIsInstance(P::class.java) + this.plugins.filterIsInstance

() interface NodeAware : NodeReadyObserver { val node: N From 25fef49f72152d08eb4ac9eee0d99b307522d609 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Wed, 17 May 2023 17:43:52 +0100 Subject: [PATCH 12/94] added simple multiplatform logger for use in LifecycleLogger.kt might have ramifications for testing where logcat shouldn't be referenced... --- .../appyx/navigation/lifecycle/LifecycleLogger.kt | 15 ++++++++------- .../bumble/appyx/utils/multiplatform/Logger.kt | 9 +++++++++ .../bumble/appyx/utils/multiplatform/Logger.kt | 5 +++++ .../bumble/appyx/utils/multiplatform/Logger.kt | 7 +++++++ .../bumble/appyx/utils/multiplatform/Logger.kt | 7 +++++++ 5 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 utils/multiplatform/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt create mode 100644 utils/multiplatform/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt create mode 100644 utils/multiplatform/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt create mode 100644 utils/multiplatform/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt index e43e503d1..43c62cd3d 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt @@ -1,35 +1,36 @@ package com.bumble.appyx.navigation.lifecycle -import android.util.Log import com.bumble.appyx.navigation.platform.DefaultLifecycleObserver import com.bumble.appyx.navigation.platform.LifecycleOwner +import com.bumble.appyx.utils.multiplatform.Logger internal object LifecycleLogger : DefaultLifecycleObserver { private const val LOG_TAG = "Lifecycle" + private val LOGGER = Logger() override fun onCreate(owner: LifecycleOwner) { - Log.d(LOG_TAG, "${owner.javaClass.simpleName}@${owner.hashCode()} onCreate") + LOGGER.d(LOG_TAG, "${owner::class.simpleName}@${owner.hashCode()} onCreate") } override fun onStart(owner: LifecycleOwner) { - Log.d(LOG_TAG, "${owner.javaClass.simpleName}@${owner.hashCode()} onStart") + LOGGER.d(LOG_TAG, "${owner::class.simpleName}@${owner.hashCode()} onStart") } override fun onResume(owner: LifecycleOwner) { - Log.d(LOG_TAG, "${owner.javaClass.simpleName}@${owner.hashCode()} onResume") + LOGGER.d(LOG_TAG, "${owner::class.simpleName}@${owner.hashCode()} onResume") } override fun onPause(owner: LifecycleOwner) { - Log.d(LOG_TAG, "${owner.javaClass.simpleName}@${owner.hashCode()} onPause") + LOGGER.d(LOG_TAG, "${owner::class.simpleName}@${owner.hashCode()} onPause") } override fun onStop(owner: LifecycleOwner) { - Log.d(LOG_TAG, "${owner.javaClass.simpleName}@${owner.hashCode()} onStop") + LOGGER.d(LOG_TAG, "${owner::class.simpleName}@${owner.hashCode()} onStop") } override fun onDestroy(owner: LifecycleOwner) { - Log.d(LOG_TAG, "${owner.javaClass.simpleName}@${owner.hashCode()} onDestroy") + LOGGER.d(LOG_TAG, "${owner::class.simpleName}@${owner.hashCode()} onDestroy") } } diff --git a/utils/multiplatform/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt b/utils/multiplatform/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt new file mode 100644 index 000000000..6919bfbcc --- /dev/null +++ b/utils/multiplatform/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt @@ -0,0 +1,9 @@ +package com.bumble.appyx.utils.multiplatform + +import android.util.Log + +actual class Logger { + actual fun d(tag: String, message: String) { + Log.d(tag, message) + } +} diff --git a/utils/multiplatform/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt b/utils/multiplatform/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt new file mode 100644 index 000000000..441b9c36e --- /dev/null +++ b/utils/multiplatform/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt @@ -0,0 +1,5 @@ +package com.bumble.appyx.utils.multiplatform + +expect class Logger() { + fun d(tag: String, message: String) +} diff --git a/utils/multiplatform/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt b/utils/multiplatform/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt new file mode 100644 index 000000000..40b90ed2b --- /dev/null +++ b/utils/multiplatform/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt @@ -0,0 +1,7 @@ +package com.bumble.appyx.utils.multiplatform + +actual class Logger { + actual fun d(tag: String, message: String) { + println("$tag: $message") + } +} diff --git a/utils/multiplatform/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt b/utils/multiplatform/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt new file mode 100644 index 000000000..40b90ed2b --- /dev/null +++ b/utils/multiplatform/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt @@ -0,0 +1,7 @@ +package com.bumble.appyx.utils.multiplatform + +actual class Logger { + actual fun d(tag: String, message: String) { + println("$tag: $message") + } +} From 53635ae68bec98ddd230943e76c78554c24843b2 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Wed, 17 May 2023 18:03:37 +0100 Subject: [PATCH 13/94] fixed UUID reference --- .../com/bumble/appyx/navigation/modality/BuildContext.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/modality/BuildContext.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/modality/BuildContext.kt index ea69fb8fc..5c5fe7984 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/modality/BuildContext.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/modality/BuildContext.kt @@ -1,11 +1,11 @@ package com.bumble.appyx.navigation.modality +import com.bumble.appyx.interactions.UUID import com.bumble.appyx.interactions.core.state.MutableSavedStateMap import com.bumble.appyx.navigation.state.SavedStateMap import com.bumble.appyx.utils.customisations.NodeCustomisation import com.bumble.appyx.utils.customisations.NodeCustomisationDirectory import com.bumble.appyx.utils.customisations.NodeCustomisationDirectoryImpl -import java.util.* data class BuildContext( val ancestryInfo: AncestryInfo, @@ -28,7 +28,7 @@ data class BuildContext( val identifier: String by lazy { if (savedStateMap == null) { - UUID.randomUUID().toString() + UUID.randomUUID() } else { savedStateMap[IDENTIFIER_KEY] as String? ?: error("onSaveInstanceState() was not called") } From 9eb7593b7fca99f95fb971f268eef3ba9436f002 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Wed, 17 May 2023 18:13:53 +0100 Subject: [PATCH 14/94] fixed interface signature --- .../com/bumble/appyx/navigation/platform/LifecycleRegistry.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt index 62ea99f6e..2db7d4108 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt @@ -4,4 +4,6 @@ interface LifecycleRegistry : Lifecycle { fun setCurrentState(state: Lifecycle.State) } -interface LifecycleRegistryProvider : (LifecycleOwner) -> LifecycleRegistry +interface LifecycleRegistryProvider { + fun invoke(lifecycleOwner: LifecycleOwner): LifecycleRegistry +} From dd93329078215c35e2820be3fd32b2a18620bb15 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Thu, 18 May 2023 17:50:08 +0100 Subject: [PATCH 15/94] implemented multiplatform LifecycleRegistry --- .../navigation/platform/LifecycleRegistry.kt | 104 ++++++++++++++++++ .../appyx/navigation/platform/Lifecycle.kt | 3 +- .../navigation/platform/LifecycleObserver.kt | 29 ++--- .../navigation/platform/LifecycleRegistry.kt | 8 +- .../navigation/platform/LifecycleRegistry.kt | 56 ++++++++++ .../navigation/platform/LifecycleRegistry.kt | 55 +++++++++ 6 files changed, 229 insertions(+), 26 deletions(-) create mode 100644 appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt create mode 100644 appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt create mode 100644 appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt diff --git a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt new file mode 100644 index 000000000..0dcf47117 --- /dev/null +++ b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt @@ -0,0 +1,104 @@ +package com.bumble.appyx.navigation.platform + +import androidx.lifecycle.LifecycleOwner +import androidx.lifecycle.LifecycleRegistry +import androidx.lifecycle.coroutineScope +import kotlinx.coroutines.CoroutineScope +import androidx.lifecycle.Lifecycle.Event as AndroidLifecycleEvent +import androidx.lifecycle.Lifecycle.State as AndroidLifecycleState + +actual class LifecycleRegistry( + private val lifecycleRegistry: LifecycleRegistry +) : Lifecycle, + androidx.lifecycle.DefaultLifecycleObserver, + androidx.lifecycle.LifecycleEventObserver { + + override var currentState: Lifecycle.State + get() = lifecycleRegistry.currentState.toCommonState() + set(value) { + lifecycleRegistry.currentState = value.toAndroidState() + } + + override val coroutineScope: CoroutineScope = lifecycleRegistry.coroutineScope + + private val managedDefaultLifecycleObservers: MutableList = + ArrayList() + private val managedLifecycleEventObservers: MutableList = + ArrayList() + + init { + lifecycleRegistry.addObserver(this) + } + + override fun addObserver(observer: LifecycleObserver) { + when (observer) { + is DefaultLifecycleObserver -> managedDefaultLifecycleObservers.add(observer) + is LifecycleEventObserver -> managedLifecycleEventObservers.add(observer) + } + } + + override fun removeObserver(observer: LifecycleObserver) { + when (observer) { + is DefaultLifecycleObserver -> managedDefaultLifecycleObservers.remove(observer) + is LifecycleEventObserver -> managedLifecycleEventObservers.remove(observer) + } + } + + override fun onStateChanged(source: LifecycleOwner, event: androidx.lifecycle.Lifecycle.Event) { + val commonEvent = event.toCommonEvent() + managedLifecycleEventObservers.forEach { it.onStateChanged(commonEvent) } + } + + override fun onCreate(owner: LifecycleOwner) { + managedDefaultLifecycleObservers.forEach { it.onCreate() } + } + + override fun onStart(owner: LifecycleOwner) { + managedDefaultLifecycleObservers.forEach { it.onStart() } + } + + override fun onResume(owner: LifecycleOwner) { + managedDefaultLifecycleObservers.forEach { it.onResume() } + } + + override fun onPause(owner: LifecycleOwner) { + managedDefaultLifecycleObservers.forEach { it.onPause() } + } + + override fun onStop(owner: LifecycleOwner) { + managedDefaultLifecycleObservers.forEach { it.onStop() } + } + + override fun onDestroy(owner: LifecycleOwner) { + managedDefaultLifecycleObservers.forEach { it.onDestroy() } + } +} + +private fun AndroidLifecycleEvent.toCommonEvent(): Lifecycle.Event = + when (this) { + AndroidLifecycleEvent.ON_CREATE -> Lifecycle.Event.ON_CREATE + AndroidLifecycleEvent.ON_START -> Lifecycle.Event.ON_START + AndroidLifecycleEvent.ON_RESUME -> Lifecycle.Event.ON_RESUME + AndroidLifecycleEvent.ON_PAUSE -> Lifecycle.Event.ON_PAUSE + AndroidLifecycleEvent.ON_STOP -> Lifecycle.Event.ON_STOP + AndroidLifecycleEvent.ON_DESTROY -> Lifecycle.Event.ON_DESTROY + AndroidLifecycleEvent.ON_ANY -> Lifecycle.Event.ON_ANY + } + +private fun Lifecycle.State.toAndroidState(): AndroidLifecycleState = + when (this) { + Lifecycle.State.INITIALIZED -> AndroidLifecycleState.INITIALIZED + Lifecycle.State.CREATED -> AndroidLifecycleState.CREATED + Lifecycle.State.STARTED -> AndroidLifecycleState.STARTED + Lifecycle.State.RESUMED -> AndroidLifecycleState.RESUMED + Lifecycle.State.DESTROYED -> AndroidLifecycleState.DESTROYED + } + +private fun AndroidLifecycleState.toCommonState(): Lifecycle.State = + when (this) { + AndroidLifecycleState.DESTROYED -> Lifecycle.State.DESTROYED + AndroidLifecycleState.INITIALIZED -> Lifecycle.State.INITIALIZED + AndroidLifecycleState.CREATED -> Lifecycle.State.CREATED + AndroidLifecycleState.STARTED -> Lifecycle.State.STARTED + AndroidLifecycleState.RESUMED -> Lifecycle.State.RESUMED + } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/Lifecycle.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/Lifecycle.kt index 26b29cd9f..f0c4e7387 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/Lifecycle.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/Lifecycle.kt @@ -3,7 +3,7 @@ package com.bumble.appyx.navigation.platform import kotlinx.coroutines.CoroutineScope interface Lifecycle { - var currentState: State + val currentState: State val coroutineScope: CoroutineScope @@ -14,6 +14,7 @@ interface Lifecycle { enum class State { INITIALIZED, CREATED, + STARTED, RESUMED, DESTROYED, } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleObserver.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleObserver.kt index 9c68e21fd..9b287d6aa 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleObserver.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleObserver.kt @@ -10,15 +10,6 @@ package com.bumble.appyx.navigation.platform interface LifecycleObserver { } -interface FullLifecycleObserver : LifecycleObserver { - fun onCreate(owner: LifecycleOwner) - fun onStart(owner: LifecycleOwner) - fun onResume(owner: LifecycleOwner) - fun onPause(owner: LifecycleOwner) - fun onStop(owner: LifecycleOwner) - fun onDestroy(owner: LifecycleOwner) -} - /** * Ported from Androidx.lifecycle * @@ -29,14 +20,17 @@ interface FullLifecycleObserver : LifecycleObserver { * * If a class implements this interface and in the same time uses OnLifecycleEvent, * then annotations will be ignored. + * + * Note that this port does not include the lifecycle owner that the lifecycle events are associated + * with, as this is a complexity that has been avoided at this point. */ -interface DefaultLifecycleObserver : FullLifecycleObserver { - override fun onCreate(owner: LifecycleOwner) {} - override fun onStart(owner: LifecycleOwner) {} - override fun onResume(owner: LifecycleOwner) {} - override fun onPause(owner: LifecycleOwner) {} - override fun onStop(owner: LifecycleOwner) {} - override fun onDestroy(owner: LifecycleOwner) {} +interface DefaultLifecycleObserver : LifecycleObserver { + fun onCreate() {} + fun onStart() {} + fun onResume() {} + fun onPause() {} + fun onStop() {} + fun onDestroy() {} } /** @@ -56,8 +50,7 @@ fun interface LifecycleEventObserver : LifecycleObserver { /** * Called when a state transition event happens. * - * @param source The source of the event * @param event The event */ - fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) + fun onStateChanged(event: Lifecycle.Event) } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt index 2db7d4108..ddfacccf5 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt @@ -1,9 +1,3 @@ package com.bumble.appyx.navigation.platform -interface LifecycleRegistry : Lifecycle { - fun setCurrentState(state: Lifecycle.State) -} - -interface LifecycleRegistryProvider { - fun invoke(lifecycleOwner: LifecycleOwner): LifecycleRegistry -} +expect class LifecycleRegistry : Lifecycle diff --git a/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt b/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt new file mode 100644 index 000000000..a8e8a2e1b --- /dev/null +++ b/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt @@ -0,0 +1,56 @@ +package com.bumble.appyx.navigation.platform + +import kotlinx.coroutines.CoroutineScope + + +actual class LifecycleRegistry( + lifecycleCoroutineScope: CoroutineScope, +) : Lifecycle { + + private val managedDefaultLifecycleObservers: MutableList = + ArrayList() + private val managedLifecycleEventObservers: MutableList = + ArrayList() + + private var _currentState: Lifecycle.State = Lifecycle.State.INITIALIZED + override var currentState: Lifecycle.State + get() = _currentState + set(value) { + when (value) { + Lifecycle.State.INITIALIZED -> Unit + Lifecycle.State.CREATED -> { + managedDefaultLifecycleObservers.forEach { it.onCreate() } + managedLifecycleEventObservers.forEach { it.onStateChanged(Lifecycle.Event.ON_CREATE) } + } + Lifecycle.State.STARTED -> { + managedDefaultLifecycleObservers.forEach { it.onStart() } + managedLifecycleEventObservers.forEach { it.onStateChanged(Lifecycle.Event.ON_START) } + } + Lifecycle.State.RESUMED -> { + managedDefaultLifecycleObservers.forEach { it.onResume() } + managedLifecycleEventObservers.forEach { it.onStateChanged(Lifecycle.Event.ON_RESUME) } + } + Lifecycle.State.DESTROYED -> { + managedDefaultLifecycleObservers.forEach { it.onDestroy() } + managedLifecycleEventObservers.forEach { it.onStateChanged(Lifecycle.Event.ON_DESTROY) } + } + } + _currentState = value + } + + override val coroutineScope: CoroutineScope = lifecycleCoroutineScope + + override fun addObserver(observer: LifecycleObserver) { + when (observer) { + is DefaultLifecycleObserver -> managedDefaultLifecycleObservers.add(observer) + is LifecycleEventObserver -> managedLifecycleEventObservers.add(observer) + } + } + + override fun removeObserver(observer: LifecycleObserver) { + when (observer) { + is DefaultLifecycleObserver -> managedDefaultLifecycleObservers.remove(observer) + is LifecycleEventObserver -> managedLifecycleEventObservers.remove(observer) + } + } +} diff --git a/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt b/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt new file mode 100644 index 000000000..6c0937350 --- /dev/null +++ b/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt @@ -0,0 +1,55 @@ +package com.bumble.appyx.navigation.platform + +import kotlinx.coroutines.CoroutineScope + +actual class LifecycleRegistry( + lifecycleCoroutineScope: CoroutineScope, +) : Lifecycle { + + private val managedDefaultLifecycleObservers: MutableList = + ArrayList() + private val managedLifecycleEventObservers: MutableList = + ArrayList() + + private var _currentState: Lifecycle.State = Lifecycle.State.INITIALIZED + override var currentState: Lifecycle.State + get() = _currentState + set(value) { + when (value) { + Lifecycle.State.INITIALIZED -> Unit + Lifecycle.State.CREATED -> { + managedDefaultLifecycleObservers.forEach { it.onCreate() } + managedLifecycleEventObservers.forEach { it.onStateChanged(Lifecycle.Event.ON_CREATE) } + } + Lifecycle.State.STARTED -> { + managedDefaultLifecycleObservers.forEach { it.onStart() } + managedLifecycleEventObservers.forEach { it.onStateChanged(Lifecycle.Event.ON_START) } + } + Lifecycle.State.RESUMED -> { + managedDefaultLifecycleObservers.forEach { it.onResume() } + managedLifecycleEventObservers.forEach { it.onStateChanged(Lifecycle.Event.ON_RESUME) } + } + Lifecycle.State.DESTROYED -> { + managedDefaultLifecycleObservers.forEach { it.onDestroy() } + managedLifecycleEventObservers.forEach { it.onStateChanged(Lifecycle.Event.ON_DESTROY) } + } + } + _currentState = value + } + + override val coroutineScope: CoroutineScope = lifecycleCoroutineScope + + override fun addObserver(observer: LifecycleObserver) { + when (observer) { + is DefaultLifecycleObserver -> managedDefaultLifecycleObservers.add(observer) + is LifecycleEventObserver -> managedLifecycleEventObservers.add(observer) + } + } + + override fun removeObserver(observer: LifecycleObserver) { + when (observer) { + is DefaultLifecycleObserver -> managedDefaultLifecycleObservers.remove(observer) + is LifecycleEventObserver -> managedLifecycleEventObservers.remove(observer) + } + } +} \ No newline at end of file From fe60c7956aa5394e9b3e7e23d3663fab6c997eae Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Thu, 18 May 2023 17:53:45 +0100 Subject: [PATCH 16/94] updated functional interface signatures that aren't compatible with JS --- .../kotlin/com/bumble/appyx/navigation/node/ViewFactory.kt | 4 +++- .../com/bumble/appyx/navigation/platform/LifecycleOwner.kt | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ViewFactory.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ViewFactory.kt index 0f9a47635..100d8820b 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ViewFactory.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ViewFactory.kt @@ -1,3 +1,5 @@ package com.bumble.appyx.navigation.node -fun interface ViewFactory : () -> View +fun interface ViewFactory { + operator fun invoke(): View +} diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleOwner.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleOwner.kt index e4efc2325..77bae9a76 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleOwner.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleOwner.kt @@ -7,4 +7,6 @@ interface LifecycleOwner { val lifecycleScope: CoroutineScope } -interface LocalLifecycleOwnerProvider : () -> LifecycleOwner +fun interface LocalLifecycleOwnerProvider { + operator fun invoke(): LifecycleOwner +} From 62218e03537b6360c202286064c1e66358a9f93f Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Thu, 18 May 2023 18:02:17 +0100 Subject: [PATCH 17/94] reference android navigation module where appropriate --- demos/appyx-navigation/build.gradle.kts | 2 +- demos/navigation-compose/build.gradle.kts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/appyx-navigation/build.gradle.kts b/demos/appyx-navigation/build.gradle.kts index eac36da14..c4b008ac9 100644 --- a/demos/appyx-navigation/build.gradle.kts +++ b/demos/appyx-navigation/build.gradle.kts @@ -56,7 +56,7 @@ dependencies { val composeBom = platform(libs.compose.bom) implementation(composeBom) - implementation(project(":appyx-navigation:common")) + implementation(project(":appyx-navigation:android")) implementation(project(":demos:common")) implementation(project(":appyx-interactions:appyx-interactions")) implementation(project(":appyx-components:spotlight:spotlight")) diff --git a/demos/navigation-compose/build.gradle.kts b/demos/navigation-compose/build.gradle.kts index 2ab0d4a06..aad7dbff4 100644 --- a/demos/navigation-compose/build.gradle.kts +++ b/demos/navigation-compose/build.gradle.kts @@ -37,7 +37,7 @@ dependencies { val composeBom = platform(libs.compose.bom) api(composeBom) - api(project(":appyx-navigation:common")) + api(project(":appyx-navigation:android")) api(project(":appyx-components:backstack:backstack")) api(libs.compose.ui.ui) From eb3f2040ce849517bf570688db5ead4ad4f83eac Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Fri, 19 May 2023 16:56:07 +0100 Subject: [PATCH 18/94] updated IntegrationPointStub.kt --- .../integrationpoint/IntegrationPointStub.kt | 31 ------------------- .../integrationpoint/IntegrationPointStub.kt | 22 +++++++++++++ 2 files changed, 22 insertions(+), 31 deletions(-) delete mode 100644 appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPointStub.kt create mode 100644 appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPointStub.kt diff --git a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPointStub.kt b/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPointStub.kt deleted file mode 100644 index d44503a7f..000000000 --- a/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPointStub.kt +++ /dev/null @@ -1,31 +0,0 @@ -package com.bumble.appyx.navigation.integrationpoint - -import com.bumble.appyx.navigation.integrationpoint.activitystarter.ActivityStarter -import com.bumble.appyx.navigation.integrationpoint.permissionrequester.PermissionRequester - -class IntegrationPointStub : IntegrationPoint(savedInstanceState = null) { - companion object { - private const val ERROR = "You're accessing an IntegrationPointStub. " + - "This means you're using a Node without ever integrating it to a proper IntegrationPoint. " + - "This is fine during tests with limited scope, but it looks like the code that leads here " + - "requires interfacing with a valid implementation. " + - "You may be attempting to access the IntegrationPoint before it is attached to the Node." - } - - override val activityStarter: ActivityStarter - get() = error(ERROR) - - override val permissionRequester: PermissionRequester - get() = error(ERROR) - - override val isChangingConfigurations: Boolean - get() = false - - override fun handleUpNavigation() { - error(ERROR) - } - - override fun onRootFinished() { - error(ERROR) - } -} diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPointStub.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPointStub.kt new file mode 100644 index 000000000..e50b252dd --- /dev/null +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integrationpoint/IntegrationPointStub.kt @@ -0,0 +1,22 @@ +package com.bumble.appyx.navigation.integrationpoint + +class IntegrationPointStub : IntegrationPoint() { + companion object { + private const val ERROR = "You're accessing an IntegrationPointStub. " + + "This means you're using a Node without ever integrating it to a proper IntegrationPoint. " + + "This is fine during tests with limited scope, but it looks like the code that leads here " + + "requires interfacing with a valid implementation. " + + "You may be attempting to access the IntegrationPoint before it is attached to the Node." + } + + override val isChangingConfigurations: Boolean + get() = false + + override fun handleUpNavigation() { + error(ERROR) + } + + override fun onRootFinished() { + error(ERROR) + } +} From a650fe5447cffb3eb16c676dd910dc5a4f4e8fa4 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Mon, 22 May 2023 12:55:47 +0100 Subject: [PATCH 19/94] renamed lifecycle classes with "platform" prefix to disambiguate with Android lifecycle classes --- .../navigation/platform/LifecycleRegistry.kt | 104 ------------------ .../children/ChildAwareCallbackInfo.kt | 6 +- .../navigation/children/ChildAwareImpl.kt | 14 +-- .../navigation/children/ChildCallback.kt | 6 +- .../appyx/navigation/integration/NodeHost.kt | 11 +- .../lifecycle/ChildNodeLifecycleManager.kt | 24 ++-- .../navigation/lifecycle/LifecycleExt.kt | 36 +++--- .../lifecycle/MinimumCombinedLifecycle.kt | 31 +++--- .../navigation/lifecycle/NodeLifecycle.kt | 8 +- .../navigation/lifecycle/NodeLifecycleImpl.kt | 6 +- .../com/bumble/appyx/navigation/node/Node.kt | 37 ++++--- .../appyx/navigation/node/ParentNode.kt | 6 +- .../appyx/navigation/platform/Lifecycle.kt | 31 ------ .../navigation/platform/LifecycleOwner.kt | 12 -- .../navigation/platform/LifecycleRegistry.kt | 3 - .../navigation/platform/OnBackPressed.kt | 2 +- .../navigation/platform/PlatformLifecycle.kt | 44 ++++++++ ...server.kt => PlatformLifecycleObserver.kt} | 12 +- .../platform/PlatformLifecycleOwner.kt | 8 ++ .../bumble/appyx/navigation/plugin/Plugins.kt | 4 +- .../navigation/platform/LifecycleRegistry.kt | 56 ---------- .../navigation/platform/LifecycleRegistry.kt | 55 --------- 22 files changed, 157 insertions(+), 359 deletions(-) delete mode 100644 appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt delete mode 100644 appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/Lifecycle.kt delete mode 100644 appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleOwner.kt delete mode 100644 appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt create mode 100644 appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycle.kt rename appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/{LifecycleObserver.kt => PlatformLifecycleObserver.kt} (81%) create mode 100644 appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleOwner.kt delete mode 100644 appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt delete mode 100644 appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt diff --git a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt deleted file mode 100644 index 0dcf47117..000000000 --- a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt +++ /dev/null @@ -1,104 +0,0 @@ -package com.bumble.appyx.navigation.platform - -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.LifecycleRegistry -import androidx.lifecycle.coroutineScope -import kotlinx.coroutines.CoroutineScope -import androidx.lifecycle.Lifecycle.Event as AndroidLifecycleEvent -import androidx.lifecycle.Lifecycle.State as AndroidLifecycleState - -actual class LifecycleRegistry( - private val lifecycleRegistry: LifecycleRegistry -) : Lifecycle, - androidx.lifecycle.DefaultLifecycleObserver, - androidx.lifecycle.LifecycleEventObserver { - - override var currentState: Lifecycle.State - get() = lifecycleRegistry.currentState.toCommonState() - set(value) { - lifecycleRegistry.currentState = value.toAndroidState() - } - - override val coroutineScope: CoroutineScope = lifecycleRegistry.coroutineScope - - private val managedDefaultLifecycleObservers: MutableList = - ArrayList() - private val managedLifecycleEventObservers: MutableList = - ArrayList() - - init { - lifecycleRegistry.addObserver(this) - } - - override fun addObserver(observer: LifecycleObserver) { - when (observer) { - is DefaultLifecycleObserver -> managedDefaultLifecycleObservers.add(observer) - is LifecycleEventObserver -> managedLifecycleEventObservers.add(observer) - } - } - - override fun removeObserver(observer: LifecycleObserver) { - when (observer) { - is DefaultLifecycleObserver -> managedDefaultLifecycleObservers.remove(observer) - is LifecycleEventObserver -> managedLifecycleEventObservers.remove(observer) - } - } - - override fun onStateChanged(source: LifecycleOwner, event: androidx.lifecycle.Lifecycle.Event) { - val commonEvent = event.toCommonEvent() - managedLifecycleEventObservers.forEach { it.onStateChanged(commonEvent) } - } - - override fun onCreate(owner: LifecycleOwner) { - managedDefaultLifecycleObservers.forEach { it.onCreate() } - } - - override fun onStart(owner: LifecycleOwner) { - managedDefaultLifecycleObservers.forEach { it.onStart() } - } - - override fun onResume(owner: LifecycleOwner) { - managedDefaultLifecycleObservers.forEach { it.onResume() } - } - - override fun onPause(owner: LifecycleOwner) { - managedDefaultLifecycleObservers.forEach { it.onPause() } - } - - override fun onStop(owner: LifecycleOwner) { - managedDefaultLifecycleObservers.forEach { it.onStop() } - } - - override fun onDestroy(owner: LifecycleOwner) { - managedDefaultLifecycleObservers.forEach { it.onDestroy() } - } -} - -private fun AndroidLifecycleEvent.toCommonEvent(): Lifecycle.Event = - when (this) { - AndroidLifecycleEvent.ON_CREATE -> Lifecycle.Event.ON_CREATE - AndroidLifecycleEvent.ON_START -> Lifecycle.Event.ON_START - AndroidLifecycleEvent.ON_RESUME -> Lifecycle.Event.ON_RESUME - AndroidLifecycleEvent.ON_PAUSE -> Lifecycle.Event.ON_PAUSE - AndroidLifecycleEvent.ON_STOP -> Lifecycle.Event.ON_STOP - AndroidLifecycleEvent.ON_DESTROY -> Lifecycle.Event.ON_DESTROY - AndroidLifecycleEvent.ON_ANY -> Lifecycle.Event.ON_ANY - } - -private fun Lifecycle.State.toAndroidState(): AndroidLifecycleState = - when (this) { - Lifecycle.State.INITIALIZED -> AndroidLifecycleState.INITIALIZED - Lifecycle.State.CREATED -> AndroidLifecycleState.CREATED - Lifecycle.State.STARTED -> AndroidLifecycleState.STARTED - Lifecycle.State.RESUMED -> AndroidLifecycleState.RESUMED - Lifecycle.State.DESTROYED -> AndroidLifecycleState.DESTROYED - } - -private fun AndroidLifecycleState.toCommonState(): Lifecycle.State = - when (this) { - AndroidLifecycleState.DESTROYED -> Lifecycle.State.DESTROYED - AndroidLifecycleState.INITIALIZED -> Lifecycle.State.INITIALIZED - AndroidLifecycleState.CREATED -> Lifecycle.State.CREATED - AndroidLifecycleState.STARTED -> Lifecycle.State.STARTED - AndroidLifecycleState.RESUMED -> Lifecycle.State.RESUMED - } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareCallbackInfo.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareCallbackInfo.kt index 9e4e6af10..900ea0caf 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareCallbackInfo.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareCallbackInfo.kt @@ -3,7 +3,7 @@ package com.bumble.appyx.navigation.children import com.bumble.appyx.navigation.lifecycle.MinimumCombinedLifecycle import com.bumble.appyx.navigation.lifecycle.isDestroyed import com.bumble.appyx.navigation.node.Node -import com.bumble.appyx.navigation.platform.Lifecycle +import com.bumble.appyx.navigation.platform.PlatformLifecycle import kotlin.reflect.KClass import kotlin.reflect.cast import kotlin.reflect.safeCast @@ -15,7 +15,7 @@ internal sealed class ChildAwareCallbackInfo { class Single( private val child: KClass, private val callback: ChildCallback, - private val parentLifecycle: Lifecycle, + private val parentLifecycle: PlatformLifecycle, ) : ChildAwareCallbackInfo() { fun onNewNodeAppeared(newNode: Node) { @@ -43,7 +43,7 @@ internal sealed class ChildAwareCallbackInfo { private val child1: KClass, private val child2: KClass, private val callback: ChildrenCallback, - private val parentLifecycle: Lifecycle, + private val parentLifecycle: PlatformLifecycle, ) : ChildAwareCallbackInfo() { fun onNewNodeAppeared( diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt index 0798ae0a8..fceca2eb9 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt @@ -4,9 +4,9 @@ import com.bumble.appyx.interactions.core.Element import com.bumble.appyx.navigation.lifecycle.isDestroyed import com.bumble.appyx.navigation.node.Node import com.bumble.appyx.navigation.node.ParentNode -import com.bumble.appyx.navigation.platform.DefaultLifecycleObserver -import com.bumble.appyx.navigation.platform.Lifecycle -import com.bumble.appyx.navigation.platform.LifecycleOwner +import com.bumble.appyx.navigation.platform.DefaultPlatformLifecycleObserver +import com.bumble.appyx.navigation.platform.PlatformLifecycle +import com.bumble.appyx.navigation.platform.PlatformLifecycleOwner import com.bumble.appyx.navigation.withPrevious import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.MutableStateFlow @@ -20,7 +20,7 @@ class ChildAwareImpl : ChildAware { private val callbacks: MutableList = ArrayList() private lateinit var children: StateFlow, ChildEntry<*>>> - private lateinit var lifecycle: Lifecycle + private lateinit var lifecycle: PlatformLifecycle private lateinit var coroutineScope: CoroutineScope override lateinit var node: N @@ -92,9 +92,9 @@ class ChildAwareImpl : ChildAware { } } - private fun Lifecycle.removeWhenDestroyed(info: ChildAwareCallbackInfo) { - addObserver(object : DefaultLifecycleObserver { - override fun onDestroy(owner: LifecycleOwner) { + private fun PlatformLifecycle.removeWhenDestroyed(info: ChildAwareCallbackInfo) { + addObserver(object : DefaultPlatformLifecycleObserver { + override fun onDestroy(owner: PlatformLifecycleOwner) { callbacks.remove(info) } }) diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildCallback.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildCallback.kt index 8afaee8bd..b4234755f 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildCallback.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildCallback.kt @@ -1,7 +1,7 @@ package com.bumble.appyx.navigation.children -import com.bumble.appyx.navigation.platform.Lifecycle +import com.bumble.appyx.navigation.platform.PlatformLifecycle -typealias ChildrenCallback = (commonLifecycle: Lifecycle, child1: T1, child2: T2) -> Unit +typealias ChildrenCallback = (commonLifecycle: PlatformLifecycle, child1: T1, child2: T2) -> Unit -typealias ChildCallback = (commonLifecycle: Lifecycle, child: T) -> Unit +typealias ChildCallback = (commonLifecycle: PlatformLifecycle, child: T) -> Unit diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt index 22e644f37..e0f286774 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt @@ -13,9 +13,8 @@ import com.bumble.appyx.navigation.integrationpoint.IntegrationPoint import com.bumble.appyx.navigation.modality.BuildContext import com.bumble.appyx.navigation.node.Node import com.bumble.appyx.navigation.node.build -import com.bumble.appyx.navigation.platform.Lifecycle -import com.bumble.appyx.navigation.platform.LifecycleEventObserver -import com.bumble.appyx.navigation.platform.LocalLifecycleOwnerProvider +import com.bumble.appyx.navigation.platform.PlatformLifecycle +import com.bumble.appyx.navigation.platform.PlatformLifecycleEventObserver import com.bumble.appyx.navigation.state.SavedStateMap import com.bumble.appyx.utils.customisations.NodeCustomisationDirectory import com.bumble.appyx.utils.customisations.NodeCustomisationDirectoryImpl @@ -35,14 +34,14 @@ fun NodeHost( ) { val node by rememberNode(factory, customisations, integrationPoint) DisposableEffect(node) { - onDispose { node.updateLifecycleState(Lifecycle.State.DESTROYED) } + onDispose { node.updateLifecycleState(PlatformLifecycle.State.DESTROYED) } } node.Compose(modifier = modifier) val lifecycle = LocalLifecycleOwner.current.lifecycle DisposableEffect(lifecycle) { node.updateLifecycleState(lifecycle.currentState) - val observer = LifecycleEventObserver { source, _ -> - node.updateLifecycleState(source.lifecycle.currentState) + val observer = PlatformLifecycleEventObserver { newState, _ -> + node.updateLifecycleState(newState) } lifecycle.addObserver(observer) onDispose { lifecycle.removeObserver(observer) } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/ChildNodeLifecycleManager.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/ChildNodeLifecycleManager.kt index 6dce1641a..eb58043e4 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/ChildNodeLifecycleManager.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/ChildNodeLifecycleManager.kt @@ -4,8 +4,8 @@ import com.bumble.appyx.interactions.core.model.InteractionModel import com.bumble.appyx.navigation.children.ChildEntry import com.bumble.appyx.navigation.children.ChildEntryMap import com.bumble.appyx.navigation.children.nodeOrNull -import com.bumble.appyx.navigation.platform.Lifecycle -import com.bumble.appyx.navigation.platform.LifecycleRegistry +import com.bumble.appyx.navigation.platform.PlatformLifecycle +import com.bumble.appyx.navigation.platform.PlatformLifecycleRegistry import com.bumble.appyx.navigation.withPrevious import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.MutableStateFlow @@ -15,7 +15,7 @@ import kotlinx.coroutines.flow.onCompletion import kotlinx.coroutines.launch /** - * Hosts [LifecycleRegistry] to manage the current node lifecycle + * Hosts [PlatformLifecycleRegistry] to manage the current node lifecycle * and updates lifecycle of children nodes when updated. */ internal class ChildNodeLifecycleManager( @@ -25,7 +25,7 @@ internal class ChildNodeLifecycleManager( private val coroutineScope: CoroutineScope, ) { - private val lifecycleState = MutableStateFlow(Lifecycle.State.INITIALIZED) + private val lifecycleState = MutableStateFlow(PlatformLifecycle.State.INITIALIZED) /** * Propagates the parent lifecycle to children. @@ -37,7 +37,7 @@ internal class ChildNodeLifecycleManager( * Otherwise a child node lifecycle might be updated before the parent. * It leads to incorrect registration order of back handlers. */ - fun propagateLifecycleToChildren(state: Lifecycle.State) { + fun propagateLifecycleToChildren(state: PlatformLifecycle.State) { lifecycleState.value = state } @@ -58,22 +58,24 @@ internal class ChildNodeLifecycleManager( children .value .values - .forEach { entry -> entry.setState(Lifecycle.State.DESTROYED) } + .forEach { entry -> entry.setState(PlatformLifecycle.State.DESTROYED) } } .collect { (parentLifecycleState, screenState, children) -> screenState.onScreen.forEach { key -> - val childState = minOf(parentLifecycleState, Lifecycle.State.RESUMED) + val childState = + minOf(parentLifecycleState, PlatformLifecycle.State.RESUMED) children.current[key]?.setState(childState) } screenState.offScreen.forEach { key -> if (keepMode == ChildEntry.KeepMode.KEEP) { - val childState = minOf(parentLifecycleState, Lifecycle.State.CREATED) + val childState = + minOf(parentLifecycleState, PlatformLifecycle.State.CREATED) children.current[key]?.setState(childState) } else { // Look up in the previous because in the current it is already suspended // and does not have a reference to the node - children.previous?.get(key)?.setState(Lifecycle.State.DESTROYED) + children.previous?.get(key)?.setState(PlatformLifecycle.State.DESTROYED) } } @@ -81,14 +83,14 @@ internal class ChildNodeLifecycleManager( val removedKeys = children.previous.keys - children.current.keys removedKeys.forEach { key -> val removedChild = children.previous[key] - removedChild?.setState(Lifecycle.State.DESTROYED) + removedChild?.setState(PlatformLifecycle.State.DESTROYED) } } } } } - private fun ChildEntry<*>.setState(state: Lifecycle.State) { + private fun ChildEntry<*>.setState(state: PlatformLifecycle.State) { nodeOrNull?.updateLifecycleState(state) } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleExt.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleExt.kt index 52115257e..46e9efc05 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleExt.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleExt.kt @@ -1,30 +1,30 @@ package com.bumble.appyx.navigation.lifecycle -import com.bumble.appyx.navigation.platform.DefaultLifecycleObserver -import com.bumble.appyx.navigation.platform.Lifecycle -import com.bumble.appyx.navigation.platform.LifecycleEventObserver -import com.bumble.appyx.navigation.platform.LifecycleOwner +import com.bumble.appyx.navigation.platform.DefaultPlatformLifecycleObserver +import com.bumble.appyx.navigation.platform.PlatformLifecycle +import com.bumble.appyx.navigation.platform.PlatformLifecycleEventObserver +import com.bumble.appyx.navigation.platform.PlatformLifecycleOwner import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow -fun LifecycleOwner.asFlow(): Flow = +fun PlatformLifecycleOwner.asFlow(): Flow = lifecycle.asFlow() -fun Lifecycle.asFlow(): Flow = +fun PlatformLifecycle.asFlow(): Flow = callbackFlow { - val observer = LifecycleEventObserver { source, _ -> - trySend(source.lifecycle.currentState) + val observer = PlatformLifecycleEventObserver { currentState, _ -> + trySend(currentState) } trySend(currentState) addObserver(observer) awaitClose { removeObserver(observer) } } -internal val Lifecycle.isDestroyed: Boolean - get() = currentState == Lifecycle.State.DESTROYED +internal val PlatformLifecycle.isDestroyed: Boolean + get() = currentState == PlatformLifecycle.State.DESTROYED -fun Lifecycle.subscribe( +fun PlatformLifecycle.subscribe( onCreate: () -> Unit = {}, onStart: () -> Unit = {}, onResume: () -> Unit = {}, @@ -33,28 +33,28 @@ fun Lifecycle.subscribe( onDestroy: () -> Unit = {} ) { addObserver( - object : DefaultLifecycleObserver { - override fun onCreate(owner: LifecycleOwner) { + object : DefaultPlatformLifecycleObserver { + override fun onCreate() { onCreate() } - override fun onStart(owner: LifecycleOwner) { + override fun onStart() { onStart() } - override fun onResume(owner: LifecycleOwner) { + override fun onResume() { onResume() } - override fun onPause(owner: LifecycleOwner) { + override fun onPause() { onPause() } - override fun onStop(owner: LifecycleOwner) { + override fun onStop() { onStop() } - override fun onDestroy(owner: LifecycleOwner) { + override fun onDestroy() { onDestroy() } } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt index 361a4526c..5dcf0f9a8 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt @@ -1,9 +1,10 @@ package com.bumble.appyx.navigation.lifecycle -import com.bumble.appyx.navigation.platform.DefaultLifecycleObserver -import com.bumble.appyx.navigation.platform.Lifecycle -import com.bumble.appyx.navigation.platform.LifecycleOwner -import com.bumble.appyx.navigation.platform.LifecycleRegistry +import com.bumble.appyx.navigation.platform.DefaultPlatformLifecycleObserver +import com.bumble.appyx.navigation.platform.PlatformLifecycle +import com.bumble.appyx.navigation.platform.PlatformLifecycleOwner +import com.bumble.appyx.navigation.platform.PlatformLifecycleRegistry +import kotlinx.coroutines.CoroutineScope /** @@ -15,10 +16,10 @@ import com.bumble.appyx.navigation.platform.LifecycleRegistry * - INITIALIZED + DESTROYED -> DESTROYED */ internal class MinimumCombinedLifecycle( - vararg lifecycles: Lifecycle, -) : LifecycleOwner { - private val registry = LifecycleRegistry(this) - private val lifecycles = ArrayList() + vararg lifecycles: PlatformLifecycle, +) : PlatformLifecycleOwner { + private val registry = PlatformLifecycleRegistry.create(this) + private val lifecycles = ArrayList() init { /* @@ -29,13 +30,13 @@ internal class MinimumCombinedLifecycle( lifecycles.sortedBy { it.currentState }.forEach { manage(it) } } - override val lifecycle: Lifecycle - get() = registry + override val lifecycle: PlatformLifecycle = registry + override val lifecycleScope: CoroutineScope = registry.coroutineScope - fun manage(lifecycle: Lifecycle) { + fun manage(lifecycle: PlatformLifecycle) { lifecycles += lifecycle - lifecycle.addObserver(object : DefaultLifecycleObserver { - override fun onCreate(owner: LifecycleOwner) { + lifecycle.addObserver(object : DefaultPlatformLifecycleObserver { + override fun onCreate() { update() } @@ -65,8 +66,8 @@ internal class MinimumCombinedLifecycle( private fun update() { lifecycles .minByOrNull { it.currentState } - ?.takeIf { it.currentState != Lifecycle.State.INITIALIZED } - ?.also { registry.currentState = it.currentState } + ?.takeIf { it.currentState != PlatformLifecycle.State.INITIALIZED } + ?.also { registry.setCurrentState(it.currentState) } } } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycle.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycle.kt index a709dc8c2..2178627db 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycle.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycle.kt @@ -1,10 +1,10 @@ package com.bumble.appyx.navigation.lifecycle -import com.bumble.appyx.navigation.platform.Lifecycle -import com.bumble.appyx.navigation.platform.LifecycleOwner +import com.bumble.appyx.navigation.platform.PlatformLifecycle +import com.bumble.appyx.navigation.platform.PlatformLifecycleOwner -interface NodeLifecycle : LifecycleOwner { +interface NodeLifecycle : PlatformLifecycleOwner { - fun updateLifecycleState(state: Lifecycle.State) + fun updateLifecycleState(state: PlatformLifecycle.State) } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt index e61f152ff..2c8840433 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt @@ -1,8 +1,8 @@ package com.bumble.appyx.navigation.lifecycle -import com.bumble.appyx.navigation.platform.Lifecycle -import com.bumble.appyx.navigation.platform.LifecycleOwner -import com.bumble.appyx.navigation.platform.LifecycleRegistry +import com.bumble.appyx.navigation.platform.PlatformLifecycle +import com.bumble.appyx.navigation.platform.PlatformLifecycleRegistry +import kotlinx.coroutines.CoroutineScope internal class NodeLifecycleImpl(owner: LifecycleOwner) : NodeLifecycle { diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt index 96b6f3655..cbe223cf8 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt @@ -7,7 +7,6 @@ import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.Stable import androidx.compose.runtime.saveable.SaverScope import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalLifecycleOwner import com.bumble.appyx.interactions.core.plugin.Plugin import com.bumble.appyx.interactions.core.plugin.SavesInstanceState import com.bumble.appyx.interactions.core.state.MutableSavedStateMap @@ -22,9 +21,10 @@ import com.bumble.appyx.navigation.lifecycle.NodeLifecycle import com.bumble.appyx.navigation.lifecycle.NodeLifecycleImpl import com.bumble.appyx.navigation.modality.AncestryInfo import com.bumble.appyx.navigation.modality.BuildContext -import com.bumble.appyx.navigation.platform.DefaultLifecycleObserver -import com.bumble.appyx.navigation.platform.Lifecycle -import com.bumble.appyx.navigation.platform.LifecycleOwner +import com.bumble.appyx.navigation.platform.DefaultPlatformLifecycleObserver +import com.bumble.appyx.navigation.platform.PlatformLifecycle +import com.bumble.appyx.navigation.platform.PlatformLifecycleOwner +import com.bumble.appyx.navigation.platform.PlatformLifecycleRegistry import com.bumble.appyx.navigation.plugin.Destroyable import com.bumble.appyx.navigation.plugin.NodeLifecycleAware import com.bumble.appyx.navigation.plugin.NodeReadyObserver @@ -66,6 +66,13 @@ open class Node @VisibleForTesting internal constructor( is AncestryInfo.Root -> null } + override val lifecycle get() = nodeLifecycle.lifecycle + + override val lifecycleScope: CoroutineScope get() = lifecycle.coroutineScope + + @Suppress("LeakingThis") // Implemented in the same way as in androidx.Fragment + private val nodeLifecycle = NodeLifecycleImpl(this) // TODO: inject lifecycleRegistryProvider + var integrationPoint: IntegrationPoint = IntegrationPointStub() get() { return if (isRoot) field @@ -86,11 +93,12 @@ open class Node @VisibleForTesting internal constructor( override val requestCodeClientId: String = id init { - if (BuildConfig.DEBUG) { - lifecycle.addObserver(LifecycleLogger) - } - lifecycle.addObserver(object : DefaultLifecycleObserver { - override fun onCreate(owner: LifecycleOwner) { + // TODO: expose debug flag +// if (BuildConfig.DEBUG) { +// lifecycle.addObserver(LifecycleLogger) +// } + lifecycle.addObserver(object : DefaultPlatformLifecycleObserver { + override fun onCreate(owner: PlatformLifecycleOwner) { if (!wasBuilt) error("onBuilt was not invoked for $this") } }) @@ -107,7 +115,7 @@ open class Node @VisibleForTesting internal constructor( open fun onBuilt() { require(!wasBuilt) { "onBuilt was already invoked" } wasBuilt = true - updateLifecycleState(Lifecycle.State.CREATED) + updateLifecycleState(PlatformLifecycle.State.CREATED) plugins>().forEach { it.init(this) } plugins().forEach { it.onCreate(lifecycle) } } @@ -128,12 +136,9 @@ open class Node @VisibleForTesting internal constructor( } - override val lifecycle: Lifecycle - get() = nodeLifecycle.lifecycle - - override fun updateLifecycleState(state: Lifecycle.State) { + override fun updateLifecycleState(state: PlatformLifecycle.State) { if (lifecycle.currentState == state) return - if (lifecycle.currentState == Lifecycle.State.DESTROYED && state != Lifecycle.State.DESTROYED) { + if (lifecycle.currentState == PlatformLifecycle.State.DESTROYED && state != PlatformLifecycle.State.DESTROYED) { Appyx.reportException( IllegalStateException( "Trying to change lifecycle state of already destroyed node ${this::class.qualifiedName}" @@ -142,7 +147,7 @@ open class Node @VisibleForTesting internal constructor( return } nodeLifecycle.updateLifecycleState(state) - if (state == Lifecycle.State.DESTROYED) { + if (state == PlatformLifecycle.State.DESTROYED) { if (!integrationPoint.isChangingConfigurations) { retainedInstanceStore.clearStore(id) } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt index a5f370a9a..d98c63b1a 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt @@ -32,7 +32,7 @@ import com.bumble.appyx.navigation.lifecycle.ChildNodeLifecycleManager import com.bumble.appyx.navigation.mapState import com.bumble.appyx.navigation.modality.BuildContext import com.bumble.appyx.navigation.navigation.Resolver -import com.bumble.appyx.navigation.platform.Lifecycle +import com.bumble.appyx.navigation.platform.PlatformLifecycle import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.launch @@ -119,12 +119,12 @@ abstract class ParentNode( PermanentChild(interactionTarget) { child -> child() } } - override fun updateLifecycleState(state: Lifecycle.State) { + override fun updateLifecycleState(state: PlatformLifecycle.State) { super.updateLifecycleState(state) childNodeLifecycleManager.propagateLifecycleToChildren(state) // TODO move to plugins - if (state == Lifecycle.State.DESTROYED) { + if (state == PlatformLifecycle.State.DESTROYED) { interactionModel.destroy() } } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/Lifecycle.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/Lifecycle.kt deleted file mode 100644 index f0c4e7387..000000000 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/Lifecycle.kt +++ /dev/null @@ -1,31 +0,0 @@ -package com.bumble.appyx.navigation.platform - -import kotlinx.coroutines.CoroutineScope - -interface Lifecycle { - val currentState: State - - val coroutineScope: CoroutineScope - - fun addObserver(observer: LifecycleObserver) - - fun removeObserver(observer: LifecycleObserver) - - enum class State { - INITIALIZED, - CREATED, - STARTED, - RESUMED, - DESTROYED, - } - - enum class Event { - ON_CREATE, - ON_START, - ON_RESUME, - ON_PAUSE, - ON_STOP, - ON_DESTROY, - ON_ANY, - } -} diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleOwner.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleOwner.kt deleted file mode 100644 index 77bae9a76..000000000 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleOwner.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.bumble.appyx.navigation.platform - -import kotlinx.coroutines.CoroutineScope - -interface LifecycleOwner { - val lifecycle: Lifecycle - val lifecycleScope: CoroutineScope -} - -fun interface LocalLifecycleOwnerProvider { - operator fun invoke(): LifecycleOwner -} diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt deleted file mode 100644 index ddfacccf5..000000000 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.bumble.appyx.navigation.platform - -expect class LifecycleRegistry : Lifecycle diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/OnBackPressed.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/OnBackPressed.kt index ed50a1b6d..a161a7cd8 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/OnBackPressed.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/OnBackPressed.kt @@ -8,7 +8,7 @@ abstract class OnBackPressedCallback(var isEnabled: Boolean) { } interface OnBackPressedDispatcher { - fun addCallback(lifecycleOwner: LifecycleOwner, callback: OnBackPressedCallback) + fun addCallback(lifecycleOwner: PlatformLifecycleOwner, callback: OnBackPressedCallback) } interface OnBackPressedDispatcherProvider : () -> OnBackPressedDispatcher? diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycle.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycle.kt new file mode 100644 index 000000000..b5556fe69 --- /dev/null +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycle.kt @@ -0,0 +1,44 @@ +package com.bumble.appyx.navigation.platform + +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.channels.awaitClose +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.callbackFlow + +interface PlatformLifecycle { + val currentState: State + + val coroutineScope: CoroutineScope + + fun addObserver(observer: PlatformLifecycleObserver) + + fun removeObserver(observer: PlatformLifecycleObserver) + + fun asFlow(): Flow = + callbackFlow { + val observer = PlatformLifecycleEventObserver { state, _ -> + trySend(state) + } + trySend(currentState) + addObserver(observer) + awaitClose { removeObserver(observer) } + } + + enum class State { + INITIALIZED, + CREATED, + STARTED, + RESUMED, + DESTROYED, + } + + enum class Event { + ON_CREATE, + ON_START, + ON_RESUME, + ON_PAUSE, + ON_STOP, + ON_DESTROY, + ON_ANY, + } +} diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleObserver.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleObserver.kt similarity index 81% rename from appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleObserver.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleObserver.kt index 9b287d6aa..2df3ae5e7 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleObserver.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleObserver.kt @@ -7,7 +7,7 @@ package com.bumble.appyx.navigation.platform * See Also: * Lifecycle - for samples and usage patterns. */ -interface LifecycleObserver { +interface PlatformLifecycleObserver { } /** @@ -24,7 +24,7 @@ interface LifecycleObserver { * Note that this port does not include the lifecycle owner that the lifecycle events are associated * with, as this is a complexity that has been avoided at this point. */ -interface DefaultLifecycleObserver : LifecycleObserver { +interface DefaultPlatformLifecycleObserver : PlatformLifecycleObserver { fun onCreate() {} fun onStart() {} fun onResume() {} @@ -38,19 +38,19 @@ interface DefaultLifecycleObserver : LifecycleObserver { * * * If a class implements both this interface and - * [DefaultLifecycleObserver], then + * [DefaultPlatformLifecycleObserver], then * methods of `DefaultLifecycleObserver` will be called first, and then followed by the call - * of [LifecycleEventObserver.onStateChanged] + * of [PlatformLifecycleEventObserver.onStateChanged] * * * If a class implements this interface and in the same time uses [OnLifecycleEvent], then * annotations will be ignored. */ -fun interface LifecycleEventObserver : LifecycleObserver { +fun interface PlatformLifecycleEventObserver : PlatformLifecycleObserver { /** * Called when a state transition event happens. * * @param event The event */ - fun onStateChanged(event: Lifecycle.Event) + fun onStateChanged(newState: PlatformLifecycle.State, event: PlatformLifecycle.Event) } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleOwner.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleOwner.kt new file mode 100644 index 000000000..2e839c396 --- /dev/null +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleOwner.kt @@ -0,0 +1,8 @@ +package com.bumble.appyx.navigation.platform + +import kotlinx.coroutines.CoroutineScope + +interface PlatformLifecycleOwner { + val lifecycle: PlatformLifecycle + val lifecycleScope: CoroutineScope +} diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt index 61aafa808..b306386b7 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt @@ -2,8 +2,8 @@ package com.bumble.appyx.navigation.plugin import com.bumble.appyx.interactions.core.plugin.Plugin import com.bumble.appyx.navigation.node.Node -import com.bumble.appyx.navigation.platform.Lifecycle import com.bumble.appyx.navigation.platform.OnBackPressedCallback +import com.bumble.appyx.navigation.platform.PlatformLifecycle inline fun Node.plugins(): List

= this.plugins.filterIsInstance

() @@ -17,7 +17,7 @@ interface NodeReadyObserver : Plugin { } interface NodeLifecycleAware : Plugin { - fun onCreate(lifecycle: Lifecycle) {} + fun onCreate(lifecycle: PlatformLifecycle) {} } interface UpNavigationHandler : Plugin { diff --git a/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt b/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt deleted file mode 100644 index a8e8a2e1b..000000000 --- a/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt +++ /dev/null @@ -1,56 +0,0 @@ -package com.bumble.appyx.navigation.platform - -import kotlinx.coroutines.CoroutineScope - - -actual class LifecycleRegistry( - lifecycleCoroutineScope: CoroutineScope, -) : Lifecycle { - - private val managedDefaultLifecycleObservers: MutableList = - ArrayList() - private val managedLifecycleEventObservers: MutableList = - ArrayList() - - private var _currentState: Lifecycle.State = Lifecycle.State.INITIALIZED - override var currentState: Lifecycle.State - get() = _currentState - set(value) { - when (value) { - Lifecycle.State.INITIALIZED -> Unit - Lifecycle.State.CREATED -> { - managedDefaultLifecycleObservers.forEach { it.onCreate() } - managedLifecycleEventObservers.forEach { it.onStateChanged(Lifecycle.Event.ON_CREATE) } - } - Lifecycle.State.STARTED -> { - managedDefaultLifecycleObservers.forEach { it.onStart() } - managedLifecycleEventObservers.forEach { it.onStateChanged(Lifecycle.Event.ON_START) } - } - Lifecycle.State.RESUMED -> { - managedDefaultLifecycleObservers.forEach { it.onResume() } - managedLifecycleEventObservers.forEach { it.onStateChanged(Lifecycle.Event.ON_RESUME) } - } - Lifecycle.State.DESTROYED -> { - managedDefaultLifecycleObservers.forEach { it.onDestroy() } - managedLifecycleEventObservers.forEach { it.onStateChanged(Lifecycle.Event.ON_DESTROY) } - } - } - _currentState = value - } - - override val coroutineScope: CoroutineScope = lifecycleCoroutineScope - - override fun addObserver(observer: LifecycleObserver) { - when (observer) { - is DefaultLifecycleObserver -> managedDefaultLifecycleObservers.add(observer) - is LifecycleEventObserver -> managedLifecycleEventObservers.add(observer) - } - } - - override fun removeObserver(observer: LifecycleObserver) { - when (observer) { - is DefaultLifecycleObserver -> managedDefaultLifecycleObservers.remove(observer) - is LifecycleEventObserver -> managedLifecycleEventObservers.remove(observer) - } - } -} diff --git a/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt b/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt deleted file mode 100644 index 6c0937350..000000000 --- a/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleRegistry.kt +++ /dev/null @@ -1,55 +0,0 @@ -package com.bumble.appyx.navigation.platform - -import kotlinx.coroutines.CoroutineScope - -actual class LifecycleRegistry( - lifecycleCoroutineScope: CoroutineScope, -) : Lifecycle { - - private val managedDefaultLifecycleObservers: MutableList = - ArrayList() - private val managedLifecycleEventObservers: MutableList = - ArrayList() - - private var _currentState: Lifecycle.State = Lifecycle.State.INITIALIZED - override var currentState: Lifecycle.State - get() = _currentState - set(value) { - when (value) { - Lifecycle.State.INITIALIZED -> Unit - Lifecycle.State.CREATED -> { - managedDefaultLifecycleObservers.forEach { it.onCreate() } - managedLifecycleEventObservers.forEach { it.onStateChanged(Lifecycle.Event.ON_CREATE) } - } - Lifecycle.State.STARTED -> { - managedDefaultLifecycleObservers.forEach { it.onStart() } - managedLifecycleEventObservers.forEach { it.onStateChanged(Lifecycle.Event.ON_START) } - } - Lifecycle.State.RESUMED -> { - managedDefaultLifecycleObservers.forEach { it.onResume() } - managedLifecycleEventObservers.forEach { it.onStateChanged(Lifecycle.Event.ON_RESUME) } - } - Lifecycle.State.DESTROYED -> { - managedDefaultLifecycleObservers.forEach { it.onDestroy() } - managedLifecycleEventObservers.forEach { it.onStateChanged(Lifecycle.Event.ON_DESTROY) } - } - } - _currentState = value - } - - override val coroutineScope: CoroutineScope = lifecycleCoroutineScope - - override fun addObserver(observer: LifecycleObserver) { - when (observer) { - is DefaultLifecycleObserver -> managedDefaultLifecycleObservers.add(observer) - is LifecycleEventObserver -> managedLifecycleEventObservers.add(observer) - } - } - - override fun removeObserver(observer: LifecycleObserver) { - when (observer) { - is DefaultLifecycleObserver -> managedDefaultLifecycleObservers.remove(observer) - is LifecycleEventObserver -> managedLifecycleEventObservers.remove(observer) - } - } -} \ No newline at end of file From 82d0ce3898947fb37b08811f8cf9a91cd6925c4d Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Mon, 22 May 2023 12:59:25 +0100 Subject: [PATCH 20/94] initial implementation of PlatformLifecycleRegistry and AndroidPlatformLifecycle --- .../platform/AndroidPlatformLifecycle.kt | 78 ++++++++++++++++ .../platform/PlatformLifecycleRegistry.kt | 92 +++++++++++++++++++ .../navigation/platform/PlatformMappers.kt | 33 +++++++ .../platform/PlatformLifecycleRegistry.kt | 9 ++ .../platform/PlatformLifecycleRegistry.kt | 85 +++++++++++++++++ .../platform/PlatformLifecycleRegistry.kt | 84 +++++++++++++++++ 6 files changed, 381 insertions(+) create mode 100644 appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/AndroidPlatformLifecycle.kt create mode 100644 appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt create mode 100644 appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformMappers.kt create mode 100644 appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt create mode 100644 appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt create mode 100644 appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt diff --git a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/AndroidPlatformLifecycle.kt b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/AndroidPlatformLifecycle.kt new file mode 100644 index 000000000..0a0a06f3a --- /dev/null +++ b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/AndroidPlatformLifecycle.kt @@ -0,0 +1,78 @@ +package com.bumble.appyx.navigation.platform + +import androidx.lifecycle.DefaultLifecycleObserver +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.LifecycleEventObserver +import androidx.lifecycle.LifecycleOwner +import androidx.lifecycle.coroutineScope +import kotlinx.coroutines.CoroutineScope + +internal class AndroidPlatformLifecycle( + val androidLifecycle: Lifecycle +) : PlatformLifecycle, + DefaultLifecycleObserver, + LifecycleEventObserver { + + private val managedDefaultLifecycleObservers: MutableList = + ArrayList() + private val managedLifecycleEventObservers: MutableList = + ArrayList() + + override val currentState: PlatformLifecycle.State + get() = androidLifecycle.currentState.toCommonState() + + override val coroutineScope: CoroutineScope = + androidLifecycle.coroutineScope + + init { + androidLifecycle.addObserver(this) + } + + override fun addObserver(observer: PlatformLifecycleObserver) { + when (observer) { + is DefaultPlatformLifecycleObserver -> managedDefaultLifecycleObservers.add(observer) + is PlatformLifecycleEventObserver -> managedLifecycleEventObservers.add(observer) + } + } + + override fun removeObserver(observer: PlatformLifecycleObserver) { + when (observer) { + is DefaultPlatformLifecycleObserver -> managedDefaultLifecycleObservers.remove(observer) + is PlatformLifecycleEventObserver -> managedLifecycleEventObservers.remove(observer) + } + } + + override fun onCreate(owner: LifecycleOwner) { + managedDefaultLifecycleObservers.forEach { it.onCreate() } + } + + override fun onStart(owner: LifecycleOwner) { + managedDefaultLifecycleObservers.forEach { it.onStart() } + } + + override fun onResume(owner: LifecycleOwner) { + managedDefaultLifecycleObservers.forEach { it.onResume() } + } + + override fun onPause(owner: LifecycleOwner) { + managedDefaultLifecycleObservers.forEach { it.onPause() } + } + + override fun onStop(owner: LifecycleOwner) { + managedDefaultLifecycleObservers.forEach { it.onStop() } + } + + override fun onDestroy(owner: LifecycleOwner) { + managedDefaultLifecycleObservers.forEach { it.onDestroy() } + } + + override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) { + val commonEvent = event.toCommonEvent() + managedLifecycleEventObservers.forEach { + it.onStateChanged( + source.lifecycle.currentState.toCommonState(), + commonEvent + ) + } + } +} diff --git a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt new file mode 100644 index 000000000..fe8eca286 --- /dev/null +++ b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt @@ -0,0 +1,92 @@ +package com.bumble.appyx.navigation.platform + +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.LifecycleOwner +import androidx.lifecycle.LifecycleRegistry +import androidx.lifecycle.coroutineScope +import kotlinx.coroutines.CoroutineScope + +actual class PlatformLifecycleRegistry( + val androidLifecycleRegistry: LifecycleRegistry +) : PlatformLifecycle, androidx.lifecycle.DefaultLifecycleObserver, + androidx.lifecycle.LifecycleEventObserver { + + private val managedDefaultLifecycleObservers: MutableList = + ArrayList() + private val managedLifecycleEventObservers: MutableList = + ArrayList() + + override val currentState: PlatformLifecycle.State + get() = androidLifecycleRegistry.currentState.toCommonState() + + actual fun setCurrentState(state: PlatformLifecycle.State) { + androidLifecycleRegistry.currentState = state.toAndroidState() + } + + override val coroutineScope: CoroutineScope = androidLifecycleRegistry.coroutineScope + + init { + androidLifecycleRegistry.addObserver(this) + } + + override fun addObserver(observer: PlatformLifecycleObserver) { + when (observer) { + is DefaultPlatformLifecycleObserver -> managedDefaultLifecycleObservers.add(observer) + is PlatformLifecycleEventObserver -> managedLifecycleEventObservers.add(observer) + } + } + + override fun removeObserver(observer: PlatformLifecycleObserver) { + when (observer) { + is DefaultPlatformLifecycleObserver -> managedDefaultLifecycleObservers.remove(observer) + is PlatformLifecycleEventObserver -> managedLifecycleEventObservers.remove(observer) + } + } + + override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) { + val commonEvent = event.toCommonEvent() + managedLifecycleEventObservers.forEach { + it.onStateChanged( + source.lifecycle.currentState.toCommonState(), commonEvent + ) + } + } + + override fun onCreate(owner: LifecycleOwner) { + managedDefaultLifecycleObservers.forEach { it.onCreate() } + } + + override fun onStart(owner: LifecycleOwner) { + managedDefaultLifecycleObservers.forEach { it.onStart() } + } + + override fun onResume(owner: LifecycleOwner) { + managedDefaultLifecycleObservers.forEach { it.onResume() } + } + + override fun onPause(owner: LifecycleOwner) { + managedDefaultLifecycleObservers.forEach { it.onPause() } + } + + override fun onStop(owner: LifecycleOwner) { + managedDefaultLifecycleObservers.forEach { it.onStop() } + } + + override fun onDestroy(owner: LifecycleOwner) { + managedDefaultLifecycleObservers.forEach { it.onDestroy() } + } + + actual companion object { + actual fun create(owner: PlatformLifecycleOwner): PlatformLifecycleRegistry = + PlatformLifecycleRegistry(LifecycleRegistry(object : LifecycleOwner { + override val lifecycle: Lifecycle + get() = when (val platformLifecycle = owner.lifecycle) { + is AndroidPlatformLifecycle -> platformLifecycle.androidLifecycle + is PlatformLifecycleRegistry -> platformLifecycle.androidLifecycleRegistry + else -> throw (IllegalStateException( + "Unable to get android lifecycle from $platformLifecycle provided by $owner" + )) + } + })) + } +} diff --git a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformMappers.kt b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformMappers.kt new file mode 100644 index 000000000..805bd02e6 --- /dev/null +++ b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformMappers.kt @@ -0,0 +1,33 @@ +package com.bumble.appyx.navigation.platform + +import androidx.lifecycle.Lifecycle + + +fun Lifecycle.Event.toCommonEvent(): PlatformLifecycle.Event = + when (this) { + Lifecycle.Event.ON_CREATE -> PlatformLifecycle.Event.ON_CREATE + Lifecycle.Event.ON_START -> PlatformLifecycle.Event.ON_START + Lifecycle.Event.ON_RESUME -> PlatformLifecycle.Event.ON_RESUME + Lifecycle.Event.ON_PAUSE -> PlatformLifecycle.Event.ON_PAUSE + Lifecycle.Event.ON_STOP -> PlatformLifecycle.Event.ON_STOP + Lifecycle.Event.ON_DESTROY -> PlatformLifecycle.Event.ON_DESTROY + Lifecycle.Event.ON_ANY -> PlatformLifecycle.Event.ON_ANY + } + +fun PlatformLifecycle.State.toAndroidState(): Lifecycle.State = + when (this) { + PlatformLifecycle.State.INITIALIZED -> Lifecycle.State.INITIALIZED + PlatformLifecycle.State.CREATED -> Lifecycle.State.CREATED + PlatformLifecycle.State.STARTED -> Lifecycle.State.STARTED + PlatformLifecycle.State.RESUMED -> Lifecycle.State.RESUMED + PlatformLifecycle.State.DESTROYED -> Lifecycle.State.DESTROYED + } + +fun Lifecycle.State.toCommonState(): PlatformLifecycle.State = + when (this) { + Lifecycle.State.DESTROYED -> PlatformLifecycle.State.DESTROYED + Lifecycle.State.INITIALIZED -> PlatformLifecycle.State.INITIALIZED + Lifecycle.State.CREATED -> PlatformLifecycle.State.CREATED + Lifecycle.State.STARTED -> PlatformLifecycle.State.STARTED + Lifecycle.State.RESUMED -> PlatformLifecycle.State.RESUMED + } \ No newline at end of file diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt new file mode 100644 index 000000000..3cfb0b9f1 --- /dev/null +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt @@ -0,0 +1,9 @@ +package com.bumble.appyx.navigation.platform + +expect class PlatformLifecycleRegistry : PlatformLifecycle { + fun setCurrentState(state: PlatformLifecycle.State) + + companion object { + fun create(owner: PlatformLifecycleOwner): PlatformLifecycleRegistry + } +} diff --git a/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt b/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt new file mode 100644 index 000000000..202c45239 --- /dev/null +++ b/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt @@ -0,0 +1,85 @@ +package com.bumble.appyx.navigation.platform + +import kotlinx.coroutines.CoroutineScope + + +actual class PlatformLifecycleRegistry( + lifecycleCoroutineScope: CoroutineScope, +) : PlatformLifecycle { + + private val managedDefaultLifecycleObservers: MutableList = + ArrayList() + private val managedLifecycleEventObservers: MutableList = + ArrayList() + + private var _currentState: PlatformLifecycle.State = PlatformLifecycle.State.INITIALIZED + override var currentState: PlatformLifecycle.State + get() = _currentState + set(value) { + when (value) { + PlatformLifecycle.State.INITIALIZED -> Unit + PlatformLifecycle.State.CREATED -> { + managedDefaultLifecycleObservers.forEach { it.onCreate() } + managedLifecycleEventObservers.forEach { + it.onStateChanged( + value, + PlatformLifecycle.Event.ON_CREATE + ) + } + } + PlatformLifecycle.State.STARTED -> { + managedDefaultLifecycleObservers.forEach { it.onStart() } + managedLifecycleEventObservers.forEach { + it.onStateChanged( + value, + PlatformLifecycle.Event.ON_START + ) + } + } + PlatformLifecycle.State.RESUMED -> { + managedDefaultLifecycleObservers.forEach { it.onResume() } + managedLifecycleEventObservers.forEach { + it.onStateChanged( + value, + PlatformLifecycle.Event.ON_RESUME + ) + } + } + PlatformLifecycle.State.DESTROYED -> { + managedDefaultLifecycleObservers.forEach { it.onDestroy() } + managedLifecycleEventObservers.forEach { + it.onStateChanged( + value, + PlatformLifecycle.Event.ON_DESTROY + ) + } + } + } + _currentState = value + } + + override val coroutineScope: CoroutineScope = lifecycleCoroutineScope + + override fun addObserver(observer: PlatformLifecycleObserver) { + when (observer) { + is DefaultPlatformLifecycleObserver -> managedDefaultLifecycleObservers.add(observer) + is PlatformLifecycleEventObserver -> managedLifecycleEventObservers.add(observer) + } + } + + override fun removeObserver(observer: PlatformLifecycleObserver) { + when (observer) { + is DefaultPlatformLifecycleObserver -> managedDefaultLifecycleObservers.remove(observer) + is PlatformLifecycleEventObserver -> managedLifecycleEventObservers.remove(observer) + } + } + + actual fun setCurrentState(state: PlatformLifecycle.State) { + } + + actual companion object { + actual fun create(owner: PlatformLifecycleOwner): PlatformLifecycleRegistry { + TODO("Not yet implemented") + } + } +} diff --git a/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt b/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt new file mode 100644 index 000000000..69b8d6821 --- /dev/null +++ b/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt @@ -0,0 +1,84 @@ +package com.bumble.appyx.navigation.platform + +import kotlinx.coroutines.CoroutineScope + +actual class PlatformLifecycleRegistry( + lifecycleCoroutineScope: CoroutineScope, +) : PlatformLifecycle { + + private val managedDefaultLifecycleObservers: MutableList = + ArrayList() + private val managedLifecycleEventObservers: MutableList = + ArrayList() + + private var _currentState: PlatformLifecycle.State = PlatformLifecycle.State.INITIALIZED + override var currentState: PlatformLifecycle.State + get() = _currentState + set(value) { + when (value) { + PlatformLifecycle.State.INITIALIZED -> Unit + PlatformLifecycle.State.CREATED -> { + managedDefaultLifecycleObservers.forEach { it.onCreate() } + managedLifecycleEventObservers.forEach { + it.onStateChanged( + value, + PlatformLifecycle.Event.ON_CREATE + ) + } + } + PlatformLifecycle.State.STARTED -> { + managedDefaultLifecycleObservers.forEach { it.onStart() } + managedLifecycleEventObservers.forEach { + it.onStateChanged( + value, + PlatformLifecycle.Event.ON_START + ) + } + } + PlatformLifecycle.State.RESUMED -> { + managedDefaultLifecycleObservers.forEach { it.onResume() } + managedLifecycleEventObservers.forEach { + it.onStateChanged( + value, + PlatformLifecycle.Event.ON_RESUME + ) + } + } + PlatformLifecycle.State.DESTROYED -> { + managedDefaultLifecycleObservers.forEach { it.onDestroy() } + managedLifecycleEventObservers.forEach { + it.onStateChanged( + value, + PlatformLifecycle.Event.ON_DESTROY + ) + } + } + } + _currentState = value + } + + override val coroutineScope: CoroutineScope = lifecycleCoroutineScope + + override fun addObserver(observer: PlatformLifecycleObserver) { + when (observer) { + is DefaultPlatformLifecycleObserver -> managedDefaultLifecycleObservers.add(observer) + is PlatformLifecycleEventObserver -> managedLifecycleEventObservers.add(observer) + } + } + + override fun removeObserver(observer: PlatformLifecycleObserver) { + when (observer) { + is DefaultPlatformLifecycleObserver -> managedDefaultLifecycleObservers.remove(observer) + is PlatformLifecycleEventObserver -> managedLifecycleEventObservers.remove(observer) + } + } + + actual fun setCurrentState(state: PlatformLifecycle.State) { + } + + actual companion object { + actual fun create(owner: PlatformLifecycleOwner): PlatformLifecycleRegistry { + TODO("Not yet implemented") + } + } +} \ No newline at end of file From bacbf9019ec6fec4df982f450e98a9e5d9c7c1ac Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Mon, 22 May 2023 13:02:42 +0100 Subject: [PATCH 21/94] wip cleanup - removing some incompatible annotations and addressing a smattering of errors and warnings --- .../navigation/lifecycle/LifecycleLogger.kt | 17 +++++++------ .../lifecycle/MinimumCombinedLifecycle.kt | 10 ++++---- .../com/bumble/appyx/navigation/node/Node.kt | 24 +++++-------------- .../appyx/navigation/node/ParentNode.kt | 3 --- .../appyx/navigation/platform/PlatformDeps.kt | 7 ------ 5 files changed, 19 insertions(+), 42 deletions(-) delete mode 100644 appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformDeps.kt diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt index 43c62cd3d..259e9191e 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt @@ -1,35 +1,34 @@ package com.bumble.appyx.navigation.lifecycle -import com.bumble.appyx.navigation.platform.DefaultLifecycleObserver -import com.bumble.appyx.navigation.platform.LifecycleOwner +import com.bumble.appyx.navigation.platform.DefaultPlatformLifecycleObserver import com.bumble.appyx.utils.multiplatform.Logger -internal object LifecycleLogger : DefaultLifecycleObserver { +internal object LifecycleLogger : DefaultPlatformLifecycleObserver { private const val LOG_TAG = "Lifecycle" private val LOGGER = Logger() - override fun onCreate(owner: LifecycleOwner) { + override fun onCreate() { LOGGER.d(LOG_TAG, "${owner::class.simpleName}@${owner.hashCode()} onCreate") } - override fun onStart(owner: LifecycleOwner) { + override fun onStart() { LOGGER.d(LOG_TAG, "${owner::class.simpleName}@${owner.hashCode()} onStart") } - override fun onResume(owner: LifecycleOwner) { + override fun onResume() { LOGGER.d(LOG_TAG, "${owner::class.simpleName}@${owner.hashCode()} onResume") } - override fun onPause(owner: LifecycleOwner) { + override fun onPause() { LOGGER.d(LOG_TAG, "${owner::class.simpleName}@${owner.hashCode()} onPause") } - override fun onStop(owner: LifecycleOwner) { + override fun onStop() { LOGGER.d(LOG_TAG, "${owner::class.simpleName}@${owner.hashCode()} onStop") } - override fun onDestroy(owner: LifecycleOwner) { + override fun onDestroy() { LOGGER.d(LOG_TAG, "${owner::class.simpleName}@${owner.hashCode()} onDestroy") } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt index 5dcf0f9a8..00676ee81 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt @@ -40,23 +40,23 @@ internal class MinimumCombinedLifecycle( update() } - override fun onStart(owner: LifecycleOwner) { + override fun onStart() { update() } - override fun onResume(owner: LifecycleOwner) { + override fun onResume() { update() } - override fun onPause(owner: LifecycleOwner) { + override fun onPause() { update() } - override fun onStop(owner: LifecycleOwner) { + override fun onStop() { update() } - override fun onDestroy(owner: LifecycleOwner) { + override fun onDestroy() { update() } }) diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt index cbe223cf8..3f43b89ef 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt @@ -1,7 +1,5 @@ package com.bumble.appyx.navigation.node -import androidx.annotation.CallSuper -import androidx.annotation.VisibleForTesting import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.Stable @@ -12,11 +10,8 @@ import com.bumble.appyx.interactions.core.plugin.SavesInstanceState import com.bumble.appyx.interactions.core.state.MutableSavedStateMap import com.bumble.appyx.interactions.core.state.MutableSavedStateMapImpl import com.bumble.appyx.navigation.Appyx -import com.bumble.appyx.navigation.BuildConfig import com.bumble.appyx.navigation.integrationpoint.IntegrationPoint import com.bumble.appyx.navigation.integrationpoint.IntegrationPointStub -import com.bumble.appyx.navigation.integrationpoint.requestcode.RequestCodeClient -import com.bumble.appyx.navigation.lifecycle.LifecycleLogger import com.bumble.appyx.navigation.lifecycle.NodeLifecycle import com.bumble.appyx.navigation.lifecycle.NodeLifecycleImpl import com.bumble.appyx.navigation.modality.AncestryInfo @@ -32,16 +27,17 @@ import com.bumble.appyx.navigation.plugin.UpNavigationHandler import com.bumble.appyx.navigation.plugin.plugins import com.bumble.appyx.navigation.state.SavedStateMap import com.bumble.appyx.navigation.store.RetainedInstanceStore +import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.withContext @Suppress("TooManyFunctions") @Stable -open class Node @VisibleForTesting internal constructor( +open class Node internal constructor( private val buildContext: BuildContext, val view: NodeView = EmptyNodeView, private val retainedInstanceStore: RetainedInstanceStore, plugins: List = emptyList() -) : NodeLifecycle, NodeView by view, RequestCodeClient { +) : NodeLifecycle, NodeView by view { constructor( buildContext: BuildContext, @@ -49,8 +45,8 @@ open class Node @VisibleForTesting internal constructor( plugins: List = emptyList() ) : this(buildContext, view, RetainedInstanceStore, plugins) - @Suppress("LeakingThis") // Implemented in the same way as in androidx.Fragment - private val nodeLifecycle = NodeLifecycleImpl(this) + val id: String + get() = buildContext.identifier val plugins: List = plugins + listOfNotNull(this as? Plugin) @@ -87,11 +83,6 @@ open class Node @VisibleForTesting internal constructor( private var wasBuilt = false - val id: String - get() = buildContext.identifier - - override val requestCodeClientId: String = id - init { // TODO: expose debug flag // if (BuildConfig.DEBUG) { @@ -111,7 +102,6 @@ open class Node @VisibleForTesting internal constructor( this@Node as T } - @CallSuper open fun onBuilt() { require(!wasBuilt) { "onBuilt was already invoked" } wasBuilt = true @@ -164,7 +154,6 @@ open class Node @VisibleForTesting internal constructor( return writer.savedState } - @CallSuper protected open fun onSaveInstanceState(state: MutableSavedStateMap) { buildContext.onSaveInstanceState(state) } @@ -187,12 +176,11 @@ open class Node @VisibleForTesting internal constructor( require(parent != null || isRoot) { "Can't navigate up, neither parent nor integration point is presented" } - if ((parent as Node).performUpNavigation() != true) { + if (!(parent as Node).performUpNavigation()) { integrationPoint.handleUpNavigation() } } - @CallSuper protected open fun performUpNavigation(): Boolean = handleUpNavigationByPlugins() || (parent as? Node)?.performUpNavigation() == true diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt index d98c63b1a..f83fe9afc 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt @@ -1,6 +1,5 @@ package com.bumble.appyx.navigation.node -import androidx.annotation.CallSuper import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.Stable @@ -78,7 +77,6 @@ abstract class ParentNode( coroutineScope = lifecycleScope, ) - @CallSuper override fun onBuilt() { super.onBuilt() childNodeCreationManager.launch(this) @@ -202,7 +200,6 @@ abstract class ParentNode( // TODO warn unhandled child } - @CallSuper // TODO save/restore state properly override fun onSaveInstanceState(state: MutableSavedStateMap) { super.onSaveInstanceState(state) diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformDeps.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformDeps.kt deleted file mode 100644 index d76561618..000000000 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformDeps.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.bumble.appyx.navigation.platform - -interface PlatformDeps { - val lifecycleRegistryProvider: LifecycleRegistryProvider - val onBackPressedDispatcherProvider: OnBackPressedDispatcherProvider - val localLifecycleOwnerProvider: LocalLifecycleOwnerProvider -} From 64f7ef33697b97e209379416a491617d47174e0e Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Mon, 22 May 2023 13:27:36 +0100 Subject: [PATCH 22/94] inject PlatformLifecycle into NodeHost, facilitating cross-platform usage --- .../bumble/appyx/navigation/AppyxTestScenario.kt | 14 ++++++++------ .../platform/AndroidPlatformLifecycle.kt | 2 +- .../appyx/navigation/integration/NodeHost.kt | 2 +- .../navigation/lifecycle/NodeLifecycleImpl.kt | 16 ++++++++-------- .../com/bumble/appyx/navigation/node/Node.kt | 7 ++----- .../com/bumble/appyx/navigation/MainActivity.kt | 7 ++++++- .../navigtion/compose/ComposeNavigationRoot.kt | 7 ++++++- .../testing/ui/rules/AppyxActivityTestRule.kt | 9 +++++++-- 8 files changed, 39 insertions(+), 25 deletions(-) diff --git a/appyx-navigation/android/src/androidTest/kotlin/com/bumble/appyx/navigation/AppyxTestScenario.kt b/appyx-navigation/android/src/androidTest/kotlin/com/bumble/appyx/navigation/AppyxTestScenario.kt index cf7290f03..a6c4be99d 100644 --- a/appyx-navigation/android/src/androidTest/kotlin/com/bumble/appyx/navigation/AppyxTestScenario.kt +++ b/appyx-navigation/android/src/androidTest/kotlin/com/bumble/appyx/navigation/AppyxTestScenario.kt @@ -2,12 +2,14 @@ package com.bumble.appyx.navigation import androidx.annotation.WorkerThread import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.test.junit4.ComposeTestRule import androidx.compose.ui.test.junit4.createEmptyComposeRule import androidx.test.core.app.ActivityScenario import com.bumble.appyx.navigation.integration.NodeFactory import com.bumble.appyx.navigation.integration.NodeHost import com.bumble.appyx.navigation.node.Node +import com.bumble.appyx.navigation.platform.AndroidPlatformLifecycle import com.bumble.appyx.utils.testing.ui.rules.AppyxTestActivity import java.util.concurrent.CountDownLatch import java.util.concurrent.TimeUnit @@ -25,13 +27,13 @@ class AppyxTestScenario( AppyxTestActivity.composableView = { activity -> decorator { NodeHost( + lifecycle = AndroidPlatformLifecycle(LocalLifecycleOwner.current.lifecycle), integrationPoint = activity.appyxIntegrationPoint, - factory = { buildContext -> - node = nodeFactory.create(buildContext) - awaitNode.countDown() - node - }, - ) + ) { buildContext -> + node = nodeFactory.create(buildContext) + awaitNode.countDown() + node + } } } val scenario = ActivityScenario.launch(InternalAppyxTestActivity::class.java) diff --git a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/AndroidPlatformLifecycle.kt b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/AndroidPlatformLifecycle.kt index 0a0a06f3a..36004e9df 100644 --- a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/AndroidPlatformLifecycle.kt +++ b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/AndroidPlatformLifecycle.kt @@ -7,7 +7,7 @@ import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.coroutineScope import kotlinx.coroutines.CoroutineScope -internal class AndroidPlatformLifecycle( +class AndroidPlatformLifecycle( val androidLifecycle: Lifecycle ) : PlatformLifecycle, DefaultLifecycleObserver, diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt index e0f286774..8ac077603 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt @@ -27,6 +27,7 @@ import com.bumble.appyx.utils.customisations.NodeCustomisationDirectoryImpl @Suppress("ComposableParamOrder") // detekt complains as 'factory' param isn't a pure lambda @Composable fun NodeHost( + lifecycle: PlatformLifecycle, integrationPoint: IntegrationPoint, modifier: Modifier = Modifier, customisations: NodeCustomisationDirectory = remember { NodeCustomisationDirectoryImpl() }, @@ -37,7 +38,6 @@ fun NodeHost( onDispose { node.updateLifecycleState(PlatformLifecycle.State.DESTROYED) } } node.Compose(modifier = modifier) - val lifecycle = LocalLifecycleOwner.current.lifecycle DisposableEffect(lifecycle) { node.updateLifecycleState(lifecycle.currentState) val observer = PlatformLifecycleEventObserver { newState, _ -> diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt index 2c8840433..af0d176f8 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt @@ -1,18 +1,18 @@ package com.bumble.appyx.navigation.lifecycle import com.bumble.appyx.navigation.platform.PlatformLifecycle +import com.bumble.appyx.navigation.platform.PlatformLifecycleOwner import com.bumble.appyx.navigation.platform.PlatformLifecycleRegistry import kotlinx.coroutines.CoroutineScope -internal class NodeLifecycleImpl(owner: LifecycleOwner) : NodeLifecycle { +internal class NodeLifecycleImpl(lifecycleOwner: PlatformLifecycleOwner) : NodeLifecycle { + private val lifecycleRegistry: PlatformLifecycleRegistry = + PlatformLifecycleRegistry.create(lifecycleOwner) - private val lifecycleRegistry = LifecycleRegistry(owner) + override val lifecycle: PlatformLifecycle = lifecycleRegistry + override val lifecycleScope: CoroutineScope = lifecycleRegistry.coroutineScope - override val lifecycle: Lifecycle = - lifecycleRegistry - - override fun updateLifecycleState(state: Lifecycle.State) { - lifecycleRegistry.currentState = state + override fun updateLifecycleState(state: PlatformLifecycle.State) { + lifecycleRegistry.setCurrentState(state) } - } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt index 3f43b89ef..34153e1fb 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt @@ -18,8 +18,6 @@ import com.bumble.appyx.navigation.modality.AncestryInfo import com.bumble.appyx.navigation.modality.BuildContext import com.bumble.appyx.navigation.platform.DefaultPlatformLifecycleObserver import com.bumble.appyx.navigation.platform.PlatformLifecycle -import com.bumble.appyx.navigation.platform.PlatformLifecycleOwner -import com.bumble.appyx.navigation.platform.PlatformLifecycleRegistry import com.bumble.appyx.navigation.plugin.Destroyable import com.bumble.appyx.navigation.plugin.NodeLifecycleAware import com.bumble.appyx.navigation.plugin.NodeReadyObserver @@ -67,7 +65,7 @@ open class Node internal constructor( override val lifecycleScope: CoroutineScope get() = lifecycle.coroutineScope @Suppress("LeakingThis") // Implemented in the same way as in androidx.Fragment - private val nodeLifecycle = NodeLifecycleImpl(this) // TODO: inject lifecycleRegistryProvider + private val nodeLifecycle = NodeLifecycleImpl(this) var integrationPoint: IntegrationPoint = IntegrationPointStub() get() { @@ -89,7 +87,7 @@ open class Node internal constructor( // lifecycle.addObserver(LifecycleLogger) // } lifecycle.addObserver(object : DefaultPlatformLifecycleObserver { - override fun onCreate(owner: PlatformLifecycleOwner) { + override fun onCreate() { if (!wasBuilt) error("onBuilt was not invoked for $this") } }) @@ -114,7 +112,6 @@ open class Node internal constructor( fun Compose(modifier: Modifier = Modifier) { CompositionLocalProvider( LocalNode provides this, - LocalLifecycleOwner provides this, ) { DerivedSetup() View(modifier) diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/MainActivity.kt b/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/MainActivity.kt index 8a7ce4330..ef98f2b02 100644 --- a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/MainActivity.kt +++ b/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/MainActivity.kt @@ -8,6 +8,7 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.runtime.Composable import androidx.compose.ui.ExperimentalComposeUiApi +import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.ExperimentalUnitApi import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen @@ -15,6 +16,7 @@ import com.bumble.appyx.navigation.integration.NodeHost import com.bumble.appyx.navigation.integrationpoint.NodeActivity import com.bumble.appyx.navigation.modality.BuildContext import com.bumble.appyx.navigation.node.container.ContainerNode +import com.bumble.appyx.navigation.platform.AndroidPlatformLifecycle import com.bumble.appyx.navigation.ui.AppyxSampleAppTheme @ExperimentalUnitApi @@ -30,7 +32,10 @@ class MainActivity : NodeActivity() { // A surface container using the 'background' color from the theme Surface(color = MaterialTheme.colorScheme.background) { Column { - NodeHost(integrationPoint = appyxIntegrationPoint) { + NodeHost( + AndroidPlatformLifecycle(LocalLifecycleOwner.current.lifecycle), + integrationPoint = appyxIntegrationPoint + ) { ContainerNode( buildContext = it, ) diff --git a/demos/navigation-compose/src/main/kotlin/com/bumble/appyx/sample/navigtion/compose/ComposeNavigationRoot.kt b/demos/navigation-compose/src/main/kotlin/com/bumble/appyx/sample/navigtion/compose/ComposeNavigationRoot.kt index bf0570cb6..a03d3308d 100644 --- a/demos/navigation-compose/src/main/kotlin/com/bumble/appyx/sample/navigtion/compose/ComposeNavigationRoot.kt +++ b/demos/navigation-compose/src/main/kotlin/com/bumble/appyx/sample/navigtion/compose/ComposeNavigationRoot.kt @@ -12,12 +12,14 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.unit.dp import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.compose.rememberNavController import com.bumble.appyx.navigation.integration.NodeHost import com.bumble.appyx.navigation.integrationpoint.LocalIntegrationPoint +import com.bumble.appyx.navigation.platform.AndroidPlatformLifecycle /** * This Composable demonstrates how to add Appyx into Jetpack Compose Navigation. @@ -67,7 +69,10 @@ internal fun GoogleRoute(modifier: Modifier = Modifier, onAppyxNavigationClick: @Composable internal fun AppyxRoute(onGoogleNavigationClick: () -> Unit) { - NodeHost(integrationPoint = LocalIntegrationPoint.current) { + NodeHost( + lifecycle = AndroidPlatformLifecycle(LocalLifecycleOwner.current.lifecycle), + integrationPoint = LocalIntegrationPoint.current + ) { ComposeNavigationContainerNode( buildContext = it, onGoogleNavigationClick = onGoogleNavigationClick diff --git a/utils/testing-ui/src/main/kotlin/com/bumble/appyx/utils/testing/ui/rules/AppyxActivityTestRule.kt b/utils/testing-ui/src/main/kotlin/com/bumble/appyx/utils/testing/ui/rules/AppyxActivityTestRule.kt index e655dee33..374e254c4 100644 --- a/utils/testing-ui/src/main/kotlin/com/bumble/appyx/utils/testing/ui/rules/AppyxActivityTestRule.kt +++ b/utils/testing-ui/src/main/kotlin/com/bumble/appyx/utils/testing/ui/rules/AppyxActivityTestRule.kt @@ -2,12 +2,14 @@ package com.bumble.appyx.utils.testing.ui.rules import androidx.annotation.CallSuper import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.test.junit4.ComposeTestRule import androidx.compose.ui.test.junit4.createEmptyComposeRule import androidx.test.rule.ActivityTestRule import com.bumble.appyx.navigation.integration.NodeFactory import com.bumble.appyx.navigation.integration.NodeHost import com.bumble.appyx.navigation.node.Node +import com.bumble.appyx.navigation.platform.AndroidPlatformLifecycle import org.junit.rules.TestRule import org.junit.runner.Description import org.junit.runners.model.Statement @@ -44,10 +46,13 @@ open class AppyxActivityTestRule( override fun beforeActivityLaunched() { AppyxTestActivity.composableView = { activity -> decorator { - NodeHost(integrationPoint = activity.appyxIntegrationPoint, factory = { buildContext -> + NodeHost( + lifecycle = AndroidPlatformLifecycle(LocalLifecycleOwner.current.lifecycle), + integrationPoint = activity.appyxIntegrationPoint + ) { buildContext -> node = nodeFactory.create(buildContext) node - }) + } } } } From 147a8f8a15141e4ffc9c00f0f52f2580a3ffeb55 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Mon, 22 May 2023 15:11:49 +0100 Subject: [PATCH 23/94] fixed LifecycleLogger --- .../navigation/lifecycle/LifecycleLogger.kt | 21 +++++++++++-------- .../com/bumble/appyx/navigation/node/Node.kt | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt index 259e9191e..db96e5e99 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt @@ -1,35 +1,38 @@ package com.bumble.appyx.navigation.lifecycle +import com.bumble.appyx.navigation.node.Node import com.bumble.appyx.navigation.platform.DefaultPlatformLifecycleObserver import com.bumble.appyx.utils.multiplatform.Logger -internal object LifecycleLogger : DefaultPlatformLifecycleObserver { +internal class LifecycleLogger(private val node: Node) : DefaultPlatformLifecycleObserver { - private const val LOG_TAG = "Lifecycle" - private val LOGGER = Logger() + private val logger = Logger() override fun onCreate() { - LOGGER.d(LOG_TAG, "${owner::class.simpleName}@${owner.hashCode()} onCreate") + logger.d(LOG_TAG, "${node::class.simpleName}@${node.hashCode()} onCreate") } override fun onStart() { - LOGGER.d(LOG_TAG, "${owner::class.simpleName}@${owner.hashCode()} onStart") + logger.d(LOG_TAG, "${node::class.simpleName}@${node.hashCode()} onStart") } override fun onResume() { - LOGGER.d(LOG_TAG, "${owner::class.simpleName}@${owner.hashCode()} onResume") + logger.d(LOG_TAG, "${node::class.simpleName}@${node.hashCode()} onResume") } override fun onPause() { - LOGGER.d(LOG_TAG, "${owner::class.simpleName}@${owner.hashCode()} onPause") + logger.d(LOG_TAG, "${node::class.simpleName}@${node.hashCode()} onPause") } override fun onStop() { - LOGGER.d(LOG_TAG, "${owner::class.simpleName}@${owner.hashCode()} onStop") + logger.d(LOG_TAG, "${node::class.simpleName}@${node.hashCode()} onStop") } override fun onDestroy() { - LOGGER.d(LOG_TAG, "${owner::class.simpleName}@${owner.hashCode()} onDestroy") + logger.d(LOG_TAG, "${node::class.simpleName}@${node.hashCode()} onDestroy") } + companion object { + private const val LOG_TAG = "Lifecycle" + } } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt index 34153e1fb..a8cc9e79e 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt @@ -84,7 +84,7 @@ open class Node internal constructor( init { // TODO: expose debug flag // if (BuildConfig.DEBUG) { -// lifecycle.addObserver(LifecycleLogger) +// lifecycle.addObserver(LifecycleLogger(this)) // } lifecycle.addObserver(object : DefaultPlatformLifecycleObserver { override fun onCreate() { From 124c109bc6f5754d85f9882e380d3963b679f0f7 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Tue, 23 May 2023 15:31:47 +0100 Subject: [PATCH 24/94] api change cleanup --- .../com/bumble/appyx/navigation/children/ChildAwareImpl.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt index fceca2eb9..8bbd0321b 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt @@ -6,7 +6,6 @@ import com.bumble.appyx.navigation.node.Node import com.bumble.appyx.navigation.node.ParentNode import com.bumble.appyx.navigation.platform.DefaultPlatformLifecycleObserver import com.bumble.appyx.navigation.platform.PlatformLifecycle -import com.bumble.appyx.navigation.platform.PlatformLifecycleOwner import com.bumble.appyx.navigation.withPrevious import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.MutableStateFlow @@ -94,7 +93,7 @@ class ChildAwareImpl : ChildAware { private fun PlatformLifecycle.removeWhenDestroyed(info: ChildAwareCallbackInfo) { addObserver(object : DefaultPlatformLifecycleObserver { - override fun onDestroy(owner: PlatformLifecycleOwner) { + override fun onDestroy() { callbacks.remove(info) } }) From 07f9b2ccfbbb74e7d09d6e34bfcd73d4c72c2bd7 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Tue, 23 May 2023 17:21:58 +0100 Subject: [PATCH 25/94] addressed a range of compilation issues --- appyx-navigation/common/build.gradle.kts | 2 +- .../appyx/navigation/node/ParentNode.kt | 2 +- utils/interop-ribs/build.gradle.kts | 2 +- .../appyx/utils/interop/ribs/InteropNode.kt | 7 ++++--- .../interop/rx2/connectable/NodeConnector.kt | 4 ++-- .../interop/rx3/connectable/NodeConnector.kt | 4 ++-- utils/testing-unit-common/build.gradle.kts | 1 + .../unit/common/helper/NodeTestHelper.kt | 20 +++++++++---------- .../common/helper/ParentNodeTestHelper.kt | 4 ++-- .../unit/common/util/InteropBuilderStub.kt | 4 ++-- .../common/util/InteropSimpleBuilderStub.kt | 4 ++-- .../unit/common/util/TestIntegrationPoint.kt | 10 +--------- 12 files changed, 29 insertions(+), 35 deletions(-) diff --git a/appyx-navigation/common/build.gradle.kts b/appyx-navigation/common/build.gradle.kts index 739ecceb6..d3dcdd0af 100644 --- a/appyx-navigation/common/build.gradle.kts +++ b/appyx-navigation/common/build.gradle.kts @@ -28,7 +28,7 @@ kotlin { api(project(":utils:multiplatform")) implementation(libs.kotlinx.serialization.json) implementation(project(":utils:customisations")) - implementation(project(":appyx-interactions:appyx-interactions")) + api(project(":appyx-interactions:appyx-interactions")) } } val commonTest by getting { diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt index f83fe9afc..59219ce7a 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt @@ -108,7 +108,7 @@ abstract class ParentNode( child?.let { - decorator(child = PermanentChildRender(it.node)) + decorator(PermanentChildRender(it.node)) } } diff --git a/utils/interop-ribs/build.gradle.kts b/utils/interop-ribs/build.gradle.kts index 7c5c92267..2ba87ce5b 100644 --- a/utils/interop-ribs/build.gradle.kts +++ b/utils/interop-ribs/build.gradle.kts @@ -30,7 +30,7 @@ android { } dependencies { - api(project(":appyx-navigation:common")) + api(project(":appyx-navigation:android")) api(libs.ribs.base) api(libs.ribs.compose) diff --git a/utils/interop-ribs/src/main/kotlin/com/bumble/appyx/utils/interop/ribs/InteropNode.kt b/utils/interop-ribs/src/main/kotlin/com/bumble/appyx/utils/interop/ribs/InteropNode.kt index fcad5eb0f..01e1de9be 100644 --- a/utils/interop-ribs/src/main/kotlin/com/bumble/appyx/utils/interop/ribs/InteropNode.kt +++ b/utils/interop-ribs/src/main/kotlin/com/bumble/appyx/utils/interop/ribs/InteropNode.kt @@ -8,9 +8,10 @@ import com.badoo.ribs.core.Rib import com.badoo.ribs.core.modality.BuildParams import com.badoo.ribs.core.view.ViewFactory import com.bumble.appyx.navigation.node.Node +import com.bumble.appyx.navigation.platform.toCommonState +import com.bumble.appyx.utils.customisations.NodeCustomisation import com.bumble.appyx.utils.interop.ribs.InteropNode.Customisation import com.bumble.appyx.utils.interop.ribs.InteropViewImpl.Factory -import com.bumble.appyx.utils.customisations.NodeCustomisation interface InteropNode : Rib { val appyxNode: N @@ -41,12 +42,12 @@ internal class InteropNodeImpl( ), InteropNode { private val observer = LifecycleEventObserver { source, _ -> - appyxNode.updateLifecycleState(source.lifecycle.currentState) + appyxNode.updateLifecycleState(source.lifecycle.currentState.toCommonState()) } override fun onCreate() { super.onCreate() - appyxNode.updateLifecycleState(lifecycle.currentState) + appyxNode.updateLifecycleState(lifecycle.currentState.toCommonState()) lifecycle.addObserver(observer) } diff --git a/utils/interop-rx2/src/main/kotlin/com/bumble/appyx/utils/interop/rx2/connectable/NodeConnector.kt b/utils/interop-rx2/src/main/kotlin/com/bumble/appyx/utils/interop/rx2/connectable/NodeConnector.kt index 3dc2e3e31..78daa2662 100644 --- a/utils/interop-rx2/src/main/kotlin/com/bumble/appyx/utils/interop/rx2/connectable/NodeConnector.kt +++ b/utils/interop-rx2/src/main/kotlin/com/bumble/appyx/utils/interop/rx2/connectable/NodeConnector.kt @@ -1,8 +1,8 @@ package com.bumble.appyx.utils.interop.rx2.connectable import android.annotation.SuppressLint -import androidx.lifecycle.Lifecycle import com.bumble.appyx.navigation.lifecycle.subscribe +import com.bumble.appyx.navigation.platform.PlatformLifecycle import com.jakewharton.rxrelay2.PublishRelay import com.jakewharton.rxrelay2.Relay import io.reactivex.Observer @@ -31,7 +31,7 @@ class NodeConnector( } - override fun onCreate(lifecycle: Lifecycle) { + override fun onCreate(lifecycle: PlatformLifecycle) { lifecycle.subscribe(onCreate = { flushOutputCache() }) } diff --git a/utils/interop-rx3/src/main/kotlin/com/bumble/appyx/utils/interop/rx3/connectable/NodeConnector.kt b/utils/interop-rx3/src/main/kotlin/com/bumble/appyx/utils/interop/rx3/connectable/NodeConnector.kt index 9632bab30..22b78d578 100644 --- a/utils/interop-rx3/src/main/kotlin/com/bumble/appyx/utils/interop/rx3/connectable/NodeConnector.kt +++ b/utils/interop-rx3/src/main/kotlin/com/bumble/appyx/utils/interop/rx3/connectable/NodeConnector.kt @@ -1,8 +1,8 @@ package com.bumble.appyx.utils.interop.rx3.connectable import android.annotation.SuppressLint -import androidx.lifecycle.Lifecycle import com.bumble.appyx.navigation.lifecycle.subscribe +import com.bumble.appyx.navigation.platform.PlatformLifecycle import com.jakewharton.rxrelay3.PublishRelay import com.jakewharton.rxrelay3.Relay import io.reactivex.rxjava3.core.Observer @@ -30,7 +30,7 @@ class NodeConnector( } - override fun onCreate(lifecycle: Lifecycle) { + override fun onCreate(lifecycle: PlatformLifecycle) { lifecycle.subscribe(onCreate = { flushOutputCache() }) } diff --git a/utils/testing-unit-common/build.gradle.kts b/utils/testing-unit-common/build.gradle.kts index 26df5d4e9..836f57ec2 100644 --- a/utils/testing-unit-common/build.gradle.kts +++ b/utils/testing-unit-common/build.gradle.kts @@ -30,5 +30,6 @@ android { dependencies { api(project(":appyx-navigation:common")) + api(project(":utils:customisations")) implementation(libs.kotlin.test) } diff --git a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/helper/NodeTestHelper.kt b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/helper/NodeTestHelper.kt index 4fbf95765..28aa3654b 100644 --- a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/helper/NodeTestHelper.kt +++ b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/helper/NodeTestHelper.kt @@ -1,8 +1,8 @@ package com.bumble.appyx.utils.testing.unit.common.helper -import androidx.lifecycle.Lifecycle import com.bumble.appyx.navigation.node.Node import com.bumble.appyx.navigation.node.build +import com.bumble.appyx.navigation.platform.PlatformLifecycle fun N.nodeTestHelper() = NodeTestHelper(this) @@ -15,8 +15,8 @@ open class NodeTestHelper(private val node: N) { node.build() } - fun moveTo(state: Lifecycle.State) { - require(state != Lifecycle.State.INITIALIZED) { + fun moveTo(state: PlatformLifecycle.State) { + require(state != PlatformLifecycle.State.INITIALIZED) { "Can't move to INITIALIZED state" } node.updateLifecycleState(state) @@ -25,16 +25,16 @@ open class NodeTestHelper(private val node: N) { /** * moves the Node to the desired state and then returns to the original state if possible */ - fun moveToStateAndCheck(state: Lifecycle.State, block: (N) -> Unit) { - require(state != Lifecycle.State.INITIALIZED) { "Can't move to INITIALIZED state" } + fun moveToStateAndCheck(state: PlatformLifecycle.State, block: (N) -> Unit) { + require(state != PlatformLifecycle.State.INITIALIZED) { "Can't move to INITIALIZED state" } val returnTo = when (val current = nodeLifecycle.currentState) { - Lifecycle.State.DESTROYED -> error("Can't move from DESTROYED state") - Lifecycle.State.INITIALIZED -> Lifecycle.State.DESTROYED - Lifecycle.State.CREATED, - Lifecycle.State.STARTED, - Lifecycle.State.RESUMED -> current + PlatformLifecycle.State.DESTROYED -> error("Can't move from DESTROYED state") + PlatformLifecycle.State.INITIALIZED -> PlatformLifecycle.State.DESTROYED + PlatformLifecycle.State.CREATED, + PlatformLifecycle.State.STARTED, + PlatformLifecycle.State.RESUMED -> current } moveTo(state) diff --git a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/helper/ParentNodeTestHelper.kt b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/helper/ParentNodeTestHelper.kt index 2203725da..05c59449b 100644 --- a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/helper/ParentNodeTestHelper.kt +++ b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/helper/ParentNodeTestHelper.kt @@ -1,8 +1,8 @@ package com.bumble.appyx.utils.testing.unit.common.helper -import androidx.lifecycle.Lifecycle import com.bumble.appyx.navigation.children.nodeOrNull import com.bumble.appyx.navigation.node.ParentNode +import com.bumble.appyx.navigation.platform.PlatformLifecycle import kotlin.test.assertEquals import kotlin.test.assertNull @@ -17,7 +17,7 @@ class ParentNodeTestHelper assertChildHasLifecycle( interactionTarget: InteractionTarget, - state: Lifecycle.State + state: PlatformLifecycle.State ) { val childMap = node.children.value val key = childMap.keys.find { it.interactionTarget == interactionTarget } diff --git a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/InteropBuilderStub.kt b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/InteropBuilderStub.kt index b7a48f2ec..7a7b8788d 100644 --- a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/InteropBuilderStub.kt +++ b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/InteropBuilderStub.kt @@ -1,9 +1,9 @@ package com.bumble.appyx.utils.testing.unit.common.util -import androidx.lifecycle.Lifecycle import com.bumble.appyx.navigation.builder.Builder import com.bumble.appyx.navigation.modality.BuildContext import com.bumble.appyx.navigation.node.Node +import com.bumble.appyx.navigation.platform.PlatformLifecycle import kotlin.test.assertEquals import kotlin.test.assertTrue @@ -36,7 +36,7 @@ class InteropBuilderStub

( assertTrue(lastNode != null, "Has not created any node") } - fun assertLastNodeState(state: Lifecycle.State) { + fun assertLastNodeState(state: PlatformLifecycle.State) { assertCreatedNode() assertEquals(state, lastNode!!.lifecycle.currentState) } diff --git a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/InteropSimpleBuilderStub.kt b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/InteropSimpleBuilderStub.kt index 5c662e97c..46f5583b3 100644 --- a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/InteropSimpleBuilderStub.kt +++ b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/InteropSimpleBuilderStub.kt @@ -1,9 +1,9 @@ package com.bumble.appyx.utils.testing.unit.common.util -import androidx.lifecycle.Lifecycle import com.bumble.appyx.navigation.builder.SimpleBuilder import com.bumble.appyx.navigation.modality.BuildContext import com.bumble.appyx.navigation.node.Node +import com.bumble.appyx.navigation.platform.PlatformLifecycle import kotlin.test.assertEquals import kotlin.test.assertTrue @@ -23,7 +23,7 @@ class InteropSimpleBuilderStub( assertTrue(lastNode != null, "Has not created any node") } - fun assertLastNodeState(state: Lifecycle.State) { + fun assertLastNodeState(state: PlatformLifecycle.State) { assertCreatedNode() assertEquals(state, lastNode!!.lifecycle.currentState) } diff --git a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/TestIntegrationPoint.kt b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/TestIntegrationPoint.kt index 7b3fa2870..2d3bbf728 100644 --- a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/TestIntegrationPoint.kt +++ b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/TestIntegrationPoint.kt @@ -1,23 +1,15 @@ package com.bumble.appyx.utils.testing.unit.common.util import com.bumble.appyx.navigation.integrationpoint.IntegrationPoint -import com.bumble.appyx.navigation.integrationpoint.activitystarter.ActivityStarter -import com.bumble.appyx.navigation.integrationpoint.permissionrequester.PermissionRequester import com.bumble.appyx.navigation.navigation.upnavigation.UpNavigationHandler class TestIntegrationPoint( private val upNavigationHandler: UpNavigationHandler, override val isChangingConfigurations: Boolean = false -) : IntegrationPoint(savedInstanceState = null), UpNavigationHandler by upNavigationHandler { +) : IntegrationPoint(), UpNavigationHandler by upNavigationHandler { var rootFinished: Boolean = false - override val activityStarter: ActivityStarter - get() = TODO() - - override val permissionRequester: PermissionRequester - get() = TODO() - override fun onRootFinished() { rootFinished = true } From b36e84557ba79088f14172cc36ae60b5a6d2bb49 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Tue, 23 May 2023 17:42:57 +0100 Subject: [PATCH 26/94] implemented PlatformBackHandler to remove back handling dependency from ParentNode Multiplatform implementations pending... --- appyx-navigation/common/build.gradle.kts | 1 + .../navigation/platform/PlatformBackHandler.kt | 9 +++++++++ .../com/bumble/appyx/navigation/node/ParentNode.kt | 3 ++- .../appyx/navigation/platform/OnBackPressed.kt | 14 -------------- .../navigation/platform/PlatformBackHandler.kt | 9 +++++++++ .../navigation/platform/PlatformBackHandler.kt | 8 ++++++++ .../navigation/platform/PlatformBackHandler.kt | 8 ++++++++ 7 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt delete mode 100644 appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/OnBackPressed.kt create mode 100644 appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt create mode 100644 appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt create mode 100644 appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt diff --git a/appyx-navigation/common/build.gradle.kts b/appyx-navigation/common/build.gradle.kts index d3dcdd0af..da3b744df 100644 --- a/appyx-navigation/common/build.gradle.kts +++ b/appyx-navigation/common/build.gradle.kts @@ -40,6 +40,7 @@ kotlin { dependencies { api(libs.androidx.appcompat) api(libs.androidx.core) + implementation(libs.androidx.activity.compose) } } val androidTest by getting { diff --git a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt new file mode 100644 index 000000000..fa01a7e53 --- /dev/null +++ b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt @@ -0,0 +1,9 @@ +package com.bumble.appyx.navigation.platform + +import androidx.activity.compose.BackHandler +import androidx.compose.runtime.Composable + +@Composable +actual fun PlatformBackHandler(enabled: Boolean, onBack: () -> Unit) { + BackHandler(enabled, onBack) +} \ No newline at end of file diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt index 59219ce7a..d1ec36cef 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt @@ -31,6 +31,7 @@ import com.bumble.appyx.navigation.lifecycle.ChildNodeLifecycleManager import com.bumble.appyx.navigation.mapState import com.bumble.appyx.navigation.modality.BuildContext import com.bumble.appyx.navigation.navigation.Resolver +import com.bumble.appyx.navigation.platform.PlatformBackHandler import com.bumble.appyx.navigation.platform.PlatformLifecycle import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow @@ -139,7 +140,7 @@ abstract class ParentNode( val canHandleBack = interactionModel .canHandeBackPress() .collectAsState(initial = false) - BackHandler(canHandleBack.value) { + PlatformBackHandler(canHandleBack.value) { interactionModel.handleBackPress() } } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/OnBackPressed.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/OnBackPressed.kt deleted file mode 100644 index a161a7cd8..000000000 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/OnBackPressed.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.bumble.appyx.navigation.platform - -abstract class OnBackPressedCallback(var isEnabled: Boolean) { - - abstract fun handleOnBackPressed() - - open fun remove() {} -} - -interface OnBackPressedDispatcher { - fun addCallback(lifecycleOwner: PlatformLifecycleOwner, callback: OnBackPressedCallback) -} - -interface OnBackPressedDispatcherProvider : () -> OnBackPressedDispatcher? diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt new file mode 100644 index 000000000..5e521f90d --- /dev/null +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt @@ -0,0 +1,9 @@ +package com.bumble.appyx.navigation.platform + +import androidx.compose.runtime.Composable + +@Composable +expect fun PlatformBackHandler( + enabled: Boolean = true, + onBack: () -> Unit +) diff --git a/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt b/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt new file mode 100644 index 000000000..18d315231 --- /dev/null +++ b/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt @@ -0,0 +1,8 @@ +package com.bumble.appyx.navigation.platform + +import androidx.compose.runtime.Composable + +@Composable +actual fun PlatformBackHandler(enabled: Boolean, onBack: () -> Unit) { + TODO() +} \ No newline at end of file diff --git a/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt b/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt new file mode 100644 index 000000000..18d315231 --- /dev/null +++ b/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt @@ -0,0 +1,8 @@ +package com.bumble.appyx.navigation.platform + +import androidx.compose.runtime.Composable + +@Composable +actual fun PlatformBackHandler(enabled: Boolean, onBack: () -> Unit) { + TODO() +} \ No newline at end of file From 0910e6d9b36fb20f8b126e79e4685d71d7ff51fe Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Tue, 23 May 2023 18:07:55 +0100 Subject: [PATCH 27/94] repackaged and renamed things for consistency of "platform" and "common" terminology --- .../appyx/navigation/AppyxTestScenario.kt | 4 +-- ...atformLifecycle.kt => AndroidLifecycle.kt} | 10 ++++-- .../platform/LifecycleCommonMappers.kt | 34 +++++++++++++++++++ .../platform/PlatformLifecycleRegistry.kt | 15 +++++--- .../navigation/platform/PlatformMappers.kt | 33 ------------------ .../children/ChildAwareCallbackInfo.kt | 6 ++-- .../navigation/children/ChildAwareImpl.kt | 8 ++--- .../navigation/children/ChildCallback.kt | 6 ++-- .../appyx/navigation/integration/NodeHost.kt | 8 ++--- .../lifecycle/ChildNodeLifecycleManager.kt | 18 +++++----- .../CommonLifecycle.kt} | 4 +-- .../CommonLifecycleObserver.kt} | 14 +++----- .../lifecycle/CommonLifecycleOwner.kt | 8 +++++ .../navigation/lifecycle/LifecycleLogger.kt | 1 - .../lifecycle/MinimumCombinedLifecycle.kt | 15 ++++---- .../navigation/lifecycle/NodeLifecycle.kt | 7 ++-- .../navigation/lifecycle/NodeLifecycleImpl.kt | 8 ++--- ...ifecycleExt.kt => PlatformLifecycleExt.kt} | 14 +++----- .../com/bumble/appyx/navigation/node/Node.kt | 12 +++---- .../appyx/navigation/node/ParentNode.kt | 6 ++-- .../platform/PlatformLifecycleOwner.kt | 8 ----- .../platform/PlatformLifecycleRegistry.kt | 9 +++-- .../bumble/appyx/navigation/plugin/Plugins.kt | 4 +-- .../platform/PlatformLifecycleRegistry.kt | 33 ++++++++++-------- .../platform/PlatformLifecycleRegistry.kt | 33 ++++++++++-------- .../bumble/appyx/navigation/MainActivity.kt | 4 +-- .../compose/ComposeNavigationRoot.kt | 4 +-- .../interop/rx2/connectable/NodeConnector.kt | 4 +-- .../interop/rx3/connectable/NodeConnector.kt | 4 +-- .../testing/ui/rules/AppyxActivityTestRule.kt | 4 +-- .../unit/common/helper/NodeTestHelper.kt | 20 +++++------ .../common/helper/ParentNodeTestHelper.kt | 4 +-- .../unit/common/util/InteropBuilderStub.kt | 4 +-- .../common/util/InteropSimpleBuilderStub.kt | 4 +-- 34 files changed, 187 insertions(+), 183 deletions(-) rename appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/{AndroidPlatformLifecycle.kt => AndroidLifecycle.kt} (86%) create mode 100644 appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleCommonMappers.kt delete mode 100644 appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformMappers.kt rename appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/{platform/PlatformLifecycle.kt => lifecycle/CommonLifecycle.kt} (92%) rename appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/{platform/PlatformLifecycleObserver.kt => lifecycle/CommonLifecycleObserver.kt} (84%) create mode 100644 appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/CommonLifecycleOwner.kt rename appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/{LifecycleExt.kt => PlatformLifecycleExt.kt} (68%) delete mode 100644 appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleOwner.kt diff --git a/appyx-navigation/android/src/androidTest/kotlin/com/bumble/appyx/navigation/AppyxTestScenario.kt b/appyx-navigation/android/src/androidTest/kotlin/com/bumble/appyx/navigation/AppyxTestScenario.kt index a6c4be99d..bb406ac13 100644 --- a/appyx-navigation/android/src/androidTest/kotlin/com/bumble/appyx/navigation/AppyxTestScenario.kt +++ b/appyx-navigation/android/src/androidTest/kotlin/com/bumble/appyx/navigation/AppyxTestScenario.kt @@ -9,7 +9,7 @@ import androidx.test.core.app.ActivityScenario import com.bumble.appyx.navigation.integration.NodeFactory import com.bumble.appyx.navigation.integration.NodeHost import com.bumble.appyx.navigation.node.Node -import com.bumble.appyx.navigation.platform.AndroidPlatformLifecycle +import com.bumble.appyx.navigation.platform.AndroidLifecycle import com.bumble.appyx.utils.testing.ui.rules.AppyxTestActivity import java.util.concurrent.CountDownLatch import java.util.concurrent.TimeUnit @@ -27,7 +27,7 @@ class AppyxTestScenario( AppyxTestActivity.composableView = { activity -> decorator { NodeHost( - lifecycle = AndroidPlatformLifecycle(LocalLifecycleOwner.current.lifecycle), + lifecycle = AndroidLifecycle(LocalLifecycleOwner.current.lifecycle), integrationPoint = activity.appyxIntegrationPoint, ) { buildContext -> node = nodeFactory.create(buildContext) diff --git a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/AndroidPlatformLifecycle.kt b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/AndroidLifecycle.kt similarity index 86% rename from appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/AndroidPlatformLifecycle.kt rename to appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/AndroidLifecycle.kt index 36004e9df..d46aaa9d6 100644 --- a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/AndroidPlatformLifecycle.kt +++ b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/AndroidLifecycle.kt @@ -5,11 +5,15 @@ import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleEventObserver import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.coroutineScope +import com.bumble.appyx.navigation.lifecycle.CommonLifecycle +import com.bumble.appyx.navigation.lifecycle.DefaultPlatformLifecycleObserver +import com.bumble.appyx.navigation.lifecycle.PlatformLifecycleEventObserver +import com.bumble.appyx.navigation.lifecycle.PlatformLifecycleObserver import kotlinx.coroutines.CoroutineScope -class AndroidPlatformLifecycle( +class AndroidLifecycle( val androidLifecycle: Lifecycle -) : PlatformLifecycle, +) : CommonLifecycle, DefaultLifecycleObserver, LifecycleEventObserver { @@ -18,7 +22,7 @@ class AndroidPlatformLifecycle( private val managedLifecycleEventObservers: MutableList = ArrayList() - override val currentState: PlatformLifecycle.State + override val currentState: CommonLifecycle.State get() = androidLifecycle.currentState.toCommonState() override val coroutineScope: CoroutineScope = diff --git a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleCommonMappers.kt b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleCommonMappers.kt new file mode 100644 index 000000000..46ed80692 --- /dev/null +++ b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleCommonMappers.kt @@ -0,0 +1,34 @@ +package com.bumble.appyx.navigation.platform + +import androidx.lifecycle.Lifecycle +import com.bumble.appyx.navigation.lifecycle.CommonLifecycle + + +fun Lifecycle.Event.toCommonEvent(): CommonLifecycle.Event = + when (this) { + Lifecycle.Event.ON_CREATE -> CommonLifecycle.Event.ON_CREATE + Lifecycle.Event.ON_START -> CommonLifecycle.Event.ON_START + Lifecycle.Event.ON_RESUME -> CommonLifecycle.Event.ON_RESUME + Lifecycle.Event.ON_PAUSE -> CommonLifecycle.Event.ON_PAUSE + Lifecycle.Event.ON_STOP -> CommonLifecycle.Event.ON_STOP + Lifecycle.Event.ON_DESTROY -> CommonLifecycle.Event.ON_DESTROY + Lifecycle.Event.ON_ANY -> CommonLifecycle.Event.ON_ANY + } + +fun CommonLifecycle.State.toAndroidState(): Lifecycle.State = + when (this) { + CommonLifecycle.State.INITIALIZED -> Lifecycle.State.INITIALIZED + CommonLifecycle.State.CREATED -> Lifecycle.State.CREATED + CommonLifecycle.State.STARTED -> Lifecycle.State.STARTED + CommonLifecycle.State.RESUMED -> Lifecycle.State.RESUMED + CommonLifecycle.State.DESTROYED -> Lifecycle.State.DESTROYED + } + +fun Lifecycle.State.toCommonState(): CommonLifecycle.State = + when (this) { + Lifecycle.State.DESTROYED -> CommonLifecycle.State.DESTROYED + Lifecycle.State.INITIALIZED -> CommonLifecycle.State.INITIALIZED + Lifecycle.State.CREATED -> CommonLifecycle.State.CREATED + Lifecycle.State.STARTED -> CommonLifecycle.State.STARTED + Lifecycle.State.RESUMED -> CommonLifecycle.State.RESUMED + } \ No newline at end of file diff --git a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt index fe8eca286..ad38f7276 100644 --- a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt +++ b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt @@ -4,11 +4,16 @@ import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LifecycleRegistry import androidx.lifecycle.coroutineScope +import com.bumble.appyx.navigation.lifecycle.CommonLifecycle +import com.bumble.appyx.navigation.lifecycle.CommonLifecycleOwner +import com.bumble.appyx.navigation.lifecycle.DefaultPlatformLifecycleObserver +import com.bumble.appyx.navigation.lifecycle.PlatformLifecycleEventObserver +import com.bumble.appyx.navigation.lifecycle.PlatformLifecycleObserver import kotlinx.coroutines.CoroutineScope actual class PlatformLifecycleRegistry( val androidLifecycleRegistry: LifecycleRegistry -) : PlatformLifecycle, androidx.lifecycle.DefaultLifecycleObserver, +) : CommonLifecycle, androidx.lifecycle.DefaultLifecycleObserver, androidx.lifecycle.LifecycleEventObserver { private val managedDefaultLifecycleObservers: MutableList = @@ -16,10 +21,10 @@ actual class PlatformLifecycleRegistry( private val managedLifecycleEventObservers: MutableList = ArrayList() - override val currentState: PlatformLifecycle.State + override val currentState: CommonLifecycle.State get() = androidLifecycleRegistry.currentState.toCommonState() - actual fun setCurrentState(state: PlatformLifecycle.State) { + actual fun setCurrentState(state: CommonLifecycle.State) { androidLifecycleRegistry.currentState = state.toAndroidState() } @@ -77,11 +82,11 @@ actual class PlatformLifecycleRegistry( } actual companion object { - actual fun create(owner: PlatformLifecycleOwner): PlatformLifecycleRegistry = + actual fun create(owner: CommonLifecycleOwner): PlatformLifecycleRegistry = PlatformLifecycleRegistry(LifecycleRegistry(object : LifecycleOwner { override val lifecycle: Lifecycle get() = when (val platformLifecycle = owner.lifecycle) { - is AndroidPlatformLifecycle -> platformLifecycle.androidLifecycle + is AndroidLifecycle -> platformLifecycle.androidLifecycle is PlatformLifecycleRegistry -> platformLifecycle.androidLifecycleRegistry else -> throw (IllegalStateException( "Unable to get android lifecycle from $platformLifecycle provided by $owner" diff --git a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformMappers.kt b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformMappers.kt deleted file mode 100644 index 805bd02e6..000000000 --- a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformMappers.kt +++ /dev/null @@ -1,33 +0,0 @@ -package com.bumble.appyx.navigation.platform - -import androidx.lifecycle.Lifecycle - - -fun Lifecycle.Event.toCommonEvent(): PlatformLifecycle.Event = - when (this) { - Lifecycle.Event.ON_CREATE -> PlatformLifecycle.Event.ON_CREATE - Lifecycle.Event.ON_START -> PlatformLifecycle.Event.ON_START - Lifecycle.Event.ON_RESUME -> PlatformLifecycle.Event.ON_RESUME - Lifecycle.Event.ON_PAUSE -> PlatformLifecycle.Event.ON_PAUSE - Lifecycle.Event.ON_STOP -> PlatformLifecycle.Event.ON_STOP - Lifecycle.Event.ON_DESTROY -> PlatformLifecycle.Event.ON_DESTROY - Lifecycle.Event.ON_ANY -> PlatformLifecycle.Event.ON_ANY - } - -fun PlatformLifecycle.State.toAndroidState(): Lifecycle.State = - when (this) { - PlatformLifecycle.State.INITIALIZED -> Lifecycle.State.INITIALIZED - PlatformLifecycle.State.CREATED -> Lifecycle.State.CREATED - PlatformLifecycle.State.STARTED -> Lifecycle.State.STARTED - PlatformLifecycle.State.RESUMED -> Lifecycle.State.RESUMED - PlatformLifecycle.State.DESTROYED -> Lifecycle.State.DESTROYED - } - -fun Lifecycle.State.toCommonState(): PlatformLifecycle.State = - when (this) { - Lifecycle.State.DESTROYED -> PlatformLifecycle.State.DESTROYED - Lifecycle.State.INITIALIZED -> PlatformLifecycle.State.INITIALIZED - Lifecycle.State.CREATED -> PlatformLifecycle.State.CREATED - Lifecycle.State.STARTED -> PlatformLifecycle.State.STARTED - Lifecycle.State.RESUMED -> PlatformLifecycle.State.RESUMED - } \ No newline at end of file diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareCallbackInfo.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareCallbackInfo.kt index 900ea0caf..8b5fba33f 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareCallbackInfo.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareCallbackInfo.kt @@ -1,9 +1,9 @@ package com.bumble.appyx.navigation.children +import com.bumble.appyx.navigation.lifecycle.CommonLifecycle import com.bumble.appyx.navigation.lifecycle.MinimumCombinedLifecycle import com.bumble.appyx.navigation.lifecycle.isDestroyed import com.bumble.appyx.navigation.node.Node -import com.bumble.appyx.navigation.platform.PlatformLifecycle import kotlin.reflect.KClass import kotlin.reflect.cast import kotlin.reflect.safeCast @@ -15,7 +15,7 @@ internal sealed class ChildAwareCallbackInfo { class Single( private val child: KClass, private val callback: ChildCallback, - private val parentLifecycle: PlatformLifecycle, + private val parentLifecycle: CommonLifecycle, ) : ChildAwareCallbackInfo() { fun onNewNodeAppeared(newNode: Node) { @@ -43,7 +43,7 @@ internal sealed class ChildAwareCallbackInfo { private val child1: KClass, private val child2: KClass, private val callback: ChildrenCallback, - private val parentLifecycle: PlatformLifecycle, + private val parentLifecycle: CommonLifecycle, ) : ChildAwareCallbackInfo() { fun onNewNodeAppeared( diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt index 8bbd0321b..e82d6e788 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt @@ -1,11 +1,11 @@ package com.bumble.appyx.navigation.children import com.bumble.appyx.interactions.core.Element +import com.bumble.appyx.navigation.lifecycle.CommonLifecycle +import com.bumble.appyx.navigation.lifecycle.DefaultPlatformLifecycleObserver import com.bumble.appyx.navigation.lifecycle.isDestroyed import com.bumble.appyx.navigation.node.Node import com.bumble.appyx.navigation.node.ParentNode -import com.bumble.appyx.navigation.platform.DefaultPlatformLifecycleObserver -import com.bumble.appyx.navigation.platform.PlatformLifecycle import com.bumble.appyx.navigation.withPrevious import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.MutableStateFlow @@ -19,7 +19,7 @@ class ChildAwareImpl : ChildAware { private val callbacks: MutableList = ArrayList() private lateinit var children: StateFlow, ChildEntry<*>>> - private lateinit var lifecycle: PlatformLifecycle + private lateinit var lifecycle: CommonLifecycle private lateinit var coroutineScope: CoroutineScope override lateinit var node: N @@ -91,7 +91,7 @@ class ChildAwareImpl : ChildAware { } } - private fun PlatformLifecycle.removeWhenDestroyed(info: ChildAwareCallbackInfo) { + private fun CommonLifecycle.removeWhenDestroyed(info: ChildAwareCallbackInfo) { addObserver(object : DefaultPlatformLifecycleObserver { override fun onDestroy() { callbacks.remove(info) diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildCallback.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildCallback.kt index b4234755f..ce6d5c748 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildCallback.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildCallback.kt @@ -1,7 +1,7 @@ package com.bumble.appyx.navigation.children -import com.bumble.appyx.navigation.platform.PlatformLifecycle +import com.bumble.appyx.navigation.lifecycle.CommonLifecycle -typealias ChildrenCallback = (commonLifecycle: PlatformLifecycle, child1: T1, child2: T2) -> Unit +typealias ChildrenCallback = (commonLifecycle: CommonLifecycle, child1: T1, child2: T2) -> Unit -typealias ChildCallback = (commonLifecycle: PlatformLifecycle, child: T) -> Unit +typealias ChildCallback = (commonLifecycle: CommonLifecycle, child: T) -> Unit diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt index 8ac077603..a1c8a6085 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt @@ -10,11 +10,11 @@ import androidx.compose.runtime.saveable.mapSaver import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.Modifier import com.bumble.appyx.navigation.integrationpoint.IntegrationPoint +import com.bumble.appyx.navigation.lifecycle.CommonLifecycle +import com.bumble.appyx.navigation.lifecycle.PlatformLifecycleEventObserver import com.bumble.appyx.navigation.modality.BuildContext import com.bumble.appyx.navigation.node.Node import com.bumble.appyx.navigation.node.build -import com.bumble.appyx.navigation.platform.PlatformLifecycle -import com.bumble.appyx.navigation.platform.PlatformLifecycleEventObserver import com.bumble.appyx.navigation.state.SavedStateMap import com.bumble.appyx.utils.customisations.NodeCustomisationDirectory import com.bumble.appyx.utils.customisations.NodeCustomisationDirectoryImpl @@ -27,7 +27,7 @@ import com.bumble.appyx.utils.customisations.NodeCustomisationDirectoryImpl @Suppress("ComposableParamOrder") // detekt complains as 'factory' param isn't a pure lambda @Composable fun NodeHost( - lifecycle: PlatformLifecycle, + lifecycle: CommonLifecycle, integrationPoint: IntegrationPoint, modifier: Modifier = Modifier, customisations: NodeCustomisationDirectory = remember { NodeCustomisationDirectoryImpl() }, @@ -35,7 +35,7 @@ fun NodeHost( ) { val node by rememberNode(factory, customisations, integrationPoint) DisposableEffect(node) { - onDispose { node.updateLifecycleState(PlatformLifecycle.State.DESTROYED) } + onDispose { node.updateLifecycleState(CommonLifecycle.State.DESTROYED) } } node.Compose(modifier = modifier) DisposableEffect(lifecycle) { diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/ChildNodeLifecycleManager.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/ChildNodeLifecycleManager.kt index eb58043e4..e86fad9c3 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/ChildNodeLifecycleManager.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/ChildNodeLifecycleManager.kt @@ -4,8 +4,6 @@ import com.bumble.appyx.interactions.core.model.InteractionModel import com.bumble.appyx.navigation.children.ChildEntry import com.bumble.appyx.navigation.children.ChildEntryMap import com.bumble.appyx.navigation.children.nodeOrNull -import com.bumble.appyx.navigation.platform.PlatformLifecycle -import com.bumble.appyx.navigation.platform.PlatformLifecycleRegistry import com.bumble.appyx.navigation.withPrevious import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.MutableStateFlow @@ -25,7 +23,7 @@ internal class ChildNodeLifecycleManager( private val coroutineScope: CoroutineScope, ) { - private val lifecycleState = MutableStateFlow(PlatformLifecycle.State.INITIALIZED) + private val lifecycleState = MutableStateFlow(CommonLifecycle.State.INITIALIZED) /** * Propagates the parent lifecycle to children. @@ -37,7 +35,7 @@ internal class ChildNodeLifecycleManager( * Otherwise a child node lifecycle might be updated before the parent. * It leads to incorrect registration order of back handlers. */ - fun propagateLifecycleToChildren(state: PlatformLifecycle.State) { + fun propagateLifecycleToChildren(state: CommonLifecycle.State) { lifecycleState.value = state } @@ -58,24 +56,24 @@ internal class ChildNodeLifecycleManager( children .value .values - .forEach { entry -> entry.setState(PlatformLifecycle.State.DESTROYED) } + .forEach { entry -> entry.setState(CommonLifecycle.State.DESTROYED) } } .collect { (parentLifecycleState, screenState, children) -> screenState.onScreen.forEach { key -> val childState = - minOf(parentLifecycleState, PlatformLifecycle.State.RESUMED) + minOf(parentLifecycleState, CommonLifecycle.State.RESUMED) children.current[key]?.setState(childState) } screenState.offScreen.forEach { key -> if (keepMode == ChildEntry.KeepMode.KEEP) { val childState = - minOf(parentLifecycleState, PlatformLifecycle.State.CREATED) + minOf(parentLifecycleState, CommonLifecycle.State.CREATED) children.current[key]?.setState(childState) } else { // Look up in the previous because in the current it is already suspended // and does not have a reference to the node - children.previous?.get(key)?.setState(PlatformLifecycle.State.DESTROYED) + children.previous?.get(key)?.setState(CommonLifecycle.State.DESTROYED) } } @@ -83,14 +81,14 @@ internal class ChildNodeLifecycleManager( val removedKeys = children.previous.keys - children.current.keys removedKeys.forEach { key -> val removedChild = children.previous[key] - removedChild?.setState(PlatformLifecycle.State.DESTROYED) + removedChild?.setState(CommonLifecycle.State.DESTROYED) } } } } } - private fun ChildEntry<*>.setState(state: PlatformLifecycle.State) { + private fun ChildEntry<*>.setState(state: CommonLifecycle.State) { nodeOrNull?.updateLifecycleState(state) } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycle.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/CommonLifecycle.kt similarity index 92% rename from appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycle.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/CommonLifecycle.kt index b5556fe69..f91e53c77 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycle.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/CommonLifecycle.kt @@ -1,11 +1,11 @@ -package com.bumble.appyx.navigation.platform +package com.bumble.appyx.navigation.lifecycle import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow -interface PlatformLifecycle { +interface CommonLifecycle { val currentState: State val coroutineScope: CoroutineScope diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleObserver.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/CommonLifecycleObserver.kt similarity index 84% rename from appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleObserver.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/CommonLifecycleObserver.kt index 2df3ae5e7..029a91a4e 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleObserver.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/CommonLifecycleObserver.kt @@ -1,4 +1,4 @@ -package com.bumble.appyx.navigation.platform +package com.bumble.appyx.navigation.lifecycle /** * Ported from Androidx.lifecycle @@ -7,8 +7,7 @@ package com.bumble.appyx.navigation.platform * See Also: * Lifecycle - for samples and usage patterns. */ -interface PlatformLifecycleObserver { -} +interface PlatformLifecycleObserver /** * Ported from Androidx.lifecycle @@ -34,17 +33,14 @@ interface DefaultPlatformLifecycleObserver : PlatformLifecycleObserver { } /** - * Class that can receive any lifecycle change and dispatch it to the receiver. + * Ported from Androidx.lifecycle * + * Class that can receive any lifecycle change and dispatch it to the receiver. * * If a class implements both this interface and * [DefaultPlatformLifecycleObserver], then * methods of `DefaultLifecycleObserver` will be called first, and then followed by the call * of [PlatformLifecycleEventObserver.onStateChanged] - * - * - * If a class implements this interface and in the same time uses [OnLifecycleEvent], then - * annotations will be ignored. */ fun interface PlatformLifecycleEventObserver : PlatformLifecycleObserver { /** @@ -52,5 +48,5 @@ fun interface PlatformLifecycleEventObserver : PlatformLifecycleObserver { * * @param event The event */ - fun onStateChanged(newState: PlatformLifecycle.State, event: PlatformLifecycle.Event) + fun onStateChanged(newState: CommonLifecycle.State, event: CommonLifecycle.Event) } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/CommonLifecycleOwner.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/CommonLifecycleOwner.kt new file mode 100644 index 000000000..0176ed545 --- /dev/null +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/CommonLifecycleOwner.kt @@ -0,0 +1,8 @@ +package com.bumble.appyx.navigation.lifecycle + +import kotlinx.coroutines.CoroutineScope + +interface CommonLifecycleOwner { + val lifecycle: CommonLifecycle + val lifecycleScope: CoroutineScope +} diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt index db96e5e99..988159d9e 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt @@ -1,7 +1,6 @@ package com.bumble.appyx.navigation.lifecycle import com.bumble.appyx.navigation.node.Node -import com.bumble.appyx.navigation.platform.DefaultPlatformLifecycleObserver import com.bumble.appyx.utils.multiplatform.Logger internal class LifecycleLogger(private val node: Node) : DefaultPlatformLifecycleObserver { diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt index 00676ee81..930c588fc 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt @@ -1,8 +1,5 @@ package com.bumble.appyx.navigation.lifecycle -import com.bumble.appyx.navigation.platform.DefaultPlatformLifecycleObserver -import com.bumble.appyx.navigation.platform.PlatformLifecycle -import com.bumble.appyx.navigation.platform.PlatformLifecycleOwner import com.bumble.appyx.navigation.platform.PlatformLifecycleRegistry import kotlinx.coroutines.CoroutineScope @@ -16,10 +13,10 @@ import kotlinx.coroutines.CoroutineScope * - INITIALIZED + DESTROYED -> DESTROYED */ internal class MinimumCombinedLifecycle( - vararg lifecycles: PlatformLifecycle, -) : PlatformLifecycleOwner { + vararg lifecycles: CommonLifecycle, +) : CommonLifecycleOwner { private val registry = PlatformLifecycleRegistry.create(this) - private val lifecycles = ArrayList() + private val lifecycles = ArrayList() init { /* @@ -30,10 +27,10 @@ internal class MinimumCombinedLifecycle( lifecycles.sortedBy { it.currentState }.forEach { manage(it) } } - override val lifecycle: PlatformLifecycle = registry + override val lifecycle: CommonLifecycle = registry override val lifecycleScope: CoroutineScope = registry.coroutineScope - fun manage(lifecycle: PlatformLifecycle) { + fun manage(lifecycle: CommonLifecycle) { lifecycles += lifecycle lifecycle.addObserver(object : DefaultPlatformLifecycleObserver { override fun onCreate() { @@ -66,7 +63,7 @@ internal class MinimumCombinedLifecycle( private fun update() { lifecycles .minByOrNull { it.currentState } - ?.takeIf { it.currentState != PlatformLifecycle.State.INITIALIZED } + ?.takeIf { it.currentState != CommonLifecycle.State.INITIALIZED } ?.also { registry.setCurrentState(it.currentState) } } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycle.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycle.kt index 2178627db..b3371fa5e 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycle.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycle.kt @@ -1,10 +1,7 @@ package com.bumble.appyx.navigation.lifecycle -import com.bumble.appyx.navigation.platform.PlatformLifecycle -import com.bumble.appyx.navigation.platform.PlatformLifecycleOwner +interface NodeLifecycle : CommonLifecycleOwner { -interface NodeLifecycle : PlatformLifecycleOwner { - - fun updateLifecycleState(state: PlatformLifecycle.State) + fun updateLifecycleState(state: CommonLifecycle.State) } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt index af0d176f8..8bca12ebd 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt @@ -1,18 +1,16 @@ package com.bumble.appyx.navigation.lifecycle -import com.bumble.appyx.navigation.platform.PlatformLifecycle -import com.bumble.appyx.navigation.platform.PlatformLifecycleOwner import com.bumble.appyx.navigation.platform.PlatformLifecycleRegistry import kotlinx.coroutines.CoroutineScope -internal class NodeLifecycleImpl(lifecycleOwner: PlatformLifecycleOwner) : NodeLifecycle { +internal class NodeLifecycleImpl(lifecycleOwner: CommonLifecycleOwner) : NodeLifecycle { private val lifecycleRegistry: PlatformLifecycleRegistry = PlatformLifecycleRegistry.create(lifecycleOwner) - override val lifecycle: PlatformLifecycle = lifecycleRegistry + override val lifecycle: CommonLifecycle = lifecycleRegistry override val lifecycleScope: CoroutineScope = lifecycleRegistry.coroutineScope - override fun updateLifecycleState(state: PlatformLifecycle.State) { + override fun updateLifecycleState(state: CommonLifecycle.State) { lifecycleRegistry.setCurrentState(state) } } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleExt.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/PlatformLifecycleExt.kt similarity index 68% rename from appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleExt.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/PlatformLifecycleExt.kt index 46e9efc05..89487bb6b 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleExt.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/PlatformLifecycleExt.kt @@ -1,17 +1,13 @@ package com.bumble.appyx.navigation.lifecycle -import com.bumble.appyx.navigation.platform.DefaultPlatformLifecycleObserver -import com.bumble.appyx.navigation.platform.PlatformLifecycle -import com.bumble.appyx.navigation.platform.PlatformLifecycleEventObserver -import com.bumble.appyx.navigation.platform.PlatformLifecycleOwner import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow -fun PlatformLifecycleOwner.asFlow(): Flow = +fun CommonLifecycleOwner.asFlow(): Flow = lifecycle.asFlow() -fun PlatformLifecycle.asFlow(): Flow = +fun CommonLifecycle.asFlow(): Flow = callbackFlow { val observer = PlatformLifecycleEventObserver { currentState, _ -> trySend(currentState) @@ -21,10 +17,10 @@ fun PlatformLifecycle.asFlow(): Flow = awaitClose { removeObserver(observer) } } -internal val PlatformLifecycle.isDestroyed: Boolean - get() = currentState == PlatformLifecycle.State.DESTROYED +internal val CommonLifecycle.isDestroyed: Boolean + get() = currentState == CommonLifecycle.State.DESTROYED -fun PlatformLifecycle.subscribe( +fun CommonLifecycle.subscribe( onCreate: () -> Unit = {}, onStart: () -> Unit = {}, onResume: () -> Unit = {}, diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt index a8cc9e79e..721a4c2ec 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt @@ -12,12 +12,12 @@ import com.bumble.appyx.interactions.core.state.MutableSavedStateMapImpl import com.bumble.appyx.navigation.Appyx import com.bumble.appyx.navigation.integrationpoint.IntegrationPoint import com.bumble.appyx.navigation.integrationpoint.IntegrationPointStub +import com.bumble.appyx.navigation.lifecycle.CommonLifecycle +import com.bumble.appyx.navigation.lifecycle.DefaultPlatformLifecycleObserver import com.bumble.appyx.navigation.lifecycle.NodeLifecycle import com.bumble.appyx.navigation.lifecycle.NodeLifecycleImpl import com.bumble.appyx.navigation.modality.AncestryInfo import com.bumble.appyx.navigation.modality.BuildContext -import com.bumble.appyx.navigation.platform.DefaultPlatformLifecycleObserver -import com.bumble.appyx.navigation.platform.PlatformLifecycle import com.bumble.appyx.navigation.plugin.Destroyable import com.bumble.appyx.navigation.plugin.NodeLifecycleAware import com.bumble.appyx.navigation.plugin.NodeReadyObserver @@ -103,7 +103,7 @@ open class Node internal constructor( open fun onBuilt() { require(!wasBuilt) { "onBuilt was already invoked" } wasBuilt = true - updateLifecycleState(PlatformLifecycle.State.CREATED) + updateLifecycleState(CommonLifecycle.State.CREATED) plugins>().forEach { it.init(this) } plugins().forEach { it.onCreate(lifecycle) } } @@ -123,9 +123,9 @@ open class Node internal constructor( } - override fun updateLifecycleState(state: PlatformLifecycle.State) { + override fun updateLifecycleState(state: CommonLifecycle.State) { if (lifecycle.currentState == state) return - if (lifecycle.currentState == PlatformLifecycle.State.DESTROYED && state != PlatformLifecycle.State.DESTROYED) { + if (lifecycle.currentState == CommonLifecycle.State.DESTROYED && state != CommonLifecycle.State.DESTROYED) { Appyx.reportException( IllegalStateException( "Trying to change lifecycle state of already destroyed node ${this::class.qualifiedName}" @@ -134,7 +134,7 @@ open class Node internal constructor( return } nodeLifecycle.updateLifecycleState(state) - if (state == PlatformLifecycle.State.DESTROYED) { + if (state == CommonLifecycle.State.DESTROYED) { if (!integrationPoint.isChangingConfigurations) { retainedInstanceStore.clearStore(id) } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt index d1ec36cef..c8e9d5de6 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt @@ -28,11 +28,11 @@ import com.bumble.appyx.navigation.children.ChildrenCallback import com.bumble.appyx.navigation.children.nodeOrNull import com.bumble.appyx.navigation.composable.ChildRenderer import com.bumble.appyx.navigation.lifecycle.ChildNodeLifecycleManager +import com.bumble.appyx.navigation.lifecycle.CommonLifecycle import com.bumble.appyx.navigation.mapState import com.bumble.appyx.navigation.modality.BuildContext import com.bumble.appyx.navigation.navigation.Resolver import com.bumble.appyx.navigation.platform.PlatformBackHandler -import com.bumble.appyx.navigation.platform.PlatformLifecycle import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.launch @@ -118,12 +118,12 @@ abstract class ParentNode( PermanentChild(interactionTarget) { child -> child() } } - override fun updateLifecycleState(state: PlatformLifecycle.State) { + override fun updateLifecycleState(state: CommonLifecycle.State) { super.updateLifecycleState(state) childNodeLifecycleManager.propagateLifecycleToChildren(state) // TODO move to plugins - if (state == PlatformLifecycle.State.DESTROYED) { + if (state == CommonLifecycle.State.DESTROYED) { interactionModel.destroy() } } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleOwner.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleOwner.kt deleted file mode 100644 index 2e839c396..000000000 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleOwner.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.bumble.appyx.navigation.platform - -import kotlinx.coroutines.CoroutineScope - -interface PlatformLifecycleOwner { - val lifecycle: PlatformLifecycle - val lifecycleScope: CoroutineScope -} diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt index 3cfb0b9f1..101f3f56f 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt @@ -1,9 +1,12 @@ package com.bumble.appyx.navigation.platform -expect class PlatformLifecycleRegistry : PlatformLifecycle { - fun setCurrentState(state: PlatformLifecycle.State) +import com.bumble.appyx.navigation.lifecycle.CommonLifecycle +import com.bumble.appyx.navigation.lifecycle.CommonLifecycleOwner + +expect class PlatformLifecycleRegistry : CommonLifecycle { + fun setCurrentState(state: CommonLifecycle.State) companion object { - fun create(owner: PlatformLifecycleOwner): PlatformLifecycleRegistry + fun create(owner: CommonLifecycleOwner): PlatformLifecycleRegistry } } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt index b306386b7..6bfde3339 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt @@ -1,9 +1,9 @@ package com.bumble.appyx.navigation.plugin import com.bumble.appyx.interactions.core.plugin.Plugin +import com.bumble.appyx.navigation.lifecycle.CommonLifecycle import com.bumble.appyx.navigation.node.Node import com.bumble.appyx.navigation.platform.OnBackPressedCallback -import com.bumble.appyx.navigation.platform.PlatformLifecycle inline fun Node.plugins(): List

= this.plugins.filterIsInstance

() @@ -17,7 +17,7 @@ interface NodeReadyObserver : Plugin { } interface NodeLifecycleAware : Plugin { - fun onCreate(lifecycle: PlatformLifecycle) {} + fun onCreate(lifecycle: CommonLifecycle) {} } interface UpNavigationHandler : Plugin { diff --git a/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt b/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt index 202c45239..068c6a9e9 100644 --- a/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt +++ b/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt @@ -1,56 +1,61 @@ package com.bumble.appyx.navigation.platform +import com.bumble.appyx.navigation.lifecycle.CommonLifecycle +import com.bumble.appyx.navigation.lifecycle.CommonLifecycleOwner +import com.bumble.appyx.navigation.lifecycle.DefaultPlatformLifecycleObserver +import com.bumble.appyx.navigation.lifecycle.PlatformLifecycleEventObserver +import com.bumble.appyx.navigation.lifecycle.PlatformLifecycleObserver import kotlinx.coroutines.CoroutineScope actual class PlatformLifecycleRegistry( lifecycleCoroutineScope: CoroutineScope, -) : PlatformLifecycle { +) : CommonLifecycle { private val managedDefaultLifecycleObservers: MutableList = ArrayList() private val managedLifecycleEventObservers: MutableList = ArrayList() - private var _currentState: PlatformLifecycle.State = PlatformLifecycle.State.INITIALIZED - override var currentState: PlatformLifecycle.State + private var _currentState: CommonLifecycle.State = CommonLifecycle.State.INITIALIZED + override var currentState: CommonLifecycle.State get() = _currentState set(value) { when (value) { - PlatformLifecycle.State.INITIALIZED -> Unit - PlatformLifecycle.State.CREATED -> { + CommonLifecycle.State.INITIALIZED -> Unit + CommonLifecycle.State.CREATED -> { managedDefaultLifecycleObservers.forEach { it.onCreate() } managedLifecycleEventObservers.forEach { it.onStateChanged( value, - PlatformLifecycle.Event.ON_CREATE + CommonLifecycle.Event.ON_CREATE ) } } - PlatformLifecycle.State.STARTED -> { + CommonLifecycle.State.STARTED -> { managedDefaultLifecycleObservers.forEach { it.onStart() } managedLifecycleEventObservers.forEach { it.onStateChanged( value, - PlatformLifecycle.Event.ON_START + CommonLifecycle.Event.ON_START ) } } - PlatformLifecycle.State.RESUMED -> { + CommonLifecycle.State.RESUMED -> { managedDefaultLifecycleObservers.forEach { it.onResume() } managedLifecycleEventObservers.forEach { it.onStateChanged( value, - PlatformLifecycle.Event.ON_RESUME + CommonLifecycle.Event.ON_RESUME ) } } - PlatformLifecycle.State.DESTROYED -> { + CommonLifecycle.State.DESTROYED -> { managedDefaultLifecycleObservers.forEach { it.onDestroy() } managedLifecycleEventObservers.forEach { it.onStateChanged( value, - PlatformLifecycle.Event.ON_DESTROY + CommonLifecycle.Event.ON_DESTROY ) } } @@ -74,11 +79,11 @@ actual class PlatformLifecycleRegistry( } } - actual fun setCurrentState(state: PlatformLifecycle.State) { + actual fun setCurrentState(state: CommonLifecycle.State) { } actual companion object { - actual fun create(owner: PlatformLifecycleOwner): PlatformLifecycleRegistry { + actual fun create(owner: CommonLifecycleOwner): PlatformLifecycleRegistry { TODO("Not yet implemented") } } diff --git a/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt b/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt index 69b8d6821..9e1716fba 100644 --- a/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt +++ b/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt @@ -1,55 +1,60 @@ package com.bumble.appyx.navigation.platform +import com.bumble.appyx.navigation.lifecycle.CommonLifecycle +import com.bumble.appyx.navigation.lifecycle.CommonLifecycleOwner +import com.bumble.appyx.navigation.lifecycle.DefaultPlatformLifecycleObserver +import com.bumble.appyx.navigation.lifecycle.PlatformLifecycleEventObserver +import com.bumble.appyx.navigation.lifecycle.PlatformLifecycleObserver import kotlinx.coroutines.CoroutineScope actual class PlatformLifecycleRegistry( lifecycleCoroutineScope: CoroutineScope, -) : PlatformLifecycle { +) : CommonLifecycle { private val managedDefaultLifecycleObservers: MutableList = ArrayList() private val managedLifecycleEventObservers: MutableList = ArrayList() - private var _currentState: PlatformLifecycle.State = PlatformLifecycle.State.INITIALIZED - override var currentState: PlatformLifecycle.State + private var _currentState: CommonLifecycle.State = CommonLifecycle.State.INITIALIZED + override var currentState: CommonLifecycle.State get() = _currentState set(value) { when (value) { - PlatformLifecycle.State.INITIALIZED -> Unit - PlatformLifecycle.State.CREATED -> { + CommonLifecycle.State.INITIALIZED -> Unit + CommonLifecycle.State.CREATED -> { managedDefaultLifecycleObservers.forEach { it.onCreate() } managedLifecycleEventObservers.forEach { it.onStateChanged( value, - PlatformLifecycle.Event.ON_CREATE + CommonLifecycle.Event.ON_CREATE ) } } - PlatformLifecycle.State.STARTED -> { + CommonLifecycle.State.STARTED -> { managedDefaultLifecycleObservers.forEach { it.onStart() } managedLifecycleEventObservers.forEach { it.onStateChanged( value, - PlatformLifecycle.Event.ON_START + CommonLifecycle.Event.ON_START ) } } - PlatformLifecycle.State.RESUMED -> { + CommonLifecycle.State.RESUMED -> { managedDefaultLifecycleObservers.forEach { it.onResume() } managedLifecycleEventObservers.forEach { it.onStateChanged( value, - PlatformLifecycle.Event.ON_RESUME + CommonLifecycle.Event.ON_RESUME ) } } - PlatformLifecycle.State.DESTROYED -> { + CommonLifecycle.State.DESTROYED -> { managedDefaultLifecycleObservers.forEach { it.onDestroy() } managedLifecycleEventObservers.forEach { it.onStateChanged( value, - PlatformLifecycle.Event.ON_DESTROY + CommonLifecycle.Event.ON_DESTROY ) } } @@ -73,11 +78,11 @@ actual class PlatformLifecycleRegistry( } } - actual fun setCurrentState(state: PlatformLifecycle.State) { + actual fun setCurrentState(state: CommonLifecycle.State) { } actual companion object { - actual fun create(owner: PlatformLifecycleOwner): PlatformLifecycleRegistry { + actual fun create(owner: CommonLifecycleOwner): PlatformLifecycleRegistry { TODO("Not yet implemented") } } diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/MainActivity.kt b/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/MainActivity.kt index ef98f2b02..c9783f1b8 100644 --- a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/MainActivity.kt +++ b/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/MainActivity.kt @@ -16,7 +16,7 @@ import com.bumble.appyx.navigation.integration.NodeHost import com.bumble.appyx.navigation.integrationpoint.NodeActivity import com.bumble.appyx.navigation.modality.BuildContext import com.bumble.appyx.navigation.node.container.ContainerNode -import com.bumble.appyx.navigation.platform.AndroidPlatformLifecycle +import com.bumble.appyx.navigation.platform.AndroidLifecycle import com.bumble.appyx.navigation.ui.AppyxSampleAppTheme @ExperimentalUnitApi @@ -33,7 +33,7 @@ class MainActivity : NodeActivity() { Surface(color = MaterialTheme.colorScheme.background) { Column { NodeHost( - AndroidPlatformLifecycle(LocalLifecycleOwner.current.lifecycle), + AndroidLifecycle(LocalLifecycleOwner.current.lifecycle), integrationPoint = appyxIntegrationPoint ) { ContainerNode( diff --git a/demos/navigation-compose/src/main/kotlin/com/bumble/appyx/sample/navigtion/compose/ComposeNavigationRoot.kt b/demos/navigation-compose/src/main/kotlin/com/bumble/appyx/sample/navigtion/compose/ComposeNavigationRoot.kt index a03d3308d..9fdde074d 100644 --- a/demos/navigation-compose/src/main/kotlin/com/bumble/appyx/sample/navigtion/compose/ComposeNavigationRoot.kt +++ b/demos/navigation-compose/src/main/kotlin/com/bumble/appyx/sample/navigtion/compose/ComposeNavigationRoot.kt @@ -19,7 +19,7 @@ import androidx.navigation.compose.composable import androidx.navigation.compose.rememberNavController import com.bumble.appyx.navigation.integration.NodeHost import com.bumble.appyx.navigation.integrationpoint.LocalIntegrationPoint -import com.bumble.appyx.navigation.platform.AndroidPlatformLifecycle +import com.bumble.appyx.navigation.platform.AndroidLifecycle /** * This Composable demonstrates how to add Appyx into Jetpack Compose Navigation. @@ -70,7 +70,7 @@ internal fun GoogleRoute(modifier: Modifier = Modifier, onAppyxNavigationClick: @Composable internal fun AppyxRoute(onGoogleNavigationClick: () -> Unit) { NodeHost( - lifecycle = AndroidPlatformLifecycle(LocalLifecycleOwner.current.lifecycle), + lifecycle = AndroidLifecycle(LocalLifecycleOwner.current.lifecycle), integrationPoint = LocalIntegrationPoint.current ) { ComposeNavigationContainerNode( diff --git a/utils/interop-rx2/src/main/kotlin/com/bumble/appyx/utils/interop/rx2/connectable/NodeConnector.kt b/utils/interop-rx2/src/main/kotlin/com/bumble/appyx/utils/interop/rx2/connectable/NodeConnector.kt index 78daa2662..b2ca21431 100644 --- a/utils/interop-rx2/src/main/kotlin/com/bumble/appyx/utils/interop/rx2/connectable/NodeConnector.kt +++ b/utils/interop-rx2/src/main/kotlin/com/bumble/appyx/utils/interop/rx2/connectable/NodeConnector.kt @@ -1,8 +1,8 @@ package com.bumble.appyx.utils.interop.rx2.connectable import android.annotation.SuppressLint +import com.bumble.appyx.navigation.lifecycle.CommonLifecycle import com.bumble.appyx.navigation.lifecycle.subscribe -import com.bumble.appyx.navigation.platform.PlatformLifecycle import com.jakewharton.rxrelay2.PublishRelay import com.jakewharton.rxrelay2.Relay import io.reactivex.Observer @@ -31,7 +31,7 @@ class NodeConnector( } - override fun onCreate(lifecycle: PlatformLifecycle) { + override fun onCreate(lifecycle: CommonLifecycle) { lifecycle.subscribe(onCreate = { flushOutputCache() }) } diff --git a/utils/interop-rx3/src/main/kotlin/com/bumble/appyx/utils/interop/rx3/connectable/NodeConnector.kt b/utils/interop-rx3/src/main/kotlin/com/bumble/appyx/utils/interop/rx3/connectable/NodeConnector.kt index 22b78d578..bd36293d4 100644 --- a/utils/interop-rx3/src/main/kotlin/com/bumble/appyx/utils/interop/rx3/connectable/NodeConnector.kt +++ b/utils/interop-rx3/src/main/kotlin/com/bumble/appyx/utils/interop/rx3/connectable/NodeConnector.kt @@ -1,8 +1,8 @@ package com.bumble.appyx.utils.interop.rx3.connectable import android.annotation.SuppressLint +import com.bumble.appyx.navigation.lifecycle.CommonLifecycle import com.bumble.appyx.navigation.lifecycle.subscribe -import com.bumble.appyx.navigation.platform.PlatformLifecycle import com.jakewharton.rxrelay3.PublishRelay import com.jakewharton.rxrelay3.Relay import io.reactivex.rxjava3.core.Observer @@ -30,7 +30,7 @@ class NodeConnector( } - override fun onCreate(lifecycle: PlatformLifecycle) { + override fun onCreate(lifecycle: CommonLifecycle) { lifecycle.subscribe(onCreate = { flushOutputCache() }) } diff --git a/utils/testing-ui/src/main/kotlin/com/bumble/appyx/utils/testing/ui/rules/AppyxActivityTestRule.kt b/utils/testing-ui/src/main/kotlin/com/bumble/appyx/utils/testing/ui/rules/AppyxActivityTestRule.kt index 374e254c4..b1e3cdf0f 100644 --- a/utils/testing-ui/src/main/kotlin/com/bumble/appyx/utils/testing/ui/rules/AppyxActivityTestRule.kt +++ b/utils/testing-ui/src/main/kotlin/com/bumble/appyx/utils/testing/ui/rules/AppyxActivityTestRule.kt @@ -9,7 +9,7 @@ import androidx.test.rule.ActivityTestRule import com.bumble.appyx.navigation.integration.NodeFactory import com.bumble.appyx.navigation.integration.NodeHost import com.bumble.appyx.navigation.node.Node -import com.bumble.appyx.navigation.platform.AndroidPlatformLifecycle +import com.bumble.appyx.navigation.platform.AndroidLifecycle import org.junit.rules.TestRule import org.junit.runner.Description import org.junit.runners.model.Statement @@ -47,7 +47,7 @@ open class AppyxActivityTestRule( AppyxTestActivity.composableView = { activity -> decorator { NodeHost( - lifecycle = AndroidPlatformLifecycle(LocalLifecycleOwner.current.lifecycle), + lifecycle = AndroidLifecycle(LocalLifecycleOwner.current.lifecycle), integrationPoint = activity.appyxIntegrationPoint ) { buildContext -> node = nodeFactory.create(buildContext) diff --git a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/helper/NodeTestHelper.kt b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/helper/NodeTestHelper.kt index 28aa3654b..d3b0eeeb6 100644 --- a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/helper/NodeTestHelper.kt +++ b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/helper/NodeTestHelper.kt @@ -1,8 +1,8 @@ package com.bumble.appyx.utils.testing.unit.common.helper +import com.bumble.appyx.navigation.lifecycle.CommonLifecycle import com.bumble.appyx.navigation.node.Node import com.bumble.appyx.navigation.node.build -import com.bumble.appyx.navigation.platform.PlatformLifecycle fun N.nodeTestHelper() = NodeTestHelper(this) @@ -15,8 +15,8 @@ open class NodeTestHelper(private val node: N) { node.build() } - fun moveTo(state: PlatformLifecycle.State) { - require(state != PlatformLifecycle.State.INITIALIZED) { + fun moveTo(state: CommonLifecycle.State) { + require(state != CommonLifecycle.State.INITIALIZED) { "Can't move to INITIALIZED state" } node.updateLifecycleState(state) @@ -25,16 +25,16 @@ open class NodeTestHelper(private val node: N) { /** * moves the Node to the desired state and then returns to the original state if possible */ - fun moveToStateAndCheck(state: PlatformLifecycle.State, block: (N) -> Unit) { - require(state != PlatformLifecycle.State.INITIALIZED) { "Can't move to INITIALIZED state" } + fun moveToStateAndCheck(state: CommonLifecycle.State, block: (N) -> Unit) { + require(state != CommonLifecycle.State.INITIALIZED) { "Can't move to INITIALIZED state" } val returnTo = when (val current = nodeLifecycle.currentState) { - PlatformLifecycle.State.DESTROYED -> error("Can't move from DESTROYED state") - PlatformLifecycle.State.INITIALIZED -> PlatformLifecycle.State.DESTROYED - PlatformLifecycle.State.CREATED, - PlatformLifecycle.State.STARTED, - PlatformLifecycle.State.RESUMED -> current + CommonLifecycle.State.DESTROYED -> error("Can't move from DESTROYED state") + CommonLifecycle.State.INITIALIZED -> CommonLifecycle.State.DESTROYED + CommonLifecycle.State.CREATED, + CommonLifecycle.State.STARTED, + CommonLifecycle.State.RESUMED -> current } moveTo(state) diff --git a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/helper/ParentNodeTestHelper.kt b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/helper/ParentNodeTestHelper.kt index 05c59449b..a4d697aa8 100644 --- a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/helper/ParentNodeTestHelper.kt +++ b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/helper/ParentNodeTestHelper.kt @@ -1,8 +1,8 @@ package com.bumble.appyx.utils.testing.unit.common.helper import com.bumble.appyx.navigation.children.nodeOrNull +import com.bumble.appyx.navigation.lifecycle.CommonLifecycle import com.bumble.appyx.navigation.node.ParentNode -import com.bumble.appyx.navigation.platform.PlatformLifecycle import kotlin.test.assertEquals import kotlin.test.assertNull @@ -17,7 +17,7 @@ class ParentNodeTestHelper assertChildHasLifecycle( interactionTarget: InteractionTarget, - state: PlatformLifecycle.State + state: CommonLifecycle.State ) { val childMap = node.children.value val key = childMap.keys.find { it.interactionTarget == interactionTarget } diff --git a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/InteropBuilderStub.kt b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/InteropBuilderStub.kt index 7a7b8788d..d8c3dfd9b 100644 --- a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/InteropBuilderStub.kt +++ b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/InteropBuilderStub.kt @@ -1,9 +1,9 @@ package com.bumble.appyx.utils.testing.unit.common.util import com.bumble.appyx.navigation.builder.Builder +import com.bumble.appyx.navigation.lifecycle.CommonLifecycle import com.bumble.appyx.navigation.modality.BuildContext import com.bumble.appyx.navigation.node.Node -import com.bumble.appyx.navigation.platform.PlatformLifecycle import kotlin.test.assertEquals import kotlin.test.assertTrue @@ -36,7 +36,7 @@ class InteropBuilderStub

( assertTrue(lastNode != null, "Has not created any node") } - fun assertLastNodeState(state: PlatformLifecycle.State) { + fun assertLastNodeState(state: CommonLifecycle.State) { assertCreatedNode() assertEquals(state, lastNode!!.lifecycle.currentState) } diff --git a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/InteropSimpleBuilderStub.kt b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/InteropSimpleBuilderStub.kt index 46f5583b3..11f652d16 100644 --- a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/InteropSimpleBuilderStub.kt +++ b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/InteropSimpleBuilderStub.kt @@ -1,9 +1,9 @@ package com.bumble.appyx.utils.testing.unit.common.util import com.bumble.appyx.navigation.builder.SimpleBuilder +import com.bumble.appyx.navigation.lifecycle.CommonLifecycle import com.bumble.appyx.navigation.modality.BuildContext import com.bumble.appyx.navigation.node.Node -import com.bumble.appyx.navigation.platform.PlatformLifecycle import kotlin.test.assertEquals import kotlin.test.assertTrue @@ -23,7 +23,7 @@ class InteropSimpleBuilderStub( assertTrue(lastNode != null, "Has not created any node") } - fun assertLastNodeState(state: PlatformLifecycle.State) { + fun assertLastNodeState(state: CommonLifecycle.State) { assertCreatedNode() assertEquals(state, lastNode!!.lifecycle.currentState) } From dd3f250e9dfbac2f917f398470e355d37b2d69f4 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Tue, 23 May 2023 18:27:43 +0100 Subject: [PATCH 28/94] simple desktop and JS PlatformLifecycleRegistry impls --- .../appyx/navigation/platform/PlatformLifecycleRegistry.kt | 6 +++--- .../appyx/navigation/platform/PlatformLifecycleRegistry.kt | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt b/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt index 068c6a9e9..692b4235c 100644 --- a/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt +++ b/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt @@ -80,11 +80,11 @@ actual class PlatformLifecycleRegistry( } actual fun setCurrentState(state: CommonLifecycle.State) { + currentState = state } actual companion object { - actual fun create(owner: CommonLifecycleOwner): PlatformLifecycleRegistry { - TODO("Not yet implemented") - } + actual fun create(owner: CommonLifecycleOwner): PlatformLifecycleRegistry = + PlatformLifecycleRegistry(owner.lifecycleScope) } } diff --git a/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt b/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt index 9e1716fba..944fb11a9 100644 --- a/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt +++ b/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt @@ -79,11 +79,11 @@ actual class PlatformLifecycleRegistry( } actual fun setCurrentState(state: CommonLifecycle.State) { + currentState = state } actual companion object { - actual fun create(owner: CommonLifecycleOwner): PlatformLifecycleRegistry { - TODO("Not yet implemented") - } + actual fun create(owner: CommonLifecycleOwner): PlatformLifecycleRegistry = + PlatformLifecycleRegistry(owner.lifecycleScope) } } \ No newline at end of file From c3fed1910979b91215ab858ac837400fe68ebe16 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Wed, 24 May 2023 13:29:59 +0100 Subject: [PATCH 29/94] added necessary OnBackPressedCallback interface for BackPressHandler interface to compile --- .../kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt index 6bfde3339..e0392ee84 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt @@ -3,7 +3,7 @@ package com.bumble.appyx.navigation.plugin import com.bumble.appyx.interactions.core.plugin.Plugin import com.bumble.appyx.navigation.lifecycle.CommonLifecycle import com.bumble.appyx.navigation.node.Node -import com.bumble.appyx.navigation.platform.OnBackPressedCallback +import com.bumble.appyx.navigation.plugin.BackPressHandler.OnBackPressedCallback inline fun Node.plugins(): List

= this.plugins.filterIsInstance

() @@ -49,4 +49,9 @@ interface BackPressHandler : Plugin { if (isEnabled) callback.handleOnBackPressed() isEnabled } + + interface OnBackPressedCallback { + val isEnabled: Boolean + fun handleOnBackPressed() + } } From a9f85e2b9b709e5805abcb5ae6dfa5325d33387e Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Thu, 25 May 2023 11:48:17 +0100 Subject: [PATCH 30/94] moved AppyxLogger into multiplatform utils --- .../demos/cards/ui/CardsMotionController.kt | 2 +- .../internal/testdrive/TestDriveExperiment.kt | 2 +- .../testdrive/ui/TestDriveMotionController.kt | 4 ++-- .../components/spotlight/utils/SpotlightUtils.kt | 4 ++-- .../core/model/BaseInteractionModel.kt | 2 +- .../model/progress/AnimatedProgressController.kt | 2 +- .../model/progress/DragProgressController.kt | 2 +- .../core/model/transition/BaseTransitionModel.kt | 2 +- .../core/model/transition/Keyframes.kt | 2 +- .../core/ui/property/MotionProperty.kt | 2 +- .../transitionmodel/BaseMotionController.kt | 2 +- .../navigation/lifecycle/LifecycleLogger.kt | 15 +++++++-------- .../appyx/interactions/sample/KnobControl.kt | 2 +- .../interactions/sample/SpotlightExperiment.kt | 2 +- .../appyx/navigation/composable/KnobControl.kt | 2 +- utils/multiplatform/build.gradle.kts | 6 +++++- .../appyx/utils/multiplatform}/AppyxLogger.kt | 14 +++++++------- .../bumble/appyx/utils/multiplatform/Logger.kt | 9 --------- .../appyx/utils/multiplatform}/AppyxLogger.kt | 2 +- .../bumble/appyx/utils/multiplatform/Logger.kt | 5 ----- .../appyx/utils/multiplatform}/AppyxLogger.kt | 16 ++++++++-------- .../bumble/appyx/utils/multiplatform/Logger.kt | 7 ------- .../appyx/utils/multiplatform}/AppyxLogger.kt | 16 ++++++++-------- .../bumble/appyx/utils/multiplatform/Logger.kt | 7 ------- 24 files changed, 52 insertions(+), 77 deletions(-) rename {appyx-interactions/common/src/androidMain/kotlin/com/bumble/appyx/interactions => utils/multiplatform/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform}/AppyxLogger.kt (65%) delete mode 100644 utils/multiplatform/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt rename {appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions => utils/multiplatform/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform}/AppyxLogger.kt (90%) delete mode 100644 utils/multiplatform/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt rename {appyx-interactions/common/src/desktopMain/kotlin/com/bumble/appyx/interactions => utils/multiplatform/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform}/AppyxLogger.kt (63%) delete mode 100644 utils/multiplatform/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt rename {appyx-interactions/common/src/jsMain/kotlin/com/bumble/appyx/interactions => utils/multiplatform/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform}/AppyxLogger.kt (63%) delete mode 100644 utils/multiplatform/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt diff --git a/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/ui/CardsMotionController.kt b/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/ui/CardsMotionController.kt index 4ad7466b1..98fbec128 100644 --- a/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/ui/CardsMotionController.kt +++ b/appyx-components/demos/common/src/commonMain/kotlin/com/bumble/appyx/components/demos/cards/ui/CardsMotionController.kt @@ -10,7 +10,6 @@ import com.bumble.appyx.components.demos.cards.CardsModel import com.bumble.appyx.components.demos.cards.CardsModel.State.Card.InvisibleCard.VotedCard.VOTED_CARD_STATE.LIKED import com.bumble.appyx.components.demos.cards.operation.VoteLike import com.bumble.appyx.components.demos.cards.operation.VotePass -import com.bumble.appyx.interactions.AppyxLogger import com.bumble.appyx.interactions.core.model.transition.Operation import com.bumble.appyx.interactions.core.ui.context.TransitionBounds import com.bumble.appyx.interactions.core.ui.context.UiContext @@ -22,6 +21,7 @@ import com.bumble.appyx.interactions.core.ui.property.impl.Scale import com.bumble.appyx.interactions.core.ui.property.impl.ZIndex import com.bumble.appyx.interactions.core.ui.state.MatchedTargetUiState import com.bumble.appyx.transitionmodel.BaseMotionController +import com.bumble.appyx.utils.multiplatform.AppyxLogger class CardsMotionController( uiContext: UiContext, diff --git a/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/TestDriveExperiment.kt b/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/TestDriveExperiment.kt index b6af0bd3c..1e360649a 100644 --- a/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/TestDriveExperiment.kt +++ b/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/TestDriveExperiment.kt @@ -31,13 +31,13 @@ import androidx.compose.ui.unit.sp import com.bumble.appyx.components.internal.testdrive.operation.next import com.bumble.appyx.components.internal.testdrive.ui.TestDriveMotionController import com.bumble.appyx.components.internal.testdrive.ui.TestDriveMotionController.Companion.toTargetUiState -import com.bumble.appyx.interactions.AppyxLogger import com.bumble.appyx.interactions.core.model.transition.Keyframes import com.bumble.appyx.interactions.core.model.transition.Operation.Mode.IMMEDIATE import com.bumble.appyx.interactions.core.model.transition.Operation.Mode.KEYFRAME import com.bumble.appyx.interactions.core.model.transition.Update import com.bumble.appyx.interactions.core.ui.helper.InteractionModelSetup import com.bumble.appyx.interactions.sample.Children +import com.bumble.appyx.utils.multiplatform.AppyxLogger @Composable diff --git a/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/ui/TestDriveMotionController.kt b/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/ui/TestDriveMotionController.kt index 30ea8de92..621c656a2 100644 --- a/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/ui/TestDriveMotionController.kt +++ b/appyx-components/internal/common/src/commonMain/kotlin/com/bumble/appyx/components/internal/testdrive/ui/TestDriveMotionController.kt @@ -5,14 +5,13 @@ import androidx.compose.animation.core.SpringSpec import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.DpOffset import androidx.compose.ui.unit.dp +import com.bumble.appyx.components.demos.testdrive.ui.TargetUiState import com.bumble.appyx.components.internal.testdrive.TestDriveModel import com.bumble.appyx.components.internal.testdrive.TestDriveModel.State.ElementState.A import com.bumble.appyx.components.internal.testdrive.TestDriveModel.State.ElementState.B import com.bumble.appyx.components.internal.testdrive.TestDriveModel.State.ElementState.C import com.bumble.appyx.components.internal.testdrive.TestDriveModel.State.ElementState.D import com.bumble.appyx.components.internal.testdrive.operation.MoveTo -import com.bumble.appyx.components.demos.testdrive.ui.TargetUiState -import com.bumble.appyx.interactions.AppyxLogger import com.bumble.appyx.interactions.core.ui.context.TransitionBounds import com.bumble.appyx.interactions.core.ui.context.UiContext import com.bumble.appyx.interactions.core.ui.gesture.Gesture @@ -25,6 +24,7 @@ import com.bumble.appyx.transitionmodel.testdrive.ui.md_light_blue_500 import com.bumble.appyx.transitionmodel.testdrive.ui.md_light_green_500 import com.bumble.appyx.transitionmodel.testdrive.ui.md_red_500 import com.bumble.appyx.transitionmodel.testdrive.ui.md_yellow_500 +import com.bumble.appyx.utils.multiplatform.AppyxLogger import kotlin.math.abs class TestDriveMotionController( diff --git a/appyx-components/spotlight/android/src/androidTest/kotlin/com/bumble/appyx/components/spotlight/utils/SpotlightUtils.kt b/appyx-components/spotlight/android/src/androidTest/kotlin/com/bumble/appyx/components/spotlight/utils/SpotlightUtils.kt index 065af2392..cd96509cf 100644 --- a/appyx-components/spotlight/android/src/androidTest/kotlin/com/bumble/appyx/components/spotlight/utils/SpotlightUtils.kt +++ b/appyx-components/spotlight/android/src/androidTest/kotlin/com/bumble/appyx/components/spotlight/utils/SpotlightUtils.kt @@ -17,12 +17,12 @@ import androidx.compose.ui.unit.dp import com.bumble.appyx.components.spotlight.Spotlight import com.bumble.appyx.components.spotlight.SpotlightModel import com.bumble.appyx.components.spotlight.ui.slider.SpotlightSlider -import com.bumble.appyx.interactions.AppyxLogger import com.bumble.appyx.interactions.core.ui.helper.InteractionModelSetup +import com.bumble.appyx.interactions.sample.InteractionTarget import com.bumble.appyx.interactions.sample.android.Children import com.bumble.appyx.interactions.sample.android.Element -import com.bumble.appyx.interactions.sample.InteractionTarget import com.bumble.appyx.interactions.theme.appyx_dark +import com.bumble.appyx.utils.multiplatform.AppyxLogger import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/BaseInteractionModel.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/BaseInteractionModel.kt index 980ddad89..f3d4458fa 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/BaseInteractionModel.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/BaseInteractionModel.kt @@ -6,7 +6,6 @@ import androidx.compose.animation.core.AnimationSpec import androidx.compose.animation.core.SpringSpec import androidx.compose.ui.geometry.Offset import androidx.compose.ui.unit.Density -import com.bumble.appyx.interactions.AppyxLogger import com.bumble.appyx.interactions.core.Element import com.bumble.appyx.interactions.core.model.backpresshandlerstrategies.BackPressHandlerStrategy import com.bumble.appyx.interactions.core.model.backpresshandlerstrategies.DontHandleBackPress @@ -27,6 +26,7 @@ import com.bumble.appyx.interactions.core.ui.context.UiContextAware import com.bumble.appyx.interactions.core.ui.context.zeroSizeTransitionBounds import com.bumble.appyx.interactions.core.ui.gesture.GestureFactory import com.bumble.appyx.interactions.core.ui.output.ElementUiModel +import com.bumble.appyx.utils.multiplatform.AppyxLogger import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/progress/AnimatedProgressController.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/progress/AnimatedProgressController.kt index a4ee28550..f35bdd8ee 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/progress/AnimatedProgressController.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/progress/AnimatedProgressController.kt @@ -3,12 +3,12 @@ package com.bumble.appyx.interactions.core.model.progress import androidx.compose.animation.core.Animatable import androidx.compose.animation.core.AnimationSpec import androidx.compose.animation.core.spring -import com.bumble.appyx.interactions.AppyxLogger import com.bumble.appyx.interactions.core.model.transition.Keyframes import com.bumble.appyx.interactions.core.model.transition.Operation import com.bumble.appyx.interactions.core.model.transition.TransitionModel import com.bumble.appyx.interactions.core.model.transition.TransitionModel.SettleDirection.COMPLETE import com.bumble.appyx.interactions.core.model.transition.TransitionModel.SettleDirection.REVERT +import com.bumble.appyx.utils.multiplatform.AppyxLogger import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/progress/DragProgressController.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/progress/DragProgressController.kt index 533f29151..9ded3cb27 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/progress/DragProgressController.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/progress/DragProgressController.kt @@ -3,13 +3,13 @@ package com.bumble.appyx.interactions.core.model.progress import androidx.compose.animation.core.AnimationSpec import androidx.compose.ui.geometry.Offset import androidx.compose.ui.unit.Density -import com.bumble.appyx.interactions.AppyxLogger import com.bumble.appyx.interactions.core.model.transition.Keyframes import com.bumble.appyx.interactions.core.model.transition.TransitionModel import com.bumble.appyx.interactions.core.model.transition.TransitionModel.SettleDirection.COMPLETE import com.bumble.appyx.interactions.core.model.transition.TransitionModel.SettleDirection.REVERT import com.bumble.appyx.interactions.core.ui.gesture.Gesture import com.bumble.appyx.interactions.core.ui.gesture.GestureFactory +import com.bumble.appyx.utils.multiplatform.AppyxLogger class DragProgressController( private val model: TransitionModel, diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/transition/BaseTransitionModel.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/transition/BaseTransitionModel.kt index 319abb9be..8ed5815ea 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/transition/BaseTransitionModel.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/transition/BaseTransitionModel.kt @@ -1,6 +1,5 @@ package com.bumble.appyx.interactions.core.model.transition -import com.bumble.appyx.interactions.AppyxLogger import com.bumble.appyx.interactions.core.Element import com.bumble.appyx.interactions.core.model.transition.Operation.Mode.GEOMETRY import com.bumble.appyx.interactions.core.model.transition.Operation.Mode.IMMEDIATE @@ -9,6 +8,7 @@ import com.bumble.appyx.interactions.core.model.transition.TransitionModel.Outpu import com.bumble.appyx.interactions.core.model.transition.TransitionModel.SettleDirection import com.bumble.appyx.interactions.core.state.MutableSavedStateMap import com.bumble.appyx.interactions.core.state.SavedStateMap +import com.bumble.appyx.utils.multiplatform.AppyxLogger import com.bumble.appyx.utils.multiplatform.Parcelable import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/transition/Keyframes.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/transition/Keyframes.kt index 482d8cd93..094bd80e6 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/transition/Keyframes.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/model/transition/Keyframes.kt @@ -1,6 +1,6 @@ package com.bumble.appyx.interactions.core.model.transition -import com.bumble.appyx.interactions.AppyxLogger +import com.bumble.appyx.utils.multiplatform.AppyxLogger import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.distinctUntilChanged diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/ui/property/MotionProperty.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/ui/property/MotionProperty.kt index 86a7f2b52..43c9ad207 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/ui/property/MotionProperty.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/core/ui/property/MotionProperty.kt @@ -12,10 +12,10 @@ import androidx.compose.animation.core.LinearEasing import androidx.compose.animation.core.SpringSpec import androidx.compose.animation.core.spring import androidx.compose.ui.Modifier -import com.bumble.appyx.interactions.AppyxLogger import com.bumble.appyx.interactions.SystemClock import com.bumble.appyx.interactions.core.ui.context.UiContext import com.bumble.appyx.mapState +import com.bumble.appyx.utils.multiplatform.AppyxLogger import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.update diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/transitionmodel/BaseMotionController.kt b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/transitionmodel/BaseMotionController.kt index 62639c968..56777b3cf 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/transitionmodel/BaseMotionController.kt +++ b/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/transitionmodel/BaseMotionController.kt @@ -9,7 +9,6 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import com.bumble.appyx.combineState -import com.bumble.appyx.interactions.AppyxLogger import com.bumble.appyx.interactions.core.Element import com.bumble.appyx.interactions.core.model.transition.Segment import com.bumble.appyx.interactions.core.model.transition.Update @@ -20,6 +19,7 @@ import com.bumble.appyx.interactions.core.ui.output.ElementUiModel import com.bumble.appyx.interactions.core.ui.property.MotionProperty import com.bumble.appyx.interactions.core.ui.state.BaseMutableUiState import com.bumble.appyx.interactions.core.ui.state.MatchedTargetUiState +import com.bumble.appyx.utils.multiplatform.AppyxLogger import com.bumble.appyx.withPrevious import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt index 988159d9e..87da606c6 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/LifecycleLogger.kt @@ -1,34 +1,33 @@ package com.bumble.appyx.navigation.lifecycle import com.bumble.appyx.navigation.node.Node -import com.bumble.appyx.utils.multiplatform.Logger +import com.bumble.appyx.utils.multiplatform.AppyxLogger internal class LifecycleLogger(private val node: Node) : DefaultPlatformLifecycleObserver { - private val logger = Logger() override fun onCreate() { - logger.d(LOG_TAG, "${node::class.simpleName}@${node.hashCode()} onCreate") + AppyxLogger.d(LOG_TAG, "${node::class.simpleName}@${node.hashCode()} onCreate") } override fun onStart() { - logger.d(LOG_TAG, "${node::class.simpleName}@${node.hashCode()} onStart") + AppyxLogger.d(LOG_TAG, "${node::class.simpleName}@${node.hashCode()} onStart") } override fun onResume() { - logger.d(LOG_TAG, "${node::class.simpleName}@${node.hashCode()} onResume") + AppyxLogger.d(LOG_TAG, "${node::class.simpleName}@${node.hashCode()} onResume") } override fun onPause() { - logger.d(LOG_TAG, "${node::class.simpleName}@${node.hashCode()} onPause") + AppyxLogger.d(LOG_TAG, "${node::class.simpleName}@${node.hashCode()} onPause") } override fun onStop() { - logger.d(LOG_TAG, "${node::class.simpleName}@${node.hashCode()} onStop") + AppyxLogger.d(LOG_TAG, "${node::class.simpleName}@${node.hashCode()} onStop") } override fun onDestroy() { - logger.d(LOG_TAG, "${node::class.simpleName}@${node.hashCode()} onDestroy") + AppyxLogger.d(LOG_TAG, "${node::class.simpleName}@${node.hashCode()} onDestroy") } companion object { diff --git a/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/KnobControl.kt b/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/KnobControl.kt index 1eda09d4f..5cb4055bd 100644 --- a/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/KnobControl.kt +++ b/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/KnobControl.kt @@ -27,8 +27,8 @@ import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.IntSize import androidx.compose.ui.unit.dp -import com.bumble.appyx.interactions.AppyxLogger import com.bumble.appyx.interactions.theme.appyx_yellow1 +import com.bumble.appyx.utils.multiplatform.AppyxLogger import kotlin.math.roundToInt diff --git a/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/SpotlightExperiment.kt b/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/SpotlightExperiment.kt index 39d969aef..b57260b08 100644 --- a/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/SpotlightExperiment.kt +++ b/demos/appyx-interactions/android/src/main/kotlin/com/bumble/appyx/interactions/sample/SpotlightExperiment.kt @@ -26,11 +26,11 @@ import com.bumble.appyx.components.spotlight.operation.next import com.bumble.appyx.components.spotlight.operation.previous import com.bumble.appyx.components.spotlight.operation.updateElements import com.bumble.appyx.components.spotlight.ui.slider.SpotlightSlider -import com.bumble.appyx.interactions.AppyxLogger import com.bumble.appyx.interactions.core.ui.helper.InteractionModelSetup import com.bumble.appyx.interactions.sample.android.Children import com.bumble.appyx.interactions.sample.android.Element import com.bumble.appyx.interactions.theme.appyx_dark +import com.bumble.appyx.utils.multiplatform.AppyxLogger @ExperimentalMaterialApi @Composable diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/composable/KnobControl.kt b/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/composable/KnobControl.kt index 2a1db9962..eebb1b4bf 100644 --- a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/composable/KnobControl.kt +++ b/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/composable/KnobControl.kt @@ -27,8 +27,8 @@ import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.IntSize import androidx.compose.ui.unit.dp -import com.bumble.appyx.interactions.AppyxLogger import com.bumble.appyx.navigation.ui.appyx_yellow1 +import com.bumble.appyx.utils.multiplatform.AppyxLogger import kotlin.math.roundToInt @ExperimentalMaterialApi diff --git a/utils/multiplatform/build.gradle.kts b/utils/multiplatform/build.gradle.kts index aa56778d4..d9cf58e09 100644 --- a/utils/multiplatform/build.gradle.kts +++ b/utils/multiplatform/build.gradle.kts @@ -26,7 +26,11 @@ kotlin { implementation(libs.kotlinx.serialization.json) } } - val androidMain by getting + val androidMain by getting { + dependencies { + api(libs.androidx.appcompat) + } + } val desktopMain by getting val jsMain by getting } diff --git a/appyx-interactions/common/src/androidMain/kotlin/com/bumble/appyx/interactions/AppyxLogger.kt b/utils/multiplatform/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform/AppyxLogger.kt similarity index 65% rename from appyx-interactions/common/src/androidMain/kotlin/com/bumble/appyx/interactions/AppyxLogger.kt rename to utils/multiplatform/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform/AppyxLogger.kt index 891c8047f..b40cbbab8 100644 --- a/appyx-interactions/common/src/androidMain/kotlin/com/bumble/appyx/interactions/AppyxLogger.kt +++ b/utils/multiplatform/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform/AppyxLogger.kt @@ -1,13 +1,13 @@ -package com.bumble.appyx.interactions +package com.bumble.appyx.utils.multiplatform import android.util.Log import androidx.annotation.IntRange -import com.bumble.appyx.interactions.AppyxLoggingLevel.DEBUG -import com.bumble.appyx.interactions.AppyxLoggingLevel.DISABLED -import com.bumble.appyx.interactions.AppyxLoggingLevel.ERROR -import com.bumble.appyx.interactions.AppyxLoggingLevel.INFO -import com.bumble.appyx.interactions.AppyxLoggingLevel.VERBOSE -import com.bumble.appyx.interactions.AppyxLoggingLevel.WARN +import com.bumble.appyx.utils.multiplatform.AppyxLoggingLevel.DEBUG +import com.bumble.appyx.utils.multiplatform.AppyxLoggingLevel.DISABLED +import com.bumble.appyx.utils.multiplatform.AppyxLoggingLevel.ERROR +import com.bumble.appyx.utils.multiplatform.AppyxLoggingLevel.INFO +import com.bumble.appyx.utils.multiplatform.AppyxLoggingLevel.VERBOSE +import com.bumble.appyx.utils.multiplatform.AppyxLoggingLevel.WARN actual object AppyxLogger { diff --git a/utils/multiplatform/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt b/utils/multiplatform/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt deleted file mode 100644 index 6919bfbcc..000000000 --- a/utils/multiplatform/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.bumble.appyx.utils.multiplatform - -import android.util.Log - -actual class Logger { - actual fun d(tag: String, message: String) { - Log.d(tag, message) - } -} diff --git a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/AppyxLogger.kt b/utils/multiplatform/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform/AppyxLogger.kt similarity index 90% rename from appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/AppyxLogger.kt rename to utils/multiplatform/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform/AppyxLogger.kt index f88bd2a70..60cf2292c 100644 --- a/appyx-interactions/common/src/commonMain/kotlin/com/bumble/appyx/interactions/AppyxLogger.kt +++ b/utils/multiplatform/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform/AppyxLogger.kt @@ -1,4 +1,4 @@ -package com.bumble.appyx.interactions +package com.bumble.appyx.utils.multiplatform object AppyxLoggingLevel { diff --git a/utils/multiplatform/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt b/utils/multiplatform/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt deleted file mode 100644 index 441b9c36e..000000000 --- a/utils/multiplatform/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.bumble.appyx.utils.multiplatform - -expect class Logger() { - fun d(tag: String, message: String) -} diff --git a/appyx-interactions/common/src/desktopMain/kotlin/com/bumble/appyx/interactions/AppyxLogger.kt b/utils/multiplatform/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform/AppyxLogger.kt similarity index 63% rename from appyx-interactions/common/src/desktopMain/kotlin/com/bumble/appyx/interactions/AppyxLogger.kt rename to utils/multiplatform/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform/AppyxLogger.kt index 32d51f954..1e91f9fc7 100644 --- a/appyx-interactions/common/src/desktopMain/kotlin/com/bumble/appyx/interactions/AppyxLogger.kt +++ b/utils/multiplatform/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform/AppyxLogger.kt @@ -1,11 +1,11 @@ -package com.bumble.appyx.interactions - -import com.bumble.appyx.interactions.AppyxLoggingLevel.DEBUG -import com.bumble.appyx.interactions.AppyxLoggingLevel.DISABLED -import com.bumble.appyx.interactions.AppyxLoggingLevel.ERROR -import com.bumble.appyx.interactions.AppyxLoggingLevel.INFO -import com.bumble.appyx.interactions.AppyxLoggingLevel.VERBOSE -import com.bumble.appyx.interactions.AppyxLoggingLevel.WARN +package com.bumble.appyx.utils.multiplatform + +import com.bumble.appyx.utils.multiplatform.AppyxLoggingLevel.DEBUG +import com.bumble.appyx.utils.multiplatform.AppyxLoggingLevel.DISABLED +import com.bumble.appyx.utils.multiplatform.AppyxLoggingLevel.ERROR +import com.bumble.appyx.utils.multiplatform.AppyxLoggingLevel.INFO +import com.bumble.appyx.utils.multiplatform.AppyxLoggingLevel.VERBOSE +import com.bumble.appyx.utils.multiplatform.AppyxLoggingLevel.WARN actual object AppyxLogger { diff --git a/utils/multiplatform/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt b/utils/multiplatform/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt deleted file mode 100644 index 40b90ed2b..000000000 --- a/utils/multiplatform/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.bumble.appyx.utils.multiplatform - -actual class Logger { - actual fun d(tag: String, message: String) { - println("$tag: $message") - } -} diff --git a/appyx-interactions/common/src/jsMain/kotlin/com/bumble/appyx/interactions/AppyxLogger.kt b/utils/multiplatform/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform/AppyxLogger.kt similarity index 63% rename from appyx-interactions/common/src/jsMain/kotlin/com/bumble/appyx/interactions/AppyxLogger.kt rename to utils/multiplatform/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform/AppyxLogger.kt index 61e7c3a72..614d3f47a 100644 --- a/appyx-interactions/common/src/jsMain/kotlin/com/bumble/appyx/interactions/AppyxLogger.kt +++ b/utils/multiplatform/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform/AppyxLogger.kt @@ -1,11 +1,11 @@ -package com.bumble.appyx.interactions - -import com.bumble.appyx.interactions.AppyxLoggingLevel.DEBUG -import com.bumble.appyx.interactions.AppyxLoggingLevel.DISABLED -import com.bumble.appyx.interactions.AppyxLoggingLevel.ERROR -import com.bumble.appyx.interactions.AppyxLoggingLevel.INFO -import com.bumble.appyx.interactions.AppyxLoggingLevel.VERBOSE -import com.bumble.appyx.interactions.AppyxLoggingLevel.WARN +package com.bumble.appyx.utils.multiplatform + +import com.bumble.appyx.utils.multiplatform.AppyxLoggingLevel.DEBUG +import com.bumble.appyx.utils.multiplatform.AppyxLoggingLevel.DISABLED +import com.bumble.appyx.utils.multiplatform.AppyxLoggingLevel.ERROR +import com.bumble.appyx.utils.multiplatform.AppyxLoggingLevel.INFO +import com.bumble.appyx.utils.multiplatform.AppyxLoggingLevel.VERBOSE +import com.bumble.appyx.utils.multiplatform.AppyxLoggingLevel.WARN actual object AppyxLogger { diff --git a/utils/multiplatform/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt b/utils/multiplatform/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt deleted file mode 100644 index 40b90ed2b..000000000 --- a/utils/multiplatform/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform/Logger.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.bumble.appyx.utils.multiplatform - -actual class Logger { - actual fun d(tag: String, message: String) { - println("$tag: $message") - } -} From fd7264d1948f863d8e38cdac89392014560b5d40 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Thu, 25 May 2023 12:12:36 +0100 Subject: [PATCH 31/94] implemented simple common BuildFlags object to handle configuration debug flag --- .../kotlin/com/bumble/appyx/navigation/node/Node.kt | 9 +++++---- .../com/bumble/appyx/utils/multiplatform/BuildFlags.kt | 5 +++++ .../com/bumble/appyx/utils/multiplatform/BuildFlags.kt | 5 +++++ .../com/bumble/appyx/utils/multiplatform/BuildFlags.kt | 5 +++++ .../com/bumble/appyx/utils/multiplatform/BuildFlags.kt | 5 +++++ 5 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 utils/multiplatform/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform/BuildFlags.kt create mode 100644 utils/multiplatform/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform/BuildFlags.kt create mode 100644 utils/multiplatform/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform/BuildFlags.kt create mode 100644 utils/multiplatform/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform/BuildFlags.kt diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt index 721a4c2ec..439fc5990 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt @@ -14,6 +14,7 @@ import com.bumble.appyx.navigation.integrationpoint.IntegrationPoint import com.bumble.appyx.navigation.integrationpoint.IntegrationPointStub import com.bumble.appyx.navigation.lifecycle.CommonLifecycle import com.bumble.appyx.navigation.lifecycle.DefaultPlatformLifecycleObserver +import com.bumble.appyx.navigation.lifecycle.LifecycleLogger import com.bumble.appyx.navigation.lifecycle.NodeLifecycle import com.bumble.appyx.navigation.lifecycle.NodeLifecycleImpl import com.bumble.appyx.navigation.modality.AncestryInfo @@ -25,6 +26,7 @@ import com.bumble.appyx.navigation.plugin.UpNavigationHandler import com.bumble.appyx.navigation.plugin.plugins import com.bumble.appyx.navigation.state.SavedStateMap import com.bumble.appyx.navigation.store.RetainedInstanceStore +import com.bumble.appyx.utils.multiplatform.BuildFlags import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.withContext @@ -82,10 +84,9 @@ open class Node internal constructor( private var wasBuilt = false init { - // TODO: expose debug flag -// if (BuildConfig.DEBUG) { -// lifecycle.addObserver(LifecycleLogger(this)) -// } + if (BuildFlags.DEBUG) { + lifecycle.addObserver(LifecycleLogger(this)) + } lifecycle.addObserver(object : DefaultPlatformLifecycleObserver { override fun onCreate() { if (!wasBuilt) error("onBuilt was not invoked for $this") diff --git a/utils/multiplatform/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform/BuildFlags.kt b/utils/multiplatform/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform/BuildFlags.kt new file mode 100644 index 000000000..06edfc660 --- /dev/null +++ b/utils/multiplatform/src/androidMain/kotlin/com/bumble/appyx/utils/multiplatform/BuildFlags.kt @@ -0,0 +1,5 @@ +package com.bumble.appyx.utils.multiplatform + +actual object BuildFlags { + actual val DEBUG: Boolean = BuildConfig.DEBUG +} diff --git a/utils/multiplatform/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform/BuildFlags.kt b/utils/multiplatform/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform/BuildFlags.kt new file mode 100644 index 000000000..18e86edfe --- /dev/null +++ b/utils/multiplatform/src/commonMain/kotlin/com/bumble/appyx/utils/multiplatform/BuildFlags.kt @@ -0,0 +1,5 @@ +package com.bumble.appyx.utils.multiplatform + +expect object BuildFlags { + val DEBUG: Boolean +} diff --git a/utils/multiplatform/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform/BuildFlags.kt b/utils/multiplatform/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform/BuildFlags.kt new file mode 100644 index 000000000..38a3021a8 --- /dev/null +++ b/utils/multiplatform/src/desktopMain/kotlin/com/bumble/appyx/utils/multiplatform/BuildFlags.kt @@ -0,0 +1,5 @@ +package com.bumble.appyx.utils.multiplatform + +actual object BuildFlags { + actual val DEBUG: Boolean = false // TODO: provide value from gradle +} diff --git a/utils/multiplatform/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform/BuildFlags.kt b/utils/multiplatform/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform/BuildFlags.kt new file mode 100644 index 000000000..38a3021a8 --- /dev/null +++ b/utils/multiplatform/src/jsMain/kotlin/com/bumble/appyx/utils/multiplatform/BuildFlags.kt @@ -0,0 +1,5 @@ +package com.bumble.appyx.utils.multiplatform + +actual object BuildFlags { + actual val DEBUG: Boolean = false // TODO: provide value from gradle +} From a4e8b2c62cfbae90deeab538e05c59415d89a319 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Tue, 6 Jun 2023 14:52:33 +0100 Subject: [PATCH 32/94] fixed crash by maintaining strong reference to wrapping LifecycleOwner in PlatformLifecycleRegistry that is released if the LifecycleOwner activity finishes --- .../platform/PlatformLifecycleRegistry.kt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt index ad38f7276..f4fee2c45 100644 --- a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt +++ b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt @@ -1,5 +1,6 @@ package com.bumble.appyx.navigation.platform +import android.app.Activity import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LifecycleRegistry @@ -12,10 +13,13 @@ import com.bumble.appyx.navigation.lifecycle.PlatformLifecycleObserver import kotlinx.coroutines.CoroutineScope actual class PlatformLifecycleRegistry( - val androidLifecycleRegistry: LifecycleRegistry + androidOwner: LifecycleOwner ) : CommonLifecycle, androidx.lifecycle.DefaultLifecycleObserver, androidx.lifecycle.LifecycleEventObserver { + private var lifecycleOwner: LifecycleOwner? = androidOwner + private val androidLifecycleRegistry = LifecycleRegistry(androidOwner) + private val managedDefaultLifecycleObservers: MutableList = ArrayList() private val managedLifecycleEventObservers: MutableList = @@ -79,11 +83,14 @@ actual class PlatformLifecycleRegistry( override fun onDestroy(owner: LifecycleOwner) { managedDefaultLifecycleObservers.forEach { it.onDestroy() } + if ((owner as? Activity)?.isFinishing == true) { + lifecycleOwner = null + } } actual companion object { actual fun create(owner: CommonLifecycleOwner): PlatformLifecycleRegistry = - PlatformLifecycleRegistry(LifecycleRegistry(object : LifecycleOwner { + PlatformLifecycleRegistry(object : LifecycleOwner { override val lifecycle: Lifecycle get() = when (val platformLifecycle = owner.lifecycle) { is AndroidLifecycle -> platformLifecycle.androidLifecycle @@ -92,6 +99,6 @@ actual class PlatformLifecycleRegistry( "Unable to get android lifecycle from $platformLifecycle provided by $owner" )) } - })) + }) } } From 82cf6fe00abec8e11577ac068fea28dab149472f Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Tue, 6 Jun 2023 16:46:07 +0100 Subject: [PATCH 33/94] added lint baseline --- appyx-navigation/android/lint-baseline.xml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 appyx-navigation/android/lint-baseline.xml diff --git a/appyx-navigation/android/lint-baseline.xml b/appyx-navigation/android/lint-baseline.xml new file mode 100644 index 000000000..ab8becf45 --- /dev/null +++ b/appyx-navigation/android/lint-baseline.xml @@ -0,0 +1,5 @@ + + + + From 479b54d1e05bebeb5ad81ef3472fa0fa82c63e11 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Wed, 7 Jun 2023 11:08:38 +0100 Subject: [PATCH 34/94] fixed nav unit test --- .../bumble/appyx/navigation/store/RetainedInstanceStoreTest.kt | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename appyx-navigation/{android/src/test => common/src/commonTest}/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreTest.kt (100%) diff --git a/appyx-navigation/android/src/test/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreTest.kt b/appyx-navigation/common/src/commonTest/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreTest.kt similarity index 100% rename from appyx-navigation/android/src/test/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreTest.kt rename to appyx-navigation/common/src/commonTest/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreTest.kt From 979ca63c0bde3031456b41da7d7d7868c0206bee Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Wed, 7 Jun 2023 13:48:47 +0100 Subject: [PATCH 35/94] removed unused dependency from testing-ui-activity --- utils/testing-ui-activity/build.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/utils/testing-ui-activity/build.gradle.kts b/utils/testing-ui-activity/build.gradle.kts index b71a15491..fe2db83bc 100644 --- a/utils/testing-ui-activity/build.gradle.kts +++ b/utils/testing-ui-activity/build.gradle.kts @@ -27,7 +27,6 @@ android { } dependencies { - api(project(":appyx-navigation:common")) implementation(libs.androidx.activity.compose) api(project(":appyx-navigation:android")) } From 4bd53517703041fd3cb68fa2a829940bc4a7104e Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Wed, 7 Jun 2023 14:49:21 +0100 Subject: [PATCH 36/94] refactored customisations module to be multiplatform friendly NOTE: JS implementation is now a no-op situation --- utils/customisations/build.gradle.kts | 19 ++++++- .../NodeCustomisationDirectoryImpl.kt | 52 +++++++++++++++++++ .../NodeCustomisationDirectoryImpl.kt | 51 +----------------- .../NodeCustomisationDirectoryImpl.kt | 52 +++++++++++++++++++ .../NodeCustomisationDirectoryImpl.kt | 33 ++++++++++++ 5 files changed, 156 insertions(+), 51 deletions(-) create mode 100644 utils/customisations/src/androidMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt create mode 100644 utils/customisations/src/desktopMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt create mode 100644 utils/customisations/src/jsMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt diff --git a/utils/customisations/build.gradle.kts b/utils/customisations/build.gradle.kts index e1a802079..11eaf1c2f 100644 --- a/utils/customisations/build.gradle.kts +++ b/utils/customisations/build.gradle.kts @@ -1,5 +1,6 @@ plugins { kotlin("multiplatform") + id("com.android.library") id("appyx-publish-multiplatform") id("appyx-detekt") } @@ -9,7 +10,10 @@ publishingPlugin { } kotlin { - jvm { + android { + publishLibraryVariants("release") + } + jvm("desktop") { compilations.all { kotlinOptions.jvmTarget = libs.versions.jvmTarget.get() } @@ -21,5 +25,18 @@ kotlin { } sourceSets { val commonMain by getting + val androidMain by getting + val desktopMain by getting + val jsMain by getting + } +} + +android { + namespace = "com.bumble.appyx.utils.multiplatform" + compileSdk = libs.versions.androidCompileSdk.get().toInt() + sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") + defaultConfig { + minSdk = libs.versions.androidMinSdk.get().toInt() + targetSdk = libs.versions.androidTargetSdk.get().toInt() } } diff --git a/utils/customisations/src/androidMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt b/utils/customisations/src/androidMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt new file mode 100644 index 000000000..9276c9490 --- /dev/null +++ b/utils/customisations/src/androidMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt @@ -0,0 +1,52 @@ +package com.bumble.appyx.utils.customisations + +import kotlin.reflect.KClass + +actual open class NodeCustomisationDirectoryImpl( + override val parent: NodeCustomisationDirectory? = null +) : MutableNodeCustomisationDirectory { + + private val map: MutableMap = hashMapOf() + + override fun put(key: KClass, value: T) { + map[key] = value + } + + fun put(vararg values: T) { + values.forEach { + map[it::class] = it + } + } + + inline operator fun T.unaryPlus() { + put(this) + } + + override fun get(key: KClass): T? = + map[key] as? T + + override fun getRecursively(key: KClass): T? = + get(key) ?: parent?.get(key) + + override fun putSubDirectory(key: KClass, value: NodeCustomisationDirectory) { + map[key] = value + } + + override fun getSubDirectory(key: KClass): NodeCustomisationDirectory? = + map[key] as? NodeCustomisationDirectory + + override fun getSubDirectoryOrSelf(key: KClass): NodeCustomisationDirectory { + val subDir = map.keys.firstOrNull { + it is KClass<*> && it.java.isAssignableFrom(key.java) + } + + return map[subDir] as? NodeCustomisationDirectory ?: this + } + + operator fun KClass<*>.invoke(block: NodeCustomisationDirectoryImpl.() -> Unit) { + if (map.containsKey(this)) { + // TODO warning for accidental override? + } + map[this] = NodeCustomisationDirectoryImpl(this@NodeCustomisationDirectoryImpl).apply(block) + } +} diff --git a/utils/customisations/src/commonMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt b/utils/customisations/src/commonMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt index 414edc4b5..b146c8574 100644 --- a/utils/customisations/src/commonMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt +++ b/utils/customisations/src/commonMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt @@ -1,52 +1,3 @@ package com.bumble.appyx.utils.customisations -import kotlin.reflect.KClass - -open class NodeCustomisationDirectoryImpl( - override val parent: NodeCustomisationDirectory? = null -) : MutableNodeCustomisationDirectory { - - private val map: MutableMap = hashMapOf() - - override fun put(key: KClass, value: T) { - map[key] = value - } - - fun put(vararg values: T) { - values.forEach { - map[it::class] = it - } - } - - inline operator fun T.unaryPlus() { - put(this) - } - - override fun get(key: KClass): T? = - map[key] as? T - - override fun getRecursively(key: KClass): T? = - get(key) ?: parent?.get(key) - - override fun putSubDirectory(key: KClass, value: NodeCustomisationDirectory) { - map[key] = value - } - - override fun getSubDirectory(key: KClass): NodeCustomisationDirectory?= - map[key] as? NodeCustomisationDirectory - - override fun getSubDirectoryOrSelf(key: KClass): NodeCustomisationDirectory { - val subDir = map.keys.firstOrNull { - it is KClass<*> && it.java.isAssignableFrom(key.java) - } - - return map[subDir] as? NodeCustomisationDirectory ?: this - } - - operator fun KClass<*>.invoke(block: NodeCustomisationDirectoryImpl.() -> Unit) { - if (map.containsKey(this)) { - // TODO warning for accidental override? - } - map[this] = NodeCustomisationDirectoryImpl(this@NodeCustomisationDirectoryImpl).apply(block) - } -} +expect class NodeCustomisationDirectoryImpl : MutableNodeCustomisationDirectory diff --git a/utils/customisations/src/desktopMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt b/utils/customisations/src/desktopMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt new file mode 100644 index 000000000..9276c9490 --- /dev/null +++ b/utils/customisations/src/desktopMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt @@ -0,0 +1,52 @@ +package com.bumble.appyx.utils.customisations + +import kotlin.reflect.KClass + +actual open class NodeCustomisationDirectoryImpl( + override val parent: NodeCustomisationDirectory? = null +) : MutableNodeCustomisationDirectory { + + private val map: MutableMap = hashMapOf() + + override fun put(key: KClass, value: T) { + map[key] = value + } + + fun put(vararg values: T) { + values.forEach { + map[it::class] = it + } + } + + inline operator fun T.unaryPlus() { + put(this) + } + + override fun get(key: KClass): T? = + map[key] as? T + + override fun getRecursively(key: KClass): T? = + get(key) ?: parent?.get(key) + + override fun putSubDirectory(key: KClass, value: NodeCustomisationDirectory) { + map[key] = value + } + + override fun getSubDirectory(key: KClass): NodeCustomisationDirectory? = + map[key] as? NodeCustomisationDirectory + + override fun getSubDirectoryOrSelf(key: KClass): NodeCustomisationDirectory { + val subDir = map.keys.firstOrNull { + it is KClass<*> && it.java.isAssignableFrom(key.java) + } + + return map[subDir] as? NodeCustomisationDirectory ?: this + } + + operator fun KClass<*>.invoke(block: NodeCustomisationDirectoryImpl.() -> Unit) { + if (map.containsKey(this)) { + // TODO warning for accidental override? + } + map[this] = NodeCustomisationDirectoryImpl(this@NodeCustomisationDirectoryImpl).apply(block) + } +} diff --git a/utils/customisations/src/jsMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt b/utils/customisations/src/jsMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt new file mode 100644 index 000000000..77c441d13 --- /dev/null +++ b/utils/customisations/src/jsMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt @@ -0,0 +1,33 @@ +package com.bumble.appyx.utils.customisations + +import kotlin.reflect.KClass + +actual open class NodeCustomisationDirectoryImpl( + override val parent: NodeCustomisationDirectory? = null +) : MutableNodeCustomisationDirectory { + + override fun put(key: KClass, value: T) { + // NO-OP + } + + override fun get(key: KClass): T? = + null + + override fun getRecursively(key: KClass): T? = + null + + override fun putSubDirectory(key: KClass, value: NodeCustomisationDirectory) { + // NO-OP + } + + override fun getSubDirectory(key: KClass): NodeCustomisationDirectory? = + null + + override fun getSubDirectoryOrSelf(key: KClass): NodeCustomisationDirectory { + return this + } + + operator fun KClass<*>.invoke(block: NodeCustomisationDirectoryImpl.() -> Unit) { + // NO-OP + } +} From 41387ec93a8a6bde733d9d4c28cb935531f605e8 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Wed, 7 Jun 2023 14:52:19 +0100 Subject: [PATCH 37/94] added artefactId to multiplatform utils module --- utils/multiplatform/build.gradle.kts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/utils/multiplatform/build.gradle.kts b/utils/multiplatform/build.gradle.kts index d9cf58e09..effff9968 100644 --- a/utils/multiplatform/build.gradle.kts +++ b/utils/multiplatform/build.gradle.kts @@ -6,6 +6,10 @@ plugins { id("appyx-publish-multiplatform") } +publishingPlugin { + artifactId = "utils-multiplatform" +} + kotlin { android { publishLibraryVariants("release") From 22daae914f34ff65107879c03fb77a331d3f8b6f Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Wed, 7 Jun 2023 15:06:55 +0100 Subject: [PATCH 38/94] moved test dependencies to match new unit test location --- appyx-navigation/android/build.gradle.kts | 3 --- appyx-navigation/common/build.gradle.kts | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/appyx-navigation/android/build.gradle.kts b/appyx-navigation/android/build.gradle.kts index d13d8c9fb..a23cbd62d 100644 --- a/appyx-navigation/android/build.gradle.kts +++ b/appyx-navigation/android/build.gradle.kts @@ -50,9 +50,6 @@ dependencies { implementation(libs.androidx.lifecycle.java8) implementation(libs.compose.foundation.layout) - testImplementation(libs.kotlin.coroutines.test) - testImplementation(libs.junit) - androidTestImplementation(composeBom) androidTestImplementation(libs.androidx.test.espresso.core) androidTestImplementation(libs.androidx.test.junit) diff --git a/appyx-navigation/common/build.gradle.kts b/appyx-navigation/common/build.gradle.kts index da3b744df..9da9aa769 100644 --- a/appyx-navigation/common/build.gradle.kts +++ b/appyx-navigation/common/build.gradle.kts @@ -34,6 +34,9 @@ kotlin { val commonTest by getting { dependencies { implementation(kotlin("test")) + + implementation(libs.kotlin.coroutines.test) + implementation(libs.junit) } } val androidMain by getting { From 6ab03ce71a47d0c6a8c8a4322ca43aeeabb7804a Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Thu, 8 Jun 2023 14:17:01 +0100 Subject: [PATCH 39/94] corrected customisation module namespace --- utils/customisations/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/customisations/build.gradle.kts b/utils/customisations/build.gradle.kts index 11eaf1c2f..d53c1cc13 100644 --- a/utils/customisations/build.gradle.kts +++ b/utils/customisations/build.gradle.kts @@ -32,7 +32,7 @@ kotlin { } android { - namespace = "com.bumble.appyx.utils.multiplatform" + namespace = "com.bumble.appyx.utils.customisation" compileSdk = libs.versions.androidCompileSdk.get().toInt() sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") defaultConfig { From f498165d38abdf5b0d42e4030fb4bacb71ed129d Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Thu, 8 Jun 2023 15:06:37 +0100 Subject: [PATCH 40/94] implemented local composition provider for screensize, based off a value required by NodeHost and consumed by Children to populate that composable's UiContext --- .../appyx/navigation/AppyxTestScenario.kt | 6 ++++ .../appyx/navigation/composable/Children.kt | 8 ++--- .../appyx/navigation/integration/NodeHost.kt | 31 ++++++++++++------- .../bumble/appyx/navigation/MainActivity.kt | 8 ++++- .../compose/ComposeNavigationRoot.kt | 8 ++++- .../testing/ui/rules/AppyxActivityTestRule.kt | 8 ++++- 6 files changed, 50 insertions(+), 19 deletions(-) diff --git a/appyx-navigation/android/src/androidTest/kotlin/com/bumble/appyx/navigation/AppyxTestScenario.kt b/appyx-navigation/android/src/androidTest/kotlin/com/bumble/appyx/navigation/AppyxTestScenario.kt index bb406ac13..b71df7db2 100644 --- a/appyx-navigation/android/src/androidTest/kotlin/com/bumble/appyx/navigation/AppyxTestScenario.kt +++ b/appyx-navigation/android/src/androidTest/kotlin/com/bumble/appyx/navigation/AppyxTestScenario.kt @@ -2,12 +2,14 @@ package com.bumble.appyx.navigation import androidx.annotation.WorkerThread import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.test.junit4.ComposeTestRule import androidx.compose.ui.test.junit4.createEmptyComposeRule import androidx.test.core.app.ActivityScenario import com.bumble.appyx.navigation.integration.NodeFactory import com.bumble.appyx.navigation.integration.NodeHost +import com.bumble.appyx.navigation.integration.ScreenSize import com.bumble.appyx.navigation.node.Node import com.bumble.appyx.navigation.platform.AndroidLifecycle import com.bumble.appyx.utils.testing.ui.rules.AppyxTestActivity @@ -29,6 +31,10 @@ class AppyxTestScenario( NodeHost( lifecycle = AndroidLifecycle(LocalLifecycleOwner.current.lifecycle), integrationPoint = activity.appyxIntegrationPoint, + screenSize = ScreenSize( + LocalConfiguration.current.screenWidthDp, + LocalConfiguration.current.screenWidthDp + ), ) { buildContext -> node = nodeFactory.create(buildContext) awaitNode.countDown() diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/Children.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/Children.kt index fad5b2279..2b43ee95e 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/Children.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/Children.kt @@ -1,6 +1,5 @@ package com.bumble.appyx.navigation.composable -import android.annotation.SuppressLint import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable @@ -17,7 +16,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clipToBounds import androidx.compose.ui.layout.boundsInRoot import androidx.compose.ui.layout.onPlaced -import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalDensity import com.bumble.appyx.interactions.core.model.BaseInteractionModel import com.bumble.appyx.interactions.core.model.removedElements @@ -25,6 +23,7 @@ import com.bumble.appyx.interactions.core.ui.context.TransitionBounds import com.bumble.appyx.interactions.core.ui.context.UiContext import com.bumble.appyx.interactions.core.ui.gesture.GestureSpec import com.bumble.appyx.interactions.core.ui.output.ElementUiModel +import com.bumble.appyx.navigation.integration.LocalScreenSize import com.bumble.appyx.navigation.node.ParentNode import gestureModifier import kotlin.math.roundToInt @@ -50,8 +49,8 @@ inline fun ParentNode(null) } LaunchedEffect(uiContext) { @@ -89,7 +88,6 @@ class ChildrenTransitionScope( private val interactionModel: BaseInteractionModel ) { - @SuppressLint("ComposableNaming") @Composable fun ParentNode.children( block: @Composable (child: ChildRenderer, elementUiModel: ElementUiModel) -> Unit diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt index a1c8a6085..3ef357f09 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt @@ -1,8 +1,10 @@ package com.bumble.appyx.navigation.integration import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.State +import androidx.compose.runtime.compositionLocalOf import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember @@ -19,6 +21,10 @@ import com.bumble.appyx.navigation.state.SavedStateMap import com.bumble.appyx.utils.customisations.NodeCustomisationDirectory import com.bumble.appyx.utils.customisations.NodeCustomisationDirectoryImpl +data class ScreenSize(val widthDp: Int, val heightDp: Int) + +val LocalScreenSize = compositionLocalOf { ScreenSize(0, 0) } + /** * Composable function to host [Node]. * @@ -29,22 +35,25 @@ import com.bumble.appyx.utils.customisations.NodeCustomisationDirectoryImpl fun NodeHost( lifecycle: CommonLifecycle, integrationPoint: IntegrationPoint, + screenSize: ScreenSize, modifier: Modifier = Modifier, customisations: NodeCustomisationDirectory = remember { NodeCustomisationDirectoryImpl() }, factory: NodeFactory ) { - val node by rememberNode(factory, customisations, integrationPoint) - DisposableEffect(node) { - onDispose { node.updateLifecycleState(CommonLifecycle.State.DESTROYED) } - } - node.Compose(modifier = modifier) - DisposableEffect(lifecycle) { - node.updateLifecycleState(lifecycle.currentState) - val observer = PlatformLifecycleEventObserver { newState, _ -> - node.updateLifecycleState(newState) + CompositionLocalProvider(LocalScreenSize provides screenSize) { + val node by rememberNode(factory, customisations, integrationPoint) + DisposableEffect(node) { + onDispose { node.updateLifecycleState(CommonLifecycle.State.DESTROYED) } + } + node.Compose(modifier = modifier) + DisposableEffect(lifecycle) { + node.updateLifecycleState(lifecycle.currentState) + val observer = PlatformLifecycleEventObserver { newState, _ -> + node.updateLifecycleState(newState) + } + lifecycle.addObserver(observer) + onDispose { lifecycle.removeObserver(observer) } } - lifecycle.addObserver(observer) - onDispose { lifecycle.removeObserver(observer) } } } diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/MainActivity.kt b/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/MainActivity.kt index c9783f1b8..af34a7aaf 100644 --- a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/MainActivity.kt +++ b/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/MainActivity.kt @@ -8,11 +8,13 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.runtime.Composable import androidx.compose.ui.ExperimentalComposeUiApi +import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.ExperimentalUnitApi import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import com.bumble.appyx.navigation.integration.NodeHost +import com.bumble.appyx.navigation.integration.ScreenSize import com.bumble.appyx.navigation.integrationpoint.NodeActivity import com.bumble.appyx.navigation.modality.BuildContext import com.bumble.appyx.navigation.node.container.ContainerNode @@ -34,7 +36,11 @@ class MainActivity : NodeActivity() { Column { NodeHost( AndroidLifecycle(LocalLifecycleOwner.current.lifecycle), - integrationPoint = appyxIntegrationPoint + integrationPoint = appyxIntegrationPoint, + screenSize = ScreenSize( + LocalConfiguration.current.screenWidthDp, + LocalConfiguration.current.screenWidthDp + ), ) { ContainerNode( buildContext = it, diff --git a/demos/navigation-compose/src/main/kotlin/com/bumble/appyx/sample/navigtion/compose/ComposeNavigationRoot.kt b/demos/navigation-compose/src/main/kotlin/com/bumble/appyx/sample/navigtion/compose/ComposeNavigationRoot.kt index 9fdde074d..b1c02055d 100644 --- a/demos/navigation-compose/src/main/kotlin/com/bumble/appyx/sample/navigtion/compose/ComposeNavigationRoot.kt +++ b/demos/navigation-compose/src/main/kotlin/com/bumble/appyx/sample/navigtion/compose/ComposeNavigationRoot.kt @@ -12,12 +12,14 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.unit.dp import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.compose.rememberNavController import com.bumble.appyx.navigation.integration.NodeHost +import com.bumble.appyx.navigation.integration.ScreenSize import com.bumble.appyx.navigation.integrationpoint.LocalIntegrationPoint import com.bumble.appyx.navigation.platform.AndroidLifecycle @@ -71,7 +73,11 @@ internal fun GoogleRoute(modifier: Modifier = Modifier, onAppyxNavigationClick: internal fun AppyxRoute(onGoogleNavigationClick: () -> Unit) { NodeHost( lifecycle = AndroidLifecycle(LocalLifecycleOwner.current.lifecycle), - integrationPoint = LocalIntegrationPoint.current + integrationPoint = LocalIntegrationPoint.current, + screenSize = ScreenSize( + LocalConfiguration.current.screenWidthDp, + LocalConfiguration.current.screenWidthDp + ), ) { ComposeNavigationContainerNode( buildContext = it, diff --git a/utils/testing-ui/src/main/kotlin/com/bumble/appyx/utils/testing/ui/rules/AppyxActivityTestRule.kt b/utils/testing-ui/src/main/kotlin/com/bumble/appyx/utils/testing/ui/rules/AppyxActivityTestRule.kt index b1e3cdf0f..77d66f524 100644 --- a/utils/testing-ui/src/main/kotlin/com/bumble/appyx/utils/testing/ui/rules/AppyxActivityTestRule.kt +++ b/utils/testing-ui/src/main/kotlin/com/bumble/appyx/utils/testing/ui/rules/AppyxActivityTestRule.kt @@ -2,12 +2,14 @@ package com.bumble.appyx.utils.testing.ui.rules import androidx.annotation.CallSuper import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.test.junit4.ComposeTestRule import androidx.compose.ui.test.junit4.createEmptyComposeRule import androidx.test.rule.ActivityTestRule import com.bumble.appyx.navigation.integration.NodeFactory import com.bumble.appyx.navigation.integration.NodeHost +import com.bumble.appyx.navigation.integration.ScreenSize import com.bumble.appyx.navigation.node.Node import com.bumble.appyx.navigation.platform.AndroidLifecycle import org.junit.rules.TestRule @@ -48,7 +50,11 @@ open class AppyxActivityTestRule( decorator { NodeHost( lifecycle = AndroidLifecycle(LocalLifecycleOwner.current.lifecycle), - integrationPoint = activity.appyxIntegrationPoint + integrationPoint = activity.appyxIntegrationPoint, + screenSize = ScreenSize( + LocalConfiguration.current.screenWidthDp, + LocalConfiguration.current.screenWidthDp + ), ) { buildContext -> node = nodeFactory.create(buildContext) node From a7c63ce5808a284778b4c23fea58390ae08445b0 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Fri, 9 Jun 2023 11:57:10 +0100 Subject: [PATCH 41/94] corrected NodeCustomisationDirectory constructor --- .../utils/customisations/NodeCustomisationDirectoryImpl.kt | 4 ++-- .../utils/customisations/NodeCustomisationDirectoryImpl.kt | 4 +++- .../utils/customisations/NodeCustomisationDirectoryImpl.kt | 4 ++-- .../utils/customisations/NodeCustomisationDirectoryImpl.kt | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/utils/customisations/src/androidMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt b/utils/customisations/src/androidMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt index 9276c9490..9ee79b8e8 100644 --- a/utils/customisations/src/androidMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt +++ b/utils/customisations/src/androidMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt @@ -2,8 +2,8 @@ package com.bumble.appyx.utils.customisations import kotlin.reflect.KClass -actual open class NodeCustomisationDirectoryImpl( - override val parent: NodeCustomisationDirectory? = null +actual open class NodeCustomisationDirectoryImpl actual constructor( + override val parent: NodeCustomisationDirectory? ) : MutableNodeCustomisationDirectory { private val map: MutableMap = hashMapOf() diff --git a/utils/customisations/src/commonMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt b/utils/customisations/src/commonMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt index b146c8574..d6b54c6fc 100644 --- a/utils/customisations/src/commonMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt +++ b/utils/customisations/src/commonMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt @@ -1,3 +1,5 @@ package com.bumble.appyx.utils.customisations -expect class NodeCustomisationDirectoryImpl : MutableNodeCustomisationDirectory +expect class NodeCustomisationDirectoryImpl( + parent: NodeCustomisationDirectory? = null +) : MutableNodeCustomisationDirectory diff --git a/utils/customisations/src/desktopMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt b/utils/customisations/src/desktopMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt index 9276c9490..9ee79b8e8 100644 --- a/utils/customisations/src/desktopMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt +++ b/utils/customisations/src/desktopMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt @@ -2,8 +2,8 @@ package com.bumble.appyx.utils.customisations import kotlin.reflect.KClass -actual open class NodeCustomisationDirectoryImpl( - override val parent: NodeCustomisationDirectory? = null +actual open class NodeCustomisationDirectoryImpl actual constructor( + override val parent: NodeCustomisationDirectory? ) : MutableNodeCustomisationDirectory { private val map: MutableMap = hashMapOf() diff --git a/utils/customisations/src/jsMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt b/utils/customisations/src/jsMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt index 77c441d13..ab99ecafb 100644 --- a/utils/customisations/src/jsMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt +++ b/utils/customisations/src/jsMain/kotlin/com/bumble/appyx/utils/customisations/NodeCustomisationDirectoryImpl.kt @@ -2,8 +2,8 @@ package com.bumble.appyx.utils.customisations import kotlin.reflect.KClass -actual open class NodeCustomisationDirectoryImpl( - override val parent: NodeCustomisationDirectory? = null +actual open class NodeCustomisationDirectoryImpl actual constructor( + override val parent: NodeCustomisationDirectory? ) : MutableNodeCustomisationDirectory { override fun put(key: KClass, value: T) { From 94dddf3e44d1b45d855a8c7d8c328a56f490240f Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Fri, 9 Jun 2023 13:36:09 +0100 Subject: [PATCH 42/94] moved JS incompatible RetainedInstanceStoreExt functions to jvm platform modules --- .../store/RetainedInstanceStoreExt.kt | 15 -------- .../store/RetainedInstanceStoreCommonExt.kt | 18 ++++++++++ .../store/RetainedInstanceStoreExt.kt | 35 +++++++++++++++++++ 3 files changed, 53 insertions(+), 15 deletions(-) rename appyx-navigation/common/src/{commonMain => androidMain}/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreExt.kt (72%) create mode 100644 appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreCommonExt.kt create mode 100644 appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreExt.kt diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreExt.kt b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreExt.kt similarity index 72% rename from appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreExt.kt rename to appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreExt.kt index 30a135636..86c7cf34f 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreExt.kt +++ b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreExt.kt @@ -33,18 +33,3 @@ inline fun BuildContext.getRetainedInstance( disposer = disposer, factory = factory ) - -/** - * Obtains or creates an instance of a class using the identifier from the BuildContext. - */ -inline fun BuildContext.getRetainedInstance( - key: String, - noinline disposer: (T) -> Unit = {}, - noinline factory: () -> T -) = - RetainedInstanceStore.get( - storeId = identifier, - key = key, - disposer = disposer, - factory = factory - ) diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreCommonExt.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreCommonExt.kt new file mode 100644 index 000000000..d112b9ba6 --- /dev/null +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreCommonExt.kt @@ -0,0 +1,18 @@ +package com.bumble.appyx.navigation.store + +import com.bumble.appyx.navigation.modality.BuildContext + +/** + * Obtains or creates an instance of a class using the identifier from the BuildContext. + */ +inline fun BuildContext.getRetainedInstance( + key: String, + noinline disposer: (T) -> Unit = {}, + noinline factory: () -> T +) = + RetainedInstanceStore.get( + storeId = identifier, + key = key, + disposer = disposer, + factory = factory + ) diff --git a/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreExt.kt b/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreExt.kt new file mode 100644 index 000000000..86c7cf34f --- /dev/null +++ b/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreExt.kt @@ -0,0 +1,35 @@ +package com.bumble.appyx.navigation.store + +import com.bumble.appyx.navigation.modality.BuildContext + +/** + * Obtains or creates an instance of a class using the class name as the key. + * If you need multiple instances of an object with the same key, do not use this extension. + */ +inline fun RetainedInstanceStore.get( + storeId: String, + noinline disposer: (T) -> Unit = {}, + noinline factory: () -> T +): T = + get( + storeId = storeId, + key = T::class.java.name, + disposer = disposer, + factory = factory + ) + +/** + * Obtains or creates an instance of a class using the class name as the key, and uses the + * identifier from the BuildContext. + * + * If you need multiple instances of an object with the same key, do not use this extension. + */ +inline fun BuildContext.getRetainedInstance( + noinline disposer: (T) -> Unit = {}, + noinline factory: () -> T +) = + RetainedInstanceStore.get( + storeId = identifier, + disposer = disposer, + factory = factory + ) From 6d9f0d568af4c6f7d10cb3a024e3c0e7c8a64288 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Fri, 9 Jun 2023 14:17:34 +0100 Subject: [PATCH 43/94] fixed RetainedInstanceStoreTest.kt to work cross-platform --- appyx-navigation/common/build.gradle.kts | 1 + .../store/RetainedInstanceStoreTest.kt | 118 +++++++++--------- 2 files changed, 62 insertions(+), 57 deletions(-) diff --git a/appyx-navigation/common/build.gradle.kts b/appyx-navigation/common/build.gradle.kts index 9da9aa769..dd759e780 100644 --- a/appyx-navigation/common/build.gradle.kts +++ b/appyx-navigation/common/build.gradle.kts @@ -35,6 +35,7 @@ kotlin { dependencies { implementation(kotlin("test")) + implementation(libs.kotlin.test) implementation(libs.kotlin.coroutines.test) implementation(libs.junit) } diff --git a/appyx-navigation/common/src/commonTest/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreTest.kt b/appyx-navigation/common/src/commonTest/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreTest.kt index 49610bd5d..84337f6f1 100644 --- a/appyx-navigation/common/src/commonTest/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreTest.kt +++ b/appyx-navigation/common/src/commonTest/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreTest.kt @@ -1,32 +1,34 @@ package com.bumble.appyx.navigation.store -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertSame -import org.junit.Assert.assertTrue -import org.junit.Test +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertSame +import kotlin.test.assertTrue +@Suppress("TestFunctionName") class RetainedInstanceStoreTest { - private val identifier = "identifier" + private val storeId = "storeId" + private val key = "key" private val store = RetainedInstanceStoreImpl() @Test - fun `GIVEN object stored WHEN get with same identifier THEN same instance is retrieved`() { + fun GIVEN_object_stored_WHEN_get_with_same_identifier_THEN_same_instance_is_retrieved() { val obj = Any() - store.get(identifier) { obj } + store.get(storeId, key) { obj } - val retrieved = store.get(identifier) { Any() } + val retrieved = store.get(storeId, key) { Any() } assertSame(obj, retrieved) } @Test - fun `GIVEN object stored WHEN get with same identifier THEN factory not called`() { + fun GIVEN_object_stored_WHEN_get_with_same_identifier_THEN_factory_not_called() { var factoryCalled = false - store.get(identifier) { Any() } + store.get(storeId, key) { Any() } - store.get(identifier) { + store.get(storeId, key) { factoryCalled = true Any() } @@ -34,68 +36,70 @@ class RetainedInstanceStoreTest { assertFalse(factoryCalled) } - @Test - fun `GIVEN two objects with different types stored WHEN get with same identifier THEN both objects returned`() { - store.get(identifier) { 1 } - store.get(identifier) { 2L } - - val integerValue = store.get(identifier) { 5 } - val longValue = store.get(identifier) { 6L } - - assertEquals(1, integerValue) - assertEquals(2L, longValue) - } + // This test requires reflection so can only be executed in JVM builds. + // TODO: move to desktop or android only tests, not common test +// @Test +// fun GIVEN_two_objects_with_different_types_stored_WHEN_get_with_same_identifier_THEN_both_objects_returned() { +// store.get(storeId, key) { 1 } +// store.get(storeId, key) { 2L } +// +// val integerValue = store.get(storeId, key) { 5 } +// val longValue = store.get(storeId, key) { 6L } +// +// assertEquals(1, integerValue) +// assertEquals(2L, longValue) +// } @Test - fun `GIVEN two objects stored with same type AND different keys WHEN get with same identifier THEN both objects returned`() { - store.get(storeId = identifier, key = "1") { 1 } - store.get(storeId = identifier, key = "2") { 2 } + fun GIVEN_two_objects_stored_with_same_type_AND_different_keys_WHEN_get_with_same_identifier_THEN_both_objects_returned() { + store.get(storeId = storeId, key = "1") { 1 } + store.get(storeId = storeId, key = "2") { 2 } - val integerValue1 = store.get(storeId = identifier, key = "1") { 5 } - val integerValue2 = store.get(storeId = identifier, key = "2") { 6L } + val integerValue1 = store.get(storeId = storeId, key = "1") { 5 } + val integerValue2 = store.get(storeId = storeId, key = "2") { 6 } assertEquals(1, integerValue1) assertEquals(2, integerValue2) } @Test - fun `GIVEN object stored WHEN clearStore with same identifier THEN object is disposed`() { + fun GIVEN_object_stored_WHEN_clearStore_with_same_identifier_THEN_object_is_disposed() { val obj = Any() var disposed = false - store.get(identifier, disposer = { disposed = true }) { obj } + store.get(storeId, key = key, disposer = { disposed = true }) { obj } - store.clearStore(identifier) + store.clearStore(storeId) assertTrue(disposed) } @Test - fun `GIVEN object stored WHEN clearStore with different identifier THEN object is not disposed`() { + fun GIVEN_object_stored_WHEN_clearStore_with_different_identifier_THEN_object_is_not_disposed() { val obj = Any() val otherIdentifier = "other" var disposed = false - store.get(identifier) { obj } - store.get(otherIdentifier, disposer = { disposed = true }) { obj } + store.get(storeId, key) { obj } + store.get(otherIdentifier, key, disposer = { disposed = true }) { obj } - store.clearStore(identifier) + store.clearStore(storeId) assertFalse(disposed) } @Test - fun `GIVEN object stored before WHEN checking if same instance retained by store id with same owner THEN expect true`() { + fun GIVEN_object_stored_before_WHEN_checking_if_same_instance_retained_by_store_id_with_same_owner_THEN_expect_true() { val obj = Any() - store.get(identifier) { obj } + store.get(storeId, key) { obj } - val isRetained = store.isRetainedByStoreId(identifier, obj) + val isRetained = store.isRetainedByStoreId(storeId, obj) assertTrue(isRetained) } @Test - fun `GIVEN object stored before WHEN checking if same instance retained by store id with different owner THEN expect false`() { + fun GIVEN_object_stored_before_WHEN_checking_if_same_instance_retained_by_store_id_with_different_owner_THEN_expect_false() { val obj = Any() - store.get(identifier) { obj } + store.get(storeId, key) { obj } val isRetained = store.isRetainedByStoreId("different-identifier", obj) @@ -103,40 +107,40 @@ class RetainedInstanceStoreTest { } @Test - fun `GIVEN object stored before WHEN checking if different instance retained by store id with same owner THEN expect false`() { + fun GIVEN_object_stored_before_WHEN_checking_if_different_instance_retained_by_store_id_with_same_owner_THEN_expect_false() { val obj = Any() val otherObj = Any() - store.get(identifier) { obj } + store.get(storeId, key) { obj } - val isRetained = store.isRetainedByStoreId(identifier, otherObj) + val isRetained = store.isRetainedByStoreId(storeId, otherObj) assertFalse(isRetained) } @Test - fun `GIVEN object stored before AND then removed WHEN checking if same instance retained by store id with same owner THEN expect false`() { + fun GIVEN_object_stored_before_AND_then_removed_WHEN_checking_if_same_instance_retained_by_store_id_with_same_owner_THEN_expect_false() { val obj = Any() - store.get(identifier) { obj } - store.clearStore(identifier) + store.get(storeId, key) { obj } + store.clearStore(storeId) - val isRetained = store.isRetainedByStoreId(identifier, obj) + val isRetained = store.isRetainedByStoreId(storeId, obj) assertFalse(isRetained) } @Test - fun `GIVEN no object stored WHEN checking if instance retained by store id THEN expect false`() { + fun GIVEN_no_object_stored_WHEN_checking_if_instance_retained_by_store_id_THEN_expect_false() { val obj = Any() - val isRetained = store.isRetainedByStoreId(identifier, obj) + val isRetained = store.isRetainedByStoreId(storeId, obj) assertFalse(isRetained) } @Test - fun `GIVEN object stored before WHEN checking if same instance retained THEN expect true`() { + fun GIVEN_object_stored_before_WHEN_checking_if_same_instance_retained_THEN_expect_true() { val obj = Any() - store.get(identifier) { obj } + store.get(storeId, key) { obj } val isRetained = store.isRetained(obj) @@ -144,10 +148,10 @@ class RetainedInstanceStoreTest { } @Test - fun `GIVEN object stored before WHEN checking if different instance retained THEN expect false`() { + fun GIVEN_object_stored_before_WHEN_checking_if_different_instance_retained_THEN_expect_false() { val obj = Any() val otherObj = Any() - store.get(identifier) { obj } + store.get(storeId, key) { obj } val isRetained = store.isRetained(otherObj) @@ -155,10 +159,10 @@ class RetainedInstanceStoreTest { } @Test - fun `GIVEN object stored before AND then removed WHEN checking if same instance retained THEN expect false`() { + fun GIVEN_object_stored_before_AND_then_removed_WHEN_checking_if_same_instance_retained_THEN_expect_false() { val obj = Any() - store.get(identifier) { obj } - store.clearStore(identifier) + store.get(storeId, key) { obj } + store.clearStore(storeId) val isRetained = store.isRetained(obj) @@ -166,7 +170,7 @@ class RetainedInstanceStoreTest { } @Test - fun `GIVEN no object stored WHEN checking if instance retained THEN expect false`() { + fun GIVEN_no_object_stored_WHEN_checking_if_instance_retained_THEN_expect_false() { val obj = Any() val isRetained = store.isRetained(obj) From 5b40546cd6313b138cb72403b4263e71482cbcb2 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Fri, 9 Jun 2023 14:18:19 +0100 Subject: [PATCH 44/94] removed usage of class.qualifiedName, which is not available in js platform --- .../commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt | 2 +- .../kotlin/com/bumble/appyx/navigation/node/ParentNodeView.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt index 439fc5990..ce4798f7f 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt @@ -129,7 +129,7 @@ open class Node internal constructor( if (lifecycle.currentState == CommonLifecycle.State.DESTROYED && state != CommonLifecycle.State.DESTROYED) { Appyx.reportException( IllegalStateException( - "Trying to change lifecycle state of already destroyed node ${this::class.qualifiedName}" + "Trying to change lifecycle state of already destroyed node ${this::class}" ) ) return diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNodeView.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNodeView.kt index 88d660b7c..d7aa820ba 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNodeView.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNodeView.kt @@ -15,7 +15,7 @@ interface ParentNodeView : NodeView { @Composable override fun View(modifier: Modifier) { val node = LocalNode.current as? ParentNode - ?: error("${this::class.qualifiedName} is not provided to the appropriate ParentNode") + ?: error("${this::class} is not provided to the appropriate ParentNode") node.NodeView(modifier = modifier) } } From bd61ca70c94410a82d9b68acfeb7692016a08a22 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Fri, 9 Jun 2023 14:18:42 +0100 Subject: [PATCH 45/94] fixed desktop PlatformLifecycleRegistry.kt getter overloading --- .../platform/PlatformLifecycleRegistry.kt | 85 +++++++++---------- 1 file changed, 41 insertions(+), 44 deletions(-) diff --git a/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt b/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt index 692b4235c..f1586f12c 100644 --- a/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt +++ b/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt @@ -18,50 +18,8 @@ actual class PlatformLifecycleRegistry( ArrayList() private var _currentState: CommonLifecycle.State = CommonLifecycle.State.INITIALIZED - override var currentState: CommonLifecycle.State + override val currentState: CommonLifecycle.State get() = _currentState - set(value) { - when (value) { - CommonLifecycle.State.INITIALIZED -> Unit - CommonLifecycle.State.CREATED -> { - managedDefaultLifecycleObservers.forEach { it.onCreate() } - managedLifecycleEventObservers.forEach { - it.onStateChanged( - value, - CommonLifecycle.Event.ON_CREATE - ) - } - } - CommonLifecycle.State.STARTED -> { - managedDefaultLifecycleObservers.forEach { it.onStart() } - managedLifecycleEventObservers.forEach { - it.onStateChanged( - value, - CommonLifecycle.Event.ON_START - ) - } - } - CommonLifecycle.State.RESUMED -> { - managedDefaultLifecycleObservers.forEach { it.onResume() } - managedLifecycleEventObservers.forEach { - it.onStateChanged( - value, - CommonLifecycle.Event.ON_RESUME - ) - } - } - CommonLifecycle.State.DESTROYED -> { - managedDefaultLifecycleObservers.forEach { it.onDestroy() } - managedLifecycleEventObservers.forEach { - it.onStateChanged( - value, - CommonLifecycle.Event.ON_DESTROY - ) - } - } - } - _currentState = value - } override val coroutineScope: CoroutineScope = lifecycleCoroutineScope @@ -80,7 +38,46 @@ actual class PlatformLifecycleRegistry( } actual fun setCurrentState(state: CommonLifecycle.State) { - currentState = state + when (state) { + CommonLifecycle.State.INITIALIZED -> Unit + CommonLifecycle.State.CREATED -> { + managedDefaultLifecycleObservers.forEach { it.onCreate() } + managedLifecycleEventObservers.forEach { + it.onStateChanged( + state, + CommonLifecycle.Event.ON_CREATE + ) + } + } + CommonLifecycle.State.STARTED -> { + managedDefaultLifecycleObservers.forEach { it.onStart() } + managedLifecycleEventObservers.forEach { + it.onStateChanged( + state, + CommonLifecycle.Event.ON_START + ) + } + } + CommonLifecycle.State.RESUMED -> { + managedDefaultLifecycleObservers.forEach { it.onResume() } + managedLifecycleEventObservers.forEach { + it.onStateChanged( + state, + CommonLifecycle.Event.ON_RESUME + ) + } + } + CommonLifecycle.State.DESTROYED -> { + managedDefaultLifecycleObservers.forEach { it.onDestroy() } + managedLifecycleEventObservers.forEach { + it.onStateChanged( + state, + CommonLifecycle.Event.ON_DESTROY + ) + } + } + } + _currentState = state } actual companion object { From d3dbc9b9e6fef7bdbaaad12edb2da7ae7f97b6b1 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Fri, 9 Jun 2023 16:31:49 +0100 Subject: [PATCH 46/94] fixed lifecycle usage in RxNodeConnectorTests --- .../rx2/connectable/Rx2NodeConnectorTest.kt | 33 +++++++++--------- .../rx3/connectable/Rx3NodeConnectorTest.kt | 34 +++++++++---------- 2 files changed, 33 insertions(+), 34 deletions(-) diff --git a/utils/interop-rx2/src/test/kotlin/com/bumble/appyx/utils/interop/rx2/connectable/Rx2NodeConnectorTest.kt b/utils/interop-rx2/src/test/kotlin/com/bumble/appyx/utils/interop/rx2/connectable/Rx2NodeConnectorTest.kt index 2c3190acf..04c2effc6 100644 --- a/utils/interop-rx2/src/test/kotlin/com/bumble/appyx/utils/interop/rx2/connectable/Rx2NodeConnectorTest.kt +++ b/utils/interop-rx2/src/test/kotlin/com/bumble/appyx/utils/interop/rx2/connectable/Rx2NodeConnectorTest.kt @@ -1,16 +1,15 @@ package com.bumble.appyx.utils.interop.rx2.connectable -import androidx.lifecycle.DefaultLifecycleObserver -import androidx.lifecycle.Lifecycle import androidx.lifecycle.Lifecycle.State.CREATED -import androidx.lifecycle.LifecycleObserver -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.LifecycleRegistry +import com.bumble.appyx.navigation.lifecycle.CommonLifecycle +import com.bumble.appyx.navigation.lifecycle.DefaultPlatformLifecycleObserver +import com.bumble.appyx.navigation.lifecycle.PlatformLifecycleObserver +import com.bumble.appyx.navigation.platform.toCommonState import com.bumble.appyx.utils.interop.rx2.connectable.Rx2NodeConnectorTest.Output.Output1 import com.bumble.appyx.utils.interop.rx2.connectable.Rx2NodeConnectorTest.Output.Output2 import com.bumble.appyx.utils.interop.rx2.connectable.Rx2NodeConnectorTest.Output.Output3 -import com.bumble.appyx.utils.interop.rx2.connectable.NodeConnector import io.reactivex.observers.TestObserver +import kotlinx.coroutines.CoroutineScope import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Assertions.assertThrows import org.junit.jupiter.api.RepeatedTest @@ -19,30 +18,30 @@ import java.util.concurrent.CyclicBarrier import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import java.util.concurrent.TimeUnit +import kotlin.coroutines.EmptyCoroutineContext class Rx2NodeConnectorTest { private val firstTestObserver = TestObserver() private val secondTestObserver = TestObserver() private var lifecycleState = CREATED - private val lifecycle = object : Lifecycle() { - private val lifecycleOwner = object : LifecycleOwner { - override val lifecycle: Lifecycle = LifecycleRegistry(this) - } + private val lifecycle = object : CommonLifecycle { + + override val currentState: CommonLifecycle.State + get() = lifecycleState.toCommonState() - override fun addObserver(observer: LifecycleObserver) { + override val coroutineScope: CoroutineScope = CoroutineScope(EmptyCoroutineContext) + + override fun addObserver(observer: PlatformLifecycleObserver) { if (lifecycleState == CREATED) { - (observer as DefaultLifecycleObserver).onCreate(lifecycleOwner) + (observer as DefaultPlatformLifecycleObserver).onCreate() } } - override fun removeObserver(observer: LifecycleObserver) { - // Deliberately empty + override fun removeObserver(observer: PlatformLifecycleObserver) { + // NO-OP } - - override val currentState: State - get() = lifecycleState } sealed class Output { diff --git a/utils/interop-rx3/src/test/kotlin/com/bumble/appyx/utils/interop/rx3/connectable/Rx3NodeConnectorTest.kt b/utils/interop-rx3/src/test/kotlin/com/bumble/appyx/utils/interop/rx3/connectable/Rx3NodeConnectorTest.kt index 822df3bd6..fe60d98bd 100644 --- a/utils/interop-rx3/src/test/kotlin/com/bumble/appyx/utils/interop/rx3/connectable/Rx3NodeConnectorTest.kt +++ b/utils/interop-rx3/src/test/kotlin/com/bumble/appyx/utils/interop/rx3/connectable/Rx3NodeConnectorTest.kt @@ -1,14 +1,15 @@ package com.bumble.appyx.utils.interop.rx3.connectable -import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleObserver -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.LifecycleRegistry +import com.bumble.appyx.navigation.lifecycle.CommonLifecycle +import com.bumble.appyx.navigation.lifecycle.DefaultPlatformLifecycleObserver +import com.bumble.appyx.navigation.lifecycle.PlatformLifecycleObserver +import com.bumble.appyx.navigation.platform.toCommonState import com.bumble.appyx.utils.interop.rx3.connectable.Rx3NodeConnectorTest.Output.Output1 import com.bumble.appyx.utils.interop.rx3.connectable.Rx3NodeConnectorTest.Output.Output2 import com.bumble.appyx.utils.interop.rx3.connectable.Rx3NodeConnectorTest.Output.Output3 import io.reactivex.rxjava3.observers.TestObserver +import kotlinx.coroutines.CoroutineScope import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Assertions.assertThrows import org.junit.jupiter.api.RepeatedTest @@ -17,31 +18,30 @@ import java.util.concurrent.CyclicBarrier import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import java.util.concurrent.TimeUnit +import kotlin.coroutines.EmptyCoroutineContext internal class Rx3NodeConnectorTest { private val firstTestObserver = TestObserver() private val secondTestObserver = TestObserver() private var lifecycleState = Lifecycle.State.CREATED - private val lifecycle = object : Lifecycle() { - private val lifecycleOwner = object : LifecycleOwner { - override val lifecycle: Lifecycle - get() = LifecycleRegistry(this) - } + private val lifecycle = object : CommonLifecycle { + + override val currentState: CommonLifecycle.State + get() = lifecycleState.toCommonState() - override fun addObserver(observer: LifecycleObserver) { - if (lifecycleState == State.CREATED) { - (observer as DefaultLifecycleObserver).onCreate(lifecycleOwner) + override val coroutineScope: CoroutineScope = CoroutineScope(EmptyCoroutineContext) + + override fun addObserver(observer: PlatformLifecycleObserver) { + if (lifecycleState == Lifecycle.State.CREATED) { + (observer as DefaultPlatformLifecycleObserver).onCreate() } } - override fun removeObserver(observer: LifecycleObserver) { - // Deliberately empty + override fun removeObserver(observer: PlatformLifecycleObserver) { + // NO-OP } - - override val currentState: State - get() = lifecycleState } sealed class Output { From 56555079eb1a1cd3b2b71d3c981c3f7429f34959 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Fri, 9 Jun 2023 17:24:30 +0100 Subject: [PATCH 47/94] fixed gradle health issues in appyx-navigation:android --- appyx-navigation/android/build.gradle.kts | 10 ++-------- appyx-navigation/common/build.gradle.kts | 2 +- demos/navigation-compose/build.gradle.kts | 2 +- utils/testing-unit-common/build.gradle.kts | 2 +- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/appyx-navigation/android/build.gradle.kts b/appyx-navigation/android/build.gradle.kts index a23cbd62d..52c82469b 100644 --- a/appyx-navigation/android/build.gradle.kts +++ b/appyx-navigation/android/build.gradle.kts @@ -34,21 +34,15 @@ dependencies { val composeBom = platform(libs.compose.bom) api(composeBom) - api(project(":utils:customisations")) - api(project(":appyx-interactions:appyx-interactions")) api(project(":appyx-navigation:common")) - api(libs.kotlin.coroutines.android) - api(libs.androidx.lifecycle.common) + runtimeOnly(libs.kotlin.coroutines.android) + implementation(libs.androidx.lifecycle.common) api(libs.compose.runtime) api(libs.compose.ui.tooling) - api(libs.compose.ui.ui) api(libs.androidx.appcompat) - implementation(libs.compose.animation.core) - implementation(libs.androidx.activity.compose) implementation(libs.androidx.lifecycle.java8) - implementation(libs.compose.foundation.layout) androidTestImplementation(composeBom) androidTestImplementation(libs.androidx.test.espresso.core) diff --git a/appyx-navigation/common/build.gradle.kts b/appyx-navigation/common/build.gradle.kts index dd759e780..605be11ef 100644 --- a/appyx-navigation/common/build.gradle.kts +++ b/appyx-navigation/common/build.gradle.kts @@ -27,7 +27,7 @@ kotlin { api(compose.material) api(project(":utils:multiplatform")) implementation(libs.kotlinx.serialization.json) - implementation(project(":utils:customisations")) + api(project(":utils:customisations")) api(project(":appyx-interactions:appyx-interactions")) } } diff --git a/demos/navigation-compose/build.gradle.kts b/demos/navigation-compose/build.gradle.kts index aad7dbff4..a7c751c8e 100644 --- a/demos/navigation-compose/build.gradle.kts +++ b/demos/navigation-compose/build.gradle.kts @@ -37,7 +37,7 @@ dependencies { val composeBom = platform(libs.compose.bom) api(composeBom) - api(project(":appyx-navigation:android")) + implementation(project(":appyx-navigation:android")) api(project(":appyx-components:backstack:backstack")) api(libs.compose.ui.ui) diff --git a/utils/testing-unit-common/build.gradle.kts b/utils/testing-unit-common/build.gradle.kts index 836f57ec2..1fc3f6aa3 100644 --- a/utils/testing-unit-common/build.gradle.kts +++ b/utils/testing-unit-common/build.gradle.kts @@ -30,6 +30,6 @@ android { dependencies { api(project(":appyx-navigation:common")) - api(project(":utils:customisations")) + implementation(project(":utils:customisations")) implementation(libs.kotlin.test) } From ea3dd5e2d4361db75455e86c74496b609ae1175f Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Mon, 12 Jun 2023 14:42:09 +0100 Subject: [PATCH 48/94] removed navigation common android and desktop test directory declarations, as these do not exist --- appyx-navigation/common/build.gradle.kts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/appyx-navigation/common/build.gradle.kts b/appyx-navigation/common/build.gradle.kts index 605be11ef..712c028cb 100644 --- a/appyx-navigation/common/build.gradle.kts +++ b/appyx-navigation/common/build.gradle.kts @@ -47,17 +47,11 @@ kotlin { implementation(libs.androidx.activity.compose) } } - val androidTest by getting { - dependencies { - implementation(libs.junit) - } - } val desktopMain by getting { dependencies { api(compose.preview) } } - val desktopTest by getting val jsMain by getting { dependencies { implementation(npm("uuid", libs.versions.uuid.get())) From fd2be9abc4b2b767ca84c9a7b5d75fb568e5f622 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Mon, 12 Jun 2023 14:58:43 +0100 Subject: [PATCH 49/94] corrected android navigation test manifest --- .../android/src/androidTest/AndroidManifest.xml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/appyx-navigation/android/src/androidTest/AndroidManifest.xml b/appyx-navigation/android/src/androidTest/AndroidManifest.xml index f404c9c82..424d9c3de 100644 --- a/appyx-navigation/android/src/androidTest/AndroidManifest.xml +++ b/appyx-navigation/android/src/androidTest/AndroidManifest.xml @@ -4,11 +4,7 @@ - - From 43642bc2464d74549ea2e515fc5fd1faa57771a1 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Mon, 12 Jun 2023 17:15:09 +0100 Subject: [PATCH 50/94] removed unnecessary test dependencies from navigation module --- appyx-navigation/common/build.gradle.kts | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/appyx-navigation/common/build.gradle.kts b/appyx-navigation/common/build.gradle.kts index 712c028cb..bb1750ee2 100644 --- a/appyx-navigation/common/build.gradle.kts +++ b/appyx-navigation/common/build.gradle.kts @@ -34,10 +34,6 @@ kotlin { val commonTest by getting { dependencies { implementation(kotlin("test")) - - implementation(libs.kotlin.test) - implementation(libs.kotlin.coroutines.test) - implementation(libs.junit) } } val androidMain by getting { @@ -67,8 +63,6 @@ android { defaultConfig { minSdk = libs.versions.androidMinSdk.get().toInt() targetSdk = libs.versions.androidTargetSdk.get().toInt() - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } buildFeatures { compose = true @@ -76,10 +70,4 @@ android { composeOptions { kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get() } - testOptions { - unitTests.all { - // interface method default implementation - it.exclude("**/*\$DefaultImpls.class") - } - } } From ff61124a07b706c2a89e5b40df17aa01d811be7e Mon Sep 17 00:00:00 2001 From: Jez <5053926+Ninjars@users.noreply.github.com> Date: Tue, 13 Jun 2023 14:59:23 +0100 Subject: [PATCH 51/94] Properly ignored test Co-authored-by: Andrey Kovalev --- .../appyx/navigation/store/RetainedInstanceStoreTest.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/appyx-navigation/common/src/commonTest/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreTest.kt b/appyx-navigation/common/src/commonTest/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreTest.kt index 84337f6f1..518ee87dd 100644 --- a/appyx-navigation/common/src/commonTest/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreTest.kt +++ b/appyx-navigation/common/src/commonTest/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreTest.kt @@ -36,9 +36,8 @@ class RetainedInstanceStoreTest { assertFalse(factoryCalled) } - // This test requires reflection so can only be executed in JVM builds. - // TODO: move to desktop or android only tests, not common test -// @Test +@Ignore(This test requires reflection so can only be executed in JVM builds. TODO: move to desktop or android only tests, not common test") +@Test // fun GIVEN_two_objects_with_different_types_stored_WHEN_get_with_same_identifier_THEN_both_objects_returned() { // store.get(storeId, key) { 1 } // store.get(storeId, key) { 2L } From f193c031e5c3edc9651e7ea8a9929e436587ea55 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Tue, 13 Jun 2023 15:01:48 +0100 Subject: [PATCH 52/94] end of file line returns --- .../com/bumble/appyx/navigation/platform/PlatformBackHandler.kt | 2 +- .../com/bumble/appyx/navigation/platform/PlatformBackHandler.kt | 2 +- .../com/bumble/appyx/navigation/platform/PlatformBackHandler.kt | 2 +- .../appyx/navigation/platform/PlatformLifecycleRegistry.kt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt index fa01a7e53..fb0989286 100644 --- a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt +++ b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt @@ -6,4 +6,4 @@ import androidx.compose.runtime.Composable @Composable actual fun PlatformBackHandler(enabled: Boolean, onBack: () -> Unit) { BackHandler(enabled, onBack) -} \ No newline at end of file +} diff --git a/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt b/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt index 18d315231..bd76fc15a 100644 --- a/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt +++ b/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt @@ -5,4 +5,4 @@ import androidx.compose.runtime.Composable @Composable actual fun PlatformBackHandler(enabled: Boolean, onBack: () -> Unit) { TODO() -} \ No newline at end of file +} diff --git a/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt b/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt index 18d315231..bd76fc15a 100644 --- a/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt +++ b/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformBackHandler.kt @@ -5,4 +5,4 @@ import androidx.compose.runtime.Composable @Composable actual fun PlatformBackHandler(enabled: Boolean, onBack: () -> Unit) { TODO() -} \ No newline at end of file +} diff --git a/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt b/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt index 944fb11a9..be6cee526 100644 --- a/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt +++ b/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt @@ -86,4 +86,4 @@ actual class PlatformLifecycleRegistry( actual fun create(owner: CommonLifecycleOwner): PlatformLifecycleRegistry = PlatformLifecycleRegistry(owner.lifecycleScope) } -} \ No newline at end of file +} From 11a0754d112d499597fd467a16561ec0c57dc620 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Tue, 13 Jun 2023 15:08:50 +0100 Subject: [PATCH 53/94] provide ScreenSize values as Dp not Int, corrected height values --- .../kotlin/com/bumble/appyx/navigation/AppyxTestScenario.kt | 5 +++-- .../com/bumble/appyx/navigation/composable/Children.kt | 4 ++-- .../com/bumble/appyx/navigation/integration/NodeHost.kt | 6 ++++-- .../main/kotlin/com/bumble/appyx/navigation/MainActivity.kt | 5 +++-- .../appyx/sample/navigtion/compose/ComposeNavigationRoot.kt | 4 ++-- .../appyx/utils/testing/ui/rules/AppyxActivityTestRule.kt | 5 +++-- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/appyx-navigation/android/src/androidTest/kotlin/com/bumble/appyx/navigation/AppyxTestScenario.kt b/appyx-navigation/android/src/androidTest/kotlin/com/bumble/appyx/navigation/AppyxTestScenario.kt index b71df7db2..767f541dc 100644 --- a/appyx-navigation/android/src/androidTest/kotlin/com/bumble/appyx/navigation/AppyxTestScenario.kt +++ b/appyx-navigation/android/src/androidTest/kotlin/com/bumble/appyx/navigation/AppyxTestScenario.kt @@ -6,6 +6,7 @@ import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.test.junit4.ComposeTestRule import androidx.compose.ui.test.junit4.createEmptyComposeRule +import androidx.compose.ui.unit.dp import androidx.test.core.app.ActivityScenario import com.bumble.appyx.navigation.integration.NodeFactory import com.bumble.appyx.navigation.integration.NodeHost @@ -32,8 +33,8 @@ class AppyxTestScenario( lifecycle = AndroidLifecycle(LocalLifecycleOwner.current.lifecycle), integrationPoint = activity.appyxIntegrationPoint, screenSize = ScreenSize( - LocalConfiguration.current.screenWidthDp, - LocalConfiguration.current.screenWidthDp + LocalConfiguration.current.screenWidthDp.dp, + LocalConfiguration.current.screenHeightDp.dp, ), ) { buildContext -> node = nodeFactory.create(buildContext) diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/Children.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/Children.kt index 2b43ee95e..0561f4d3d 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/Children.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/composable/Children.kt @@ -49,8 +49,8 @@ inline fun ParentNode(null) } LaunchedEffect(uiContext) { diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt index 3ef357f09..8353333b5 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt @@ -11,6 +11,8 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.saveable.mapSaver import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp import com.bumble.appyx.navigation.integrationpoint.IntegrationPoint import com.bumble.appyx.navigation.lifecycle.CommonLifecycle import com.bumble.appyx.navigation.lifecycle.PlatformLifecycleEventObserver @@ -21,9 +23,9 @@ import com.bumble.appyx.navigation.state.SavedStateMap import com.bumble.appyx.utils.customisations.NodeCustomisationDirectory import com.bumble.appyx.utils.customisations.NodeCustomisationDirectoryImpl -data class ScreenSize(val widthDp: Int, val heightDp: Int) +data class ScreenSize(val widthDp: Dp, val heightDp: Dp) -val LocalScreenSize = compositionLocalOf { ScreenSize(0, 0) } +val LocalScreenSize = compositionLocalOf { ScreenSize(0.dp, 0.dp) } /** * Composable function to host [Node]. diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/MainActivity.kt b/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/MainActivity.kt index af34a7aaf..559d10341 100644 --- a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/MainActivity.kt +++ b/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/MainActivity.kt @@ -12,6 +12,7 @@ import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.ExperimentalUnitApi +import androidx.compose.ui.unit.dp import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import com.bumble.appyx.navigation.integration.NodeHost import com.bumble.appyx.navigation.integration.ScreenSize @@ -38,8 +39,8 @@ class MainActivity : NodeActivity() { AndroidLifecycle(LocalLifecycleOwner.current.lifecycle), integrationPoint = appyxIntegrationPoint, screenSize = ScreenSize( - LocalConfiguration.current.screenWidthDp, - LocalConfiguration.current.screenWidthDp + LocalConfiguration.current.screenWidthDp.dp, + LocalConfiguration.current.screenHeightDp.dp, ), ) { ContainerNode( diff --git a/demos/navigation-compose/src/main/kotlin/com/bumble/appyx/sample/navigtion/compose/ComposeNavigationRoot.kt b/demos/navigation-compose/src/main/kotlin/com/bumble/appyx/sample/navigtion/compose/ComposeNavigationRoot.kt index b1c02055d..370061cc8 100644 --- a/demos/navigation-compose/src/main/kotlin/com/bumble/appyx/sample/navigtion/compose/ComposeNavigationRoot.kt +++ b/demos/navigation-compose/src/main/kotlin/com/bumble/appyx/sample/navigtion/compose/ComposeNavigationRoot.kt @@ -75,8 +75,8 @@ internal fun AppyxRoute(onGoogleNavigationClick: () -> Unit) { lifecycle = AndroidLifecycle(LocalLifecycleOwner.current.lifecycle), integrationPoint = LocalIntegrationPoint.current, screenSize = ScreenSize( - LocalConfiguration.current.screenWidthDp, - LocalConfiguration.current.screenWidthDp + LocalConfiguration.current.screenWidthDp.dp, + LocalConfiguration.current.screenHeightDp.dp, ), ) { ComposeNavigationContainerNode( diff --git a/utils/testing-ui/src/main/kotlin/com/bumble/appyx/utils/testing/ui/rules/AppyxActivityTestRule.kt b/utils/testing-ui/src/main/kotlin/com/bumble/appyx/utils/testing/ui/rules/AppyxActivityTestRule.kt index 77d66f524..25e1a3b87 100644 --- a/utils/testing-ui/src/main/kotlin/com/bumble/appyx/utils/testing/ui/rules/AppyxActivityTestRule.kt +++ b/utils/testing-ui/src/main/kotlin/com/bumble/appyx/utils/testing/ui/rules/AppyxActivityTestRule.kt @@ -6,6 +6,7 @@ import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.test.junit4.ComposeTestRule import androidx.compose.ui.test.junit4.createEmptyComposeRule +import androidx.compose.ui.unit.dp import androidx.test.rule.ActivityTestRule import com.bumble.appyx.navigation.integration.NodeFactory import com.bumble.appyx.navigation.integration.NodeHost @@ -52,8 +53,8 @@ open class AppyxActivityTestRule( lifecycle = AndroidLifecycle(LocalLifecycleOwner.current.lifecycle), integrationPoint = activity.appyxIntegrationPoint, screenSize = ScreenSize( - LocalConfiguration.current.screenWidthDp, - LocalConfiguration.current.screenWidthDp + LocalConfiguration.current.screenWidthDp.dp, + LocalConfiguration.current.screenHeightDp.dp, ), ) { buildContext -> node = nodeFactory.create(buildContext) From 64b807c1e770731dd15f30e149b0d79d05a0e34c Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Tue, 13 Jun 2023 15:12:20 +0100 Subject: [PATCH 54/94] removed Common prefix from Lifecycle --- .../navigation/platform/AndroidLifecycle.kt | 11 +++-- .../platform/LifecycleCommonMappers.kt | 43 +++++++++---------- .../platform/PlatformLifecycleRegistry.kt | 13 +++--- .../children/ChildAwareCallbackInfo.kt | 6 +-- .../navigation/children/ChildAwareImpl.kt | 6 +-- .../navigation/children/ChildCallback.kt | 6 +-- .../appyx/navigation/integration/NodeHost.kt | 6 +-- .../lifecycle/ChildNodeLifecycleManager.kt | 16 +++---- .../lifecycle/CommonLifecycleObserver.kt | 2 +- .../lifecycle/CommonLifecycleOwner.kt | 2 +- .../{CommonLifecycle.kt => Lifecycle.kt} | 2 +- .../lifecycle/MinimumCombinedLifecycle.kt | 10 ++--- .../navigation/lifecycle/NodeLifecycle.kt | 2 +- .../navigation/lifecycle/NodeLifecycleImpl.kt | 4 +- .../lifecycle/PlatformLifecycleExt.kt | 10 ++--- .../com/bumble/appyx/navigation/node/Node.kt | 10 ++--- .../appyx/navigation/node/ParentNode.kt | 6 +-- .../platform/PlatformLifecycleRegistry.kt | 6 +-- .../bumble/appyx/navigation/plugin/Plugins.kt | 4 +- .../platform/PlatformLifecycleRegistry.kt | 28 ++++++------ .../platform/PlatformLifecycleRegistry.kt | 28 ++++++------ .../interop/rx2/connectable/NodeConnector.kt | 4 +- .../rx2/connectable/Rx2NodeConnectorTest.kt | 6 +-- .../interop/rx3/connectable/NodeConnector.kt | 4 +- .../rx3/connectable/Rx3NodeConnectorTest.kt | 12 +++--- .../unit/common/helper/NodeTestHelper.kt | 20 ++++----- .../common/helper/ParentNodeTestHelper.kt | 4 +- .../unit/common/util/InteropBuilderStub.kt | 4 +- .../common/util/InteropSimpleBuilderStub.kt | 4 +- 29 files changed, 138 insertions(+), 141 deletions(-) rename appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/{CommonLifecycle.kt => Lifecycle.kt} (97%) diff --git a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/AndroidLifecycle.kt b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/AndroidLifecycle.kt index d46aaa9d6..02e8a1bff 100644 --- a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/AndroidLifecycle.kt +++ b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/AndroidLifecycle.kt @@ -1,19 +1,18 @@ package com.bumble.appyx.navigation.platform import androidx.lifecycle.DefaultLifecycleObserver -import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleEventObserver import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.coroutineScope -import com.bumble.appyx.navigation.lifecycle.CommonLifecycle import com.bumble.appyx.navigation.lifecycle.DefaultPlatformLifecycleObserver +import com.bumble.appyx.navigation.lifecycle.Lifecycle import com.bumble.appyx.navigation.lifecycle.PlatformLifecycleEventObserver import com.bumble.appyx.navigation.lifecycle.PlatformLifecycleObserver import kotlinx.coroutines.CoroutineScope class AndroidLifecycle( - val androidLifecycle: Lifecycle -) : CommonLifecycle, + val androidLifecycle: androidx.lifecycle.Lifecycle +) : Lifecycle, DefaultLifecycleObserver, LifecycleEventObserver { @@ -22,7 +21,7 @@ class AndroidLifecycle( private val managedLifecycleEventObservers: MutableList = ArrayList() - override val currentState: CommonLifecycle.State + override val currentState: Lifecycle.State get() = androidLifecycle.currentState.toCommonState() override val coroutineScope: CoroutineScope = @@ -70,7 +69,7 @@ class AndroidLifecycle( managedDefaultLifecycleObservers.forEach { it.onDestroy() } } - override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) { + override fun onStateChanged(source: LifecycleOwner, event: androidx.lifecycle.Lifecycle.Event) { val commonEvent = event.toCommonEvent() managedLifecycleEventObservers.forEach { it.onStateChanged( diff --git a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleCommonMappers.kt b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleCommonMappers.kt index 46ed80692..d9560f2f4 100644 --- a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleCommonMappers.kt +++ b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleCommonMappers.kt @@ -1,34 +1,33 @@ package com.bumble.appyx.navigation.platform -import androidx.lifecycle.Lifecycle -import com.bumble.appyx.navigation.lifecycle.CommonLifecycle +import com.bumble.appyx.navigation.lifecycle.Lifecycle -fun Lifecycle.Event.toCommonEvent(): CommonLifecycle.Event = +fun androidx.lifecycle.Lifecycle.Event.toCommonEvent(): Lifecycle.Event = when (this) { - Lifecycle.Event.ON_CREATE -> CommonLifecycle.Event.ON_CREATE - Lifecycle.Event.ON_START -> CommonLifecycle.Event.ON_START - Lifecycle.Event.ON_RESUME -> CommonLifecycle.Event.ON_RESUME - Lifecycle.Event.ON_PAUSE -> CommonLifecycle.Event.ON_PAUSE - Lifecycle.Event.ON_STOP -> CommonLifecycle.Event.ON_STOP - Lifecycle.Event.ON_DESTROY -> CommonLifecycle.Event.ON_DESTROY - Lifecycle.Event.ON_ANY -> CommonLifecycle.Event.ON_ANY + androidx.lifecycle.Lifecycle.Event.ON_CREATE -> Lifecycle.Event.ON_CREATE + androidx.lifecycle.Lifecycle.Event.ON_START -> Lifecycle.Event.ON_START + androidx.lifecycle.Lifecycle.Event.ON_RESUME -> Lifecycle.Event.ON_RESUME + androidx.lifecycle.Lifecycle.Event.ON_PAUSE -> Lifecycle.Event.ON_PAUSE + androidx.lifecycle.Lifecycle.Event.ON_STOP -> Lifecycle.Event.ON_STOP + androidx.lifecycle.Lifecycle.Event.ON_DESTROY -> Lifecycle.Event.ON_DESTROY + androidx.lifecycle.Lifecycle.Event.ON_ANY -> Lifecycle.Event.ON_ANY } -fun CommonLifecycle.State.toAndroidState(): Lifecycle.State = +fun Lifecycle.State.toAndroidState(): androidx.lifecycle.Lifecycle.State = when (this) { - CommonLifecycle.State.INITIALIZED -> Lifecycle.State.INITIALIZED - CommonLifecycle.State.CREATED -> Lifecycle.State.CREATED - CommonLifecycle.State.STARTED -> Lifecycle.State.STARTED - CommonLifecycle.State.RESUMED -> Lifecycle.State.RESUMED - CommonLifecycle.State.DESTROYED -> Lifecycle.State.DESTROYED + Lifecycle.State.INITIALIZED -> androidx.lifecycle.Lifecycle.State.INITIALIZED + Lifecycle.State.CREATED -> androidx.lifecycle.Lifecycle.State.CREATED + Lifecycle.State.STARTED -> androidx.lifecycle.Lifecycle.State.STARTED + Lifecycle.State.RESUMED -> androidx.lifecycle.Lifecycle.State.RESUMED + Lifecycle.State.DESTROYED -> androidx.lifecycle.Lifecycle.State.DESTROYED } -fun Lifecycle.State.toCommonState(): CommonLifecycle.State = +fun androidx.lifecycle.Lifecycle.State.toCommonState(): Lifecycle.State = when (this) { - Lifecycle.State.DESTROYED -> CommonLifecycle.State.DESTROYED - Lifecycle.State.INITIALIZED -> CommonLifecycle.State.INITIALIZED - Lifecycle.State.CREATED -> CommonLifecycle.State.CREATED - Lifecycle.State.STARTED -> CommonLifecycle.State.STARTED - Lifecycle.State.RESUMED -> CommonLifecycle.State.RESUMED + androidx.lifecycle.Lifecycle.State.DESTROYED -> Lifecycle.State.DESTROYED + androidx.lifecycle.Lifecycle.State.INITIALIZED -> Lifecycle.State.INITIALIZED + androidx.lifecycle.Lifecycle.State.CREATED -> Lifecycle.State.CREATED + androidx.lifecycle.Lifecycle.State.STARTED -> Lifecycle.State.STARTED + androidx.lifecycle.Lifecycle.State.RESUMED -> Lifecycle.State.RESUMED } \ No newline at end of file diff --git a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt index f4fee2c45..dc93e8335 100644 --- a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt +++ b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt @@ -1,20 +1,19 @@ package com.bumble.appyx.navigation.platform import android.app.Activity -import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LifecycleRegistry import androidx.lifecycle.coroutineScope -import com.bumble.appyx.navigation.lifecycle.CommonLifecycle import com.bumble.appyx.navigation.lifecycle.CommonLifecycleOwner import com.bumble.appyx.navigation.lifecycle.DefaultPlatformLifecycleObserver +import com.bumble.appyx.navigation.lifecycle.Lifecycle import com.bumble.appyx.navigation.lifecycle.PlatformLifecycleEventObserver import com.bumble.appyx.navigation.lifecycle.PlatformLifecycleObserver import kotlinx.coroutines.CoroutineScope actual class PlatformLifecycleRegistry( androidOwner: LifecycleOwner -) : CommonLifecycle, androidx.lifecycle.DefaultLifecycleObserver, +) : Lifecycle, androidx.lifecycle.DefaultLifecycleObserver, androidx.lifecycle.LifecycleEventObserver { private var lifecycleOwner: LifecycleOwner? = androidOwner @@ -25,10 +24,10 @@ actual class PlatformLifecycleRegistry( private val managedLifecycleEventObservers: MutableList = ArrayList() - override val currentState: CommonLifecycle.State + override val currentState: Lifecycle.State get() = androidLifecycleRegistry.currentState.toCommonState() - actual fun setCurrentState(state: CommonLifecycle.State) { + actual fun setCurrentState(state: Lifecycle.State) { androidLifecycleRegistry.currentState = state.toAndroidState() } @@ -52,7 +51,7 @@ actual class PlatformLifecycleRegistry( } } - override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) { + override fun onStateChanged(source: LifecycleOwner, event: androidx.lifecycle.Lifecycle.Event) { val commonEvent = event.toCommonEvent() managedLifecycleEventObservers.forEach { it.onStateChanged( @@ -91,7 +90,7 @@ actual class PlatformLifecycleRegistry( actual companion object { actual fun create(owner: CommonLifecycleOwner): PlatformLifecycleRegistry = PlatformLifecycleRegistry(object : LifecycleOwner { - override val lifecycle: Lifecycle + override val lifecycle: androidx.lifecycle.Lifecycle get() = when (val platformLifecycle = owner.lifecycle) { is AndroidLifecycle -> platformLifecycle.androidLifecycle is PlatformLifecycleRegistry -> platformLifecycle.androidLifecycleRegistry diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareCallbackInfo.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareCallbackInfo.kt index 8b5fba33f..926398fca 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareCallbackInfo.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareCallbackInfo.kt @@ -1,6 +1,6 @@ package com.bumble.appyx.navigation.children -import com.bumble.appyx.navigation.lifecycle.CommonLifecycle +import com.bumble.appyx.navigation.lifecycle.Lifecycle import com.bumble.appyx.navigation.lifecycle.MinimumCombinedLifecycle import com.bumble.appyx.navigation.lifecycle.isDestroyed import com.bumble.appyx.navigation.node.Node @@ -15,7 +15,7 @@ internal sealed class ChildAwareCallbackInfo { class Single( private val child: KClass, private val callback: ChildCallback, - private val parentLifecycle: CommonLifecycle, + private val parentLifecycle: Lifecycle, ) : ChildAwareCallbackInfo() { fun onNewNodeAppeared(newNode: Node) { @@ -43,7 +43,7 @@ internal sealed class ChildAwareCallbackInfo { private val child1: KClass, private val child2: KClass, private val callback: ChildrenCallback, - private val parentLifecycle: CommonLifecycle, + private val parentLifecycle: Lifecycle, ) : ChildAwareCallbackInfo() { fun onNewNodeAppeared( diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt index e82d6e788..d3b04d9c7 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildAwareImpl.kt @@ -1,8 +1,8 @@ package com.bumble.appyx.navigation.children import com.bumble.appyx.interactions.core.Element -import com.bumble.appyx.navigation.lifecycle.CommonLifecycle import com.bumble.appyx.navigation.lifecycle.DefaultPlatformLifecycleObserver +import com.bumble.appyx.navigation.lifecycle.Lifecycle import com.bumble.appyx.navigation.lifecycle.isDestroyed import com.bumble.appyx.navigation.node.Node import com.bumble.appyx.navigation.node.ParentNode @@ -19,7 +19,7 @@ class ChildAwareImpl : ChildAware { private val callbacks: MutableList = ArrayList() private lateinit var children: StateFlow, ChildEntry<*>>> - private lateinit var lifecycle: CommonLifecycle + private lateinit var lifecycle: Lifecycle private lateinit var coroutineScope: CoroutineScope override lateinit var node: N @@ -91,7 +91,7 @@ class ChildAwareImpl : ChildAware { } } - private fun CommonLifecycle.removeWhenDestroyed(info: ChildAwareCallbackInfo) { + private fun Lifecycle.removeWhenDestroyed(info: ChildAwareCallbackInfo) { addObserver(object : DefaultPlatformLifecycleObserver { override fun onDestroy() { callbacks.remove(info) diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildCallback.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildCallback.kt index ce6d5c748..6dda7298d 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildCallback.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/children/ChildCallback.kt @@ -1,7 +1,7 @@ package com.bumble.appyx.navigation.children -import com.bumble.appyx.navigation.lifecycle.CommonLifecycle +import com.bumble.appyx.navigation.lifecycle.Lifecycle -typealias ChildrenCallback = (commonLifecycle: CommonLifecycle, child1: T1, child2: T2) -> Unit +typealias ChildrenCallback = (lifecycle: Lifecycle, child1: T1, child2: T2) -> Unit -typealias ChildCallback = (commonLifecycle: CommonLifecycle, child: T) -> Unit +typealias ChildCallback = (lifecycle: Lifecycle, child: T) -> Unit diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt index 8353333b5..4ce9f4c76 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/integration/NodeHost.kt @@ -14,7 +14,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.bumble.appyx.navigation.integrationpoint.IntegrationPoint -import com.bumble.appyx.navigation.lifecycle.CommonLifecycle +import com.bumble.appyx.navigation.lifecycle.Lifecycle import com.bumble.appyx.navigation.lifecycle.PlatformLifecycleEventObserver import com.bumble.appyx.navigation.modality.BuildContext import com.bumble.appyx.navigation.node.Node @@ -35,7 +35,7 @@ val LocalScreenSize = compositionLocalOf { ScreenSize(0.dp, 0.dp) } @Suppress("ComposableParamOrder") // detekt complains as 'factory' param isn't a pure lambda @Composable fun NodeHost( - lifecycle: CommonLifecycle, + lifecycle: Lifecycle, integrationPoint: IntegrationPoint, screenSize: ScreenSize, modifier: Modifier = Modifier, @@ -45,7 +45,7 @@ fun NodeHost( CompositionLocalProvider(LocalScreenSize provides screenSize) { val node by rememberNode(factory, customisations, integrationPoint) DisposableEffect(node) { - onDispose { node.updateLifecycleState(CommonLifecycle.State.DESTROYED) } + onDispose { node.updateLifecycleState(Lifecycle.State.DESTROYED) } } node.Compose(modifier = modifier) DisposableEffect(lifecycle) { diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/ChildNodeLifecycleManager.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/ChildNodeLifecycleManager.kt index e86fad9c3..de8527627 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/ChildNodeLifecycleManager.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/ChildNodeLifecycleManager.kt @@ -23,7 +23,7 @@ internal class ChildNodeLifecycleManager( private val coroutineScope: CoroutineScope, ) { - private val lifecycleState = MutableStateFlow(CommonLifecycle.State.INITIALIZED) + private val lifecycleState = MutableStateFlow(Lifecycle.State.INITIALIZED) /** * Propagates the parent lifecycle to children. @@ -35,7 +35,7 @@ internal class ChildNodeLifecycleManager( * Otherwise a child node lifecycle might be updated before the parent. * It leads to incorrect registration order of back handlers. */ - fun propagateLifecycleToChildren(state: CommonLifecycle.State) { + fun propagateLifecycleToChildren(state: Lifecycle.State) { lifecycleState.value = state } @@ -56,24 +56,24 @@ internal class ChildNodeLifecycleManager( children .value .values - .forEach { entry -> entry.setState(CommonLifecycle.State.DESTROYED) } + .forEach { entry -> entry.setState(Lifecycle.State.DESTROYED) } } .collect { (parentLifecycleState, screenState, children) -> screenState.onScreen.forEach { key -> val childState = - minOf(parentLifecycleState, CommonLifecycle.State.RESUMED) + minOf(parentLifecycleState, Lifecycle.State.RESUMED) children.current[key]?.setState(childState) } screenState.offScreen.forEach { key -> if (keepMode == ChildEntry.KeepMode.KEEP) { val childState = - minOf(parentLifecycleState, CommonLifecycle.State.CREATED) + minOf(parentLifecycleState, Lifecycle.State.CREATED) children.current[key]?.setState(childState) } else { // Look up in the previous because in the current it is already suspended // and does not have a reference to the node - children.previous?.get(key)?.setState(CommonLifecycle.State.DESTROYED) + children.previous?.get(key)?.setState(Lifecycle.State.DESTROYED) } } @@ -81,14 +81,14 @@ internal class ChildNodeLifecycleManager( val removedKeys = children.previous.keys - children.current.keys removedKeys.forEach { key -> val removedChild = children.previous[key] - removedChild?.setState(CommonLifecycle.State.DESTROYED) + removedChild?.setState(Lifecycle.State.DESTROYED) } } } } } - private fun ChildEntry<*>.setState(state: CommonLifecycle.State) { + private fun ChildEntry<*>.setState(state: Lifecycle.State) { nodeOrNull?.updateLifecycleState(state) } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/CommonLifecycleObserver.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/CommonLifecycleObserver.kt index 029a91a4e..a81f7363a 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/CommonLifecycleObserver.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/CommonLifecycleObserver.kt @@ -48,5 +48,5 @@ fun interface PlatformLifecycleEventObserver : PlatformLifecycleObserver { * * @param event The event */ - fun onStateChanged(newState: CommonLifecycle.State, event: CommonLifecycle.Event) + fun onStateChanged(newState: Lifecycle.State, event: Lifecycle.Event) } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/CommonLifecycleOwner.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/CommonLifecycleOwner.kt index 0176ed545..30301edfb 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/CommonLifecycleOwner.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/CommonLifecycleOwner.kt @@ -3,6 +3,6 @@ package com.bumble.appyx.navigation.lifecycle import kotlinx.coroutines.CoroutineScope interface CommonLifecycleOwner { - val lifecycle: CommonLifecycle + val lifecycle: Lifecycle val lifecycleScope: CoroutineScope } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/CommonLifecycle.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/Lifecycle.kt similarity index 97% rename from appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/CommonLifecycle.kt rename to appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/Lifecycle.kt index f91e53c77..adc24ab6d 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/CommonLifecycle.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/Lifecycle.kt @@ -5,7 +5,7 @@ import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow -interface CommonLifecycle { +interface Lifecycle { val currentState: State val coroutineScope: CoroutineScope diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt index 930c588fc..5271c2efe 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/MinimumCombinedLifecycle.kt @@ -13,10 +13,10 @@ import kotlinx.coroutines.CoroutineScope * - INITIALIZED + DESTROYED -> DESTROYED */ internal class MinimumCombinedLifecycle( - vararg lifecycles: CommonLifecycle, + vararg lifecycles: Lifecycle, ) : CommonLifecycleOwner { private val registry = PlatformLifecycleRegistry.create(this) - private val lifecycles = ArrayList() + private val lifecycles = ArrayList() init { /* @@ -27,10 +27,10 @@ internal class MinimumCombinedLifecycle( lifecycles.sortedBy { it.currentState }.forEach { manage(it) } } - override val lifecycle: CommonLifecycle = registry + override val lifecycle: Lifecycle = registry override val lifecycleScope: CoroutineScope = registry.coroutineScope - fun manage(lifecycle: CommonLifecycle) { + fun manage(lifecycle: Lifecycle) { lifecycles += lifecycle lifecycle.addObserver(object : DefaultPlatformLifecycleObserver { override fun onCreate() { @@ -63,7 +63,7 @@ internal class MinimumCombinedLifecycle( private fun update() { lifecycles .minByOrNull { it.currentState } - ?.takeIf { it.currentState != CommonLifecycle.State.INITIALIZED } + ?.takeIf { it.currentState != Lifecycle.State.INITIALIZED } ?.also { registry.setCurrentState(it.currentState) } } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycle.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycle.kt index b3371fa5e..62571e4bb 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycle.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycle.kt @@ -2,6 +2,6 @@ package com.bumble.appyx.navigation.lifecycle interface NodeLifecycle : CommonLifecycleOwner { - fun updateLifecycleState(state: CommonLifecycle.State) + fun updateLifecycleState(state: Lifecycle.State) } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt index 8bca12ebd..83a4dbfe4 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/NodeLifecycleImpl.kt @@ -7,10 +7,10 @@ internal class NodeLifecycleImpl(lifecycleOwner: CommonLifecycleOwner) : NodeLif private val lifecycleRegistry: PlatformLifecycleRegistry = PlatformLifecycleRegistry.create(lifecycleOwner) - override val lifecycle: CommonLifecycle = lifecycleRegistry + override val lifecycle: Lifecycle = lifecycleRegistry override val lifecycleScope: CoroutineScope = lifecycleRegistry.coroutineScope - override fun updateLifecycleState(state: CommonLifecycle.State) { + override fun updateLifecycleState(state: Lifecycle.State) { lifecycleRegistry.setCurrentState(state) } } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/PlatformLifecycleExt.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/PlatformLifecycleExt.kt index 89487bb6b..b75f5b08b 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/PlatformLifecycleExt.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/lifecycle/PlatformLifecycleExt.kt @@ -4,10 +4,10 @@ import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow -fun CommonLifecycleOwner.asFlow(): Flow = +fun CommonLifecycleOwner.asFlow(): Flow = lifecycle.asFlow() -fun CommonLifecycle.asFlow(): Flow = +fun Lifecycle.asFlow(): Flow = callbackFlow { val observer = PlatformLifecycleEventObserver { currentState, _ -> trySend(currentState) @@ -17,10 +17,10 @@ fun CommonLifecycle.asFlow(): Flow = awaitClose { removeObserver(observer) } } -internal val CommonLifecycle.isDestroyed: Boolean - get() = currentState == CommonLifecycle.State.DESTROYED +internal val Lifecycle.isDestroyed: Boolean + get() = currentState == Lifecycle.State.DESTROYED -fun CommonLifecycle.subscribe( +fun Lifecycle.subscribe( onCreate: () -> Unit = {}, onStart: () -> Unit = {}, onResume: () -> Unit = {}, diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt index ce4798f7f..91423623c 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/Node.kt @@ -12,8 +12,8 @@ import com.bumble.appyx.interactions.core.state.MutableSavedStateMapImpl import com.bumble.appyx.navigation.Appyx import com.bumble.appyx.navigation.integrationpoint.IntegrationPoint import com.bumble.appyx.navigation.integrationpoint.IntegrationPointStub -import com.bumble.appyx.navigation.lifecycle.CommonLifecycle import com.bumble.appyx.navigation.lifecycle.DefaultPlatformLifecycleObserver +import com.bumble.appyx.navigation.lifecycle.Lifecycle import com.bumble.appyx.navigation.lifecycle.LifecycleLogger import com.bumble.appyx.navigation.lifecycle.NodeLifecycle import com.bumble.appyx.navigation.lifecycle.NodeLifecycleImpl @@ -104,7 +104,7 @@ open class Node internal constructor( open fun onBuilt() { require(!wasBuilt) { "onBuilt was already invoked" } wasBuilt = true - updateLifecycleState(CommonLifecycle.State.CREATED) + updateLifecycleState(Lifecycle.State.CREATED) plugins>().forEach { it.init(this) } plugins().forEach { it.onCreate(lifecycle) } } @@ -124,9 +124,9 @@ open class Node internal constructor( } - override fun updateLifecycleState(state: CommonLifecycle.State) { + override fun updateLifecycleState(state: Lifecycle.State) { if (lifecycle.currentState == state) return - if (lifecycle.currentState == CommonLifecycle.State.DESTROYED && state != CommonLifecycle.State.DESTROYED) { + if (lifecycle.currentState == Lifecycle.State.DESTROYED && state != Lifecycle.State.DESTROYED) { Appyx.reportException( IllegalStateException( "Trying to change lifecycle state of already destroyed node ${this::class}" @@ -135,7 +135,7 @@ open class Node internal constructor( return } nodeLifecycle.updateLifecycleState(state) - if (state == CommonLifecycle.State.DESTROYED) { + if (state == Lifecycle.State.DESTROYED) { if (!integrationPoint.isChangingConfigurations) { retainedInstanceStore.clearStore(id) } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt index c8e9d5de6..418a7d2d1 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/node/ParentNode.kt @@ -28,7 +28,7 @@ import com.bumble.appyx.navigation.children.ChildrenCallback import com.bumble.appyx.navigation.children.nodeOrNull import com.bumble.appyx.navigation.composable.ChildRenderer import com.bumble.appyx.navigation.lifecycle.ChildNodeLifecycleManager -import com.bumble.appyx.navigation.lifecycle.CommonLifecycle +import com.bumble.appyx.navigation.lifecycle.Lifecycle import com.bumble.appyx.navigation.mapState import com.bumble.appyx.navigation.modality.BuildContext import com.bumble.appyx.navigation.navigation.Resolver @@ -118,12 +118,12 @@ abstract class ParentNode( PermanentChild(interactionTarget) { child -> child() } } - override fun updateLifecycleState(state: CommonLifecycle.State) { + override fun updateLifecycleState(state: Lifecycle.State) { super.updateLifecycleState(state) childNodeLifecycleManager.propagateLifecycleToChildren(state) // TODO move to plugins - if (state == CommonLifecycle.State.DESTROYED) { + if (state == Lifecycle.State.DESTROYED) { interactionModel.destroy() } } diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt index 101f3f56f..8f7c43724 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt @@ -1,10 +1,10 @@ package com.bumble.appyx.navigation.platform -import com.bumble.appyx.navigation.lifecycle.CommonLifecycle import com.bumble.appyx.navigation.lifecycle.CommonLifecycleOwner +import com.bumble.appyx.navigation.lifecycle.Lifecycle -expect class PlatformLifecycleRegistry : CommonLifecycle { - fun setCurrentState(state: CommonLifecycle.State) +expect class PlatformLifecycleRegistry : Lifecycle { + fun setCurrentState(state: Lifecycle.State) companion object { fun create(owner: CommonLifecycleOwner): PlatformLifecycleRegistry diff --git a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt index e0392ee84..d0aef44f8 100644 --- a/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt +++ b/appyx-navigation/common/src/commonMain/kotlin/com/bumble/appyx/navigation/plugin/Plugins.kt @@ -1,7 +1,7 @@ package com.bumble.appyx.navigation.plugin import com.bumble.appyx.interactions.core.plugin.Plugin -import com.bumble.appyx.navigation.lifecycle.CommonLifecycle +import com.bumble.appyx.navigation.lifecycle.Lifecycle import com.bumble.appyx.navigation.node.Node import com.bumble.appyx.navigation.plugin.BackPressHandler.OnBackPressedCallback @@ -17,7 +17,7 @@ interface NodeReadyObserver : Plugin { } interface NodeLifecycleAware : Plugin { - fun onCreate(lifecycle: CommonLifecycle) {} + fun onCreate(lifecycle: Lifecycle) {} } interface UpNavigationHandler : Plugin { diff --git a/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt b/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt index f1586f12c..872e1e8ae 100644 --- a/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt +++ b/appyx-navigation/common/src/desktopMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt @@ -1,8 +1,8 @@ package com.bumble.appyx.navigation.platform -import com.bumble.appyx.navigation.lifecycle.CommonLifecycle import com.bumble.appyx.navigation.lifecycle.CommonLifecycleOwner import com.bumble.appyx.navigation.lifecycle.DefaultPlatformLifecycleObserver +import com.bumble.appyx.navigation.lifecycle.Lifecycle import com.bumble.appyx.navigation.lifecycle.PlatformLifecycleEventObserver import com.bumble.appyx.navigation.lifecycle.PlatformLifecycleObserver import kotlinx.coroutines.CoroutineScope @@ -10,15 +10,15 @@ import kotlinx.coroutines.CoroutineScope actual class PlatformLifecycleRegistry( lifecycleCoroutineScope: CoroutineScope, -) : CommonLifecycle { +) : Lifecycle { private val managedDefaultLifecycleObservers: MutableList = ArrayList() private val managedLifecycleEventObservers: MutableList = ArrayList() - private var _currentState: CommonLifecycle.State = CommonLifecycle.State.INITIALIZED - override val currentState: CommonLifecycle.State + private var _currentState: Lifecycle.State = Lifecycle.State.INITIALIZED + override val currentState: Lifecycle.State get() = _currentState override val coroutineScope: CoroutineScope = lifecycleCoroutineScope @@ -37,42 +37,42 @@ actual class PlatformLifecycleRegistry( } } - actual fun setCurrentState(state: CommonLifecycle.State) { + actual fun setCurrentState(state: Lifecycle.State) { when (state) { - CommonLifecycle.State.INITIALIZED -> Unit - CommonLifecycle.State.CREATED -> { + Lifecycle.State.INITIALIZED -> Unit + Lifecycle.State.CREATED -> { managedDefaultLifecycleObservers.forEach { it.onCreate() } managedLifecycleEventObservers.forEach { it.onStateChanged( state, - CommonLifecycle.Event.ON_CREATE + Lifecycle.Event.ON_CREATE ) } } - CommonLifecycle.State.STARTED -> { + Lifecycle.State.STARTED -> { managedDefaultLifecycleObservers.forEach { it.onStart() } managedLifecycleEventObservers.forEach { it.onStateChanged( state, - CommonLifecycle.Event.ON_START + Lifecycle.Event.ON_START ) } } - CommonLifecycle.State.RESUMED -> { + Lifecycle.State.RESUMED -> { managedDefaultLifecycleObservers.forEach { it.onResume() } managedLifecycleEventObservers.forEach { it.onStateChanged( state, - CommonLifecycle.Event.ON_RESUME + Lifecycle.Event.ON_RESUME ) } } - CommonLifecycle.State.DESTROYED -> { + Lifecycle.State.DESTROYED -> { managedDefaultLifecycleObservers.forEach { it.onDestroy() } managedLifecycleEventObservers.forEach { it.onStateChanged( state, - CommonLifecycle.Event.ON_DESTROY + Lifecycle.Event.ON_DESTROY ) } } diff --git a/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt b/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt index be6cee526..4f72f0459 100644 --- a/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt +++ b/appyx-navigation/common/src/jsMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt @@ -1,60 +1,60 @@ package com.bumble.appyx.navigation.platform -import com.bumble.appyx.navigation.lifecycle.CommonLifecycle import com.bumble.appyx.navigation.lifecycle.CommonLifecycleOwner import com.bumble.appyx.navigation.lifecycle.DefaultPlatformLifecycleObserver +import com.bumble.appyx.navigation.lifecycle.Lifecycle import com.bumble.appyx.navigation.lifecycle.PlatformLifecycleEventObserver import com.bumble.appyx.navigation.lifecycle.PlatformLifecycleObserver import kotlinx.coroutines.CoroutineScope actual class PlatformLifecycleRegistry( lifecycleCoroutineScope: CoroutineScope, -) : CommonLifecycle { +) : Lifecycle { private val managedDefaultLifecycleObservers: MutableList = ArrayList() private val managedLifecycleEventObservers: MutableList = ArrayList() - private var _currentState: CommonLifecycle.State = CommonLifecycle.State.INITIALIZED - override var currentState: CommonLifecycle.State + private var _currentState: Lifecycle.State = Lifecycle.State.INITIALIZED + override var currentState: Lifecycle.State get() = _currentState set(value) { when (value) { - CommonLifecycle.State.INITIALIZED -> Unit - CommonLifecycle.State.CREATED -> { + Lifecycle.State.INITIALIZED -> Unit + Lifecycle.State.CREATED -> { managedDefaultLifecycleObservers.forEach { it.onCreate() } managedLifecycleEventObservers.forEach { it.onStateChanged( value, - CommonLifecycle.Event.ON_CREATE + Lifecycle.Event.ON_CREATE ) } } - CommonLifecycle.State.STARTED -> { + Lifecycle.State.STARTED -> { managedDefaultLifecycleObservers.forEach { it.onStart() } managedLifecycleEventObservers.forEach { it.onStateChanged( value, - CommonLifecycle.Event.ON_START + Lifecycle.Event.ON_START ) } } - CommonLifecycle.State.RESUMED -> { + Lifecycle.State.RESUMED -> { managedDefaultLifecycleObservers.forEach { it.onResume() } managedLifecycleEventObservers.forEach { it.onStateChanged( value, - CommonLifecycle.Event.ON_RESUME + Lifecycle.Event.ON_RESUME ) } } - CommonLifecycle.State.DESTROYED -> { + Lifecycle.State.DESTROYED -> { managedDefaultLifecycleObservers.forEach { it.onDestroy() } managedLifecycleEventObservers.forEach { it.onStateChanged( value, - CommonLifecycle.Event.ON_DESTROY + Lifecycle.Event.ON_DESTROY ) } } @@ -78,7 +78,7 @@ actual class PlatformLifecycleRegistry( } } - actual fun setCurrentState(state: CommonLifecycle.State) { + actual fun setCurrentState(state: Lifecycle.State) { currentState = state } diff --git a/utils/interop-rx2/src/main/kotlin/com/bumble/appyx/utils/interop/rx2/connectable/NodeConnector.kt b/utils/interop-rx2/src/main/kotlin/com/bumble/appyx/utils/interop/rx2/connectable/NodeConnector.kt index b2ca21431..999759f43 100644 --- a/utils/interop-rx2/src/main/kotlin/com/bumble/appyx/utils/interop/rx2/connectable/NodeConnector.kt +++ b/utils/interop-rx2/src/main/kotlin/com/bumble/appyx/utils/interop/rx2/connectable/NodeConnector.kt @@ -1,7 +1,7 @@ package com.bumble.appyx.utils.interop.rx2.connectable import android.annotation.SuppressLint -import com.bumble.appyx.navigation.lifecycle.CommonLifecycle +import com.bumble.appyx.navigation.lifecycle.Lifecycle import com.bumble.appyx.navigation.lifecycle.subscribe import com.jakewharton.rxrelay2.PublishRelay import com.jakewharton.rxrelay2.Relay @@ -31,7 +31,7 @@ class NodeConnector( } - override fun onCreate(lifecycle: CommonLifecycle) { + override fun onCreate(lifecycle: Lifecycle) { lifecycle.subscribe(onCreate = { flushOutputCache() }) } diff --git a/utils/interop-rx2/src/test/kotlin/com/bumble/appyx/utils/interop/rx2/connectable/Rx2NodeConnectorTest.kt b/utils/interop-rx2/src/test/kotlin/com/bumble/appyx/utils/interop/rx2/connectable/Rx2NodeConnectorTest.kt index 04c2effc6..3b4a8b690 100644 --- a/utils/interop-rx2/src/test/kotlin/com/bumble/appyx/utils/interop/rx2/connectable/Rx2NodeConnectorTest.kt +++ b/utils/interop-rx2/src/test/kotlin/com/bumble/appyx/utils/interop/rx2/connectable/Rx2NodeConnectorTest.kt @@ -1,8 +1,8 @@ package com.bumble.appyx.utils.interop.rx2.connectable import androidx.lifecycle.Lifecycle.State.CREATED -import com.bumble.appyx.navigation.lifecycle.CommonLifecycle import com.bumble.appyx.navigation.lifecycle.DefaultPlatformLifecycleObserver +import com.bumble.appyx.navigation.lifecycle.Lifecycle import com.bumble.appyx.navigation.lifecycle.PlatformLifecycleObserver import com.bumble.appyx.navigation.platform.toCommonState import com.bumble.appyx.utils.interop.rx2.connectable.Rx2NodeConnectorTest.Output.Output1 @@ -26,9 +26,9 @@ class Rx2NodeConnectorTest { private val secondTestObserver = TestObserver() private var lifecycleState = CREATED - private val lifecycle = object : CommonLifecycle { + private val lifecycle = object : Lifecycle { - override val currentState: CommonLifecycle.State + override val currentState: Lifecycle.State get() = lifecycleState.toCommonState() override val coroutineScope: CoroutineScope = CoroutineScope(EmptyCoroutineContext) diff --git a/utils/interop-rx3/src/main/kotlin/com/bumble/appyx/utils/interop/rx3/connectable/NodeConnector.kt b/utils/interop-rx3/src/main/kotlin/com/bumble/appyx/utils/interop/rx3/connectable/NodeConnector.kt index bd36293d4..7a1ddd746 100644 --- a/utils/interop-rx3/src/main/kotlin/com/bumble/appyx/utils/interop/rx3/connectable/NodeConnector.kt +++ b/utils/interop-rx3/src/main/kotlin/com/bumble/appyx/utils/interop/rx3/connectable/NodeConnector.kt @@ -1,7 +1,7 @@ package com.bumble.appyx.utils.interop.rx3.connectable import android.annotation.SuppressLint -import com.bumble.appyx.navigation.lifecycle.CommonLifecycle +import com.bumble.appyx.navigation.lifecycle.Lifecycle import com.bumble.appyx.navigation.lifecycle.subscribe import com.jakewharton.rxrelay3.PublishRelay import com.jakewharton.rxrelay3.Relay @@ -30,7 +30,7 @@ class NodeConnector( } - override fun onCreate(lifecycle: CommonLifecycle) { + override fun onCreate(lifecycle: Lifecycle) { lifecycle.subscribe(onCreate = { flushOutputCache() }) } diff --git a/utils/interop-rx3/src/test/kotlin/com/bumble/appyx/utils/interop/rx3/connectable/Rx3NodeConnectorTest.kt b/utils/interop-rx3/src/test/kotlin/com/bumble/appyx/utils/interop/rx3/connectable/Rx3NodeConnectorTest.kt index fe60d98bd..7665cf17f 100644 --- a/utils/interop-rx3/src/test/kotlin/com/bumble/appyx/utils/interop/rx3/connectable/Rx3NodeConnectorTest.kt +++ b/utils/interop-rx3/src/test/kotlin/com/bumble/appyx/utils/interop/rx3/connectable/Rx3NodeConnectorTest.kt @@ -1,8 +1,7 @@ package com.bumble.appyx.utils.interop.rx3.connectable -import androidx.lifecycle.Lifecycle -import com.bumble.appyx.navigation.lifecycle.CommonLifecycle import com.bumble.appyx.navigation.lifecycle.DefaultPlatformLifecycleObserver +import com.bumble.appyx.navigation.lifecycle.Lifecycle import com.bumble.appyx.navigation.lifecycle.PlatformLifecycleObserver import com.bumble.appyx.navigation.platform.toCommonState import com.bumble.appyx.utils.interop.rx3.connectable.Rx3NodeConnectorTest.Output.Output1 @@ -24,17 +23,18 @@ internal class Rx3NodeConnectorTest { private val firstTestObserver = TestObserver() private val secondTestObserver = TestObserver() - private var lifecycleState = Lifecycle.State.CREATED + private var lifecycleState = androidx.lifecycle.Lifecycle.State.CREATED - private val lifecycle = object : CommonLifecycle { + private val lifecycle = object : + Lifecycle { - override val currentState: CommonLifecycle.State + override val currentState: Lifecycle.State get() = lifecycleState.toCommonState() override val coroutineScope: CoroutineScope = CoroutineScope(EmptyCoroutineContext) override fun addObserver(observer: PlatformLifecycleObserver) { - if (lifecycleState == Lifecycle.State.CREATED) { + if (lifecycleState == androidx.lifecycle.Lifecycle.State.CREATED) { (observer as DefaultPlatformLifecycleObserver).onCreate() } } diff --git a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/helper/NodeTestHelper.kt b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/helper/NodeTestHelper.kt index d3b0eeeb6..f59e33394 100644 --- a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/helper/NodeTestHelper.kt +++ b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/helper/NodeTestHelper.kt @@ -1,6 +1,6 @@ package com.bumble.appyx.utils.testing.unit.common.helper -import com.bumble.appyx.navigation.lifecycle.CommonLifecycle +import com.bumble.appyx.navigation.lifecycle.Lifecycle import com.bumble.appyx.navigation.node.Node import com.bumble.appyx.navigation.node.build @@ -15,8 +15,8 @@ open class NodeTestHelper(private val node: N) { node.build() } - fun moveTo(state: CommonLifecycle.State) { - require(state != CommonLifecycle.State.INITIALIZED) { + fun moveTo(state: Lifecycle.State) { + require(state != Lifecycle.State.INITIALIZED) { "Can't move to INITIALIZED state" } node.updateLifecycleState(state) @@ -25,16 +25,16 @@ open class NodeTestHelper(private val node: N) { /** * moves the Node to the desired state and then returns to the original state if possible */ - fun moveToStateAndCheck(state: CommonLifecycle.State, block: (N) -> Unit) { - require(state != CommonLifecycle.State.INITIALIZED) { "Can't move to INITIALIZED state" } + fun moveToStateAndCheck(state: Lifecycle.State, block: (N) -> Unit) { + require(state != Lifecycle.State.INITIALIZED) { "Can't move to INITIALIZED state" } val returnTo = when (val current = nodeLifecycle.currentState) { - CommonLifecycle.State.DESTROYED -> error("Can't move from DESTROYED state") - CommonLifecycle.State.INITIALIZED -> CommonLifecycle.State.DESTROYED - CommonLifecycle.State.CREATED, - CommonLifecycle.State.STARTED, - CommonLifecycle.State.RESUMED -> current + Lifecycle.State.DESTROYED -> error("Can't move from DESTROYED state") + Lifecycle.State.INITIALIZED -> Lifecycle.State.DESTROYED + Lifecycle.State.CREATED, + Lifecycle.State.STARTED, + Lifecycle.State.RESUMED -> current } moveTo(state) diff --git a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/helper/ParentNodeTestHelper.kt b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/helper/ParentNodeTestHelper.kt index a4d697aa8..0ed8593a2 100644 --- a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/helper/ParentNodeTestHelper.kt +++ b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/helper/ParentNodeTestHelper.kt @@ -1,7 +1,7 @@ package com.bumble.appyx.utils.testing.unit.common.helper import com.bumble.appyx.navigation.children.nodeOrNull -import com.bumble.appyx.navigation.lifecycle.CommonLifecycle +import com.bumble.appyx.navigation.lifecycle.Lifecycle import com.bumble.appyx.navigation.node.ParentNode import kotlin.test.assertEquals import kotlin.test.assertNull @@ -17,7 +17,7 @@ class ParentNodeTestHelper assertChildHasLifecycle( interactionTarget: InteractionTarget, - state: CommonLifecycle.State + state: Lifecycle.State ) { val childMap = node.children.value val key = childMap.keys.find { it.interactionTarget == interactionTarget } diff --git a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/InteropBuilderStub.kt b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/InteropBuilderStub.kt index d8c3dfd9b..e16899d2e 100644 --- a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/InteropBuilderStub.kt +++ b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/InteropBuilderStub.kt @@ -1,7 +1,7 @@ package com.bumble.appyx.utils.testing.unit.common.util import com.bumble.appyx.navigation.builder.Builder -import com.bumble.appyx.navigation.lifecycle.CommonLifecycle +import com.bumble.appyx.navigation.lifecycle.Lifecycle import com.bumble.appyx.navigation.modality.BuildContext import com.bumble.appyx.navigation.node.Node import kotlin.test.assertEquals @@ -36,7 +36,7 @@ class InteropBuilderStub

( assertTrue(lastNode != null, "Has not created any node") } - fun assertLastNodeState(state: CommonLifecycle.State) { + fun assertLastNodeState(state: Lifecycle.State) { assertCreatedNode() assertEquals(state, lastNode!!.lifecycle.currentState) } diff --git a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/InteropSimpleBuilderStub.kt b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/InteropSimpleBuilderStub.kt index 11f652d16..ed050e37f 100644 --- a/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/InteropSimpleBuilderStub.kt +++ b/utils/testing-unit-common/src/main/kotlin/com/bumble/appyx/utils/testing/unit/common/util/InteropSimpleBuilderStub.kt @@ -1,7 +1,7 @@ package com.bumble.appyx.utils.testing.unit.common.util import com.bumble.appyx.navigation.builder.SimpleBuilder -import com.bumble.appyx.navigation.lifecycle.CommonLifecycle +import com.bumble.appyx.navigation.lifecycle.Lifecycle import com.bumble.appyx.navigation.modality.BuildContext import com.bumble.appyx.navigation.node.Node import kotlin.test.assertEquals @@ -23,7 +23,7 @@ class InteropSimpleBuilderStub( assertTrue(lastNode != null, "Has not created any node") } - fun assertLastNodeState(state: CommonLifecycle.State) { + fun assertLastNodeState(state: Lifecycle.State) { assertCreatedNode() assertEquals(state, lastNode!!.lifecycle.currentState) } From 7a7eb713aff666b5c161b6c35e22f4b806bdf505 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Tue, 13 Jun 2023 15:24:50 +0100 Subject: [PATCH 55/94] fixed test annotation --- .../store/RetainedInstanceStoreTest.kt | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/appyx-navigation/common/src/commonTest/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreTest.kt b/appyx-navigation/common/src/commonTest/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreTest.kt index 518ee87dd..27533a3dd 100644 --- a/appyx-navigation/common/src/commonTest/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreTest.kt +++ b/appyx-navigation/common/src/commonTest/kotlin/com/bumble/appyx/navigation/store/RetainedInstanceStoreTest.kt @@ -1,5 +1,6 @@ package com.bumble.appyx.navigation.store +import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFalse @@ -36,18 +37,20 @@ class RetainedInstanceStoreTest { assertFalse(factoryCalled) } -@Ignore(This test requires reflection so can only be executed in JVM builds. TODO: move to desktop or android only tests, not common test") -@Test -// fun GIVEN_two_objects_with_different_types_stored_WHEN_get_with_same_identifier_THEN_both_objects_returned() { -// store.get(storeId, key) { 1 } -// store.get(storeId, key) { 2L } -// -// val integerValue = store.get(storeId, key) { 5 } -// val longValue = store.get(storeId, key) { 6L } -// -// assertEquals(1, integerValue) -// assertEquals(2L, longValue) -// } + // This test requires reflection so can only be executed in JVM builds. + // TODO: move to desktop or android only tests, not common test + @Ignore + @Test + fun GIVEN_two_objects_with_different_types_stored_WHEN_get_with_same_identifier_THEN_both_objects_returned() { + store.get(storeId, key) { 1 } + store.get(storeId, key) { 2L } + + val integerValue = store.get(storeId, key) { 5 } + val longValue = store.get(storeId, key) { 6L } + + assertEquals(1, integerValue) + assertEquals(2L, longValue) + } @Test fun GIVEN_two_objects_stored_with_same_type_AND_different_keys_WHEN_get_with_same_identifier_THEN_both_objects_returned() { From ae5f189b0053c5b8d798195ec434dd7618764b57 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Wed, 14 Jun 2023 10:45:18 +0100 Subject: [PATCH 56/94] added Android platform NodeHost constructor to avoid needing to reference LocalConfiguration manually --- .../appyx/navigation/AppyxTestScenario.kt | 7 ---- .../navigation/integration/AndroidNodeHost.kt | 40 +++++++++++++++++++ .../bumble/appyx/navigation/MainActivity.kt | 7 ---- .../compose/ComposeNavigationRoot.kt | 6 --- .../testing/ui/rules/AppyxActivityTestRule.kt | 7 ---- 5 files changed, 40 insertions(+), 27 deletions(-) create mode 100644 appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/integration/AndroidNodeHost.kt diff --git a/appyx-navigation/android/src/androidTest/kotlin/com/bumble/appyx/navigation/AppyxTestScenario.kt b/appyx-navigation/android/src/androidTest/kotlin/com/bumble/appyx/navigation/AppyxTestScenario.kt index 767f541dc..bb406ac13 100644 --- a/appyx-navigation/android/src/androidTest/kotlin/com/bumble/appyx/navigation/AppyxTestScenario.kt +++ b/appyx-navigation/android/src/androidTest/kotlin/com/bumble/appyx/navigation/AppyxTestScenario.kt @@ -2,15 +2,12 @@ package com.bumble.appyx.navigation import androidx.annotation.WorkerThread import androidx.compose.runtime.Composable -import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.test.junit4.ComposeTestRule import androidx.compose.ui.test.junit4.createEmptyComposeRule -import androidx.compose.ui.unit.dp import androidx.test.core.app.ActivityScenario import com.bumble.appyx.navigation.integration.NodeFactory import com.bumble.appyx.navigation.integration.NodeHost -import com.bumble.appyx.navigation.integration.ScreenSize import com.bumble.appyx.navigation.node.Node import com.bumble.appyx.navigation.platform.AndroidLifecycle import com.bumble.appyx.utils.testing.ui.rules.AppyxTestActivity @@ -32,10 +29,6 @@ class AppyxTestScenario( NodeHost( lifecycle = AndroidLifecycle(LocalLifecycleOwner.current.lifecycle), integrationPoint = activity.appyxIntegrationPoint, - screenSize = ScreenSize( - LocalConfiguration.current.screenWidthDp.dp, - LocalConfiguration.current.screenHeightDp.dp, - ), ) { buildContext -> node = nodeFactory.create(buildContext) awaitNode.countDown() diff --git a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/integration/AndroidNodeHost.kt b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/integration/AndroidNodeHost.kt new file mode 100644 index 000000000..15ac3ea84 --- /dev/null +++ b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/integration/AndroidNodeHost.kt @@ -0,0 +1,40 @@ +package com.bumble.appyx.navigation.integration + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalConfiguration +import androidx.compose.ui.unit.dp +import com.bumble.appyx.navigation.integrationpoint.IntegrationPoint +import com.bumble.appyx.navigation.lifecycle.Lifecycle +import com.bumble.appyx.navigation.node.Node +import com.bumble.appyx.utils.customisations.NodeCustomisationDirectory +import com.bumble.appyx.utils.customisations.NodeCustomisationDirectoryImpl + + +/** + * Composable function to host [Node]. + * + * Aligns lifecycle and manages state restoration. + */ +@Suppress("ComposableParamOrder") // detekt complains as 'factory' param isn't a pure lambda +@Composable +fun NodeHost( + lifecycle: Lifecycle, + integrationPoint: IntegrationPoint, + modifier: Modifier = Modifier, + customisations: NodeCustomisationDirectory = remember { NodeCustomisationDirectoryImpl() }, + factory: NodeFactory +) { + NodeHost( + lifecycle = lifecycle, + integrationPoint = integrationPoint, + modifier = modifier, + customisations = customisations, + screenSize = ScreenSize( + LocalConfiguration.current.screenWidthDp.dp, + LocalConfiguration.current.screenHeightDp.dp, + ), + factory = factory, + ) +} \ No newline at end of file diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/MainActivity.kt b/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/MainActivity.kt index 559d10341..cf85a6036 100644 --- a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/MainActivity.kt +++ b/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/MainActivity.kt @@ -8,14 +8,11 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.runtime.Composable import androidx.compose.ui.ExperimentalComposeUiApi -import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.ExperimentalUnitApi -import androidx.compose.ui.unit.dp import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import com.bumble.appyx.navigation.integration.NodeHost -import com.bumble.appyx.navigation.integration.ScreenSize import com.bumble.appyx.navigation.integrationpoint.NodeActivity import com.bumble.appyx.navigation.modality.BuildContext import com.bumble.appyx.navigation.node.container.ContainerNode @@ -38,10 +35,6 @@ class MainActivity : NodeActivity() { NodeHost( AndroidLifecycle(LocalLifecycleOwner.current.lifecycle), integrationPoint = appyxIntegrationPoint, - screenSize = ScreenSize( - LocalConfiguration.current.screenWidthDp.dp, - LocalConfiguration.current.screenHeightDp.dp, - ), ) { ContainerNode( buildContext = it, diff --git a/demos/navigation-compose/src/main/kotlin/com/bumble/appyx/sample/navigtion/compose/ComposeNavigationRoot.kt b/demos/navigation-compose/src/main/kotlin/com/bumble/appyx/sample/navigtion/compose/ComposeNavigationRoot.kt index 370061cc8..aa2c9d425 100644 --- a/demos/navigation-compose/src/main/kotlin/com/bumble/appyx/sample/navigtion/compose/ComposeNavigationRoot.kt +++ b/demos/navigation-compose/src/main/kotlin/com/bumble/appyx/sample/navigtion/compose/ComposeNavigationRoot.kt @@ -12,14 +12,12 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.unit.dp import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.compose.rememberNavController import com.bumble.appyx.navigation.integration.NodeHost -import com.bumble.appyx.navigation.integration.ScreenSize import com.bumble.appyx.navigation.integrationpoint.LocalIntegrationPoint import com.bumble.appyx.navigation.platform.AndroidLifecycle @@ -74,10 +72,6 @@ internal fun AppyxRoute(onGoogleNavigationClick: () -> Unit) { NodeHost( lifecycle = AndroidLifecycle(LocalLifecycleOwner.current.lifecycle), integrationPoint = LocalIntegrationPoint.current, - screenSize = ScreenSize( - LocalConfiguration.current.screenWidthDp.dp, - LocalConfiguration.current.screenHeightDp.dp, - ), ) { ComposeNavigationContainerNode( buildContext = it, diff --git a/utils/testing-ui/src/main/kotlin/com/bumble/appyx/utils/testing/ui/rules/AppyxActivityTestRule.kt b/utils/testing-ui/src/main/kotlin/com/bumble/appyx/utils/testing/ui/rules/AppyxActivityTestRule.kt index 25e1a3b87..e17b5eaf9 100644 --- a/utils/testing-ui/src/main/kotlin/com/bumble/appyx/utils/testing/ui/rules/AppyxActivityTestRule.kt +++ b/utils/testing-ui/src/main/kotlin/com/bumble/appyx/utils/testing/ui/rules/AppyxActivityTestRule.kt @@ -2,15 +2,12 @@ package com.bumble.appyx.utils.testing.ui.rules import androidx.annotation.CallSuper import androidx.compose.runtime.Composable -import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.test.junit4.ComposeTestRule import androidx.compose.ui.test.junit4.createEmptyComposeRule -import androidx.compose.ui.unit.dp import androidx.test.rule.ActivityTestRule import com.bumble.appyx.navigation.integration.NodeFactory import com.bumble.appyx.navigation.integration.NodeHost -import com.bumble.appyx.navigation.integration.ScreenSize import com.bumble.appyx.navigation.node.Node import com.bumble.appyx.navigation.platform.AndroidLifecycle import org.junit.rules.TestRule @@ -52,10 +49,6 @@ open class AppyxActivityTestRule( NodeHost( lifecycle = AndroidLifecycle(LocalLifecycleOwner.current.lifecycle), integrationPoint = activity.appyxIntegrationPoint, - screenSize = ScreenSize( - LocalConfiguration.current.screenWidthDp.dp, - LocalConfiguration.current.screenHeightDp.dp, - ), ) { buildContext -> node = nodeFactory.create(buildContext) node From 943c94147487cdd00eace96212d7f4add8587a35 Mon Sep 17 00:00:00 2001 From: JeremyStevens Date: Thu, 22 Jun 2023 16:58:09 +0100 Subject: [PATCH 57/94] moved demos/appyx-navigation into demos/appyx-navigation/android --- .../appyx-navigation/{ => android}/build.gradle.kts | 0 demos/appyx-navigation/{ => android}/debug.keystore | Bin .../{ => android}/detekt-baseline.xml | 0 demos/appyx-navigation/{ => android}/detekt.yml | 0 .../{ => android}/lint-baseline.xml | 0 demos/appyx-navigation/{ => android}/lint.xml | 0 .../{ => android}/proguard-rules.pro | 0 .../{ => android}/src/main/AndroidManifest.xml | 0 .../main/kotlin/com/bumble/appyx/navigation/Ext.kt | 0 .../com/bumble/appyx/navigation/MainActivity.kt | 0 .../appyx/navigation/composable/KnobControl.kt | 0 .../node/backstack/BackStackExamplesNode.kt | 0 .../navigation/node/backstack/BackStackNode.kt | 0 .../node/backstack/debug/BackstackDebugNode.kt | 0 .../navigation/node/container/ContainerNode.kt | 0 .../navigation/node/datingcards/DatingCardsNode.kt | 0 .../appyx/navigation/node/datingcards/Profile.kt | 0 .../node/permanentchild/PermanentChildNode.kt | 0 .../navigation/node/profilecard/ProfileCardNode.kt | 0 .../appyx/navigation/node/promoter/PromoterNode.kt | 0 .../navigation/node/spotlight/SpotlightNode.kt | 0 .../node/spotlight/debug/SpotlightDebugNode.kt | 0 .../kotlin/com/bumble/appyx/navigation/ui/Color.kt | 0 .../bumble/appyx/navigation/ui/MaterialColors.kt | 0 .../kotlin/com/bumble/appyx/navigation/ui/Shape.kt | 0 .../com/bumble/appyx/navigation/ui/TextButton.kt | 0 .../kotlin/com/bumble/appyx/navigation/ui/Theme.kt | 0 .../kotlin/com/bumble/appyx/navigation/ui/Type.kt | 0 .../{ => android}/src/main/res/drawable/appyx.xml | 0 .../src/main/res/values-night/themes.xml | 2 +- .../{ => android}/src/main/res/values/colors.xml | 0 .../{ => android}/src/main/res/values/strings.xml | 0 .../{ => android}/src/main/res/values/themes.xml | 0 settings.gradle.kts | 2 +- 34 files changed, 2 insertions(+), 2 deletions(-) rename demos/appyx-navigation/{ => android}/build.gradle.kts (100%) rename demos/appyx-navigation/{ => android}/debug.keystore (100%) rename demos/appyx-navigation/{ => android}/detekt-baseline.xml (100%) rename demos/appyx-navigation/{ => android}/detekt.yml (100%) rename demos/appyx-navigation/{ => android}/lint-baseline.xml (100%) rename demos/appyx-navigation/{ => android}/lint.xml (100%) rename demos/appyx-navigation/{ => android}/proguard-rules.pro (100%) rename demos/appyx-navigation/{ => android}/src/main/AndroidManifest.xml (100%) rename demos/appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/Ext.kt (100%) rename demos/appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/MainActivity.kt (100%) rename demos/appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/composable/KnobControl.kt (100%) rename demos/appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/node/backstack/BackStackExamplesNode.kt (100%) rename demos/appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/node/backstack/BackStackNode.kt (100%) rename demos/appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/node/backstack/debug/BackstackDebugNode.kt (100%) rename demos/appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/node/container/ContainerNode.kt (100%) rename demos/appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/node/datingcards/DatingCardsNode.kt (100%) rename demos/appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/node/datingcards/Profile.kt (100%) rename demos/appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/node/permanentchild/PermanentChildNode.kt (100%) rename demos/appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/node/profilecard/ProfileCardNode.kt (100%) rename demos/appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/node/promoter/PromoterNode.kt (100%) rename demos/appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/node/spotlight/SpotlightNode.kt (100%) rename demos/appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/node/spotlight/debug/SpotlightDebugNode.kt (100%) rename demos/appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/ui/Color.kt (100%) rename demos/appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/ui/MaterialColors.kt (100%) rename demos/appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/ui/Shape.kt (100%) rename demos/appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/ui/TextButton.kt (100%) rename demos/appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/ui/Theme.kt (100%) rename demos/appyx-navigation/{ => android}/src/main/kotlin/com/bumble/appyx/navigation/ui/Type.kt (100%) rename demos/appyx-navigation/{ => android}/src/main/res/drawable/appyx.xml (100%) rename demos/appyx-navigation/{ => android}/src/main/res/values-night/themes.xml (95%) rename demos/appyx-navigation/{ => android}/src/main/res/values/colors.xml (100%) rename demos/appyx-navigation/{ => android}/src/main/res/values/strings.xml (100%) rename demos/appyx-navigation/{ => android}/src/main/res/values/themes.xml (100%) diff --git a/demos/appyx-navigation/build.gradle.kts b/demos/appyx-navigation/android/build.gradle.kts similarity index 100% rename from demos/appyx-navigation/build.gradle.kts rename to demos/appyx-navigation/android/build.gradle.kts diff --git a/demos/appyx-navigation/debug.keystore b/demos/appyx-navigation/android/debug.keystore similarity index 100% rename from demos/appyx-navigation/debug.keystore rename to demos/appyx-navigation/android/debug.keystore diff --git a/demos/appyx-navigation/detekt-baseline.xml b/demos/appyx-navigation/android/detekt-baseline.xml similarity index 100% rename from demos/appyx-navigation/detekt-baseline.xml rename to demos/appyx-navigation/android/detekt-baseline.xml diff --git a/demos/appyx-navigation/detekt.yml b/demos/appyx-navigation/android/detekt.yml similarity index 100% rename from demos/appyx-navigation/detekt.yml rename to demos/appyx-navigation/android/detekt.yml diff --git a/demos/appyx-navigation/lint-baseline.xml b/demos/appyx-navigation/android/lint-baseline.xml similarity index 100% rename from demos/appyx-navigation/lint-baseline.xml rename to demos/appyx-navigation/android/lint-baseline.xml diff --git a/demos/appyx-navigation/lint.xml b/demos/appyx-navigation/android/lint.xml similarity index 100% rename from demos/appyx-navigation/lint.xml rename to demos/appyx-navigation/android/lint.xml diff --git a/demos/appyx-navigation/proguard-rules.pro b/demos/appyx-navigation/android/proguard-rules.pro similarity index 100% rename from demos/appyx-navigation/proguard-rules.pro rename to demos/appyx-navigation/android/proguard-rules.pro diff --git a/demos/appyx-navigation/src/main/AndroidManifest.xml b/demos/appyx-navigation/android/src/main/AndroidManifest.xml similarity index 100% rename from demos/appyx-navigation/src/main/AndroidManifest.xml rename to demos/appyx-navigation/android/src/main/AndroidManifest.xml diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/Ext.kt b/demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/Ext.kt similarity index 100% rename from demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/Ext.kt rename to demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/Ext.kt diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/MainActivity.kt b/demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/MainActivity.kt similarity index 100% rename from demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/MainActivity.kt rename to demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/MainActivity.kt diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/composable/KnobControl.kt b/demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/composable/KnobControl.kt similarity index 100% rename from demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/composable/KnobControl.kt rename to demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/composable/KnobControl.kt diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/node/backstack/BackStackExamplesNode.kt b/demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/backstack/BackStackExamplesNode.kt similarity index 100% rename from demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/node/backstack/BackStackExamplesNode.kt rename to demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/backstack/BackStackExamplesNode.kt diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/node/backstack/BackStackNode.kt b/demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/backstack/BackStackNode.kt similarity index 100% rename from demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/node/backstack/BackStackNode.kt rename to demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/backstack/BackStackNode.kt diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/node/backstack/debug/BackstackDebugNode.kt b/demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/backstack/debug/BackstackDebugNode.kt similarity index 100% rename from demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/node/backstack/debug/BackstackDebugNode.kt rename to demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/backstack/debug/BackstackDebugNode.kt diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/node/container/ContainerNode.kt b/demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/container/ContainerNode.kt similarity index 100% rename from demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/node/container/ContainerNode.kt rename to demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/container/ContainerNode.kt diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/node/datingcards/DatingCardsNode.kt b/demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/datingcards/DatingCardsNode.kt similarity index 100% rename from demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/node/datingcards/DatingCardsNode.kt rename to demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/datingcards/DatingCardsNode.kt diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/node/datingcards/Profile.kt b/demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/datingcards/Profile.kt similarity index 100% rename from demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/node/datingcards/Profile.kt rename to demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/datingcards/Profile.kt diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/node/permanentchild/PermanentChildNode.kt b/demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/permanentchild/PermanentChildNode.kt similarity index 100% rename from demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/node/permanentchild/PermanentChildNode.kt rename to demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/permanentchild/PermanentChildNode.kt diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/node/profilecard/ProfileCardNode.kt b/demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/profilecard/ProfileCardNode.kt similarity index 100% rename from demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/node/profilecard/ProfileCardNode.kt rename to demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/profilecard/ProfileCardNode.kt diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/node/promoter/PromoterNode.kt b/demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/promoter/PromoterNode.kt similarity index 100% rename from demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/node/promoter/PromoterNode.kt rename to demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/promoter/PromoterNode.kt diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/node/spotlight/SpotlightNode.kt b/demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/spotlight/SpotlightNode.kt similarity index 100% rename from demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/node/spotlight/SpotlightNode.kt rename to demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/spotlight/SpotlightNode.kt diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/node/spotlight/debug/SpotlightDebugNode.kt b/demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/spotlight/debug/SpotlightDebugNode.kt similarity index 100% rename from demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/node/spotlight/debug/SpotlightDebugNode.kt rename to demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/node/spotlight/debug/SpotlightDebugNode.kt diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/ui/Color.kt b/demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/ui/Color.kt similarity index 100% rename from demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/ui/Color.kt rename to demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/ui/Color.kt diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/ui/MaterialColors.kt b/demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/ui/MaterialColors.kt similarity index 100% rename from demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/ui/MaterialColors.kt rename to demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/ui/MaterialColors.kt diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/ui/Shape.kt b/demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/ui/Shape.kt similarity index 100% rename from demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/ui/Shape.kt rename to demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/ui/Shape.kt diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/ui/TextButton.kt b/demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/ui/TextButton.kt similarity index 100% rename from demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/ui/TextButton.kt rename to demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/ui/TextButton.kt diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/ui/Theme.kt b/demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/ui/Theme.kt similarity index 100% rename from demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/ui/Theme.kt rename to demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/ui/Theme.kt diff --git a/demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/ui/Type.kt b/demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/ui/Type.kt similarity index 100% rename from demos/appyx-navigation/src/main/kotlin/com/bumble/appyx/navigation/ui/Type.kt rename to demos/appyx-navigation/android/src/main/kotlin/com/bumble/appyx/navigation/ui/Type.kt diff --git a/demos/appyx-navigation/src/main/res/drawable/appyx.xml b/demos/appyx-navigation/android/src/main/res/drawable/appyx.xml similarity index 100% rename from demos/appyx-navigation/src/main/res/drawable/appyx.xml rename to demos/appyx-navigation/android/src/main/res/drawable/appyx.xml diff --git a/demos/appyx-navigation/src/main/res/values-night/themes.xml b/demos/appyx-navigation/android/src/main/res/values-night/themes.xml similarity index 95% rename from demos/appyx-navigation/src/main/res/values-night/themes.xml rename to demos/appyx-navigation/android/src/main/res/values-night/themes.xml index 156cbcc42..4ee3696c4 100644 --- a/demos/appyx-navigation/src/main/res/values-night/themes.xml +++ b/demos/appyx-navigation/android/src/main/res/values-night/themes.xml @@ -1,4 +1,4 @@ - +