diff --git a/appnav/src/main/kotlin/io/element/android/appnav/room/RoomFlowNode.kt b/appnav/src/main/kotlin/io/element/android/appnav/room/RoomFlowNode.kt index beef8a883c..7149937e7e 100644 --- a/appnav/src/main/kotlin/io/element/android/appnav/room/RoomFlowNode.kt +++ b/appnav/src/main/kotlin/io/element/android/appnav/room/RoomFlowNode.kt @@ -34,16 +34,15 @@ import com.bumble.appyx.navmodel.backstack.operation.newRoot import dagger.assisted.Assisted import dagger.assisted.AssistedInject import io.element.android.anvilannotations.ContributesNode -import io.element.android.appnav.room.join.JoinRoomNode import io.element.android.appnav.room.joined.JoinedRoomFlowNode import io.element.android.appnav.room.joined.JoinedRoomLoadedFlowNode +import io.element.android.features.joinroom.api.JoinRoomEntryPoint import io.element.android.libraries.architecture.BackstackView import io.element.android.libraries.architecture.BaseFlowNode import io.element.android.libraries.architecture.NodeInputs import io.element.android.libraries.architecture.createNode import io.element.android.libraries.architecture.inputs import io.element.android.libraries.designsystem.theme.components.CircularProgressIndicator -import io.element.android.libraries.designsystem.theme.components.Text import io.element.android.libraries.di.SessionScope import io.element.android.libraries.matrix.api.core.RoomId import io.element.android.libraries.matrix.api.room.CurrentUserMembership @@ -64,6 +63,7 @@ class RoomFlowNode @AssistedInject constructor( @Assisted plugins: List, private val roomListService: RoomListService, private val roomMembershipObserver: RoomMembershipObserver, + private val joinRoomEntryPoint: JoinRoomEntryPoint, ) : BaseFlowNode( backstack = BackStack( initialElement = NavTarget.Loading, @@ -118,8 +118,8 @@ class RoomFlowNode @AssistedInject constructor( return when (navTarget) { NavTarget.Loading -> loadingNode(buildContext) NavTarget.JoinRoom -> { - val inputs = JoinRoomNode.Inputs(inputs.roomId) - createNode(buildContext, plugins = listOf(inputs)) + val inputs = JoinRoomEntryPoint.Inputs(inputs.roomId) + joinRoomEntryPoint.createNode(this, buildContext, inputs) } NavTarget.JoinedRoom -> { val roomFlowNodeCallback = plugins() diff --git a/features/joinroom/api/build.gradle.kts b/features/joinroom/api/build.gradle.kts new file mode 100644 index 0000000000..697dc5deee --- /dev/null +++ b/features/joinroom/api/build.gradle.kts @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 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. + */ + +plugins { + id("io.element.android-library") +} + +android { + namespace = "io.element.android.features.joinroom.api" +} + +dependencies { + implementation(projects.libraries.architecture) + implementation(projects.libraries.matrix.api) +} diff --git a/features/joinroom/api/src/main/kotlin/io/element/android/features/joinroom/api/JoinRoomEntryPoint.kt b/features/joinroom/api/src/main/kotlin/io/element/android/features/joinroom/api/JoinRoomEntryPoint.kt new file mode 100644 index 0000000000..50dc1010d8 --- /dev/null +++ b/features/joinroom/api/src/main/kotlin/io/element/android/features/joinroom/api/JoinRoomEntryPoint.kt @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 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.joinroom.api + +import com.bumble.appyx.core.modality.BuildContext +import com.bumble.appyx.core.node.Node +import io.element.android.libraries.architecture.FeatureEntryPoint +import io.element.android.libraries.architecture.NodeInputs +import io.element.android.libraries.matrix.api.core.RoomId + +interface JoinRoomEntryPoint : FeatureEntryPoint { + + fun createNode(parentNode: Node, buildContext: BuildContext, inputs: Inputs): Node + + data class Inputs( + val roomId: RoomId, + ) : NodeInputs +} + diff --git a/features/joinroom/impl/build.gradle.kts b/features/joinroom/impl/build.gradle.kts new file mode 100644 index 0000000000..047bc1d960 --- /dev/null +++ b/features/joinroom/impl/build.gradle.kts @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 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. + */ + +@Suppress("DSL_SCOPE_VIOLATION") +plugins { + id("io.element.android-compose-library") + alias(libs.plugins.anvil) + alias(libs.plugins.ksp) + id("kotlin-parcelize") +} + +android { + namespace = "io.element.android.features.joinroom.impl" +} + +anvil { + generateDaggerFactories.set(true) +} + +dependencies { + implementation(projects.anvilannotations) + anvil(projects.anvilcodegen) + api(projects.features.joinroom.api) + implementation(projects.libraries.core) + implementation(projects.libraries.architecture) + implementation(projects.libraries.matrix.api) + implementation(projects.libraries.matrixui) + implementation(projects.libraries.designsystem) + implementation(projects.features.invite.api) + implementation(projects.libraries.uiStrings) + + + testImplementation(libs.test.junit) + testImplementation(libs.coroutines.test) + testImplementation(libs.molecule.runtime) + testImplementation(libs.test.truth) + testImplementation(libs.test.turbine) + testImplementation(projects.libraries.matrix.test) + + ksp(libs.showkase.processor) +} diff --git a/features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/DefaultJoinRoomEntryPoint.kt b/features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/DefaultJoinRoomEntryPoint.kt new file mode 100644 index 0000000000..ab2745a63f --- /dev/null +++ b/features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/DefaultJoinRoomEntryPoint.kt @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 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.joinroom.impl + +import com.bumble.appyx.core.modality.BuildContext +import com.bumble.appyx.core.node.Node +import com.squareup.anvil.annotations.ContributesBinding +import io.element.android.features.joinroom.api.JoinRoomEntryPoint +import io.element.android.libraries.architecture.createNode +import io.element.android.libraries.di.AppScope +import javax.inject.Inject + +@ContributesBinding(AppScope::class) +class DefaultJoinRoomEntryPoint @Inject constructor() : JoinRoomEntryPoint { + + override fun createNode(parentNode: Node, buildContext: BuildContext, inputs: JoinRoomEntryPoint.Inputs): Node { + return parentNode.createNode( + buildContext = buildContext, + plugins = listOf(inputs) + ) + } +} diff --git a/appnav/src/main/kotlin/io/element/android/appnav/room/join/JoinRoomEvents.kt b/features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomEvents.kt similarity index 93% rename from appnav/src/main/kotlin/io/element/android/appnav/room/join/JoinRoomEvents.kt rename to features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomEvents.kt index 7679e77c63..e3dc73f505 100644 --- a/appnav/src/main/kotlin/io/element/android/appnav/room/join/JoinRoomEvents.kt +++ b/features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomEvents.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.appnav.room.join +package io.element.android.features.joinroom.impl sealed interface JoinRoomEvents { data object JoinRoom: JoinRoomEvents diff --git a/appnav/src/main/kotlin/io/element/android/appnav/room/join/JoinRoomNode.kt b/features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomNode.kt similarity index 87% rename from appnav/src/main/kotlin/io/element/android/appnav/room/join/JoinRoomNode.kt rename to features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomNode.kt index 3574b37e2d..a0dcf7a52c 100644 --- a/appnav/src/main/kotlin/io/element/android/appnav/room/join/JoinRoomNode.kt +++ b/features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomNode.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.appnav.room.join +package io.element.android.features.joinroom.impl import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier @@ -25,10 +25,9 @@ import dagger.assisted.Assisted import dagger.assisted.AssistedInject import io.element.android.anvilannotations.ContributesNode import io.element.android.features.invite.api.response.AcceptDeclineInviteView -import io.element.android.libraries.architecture.NodeInputs +import io.element.android.features.joinroom.api.JoinRoomEntryPoint import io.element.android.libraries.architecture.inputs import io.element.android.libraries.di.SessionScope -import io.element.android.libraries.matrix.api.core.RoomId @ContributesNode(SessionScope::class) class JoinRoomNode @AssistedInject constructor( @@ -38,11 +37,7 @@ class JoinRoomNode @AssistedInject constructor( private val acceptDeclineInviteView: AcceptDeclineInviteView, ) : Node(buildContext, plugins = plugins) { - data class Inputs( - val roomId: RoomId, - ) : NodeInputs - - private val inputs: Inputs = inputs() + private val inputs: JoinRoomEntryPoint.Inputs = inputs() private val presenter = presenterFactory.create(inputs.roomId) @Composable diff --git a/appnav/src/main/kotlin/io/element/android/appnav/room/join/JoinRoomPresenter.kt b/features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomPresenter.kt similarity index 98% rename from appnav/src/main/kotlin/io/element/android/appnav/room/join/JoinRoomPresenter.kt rename to features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomPresenter.kt index 60a59652bf..d74ec9d75b 100644 --- a/appnav/src/main/kotlin/io/element/android/appnav/room/join/JoinRoomPresenter.kt +++ b/features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomPresenter.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.appnav.room.join +package io.element.android.features.joinroom.impl import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState diff --git a/appnav/src/main/kotlin/io/element/android/appnav/room/join/JoinRoomState.kt b/features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomState.kt similarity index 97% rename from appnav/src/main/kotlin/io/element/android/appnav/room/join/JoinRoomState.kt rename to features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomState.kt index ca9f71baba..2437a76b3e 100644 --- a/appnav/src/main/kotlin/io/element/android/appnav/room/join/JoinRoomState.kt +++ b/features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomState.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.appnav.room.join +package io.element.android.features.joinroom.impl import androidx.compose.runtime.Immutable import io.element.android.features.invite.api.response.AcceptDeclineInviteState diff --git a/appnav/src/main/kotlin/io/element/android/appnav/room/join/JoinRoomStateProvider.kt b/features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomStateProvider.kt similarity index 97% rename from appnav/src/main/kotlin/io/element/android/appnav/room/join/JoinRoomStateProvider.kt rename to features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomStateProvider.kt index 6ac24cbdcb..063f8b1315 100644 --- a/appnav/src/main/kotlin/io/element/android/appnav/room/join/JoinRoomStateProvider.kt +++ b/features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomStateProvider.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.appnav.room.join +package io.element.android.features.joinroom.impl import androidx.compose.ui.tooling.preview.PreviewParameterProvider import io.element.android.features.invite.api.response.AcceptDeclineInviteState diff --git a/appnav/src/main/kotlin/io/element/android/appnav/room/join/JoinRoomView.kt b/features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomView.kt similarity index 99% rename from appnav/src/main/kotlin/io/element/android/appnav/room/join/JoinRoomView.kt rename to features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomView.kt index eff9181c11..e803c8315c 100644 --- a/appnav/src/main/kotlin/io/element/android/appnav/room/join/JoinRoomView.kt +++ b/features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomView.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.appnav.room.join +package io.element.android.features.joinroom.impl import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement diff --git a/appnav/src/main/kotlin/io/element/android/appnav/room/join/di/JoinRoomModule.kt b/features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/di/JoinRoomModule.kt similarity index 93% rename from appnav/src/main/kotlin/io/element/android/appnav/room/join/di/JoinRoomModule.kt rename to features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/di/JoinRoomModule.kt index 15b7f72ef0..b4fc45ca18 100644 --- a/appnav/src/main/kotlin/io/element/android/appnav/room/join/di/JoinRoomModule.kt +++ b/features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/di/JoinRoomModule.kt @@ -14,13 +14,13 @@ * limitations under the License. */ -package io.element.android.appnav.room.join.di +package io.element.android.features.joinroom.impl.di import com.squareup.anvil.annotations.ContributesTo import dagger.Module import dagger.Provides -import io.element.android.appnav.room.join.JoinRoomPresenter import io.element.android.features.invite.api.response.AcceptDeclineInvitePresenter +import io.element.android.features.joinroom.impl.JoinRoomPresenter import io.element.android.libraries.di.SessionScope import io.element.android.libraries.matrix.api.MatrixClient import io.element.android.libraries.matrix.api.core.RoomId