Browse Source

[Architecture] split createroom feature module

misc/jme/add-logging-to-state-machine
ganfra 2 years ago
parent
commit
bea510f432
  1. 2
      appnav/build.gradle.kts
  2. 5
      appnav/src/main/kotlin/io/element/android/appnav/LoggedInFlowNode.kt
  3. 1
      features/createroom/.gitignore
  4. 27
      features/createroom/api/build.gradle.kts
  5. 21
      features/createroom/api/src/main/kotlin/io/element/android/features/createroom/api/CreateRoomEntryPoint.kt
  6. 0
      features/createroom/consumer-rules.pro
  7. 13
      features/createroom/impl/build.gradle.kts
  8. 25
      features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/CreateRoomFlowNode.kt
  9. 32
      features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/DefaultCreateRoomEntryPoint.kt
  10. 2
      features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootEvents.kt
  11. 2
      features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootNode.kt
  12. 2
      features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootPresenter.kt
  13. 2
      features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootScreen.kt
  14. 2
      features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootState.kt
  15. 2
      features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootStateProvider.kt
  16. 4
      features/createroom/impl/src/test/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootPresenterTests.kt
  17. 21
      features/createroom/proguard-rules.pro
  18. 20
      features/createroom/src/main/AndroidManifest.xml
  19. 2
      plugins/src/main/kotlin/extension/DependencyHandleScope.kt
  20. 3
      settings.gradle.kts

2
appnav/build.gradle.kts

@ -43,7 +43,7 @@ dependencies { @@ -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)

5
appnav/src/main/kotlin/io/element/android/appnav/LoggedInFlowNode.kt

@ -35,7 +35,7 @@ import com.bumble.appyx.navmodel.backstack.operation.push @@ -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( @@ -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( @@ -160,7 +161,7 @@ class LoggedInFlowNode @AssistedInject constructor(
.build()
}
NavTarget.CreateRoom -> {
CreateRoomFlowNode(buildContext)
createRoomEntryPoint.createNode(this, buildContext)
}
}
}

1
features/createroom/.gitignore vendored

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

27
features/createroom/api/build.gradle.kts

@ -0,0 +1,27 @@ @@ -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)
}

21
features/createroom/api/src/main/kotlin/io/element/android/features/createroom/api/CreateRoomEntryPoint.kt

@ -0,0 +1,21 @@ @@ -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

0
features/createroom/consumer-rules.pro

13
features/createroom/build.gradle.kts → features/createroom/impl/build.gradle.kts

@ -1,5 +1,5 @@ @@ -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 @@ @@ -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 { @@ -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)

25
features/createroom/src/main/kotlin/io/element/android/features/createroom/CreateRoomFlowNode.kt → features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/CreateRoomFlowNode.kt

@ -14,7 +14,7 @@ @@ -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 @@ -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 {

32
features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/DefaultCreateRoomEntryPoint.kt

@ -0,0 +1,32 @@ @@ -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)
}
}

2
features/createroom/src/main/kotlin/io/element/android/features/createroom/root/CreateRoomRootEvents.kt → features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootEvents.kt

@ -14,7 +14,7 @@ @@ -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

2
features/createroom/src/main/kotlin/io/element/android/features/createroom/root/CreateRoomRootNode.kt → features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootNode.kt

@ -14,7 +14,7 @@ @@ -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

2
features/createroom/src/main/kotlin/io/element/android/features/createroom/root/CreateRoomRootPresenter.kt → features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootPresenter.kt

@ -14,7 +14,7 @@ @@ -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

2
features/createroom/src/main/kotlin/io/element/android/features/createroom/root/CreateRoomRootScreen.kt → features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootScreen.kt

@ -14,7 +14,7 @@ @@ -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

2
features/createroom/src/main/kotlin/io/element/android/features/createroom/root/CreateRoomRootState.kt → features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootState.kt

@ -14,7 +14,7 @@ @@ -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.

2
features/createroom/src/main/kotlin/io/element/android/features/createroom/root/CreateRoomRootStateProvider.kt → features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootStateProvider.kt

@ -14,7 +14,7 @@ @@ -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

4
features/createroom/src/test/kotlin/io/element/android/features/createroom/root/CreateRoomRootPresenterTests.kt → features/createroom/impl/src/test/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootPresenterTests.kt

@ -16,12 +16,14 @@ @@ -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

21
features/createroom/proguard-rules.pro vendored

@ -1,21 +0,0 @@ @@ -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

20
features/createroom/src/main/AndroidManifest.xml

@ -1,20 +0,0 @@ @@ -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>

2
plugins/src/main/kotlin/extension/DependencyHandleScope.kt

@ -69,5 +69,5 @@ fun DependencyHandlerScope.allFeatures() { @@ -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"))
}

3
settings.gradle.kts

@ -80,4 +80,5 @@ include(":features:messages:api") @@ -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")

Loading…
Cancel
Save