diff --git a/app/src/main/kotlin/io/element/android/x/node/LoggedInFlowNode.kt b/app/src/main/kotlin/io/element/android/x/node/LoggedInFlowNode.kt index ac58edbc93..a86daa5380 100644 --- a/app/src/main/kotlin/io/element/android/x/node/LoggedInFlowNode.kt +++ b/app/src/main/kotlin/io/element/android/x/node/LoggedInFlowNode.kt @@ -36,7 +36,7 @@ import com.bumble.appyx.navmodel.backstack.operation.push import dagger.assisted.Assisted import dagger.assisted.AssistedInject import io.element.android.anvilannotations.ContributesNode -import io.element.android.features.preferences.PreferencesFlowNode +import io.element.android.features.preferences.api.PreferencesEntryPoint import io.element.android.features.roomlist.api.RoomListEntryPoint import io.element.android.libraries.architecture.NodeInputs import io.element.android.libraries.architecture.animation.rememberDefaultTransitionHandler @@ -59,6 +59,7 @@ class LoggedInFlowNode( plugins: List, private val backstack: BackStack, private val roomListEntryPoint: RoomListEntryPoint, + private val preferencesEntryPoint: PreferencesEntryPoint, ) : ParentNode( navModel = backstack, buildContext = buildContext, @@ -70,10 +71,12 @@ class LoggedInFlowNode( @Assisted buildContext: BuildContext, @Assisted plugins: List, roomListEntryPoint: RoomListEntryPoint, + preferencesEntryPoint: PreferencesEntryPoint, ) : this( buildContext = buildContext, plugins = plugins, roomListEntryPoint = roomListEntryPoint, + preferencesEntryPoint = preferencesEntryPoint, backstack = BackStack( initialElement = NavTarget.RoomList, savedStateMap = buildContext.savedStateMap, @@ -149,12 +152,12 @@ class LoggedInFlowNode( } } NavTarget.Settings -> { - val callback = object : PreferencesFlowNode.Callback { + val callback = object : PreferencesEntryPoint.Callback { override fun onOpenBugReport() { plugins().forEach { it.onOpenBugReport() } } } - createNode(buildContext, plugins = listOf(callback)) + preferencesEntryPoint.node(this, buildContext, plugins = listOf(callback)) } } } diff --git a/app/src/main/kotlin/io/element/android/x/node/RoomFlowNode.kt b/app/src/main/kotlin/io/element/android/x/node/RoomFlowNode.kt index 900d0f7989..4d5c120958 100644 --- a/app/src/main/kotlin/io/element/android/x/node/RoomFlowNode.kt +++ b/app/src/main/kotlin/io/element/android/x/node/RoomFlowNode.kt @@ -42,7 +42,7 @@ import kotlinx.parcelize.Parcelize import timber.log.Timber @ContributesNode(SessionScope::class) -class RoomFlowNode( +class RoomFlowNode private constructor( buildContext: BuildContext, plugins: List, private val backstack: BackStack, diff --git a/features/login/src/main/kotlin/io/element/android/features/login/api/LoginEntryPoint.kt b/features/login/src/main/kotlin/io/element/android/features/login/api/LoginEntryPoint.kt index 6a64b459d2..59fe87007d 100644 --- a/features/login/src/main/kotlin/io/element/android/features/login/api/LoginEntryPoint.kt +++ b/features/login/src/main/kotlin/io/element/android/features/login/api/LoginEntryPoint.kt @@ -16,6 +16,6 @@ package io.element.android.features.login.api -import io.element.android.libraries.architecture.EntryPoint +import io.element.android.libraries.architecture.FeatureEntryPoint -interface LoginEntryPoint : EntryPoint +interface LoginEntryPoint : FeatureEntryPoint diff --git a/features/onboarding/src/main/kotlin/io/element/android/features/onboarding/api/OnBoardingEntryPoint.kt b/features/onboarding/src/main/kotlin/io/element/android/features/onboarding/api/OnBoardingEntryPoint.kt index b603e8d40e..8c256547c3 100644 --- a/features/onboarding/src/main/kotlin/io/element/android/features/onboarding/api/OnBoardingEntryPoint.kt +++ b/features/onboarding/src/main/kotlin/io/element/android/features/onboarding/api/OnBoardingEntryPoint.kt @@ -17,9 +17,9 @@ package io.element.android.features.onboarding.api import com.bumble.appyx.core.plugin.Plugin -import io.element.android.libraries.architecture.EntryPoint +import io.element.android.libraries.architecture.FeatureEntryPoint -interface OnBoardingEntryPoint : EntryPoint { +interface OnBoardingEntryPoint : FeatureEntryPoint { interface Callback : Plugin { fun onSignUp() fun onSignIn() diff --git a/features/preferences/src/main/kotlin/io/element/android/features/preferences/api/PreferencesEntryPoint.kt b/features/preferences/src/main/kotlin/io/element/android/features/preferences/api/PreferencesEntryPoint.kt new file mode 100644 index 0000000000..1ed5fe3823 --- /dev/null +++ b/features/preferences/src/main/kotlin/io/element/android/features/preferences/api/PreferencesEntryPoint.kt @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.element.android.features.preferences.api + +import com.bumble.appyx.core.plugin.Plugin +import io.element.android.libraries.architecture.FeatureEntryPoint + +interface PreferencesEntryPoint: FeatureEntryPoint { + interface Callback : Plugin { + fun onOpenBugReport() + } +} diff --git a/features/preferences/src/main/kotlin/io/element/android/features/preferences/impl/DefaultPreferencesEntryPoint.kt b/features/preferences/src/main/kotlin/io/element/android/features/preferences/impl/DefaultPreferencesEntryPoint.kt new file mode 100644 index 0000000000..91ba3bf0a3 --- /dev/null +++ b/features/preferences/src/main/kotlin/io/element/android/features/preferences/impl/DefaultPreferencesEntryPoint.kt @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.element.android.features.preferences.impl + +import com.bumble.appyx.core.modality.BuildContext +import com.bumble.appyx.core.node.Node +import com.bumble.appyx.core.plugin.Plugin +import com.squareup.anvil.annotations.ContributesBinding +import io.element.android.features.preferences.api.PreferencesEntryPoint +import io.element.android.libraries.architecture.createNode +import io.element.android.libraries.di.AppScope +import javax.inject.Inject + +@ContributesBinding(AppScope::class) +class DefaultPreferencesEntryPoint @Inject constructor() : PreferencesEntryPoint { + override fun node(parentNode: Node, buildContext: BuildContext, plugins: List): Node { + return parentNode.createNode(buildContext, plugins) + } +} diff --git a/features/preferences/src/main/kotlin/io/element/android/features/preferences/PreferencesFlowNode.kt b/features/preferences/src/main/kotlin/io/element/android/features/preferences/impl/PreferencesFlowNode.kt similarity index 80% rename from features/preferences/src/main/kotlin/io/element/android/features/preferences/PreferencesFlowNode.kt rename to features/preferences/src/main/kotlin/io/element/android/features/preferences/impl/PreferencesFlowNode.kt index 54eb593ee7..fa76f5b3e7 100644 --- a/features/preferences/src/main/kotlin/io/element/android/features/preferences/PreferencesFlowNode.kt +++ b/features/preferences/src/main/kotlin/io/element/android/features/preferences/impl/PreferencesFlowNode.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.features.preferences +package io.element.android.features.preferences.impl import android.os.Parcelable import androidx.compose.runtime.Composable @@ -29,7 +29,8 @@ import com.bumble.appyx.navmodel.backstack.BackStack import dagger.assisted.Assisted import dagger.assisted.AssistedInject import io.element.android.anvilannotations.ContributesNode -import io.element.android.features.preferences.root.PreferencesRootNode +import io.element.android.features.preferences.api.PreferencesEntryPoint +import io.element.android.features.preferences.impl.root.PreferencesRootNode import io.element.android.libraries.architecture.animation.rememberDefaultTransitionHandler import io.element.android.libraries.architecture.createNode import io.element.android.libraries.di.SessionScope @@ -56,16 +57,6 @@ class PreferencesFlowNode( ) ) - interface Callback : Plugin { - fun onOpenBugReport() - } - - private val preferencesRootNodeCallback = object : PreferencesRootNode.Callback { - override fun onOpenBugReport() { - plugins().forEach { it.onOpenBugReport() } - } - } - sealed interface NavTarget : Parcelable { @Parcelize object Root : NavTarget @@ -73,7 +64,14 @@ class PreferencesFlowNode( override fun resolve(navTarget: NavTarget, buildContext: BuildContext): Node { return when (navTarget) { - NavTarget.Root -> createNode(buildContext, plugins = listOf(preferencesRootNodeCallback)) + NavTarget.Root -> { + val callback = object : PreferencesRootNode.Callback { + override fun onOpenBugReport() { + plugins().forEach { it.onOpenBugReport() } + } + } + createNode(buildContext, plugins = listOf(callback)) + } } } diff --git a/features/preferences/src/main/kotlin/io/element/android/features/preferences/root/PreferencesRootNode.kt b/features/preferences/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootNode.kt similarity index 96% rename from features/preferences/src/main/kotlin/io/element/android/features/preferences/root/PreferencesRootNode.kt rename to features/preferences/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootNode.kt index cd9ed99302..36e4afab84 100644 --- a/features/preferences/src/main/kotlin/io/element/android/features/preferences/root/PreferencesRootNode.kt +++ b/features/preferences/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootNode.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.features.preferences.root +package io.element.android.features.preferences.impl.root import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier diff --git a/features/preferences/src/main/kotlin/io/element/android/features/preferences/root/PreferencesRootPresenter.kt b/features/preferences/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootPresenter.kt similarity index 96% rename from features/preferences/src/main/kotlin/io/element/android/features/preferences/root/PreferencesRootPresenter.kt rename to features/preferences/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootPresenter.kt index b9df73853c..eebc52ab36 100644 --- a/features/preferences/src/main/kotlin/io/element/android/features/preferences/root/PreferencesRootPresenter.kt +++ b/features/preferences/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootPresenter.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.features.preferences.root +package io.element.android.features.preferences.impl.root import androidx.compose.runtime.Composable import io.element.android.features.logout.LogoutPreferencePresenter diff --git a/features/preferences/src/main/kotlin/io/element/android/features/preferences/root/PreferencesRootState.kt b/features/preferences/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootState.kt similarity index 94% rename from features/preferences/src/main/kotlin/io/element/android/features/preferences/root/PreferencesRootState.kt rename to features/preferences/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootState.kt index 2bcc9fc549..38704b3674 100644 --- a/features/preferences/src/main/kotlin/io/element/android/features/preferences/root/PreferencesRootState.kt +++ b/features/preferences/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootState.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.features.preferences.root +package io.element.android.features.preferences.impl.root import io.element.android.features.logout.LogoutPreferenceState import io.element.android.features.rageshake.preferences.RageshakePreferencesState diff --git a/features/preferences/src/main/kotlin/io/element/android/features/preferences/root/PreferencesRootStateProvider.kt b/features/preferences/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootStateProvider.kt similarity index 94% rename from features/preferences/src/main/kotlin/io/element/android/features/preferences/root/PreferencesRootStateProvider.kt rename to features/preferences/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootStateProvider.kt index dc9f23afd7..619c20a047 100644 --- a/features/preferences/src/main/kotlin/io/element/android/features/preferences/root/PreferencesRootStateProvider.kt +++ b/features/preferences/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootStateProvider.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.features.preferences.root +package io.element.android.features.preferences.impl.root import io.element.android.features.logout.aLogoutPreferenceState import io.element.android.features.rageshake.preferences.aRageshakePreferencesState diff --git a/features/preferences/src/main/kotlin/io/element/android/features/preferences/root/PreferencesRootView.kt b/features/preferences/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootView.kt similarity index 95% rename from features/preferences/src/main/kotlin/io/element/android/features/preferences/root/PreferencesRootView.kt rename to features/preferences/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootView.kt index 8e84ed8ae0..39827dcd7e 100644 --- a/features/preferences/src/main/kotlin/io/element/android/features/preferences/root/PreferencesRootView.kt +++ b/features/preferences/src/main/kotlin/io/element/android/features/preferences/impl/root/PreferencesRootView.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.features.preferences.root +package io.element.android.features.preferences.impl.root import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier @@ -22,7 +22,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import io.element.android.features.logout.LogoutPreferenceView -import io.element.android.features.preferences.user.UserPreferences +import io.element.android.features.preferences.impl.user.UserPreferences import io.element.android.features.rageshake.preferences.RageshakePreferencesView import io.element.android.libraries.architecture.Async import io.element.android.libraries.designsystem.components.preferences.PreferenceView diff --git a/features/preferences/src/main/kotlin/io/element/android/features/preferences/user/UserPreferences.kt b/features/preferences/src/main/kotlin/io/element/android/features/preferences/impl/user/UserPreferences.kt similarity index 97% rename from features/preferences/src/main/kotlin/io/element/android/features/preferences/user/UserPreferences.kt rename to features/preferences/src/main/kotlin/io/element/android/features/preferences/impl/user/UserPreferences.kt index 34e0137137..5b9dda8c28 100644 --- a/features/preferences/src/main/kotlin/io/element/android/features/preferences/user/UserPreferences.kt +++ b/features/preferences/src/main/kotlin/io/element/android/features/preferences/impl/user/UserPreferences.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.features.preferences.user +package io.element.android.features.preferences.impl.user import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.height diff --git a/features/preferences/src/test/kotlin/io/element/android/features/preferences/root/PreferencesRootPresenterTest.kt b/features/preferences/src/test/kotlin/io/element/android/features/preferences/root/PreferencesRootPresenterTest.kt index 77d5ff9a07..cf303c8384 100644 --- a/features/preferences/src/test/kotlin/io/element/android/features/preferences/root/PreferencesRootPresenterTest.kt +++ b/features/preferences/src/test/kotlin/io/element/android/features/preferences/root/PreferencesRootPresenterTest.kt @@ -23,6 +23,7 @@ import app.cash.molecule.moleculeFlow import app.cash.turbine.test import com.google.common.truth.Truth.assertThat import io.element.android.features.logout.LogoutPreferencePresenter +import io.element.android.features.preferences.impl.root.PreferencesRootPresenter import io.element.android.features.rageshake.preferences.RageshakePreferencesPresenter import io.element.android.libraries.architecture.Async import io.element.android.libraries.matrixtest.FakeMatrixClient diff --git a/features/rageshake/src/main/kotlin/io/element/android/features/rageshake/bugreport/BugReportEntryPoint.kt b/features/rageshake/src/main/kotlin/io/element/android/features/rageshake/bugreport/BugReportEntryPoint.kt index 43f916328d..46a3e3bbf4 100644 --- a/features/rageshake/src/main/kotlin/io/element/android/features/rageshake/bugreport/BugReportEntryPoint.kt +++ b/features/rageshake/src/main/kotlin/io/element/android/features/rageshake/bugreport/BugReportEntryPoint.kt @@ -17,9 +17,9 @@ package io.element.android.features.rageshake.bugreport import com.bumble.appyx.core.plugin.Plugin -import io.element.android.libraries.architecture.EntryPoint +import io.element.android.libraries.architecture.FeatureEntryPoint -interface BugReportEntryPoint : EntryPoint { +interface BugReportEntryPoint : FeatureEntryPoint { interface Callback : Plugin { fun onBugReportSent() } diff --git a/features/roomlist/src/main/kotlin/io/element/android/features/roomlist/api/RoomListEntryPoint.kt b/features/roomlist/src/main/kotlin/io/element/android/features/roomlist/api/RoomListEntryPoint.kt index cadd4ea93d..5b5608c589 100644 --- a/features/roomlist/src/main/kotlin/io/element/android/features/roomlist/api/RoomListEntryPoint.kt +++ b/features/roomlist/src/main/kotlin/io/element/android/features/roomlist/api/RoomListEntryPoint.kt @@ -17,10 +17,10 @@ package io.element.android.features.roomlist.api import com.bumble.appyx.core.plugin.Plugin -import io.element.android.libraries.architecture.EntryPoint +import io.element.android.libraries.architecture.FeatureEntryPoint import io.element.android.libraries.matrix.core.RoomId -interface RoomListEntryPoint : EntryPoint { +interface RoomListEntryPoint : FeatureEntryPoint { interface Callback : Plugin { fun onRoomClicked(roomId: RoomId) fun onSettingsClicked() diff --git a/libraries/architecture/src/main/kotlin/io/element/android/libraries/architecture/EntryPoint.kt b/libraries/architecture/src/main/kotlin/io/element/android/libraries/architecture/FeatureEntryPoint.kt similarity index 96% rename from libraries/architecture/src/main/kotlin/io/element/android/libraries/architecture/EntryPoint.kt rename to libraries/architecture/src/main/kotlin/io/element/android/libraries/architecture/FeatureEntryPoint.kt index 4330b67e7e..974d3d553c 100644 --- a/libraries/architecture/src/main/kotlin/io/element/android/libraries/architecture/EntryPoint.kt +++ b/libraries/architecture/src/main/kotlin/io/element/android/libraries/architecture/FeatureEntryPoint.kt @@ -20,6 +20,6 @@ import com.bumble.appyx.core.modality.BuildContext import com.bumble.appyx.core.node.Node import com.bumble.appyx.core.plugin.Plugin -interface EntryPoint { +interface FeatureEntryPoint { fun node(parentNode: Node, buildContext: BuildContext, plugins: List = emptyList()): Node }