diff --git a/features/template/.gitignore b/features/template/.gitignore deleted file mode 100644 index 42afabfd2a..0000000000 --- a/features/template/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build \ No newline at end of file diff --git a/features/template/build.gradle.kts b/features/template/build.gradle.kts deleted file mode 100644 index 409a0c9bc5..0000000000 --- a/features/template/build.gradle.kts +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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. - */ - -// TODO: Remove once https://youtrack.jetbrains.com/issue/KTIJ-19369 is fixed -@Suppress("DSL_SCOPE_VIOLATION") -plugins { - id("io.element.android-compose-library") - alias(libs.plugins.anvil) - alias(libs.plugins.ksp) -} - -android { - // TODO change the namespace (and your classes package) - namespace = "io.element.android.features.template" -} - -anvil { - generateDaggerFactories.set(true) -} - -dependencies { - anvil(projects.anvilcodegen) - implementation(projects.anvilannotations) - - implementation(projects.libraries.core) - implementation(projects.libraries.architecture) - implementation(projects.libraries.matrix.api) - implementation(projects.libraries.matrixui) - implementation(projects.libraries.designsystem) - implementation(projects.libraries.elementresources) - 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) - - androidTestImplementation(libs.test.junitext) - - ksp(libs.showkase.processor) -} diff --git a/features/template/consumer-rules.pro b/features/template/consumer-rules.pro deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/features/template/proguard-rules.pro b/features/template/proguard-rules.pro deleted file mode 100644 index 481bb43481..0000000000 --- a/features/template/proguard-rules.pro +++ /dev/null @@ -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 \ No newline at end of file diff --git a/features/template/src/main/AndroidManifest.xml b/features/template/src/main/AndroidManifest.xml deleted file mode 100644 index 86d497f107..0000000000 --- a/features/template/src/main/AndroidManifest.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - diff --git a/features/template/src/main/kotlin/io/element/android/features/template/TemplateEvents.kt b/features/template/src/main/kotlin/io/element/android/features/template/TemplateEvents.kt deleted file mode 100644 index 57d0b0cc25..0000000000 --- a/features/template/src/main/kotlin/io/element/android/features/template/TemplateEvents.kt +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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.template - -// TODO Add your events or remove the file completely if no events -sealed interface TemplateEvents { - object MyEvent: TemplateEvents -} diff --git a/features/template/src/main/kotlin/io/element/android/features/template/TemplateNode.kt b/features/template/src/main/kotlin/io/element/android/features/template/TemplateNode.kt deleted file mode 100644 index 4be5178ede..0000000000 --- a/features/template/src/main/kotlin/io/element/android/features/template/TemplateNode.kt +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.template - -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import com.bumble.appyx.core.modality.BuildContext -import com.bumble.appyx.core.node.Node -import com.bumble.appyx.core.plugin.Plugin -import dagger.assisted.Assisted -import dagger.assisted.AssistedInject -import io.element.android.anvilannotations.ContributesNode -import io.element.android.libraries.di.AppScope - -// TODO Change to use the right Scope for your feature. For now it can be AppScope, SessionScope or RoomScope -@ContributesNode(AppScope::class) -class TemplateNode @AssistedInject constructor( - @Assisted buildContext: BuildContext, - @Assisted plugins: List, - private val presenter: TemplatePresenter, -) : Node(buildContext, plugins = plugins) { - - @Composable - override fun View(modifier: Modifier) { - val state = presenter.present() - TemplateView( - state = state, - modifier = modifier - ) - } -} diff --git a/features/template/src/main/kotlin/io/element/android/features/template/TemplatePresenter.kt b/features/template/src/main/kotlin/io/element/android/features/template/TemplatePresenter.kt deleted file mode 100644 index 254a5fc048..0000000000 --- a/features/template/src/main/kotlin/io/element/android/features/template/TemplatePresenter.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.template - -import androidx.compose.runtime.Composable -import io.element.android.libraries.architecture.Presenter -import javax.inject.Inject - -class TemplatePresenter @Inject constructor() : Presenter { - - @Composable - override fun present(): TemplateState { - - fun handleEvents(event: TemplateEvents) { - when (event) { - TemplateEvents.MyEvent -> Unit - } - } - - return TemplateState( - eventSink = ::handleEvents - ) - } -} diff --git a/features/template/src/main/kotlin/io/element/android/features/template/TemplateState.kt b/features/template/src/main/kotlin/io/element/android/features/template/TemplateState.kt deleted file mode 100644 index b9a48a7378..0000000000 --- a/features/template/src/main/kotlin/io/element/android/features/template/TemplateState.kt +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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.template - -// 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. -data class TemplateState( - val eventSink: (TemplateEvents) -> Unit -) diff --git a/features/template/src/main/kotlin/io/element/android/features/template/TemplateStateProvider.kt b/features/template/src/main/kotlin/io/element/android/features/template/TemplateStateProvider.kt deleted file mode 100644 index 7541e1667a..0000000000 --- a/features/template/src/main/kotlin/io/element/android/features/template/TemplateStateProvider.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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.template - -import androidx.compose.ui.tooling.preview.PreviewParameterProvider - -open class TemplateStateProvider : PreviewParameterProvider { - override val values: Sequence - get() = sequenceOf( - aTemplateState(), - // Add other state here - ) -} - -fun aTemplateState() = TemplateState( - eventSink = {} -) diff --git a/features/template/src/main/kotlin/io/element/android/features/template/TemplateView.kt b/features/template/src/main/kotlin/io/element/android/features/template/TemplateView.kt deleted file mode 100644 index c7456ad49a..0000000000 --- a/features/template/src/main/kotlin/io/element/android/features/template/TemplateView.kt +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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. - * 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.template - -import androidx.compose.foundation.layout.Box -import androidx.compose.material3.MaterialTheme -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.tooling.preview.PreviewParameter -import io.element.android.libraries.designsystem.preview.ElementPreviewDark -import io.element.android.libraries.designsystem.preview.ElementPreviewLight -import io.element.android.libraries.designsystem.theme.components.Text - -@Composable -fun TemplateView( - state: TemplateState, - modifier: Modifier = Modifier, -) { - Box(modifier, contentAlignment = Alignment.Center) { - Text( - "Template feature view", - color = MaterialTheme.colorScheme.primary, - ) - } -} - -@Preview -@Composable -fun TemplateViewLightPreview(@PreviewParameter(TemplateStateProvider::class) state: TemplateState) = - ElementPreviewLight { ContentToPreview(state) } - -@Preview -@Composable -fun TemplateViewDarkPreview(@PreviewParameter(TemplateStateProvider::class) state: TemplateState) = - ElementPreviewDark { ContentToPreview(state) } - -@Composable -private fun ContentToPreview(state: TemplateState) { - TemplateView( - state = state, - ) -} diff --git a/features/template/src/test/kotlin/io/element/android/features/template/TemplatePresenterTests.kt b/features/template/src/test/kotlin/io/element/android/features/template/TemplatePresenterTests.kt deleted file mode 100644 index a14cd2761e..0000000000 --- a/features/template/src/test/kotlin/io/element/android/features/template/TemplatePresenterTests.kt +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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. - */ - -@file:OptIn(ExperimentalCoroutinesApi::class) - -package io.element.android.features.template - -import app.cash.molecule.RecompositionClock -import app.cash.molecule.moleculeFlow -import app.cash.turbine.test -import com.google.common.truth.Truth.assertThat -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.runTest -import org.junit.Test - -class TemplatePresenterTests { - - @Test - fun `present - initial state`() = runTest { - val presenter = TemplatePresenter() - moleculeFlow(RecompositionClock.Immediate) { - presenter.present() - }.test { - val initialState = awaitItem() - assertThat(initialState) - } - } - - @Test - fun `present - send event`() = runTest { - val presenter = TemplatePresenter() - moleculeFlow(RecompositionClock.Immediate) { - presenter.present() - }.test { - val initialState = awaitItem() - initialState.eventSink.invoke(TemplateEvents.MyEvent) - } - } -}