[Architecture] split createroom feature module

This commit is contained in:
ganfra
2023-03-09 12:31:30 +01:00
parent ed2706f7ef
commit 184a68b637
20 changed files with 122 additions and 66 deletions

View File

@@ -43,7 +43,7 @@ dependencies {
implementation(projects.features.preferences.api)
implementation(projects.features.logout.api)
implementation(projects.features.onboarding.api)
implementation(projects.features.createroom)
implementation(projects.features.createroom.api)
implementation(projects.libraries.core)
implementation(projects.libraries.architecture)

View File

@@ -35,7 +35,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.createroom.CreateRoomFlowNode
import io.element.android.features.createroom.api.CreateRoomEntryPoint
import io.element.android.features.preferences.api.PreferencesEntryPoint
import io.element.android.features.roomlist.api.RoomListEntryPoint
import io.element.android.libraries.architecture.BackstackNode
@@ -57,6 +57,7 @@ class LoggedInFlowNode @AssistedInject constructor(
@Assisted plugins: List<Plugin>,
private val roomListEntryPoint: RoomListEntryPoint,
private val preferencesEntryPoint: PreferencesEntryPoint,
private val createRoomEntryPoint: CreateRoomEntryPoint,
) : BackstackNode<LoggedInFlowNode.NavTarget>(
backstack = BackStack(
initialElement = NavTarget.RoomList,
@@ -160,7 +161,7 @@ class LoggedInFlowNode @AssistedInject constructor(
.build()
}
NavTarget.CreateRoom -> {
CreateRoomFlowNode(buildContext)
createRoomEntryPoint.createNode(this, buildContext)
}
}
}

View File

@@ -1 +0,0 @@
/build

View File

@@ -0,0 +1,27 @@
/*
* 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.
*/
plugins {
id("io.element.android-library")
}
android {
namespace = "io.element.android.features.createroom.api"
}
dependencies {
implementation(projects.libraries.architecture)
}

View File

@@ -0,0 +1,21 @@
/*
* 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.createroom.api
import io.element.android.libraries.architecture.SimpleFeatureEntryPoint
interface CreateRoomEntryPoint : SimpleFeatureEntryPoint

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 New Vector Ltd
* Copyright (c) 2022 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.
@@ -18,13 +18,19 @@
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
id("io.element.android-compose-library")
alias(libs.plugins.ksp)
alias(libs.plugins.anvil)
alias(libs.plugins.ksp)
id("kotlin-parcelize")
}
android {
namespace = "io.element.android.features.createroom"
namespace = "io.element.android.features.createroom.impl"
testOptions {
unitTests {
isIncludeAndroidResources = true
}
}
}
anvil {
@@ -42,6 +48,7 @@ dependencies {
implementation(projects.libraries.designsystem)
implementation(projects.libraries.elementresources)
implementation(projects.libraries.uiStrings)
api(projects.features.createroom.api)
testImplementation(libs.test.junit)
testImplementation(libs.coroutines.test)

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.element.android.features.createroom
package io.element.android.features.createroom.impl
import android.os.Parcelable
import androidx.compose.runtime.Composable
@@ -22,22 +22,29 @@ import androidx.compose.ui.Modifier
import com.bumble.appyx.core.composable.Children
import com.bumble.appyx.core.modality.BuildContext
import com.bumble.appyx.core.node.Node
import com.bumble.appyx.core.node.ParentNode
import com.bumble.appyx.core.plugin.Plugin
import com.bumble.appyx.navmodel.backstack.BackStack
import io.element.android.features.createroom.root.CreateRoomRootNode
import dagger.assisted.Assisted
import dagger.assisted.AssistedInject
import io.element.android.anvilannotations.ContributesNode
import io.element.android.features.createroom.impl.root.CreateRoomRootNode
import io.element.android.libraries.architecture.BackstackNode
import io.element.android.libraries.architecture.animation.rememberDefaultTransitionHandler
import io.element.android.libraries.architecture.createNode
import io.element.android.libraries.di.SessionScope
import kotlinx.parcelize.Parcelize
class CreateRoomFlowNode(
buildContext: BuildContext,
private val backstack: BackStack<NavTarget> = BackStack(
@ContributesNode(SessionScope::class)
class CreateRoomFlowNode @AssistedInject constructor(
@Assisted buildContext: BuildContext,
@Assisted plugins: List<Plugin>,
) : BackstackNode<CreateRoomFlowNode.NavTarget>(
backstack = BackStack(
initialElement = NavTarget.Root,
savedStateMap = buildContext.savedStateMap,
),
) : ParentNode<CreateRoomFlowNode.NavTarget>(
navModel = backstack,
buildContext = buildContext
buildContext = buildContext,
plugins = plugins
) {
sealed interface NavTarget : Parcelable {

View File

@@ -0,0 +1,32 @@
/*
* 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.createroom.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.createroom.api.CreateRoomEntryPoint
import io.element.android.libraries.architecture.createNode
import io.element.android.libraries.di.AppScope
import javax.inject.Inject
@ContributesBinding(AppScope::class)
class DefaultCreateRoomEntryPoint @Inject constructor() : CreateRoomEntryPoint {
override fun createNode(parentNode: Node, buildContext: BuildContext): Node {
return parentNode.createNode<CreateRoomFlowNode>(buildContext)
}
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.element.android.features.createroom.root
package io.element.android.features.createroom.impl.root
sealed interface CreateRoomRootEvents {
object CreateRoom : CreateRoomRootEvents

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.element.android.features.createroom.root
package io.element.android.features.createroom.impl.root
import android.os.Parcelable
import androidx.compose.runtime.Composable

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.element.android.features.createroom.root
package io.element.android.features.createroom.impl.root
import androidx.compose.runtime.Composable
import io.element.android.libraries.architecture.Presenter

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.element.android.features.createroom.root
package io.element.android.features.createroom.impl.root
import androidx.annotation.DrawableRes
import androidx.compose.foundation.clickable

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.element.android.features.createroom.root
package io.element.android.features.createroom.impl.root
// TODO add your ui models. Remove the eventSink if you don't have events.
// Do not use default value, so no member get forgotten in the presenters.

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.element.android.features.createroom.root
package io.element.android.features.createroom.impl.root
import androidx.compose.ui.tooling.preview.PreviewParameterProvider

View File

@@ -16,12 +16,14 @@
@file:OptIn(ExperimentalCoroutinesApi::class)
package io.element.android.features.createroom.root
package io.element.android.features.createroom.impl.root
import app.cash.molecule.RecompositionClock
import app.cash.molecule.moleculeFlow
import app.cash.turbine.test
import com.google.common.truth.Truth.assertThat
import io.element.android.features.createroom.impl.root.CreateRoomRootEvents
import io.element.android.features.createroom.impl.root.CreateRoomRootPresenter
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import org.junit.Test

View File

@@ -1,21 +0,0 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ 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.
-->
<manifest>
</manifest>

View File

@@ -69,5 +69,5 @@ fun DependencyHandlerScope.allFeatures() {
implementation(project(":features:messages:impl"))
implementation(project(":features:rageshake:impl"))
implementation(project(":features:preferences:impl"))
implementation(project(":features:createroom"))
implementation(project(":features:createroom:impl"))
}

View File

@@ -80,4 +80,5 @@ include(":features:messages:api")
include(":features:messages:impl")
include(":features:login:api")
include(":features:login:impl")
include(":features:createroom")
include(":features:createroom:api")
include(":features:createroom:impl")