-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2620 from element-hq/feature/fga/room_directory
Feature/fga/room directory
- Loading branch information
Showing
78 changed files
with
2,114 additions
and
41 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* 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.roomdirectory.api" | ||
} | ||
|
||
dependencies { | ||
implementation(projects.libraries.architecture) | ||
implementation(projects.libraries.matrix.api) | ||
implementation(projects.libraries.designsystem) | ||
} |
28 changes: 28 additions & 0 deletions
28
...tory/api/src/main/kotlin/io/element/android/features/roomdirectory/api/RoomDescription.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
*/ | ||
|
||
package io.element.android.features.roomdirectory.api | ||
|
||
import io.element.android.libraries.designsystem.components.avatar.AvatarData | ||
import io.element.android.libraries.matrix.api.core.RoomId | ||
|
||
data class RoomDescription( | ||
val roomId: RoomId, | ||
val name: String, | ||
val description: String, | ||
val avatarData: AvatarData, | ||
val canBeJoined: Boolean, | ||
) |
36 changes: 36 additions & 0 deletions
36
.../src/main/kotlin/io/element/android/features/roomdirectory/api/RoomDirectoryEntryPoint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.roomdirectory.api | ||
|
||
import com.bumble.appyx.core.modality.BuildContext | ||
import com.bumble.appyx.core.node.Node | ||
import com.bumble.appyx.core.plugin.Plugin | ||
import io.element.android.libraries.architecture.FeatureEntryPoint | ||
import io.element.android.libraries.matrix.api.core.RoomId | ||
|
||
interface RoomDirectoryEntryPoint : FeatureEntryPoint { | ||
fun nodeBuilder(parentNode: Node, buildContext: BuildContext): NodeBuilder | ||
|
||
interface NodeBuilder { | ||
fun callback(callback: Callback): NodeBuilder | ||
fun build(): Node | ||
} | ||
|
||
interface Callback : Plugin { | ||
fun onOpenRoom(roomId: RoomId) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* 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-compose-library") | ||
alias(libs.plugins.anvil) | ||
alias(libs.plugins.ksp) | ||
id("kotlin-parcelize") | ||
} | ||
|
||
android { | ||
namespace = "io.element.android.features.roomdirectory.impl" | ||
testOptions { | ||
unitTests { | ||
isIncludeAndroidResources = true | ||
} | ||
} | ||
} | ||
|
||
anvil { | ||
generateDaggerFactories.set(true) | ||
} | ||
|
||
dependencies { | ||
implementation(projects.anvilannotations) | ||
anvil(projects.anvilcodegen) | ||
api(projects.features.roomdirectory.api) | ||
implementation(projects.libraries.core) | ||
implementation(projects.libraries.architecture) | ||
implementation(projects.libraries.matrix.api) | ||
implementation(projects.libraries.matrixui) | ||
implementation(projects.libraries.designsystem) | ||
implementation(projects.libraries.uiStrings) | ||
implementation(projects.libraries.testtags) | ||
|
||
testImplementation(libs.test.junit) | ||
testImplementation(libs.androidx.compose.ui.test.junit) | ||
testImplementation(libs.test.robolectric) | ||
testImplementation(libs.coroutines.test) | ||
testImplementation(libs.molecule.runtime) | ||
testImplementation(libs.test.truth) | ||
testImplementation(libs.test.turbine) | ||
testImplementation(projects.libraries.matrix.test) | ||
testImplementation(projects.tests.testutils) | ||
|
||
ksp(libs.showkase.processor) | ||
} |
45 changes: 45 additions & 0 deletions
45
...n/kotlin/io/element/android/features/roomdirectory/impl/DefaultRoomDirectoryEntryPoint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* 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.roomdirectory.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.roomdirectory.api.RoomDirectoryEntryPoint | ||
import io.element.android.features.roomdirectory.impl.root.RoomDirectoryNode | ||
import io.element.android.libraries.architecture.createNode | ||
import io.element.android.libraries.di.AppScope | ||
import javax.inject.Inject | ||
|
||
@ContributesBinding(AppScope::class) | ||
class DefaultRoomDirectoryEntryPoint @Inject constructor() : RoomDirectoryEntryPoint { | ||
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext): RoomDirectoryEntryPoint.NodeBuilder { | ||
val plugins = ArrayList<Plugin>() | ||
|
||
return object : RoomDirectoryEntryPoint.NodeBuilder { | ||
override fun callback(callback: RoomDirectoryEntryPoint.Callback): RoomDirectoryEntryPoint.NodeBuilder { | ||
plugins += callback | ||
return this | ||
} | ||
|
||
override fun build(): Node { | ||
return parentNode.createNode<RoomDirectoryNode>(buildContext, plugins) | ||
} | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...rc/main/kotlin/io/element/android/features/roomdirectory/impl/root/RoomDirectoryEvents.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* 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.roomdirectory.impl.root | ||
|
||
import io.element.android.libraries.matrix.api.core.RoomId | ||
|
||
sealed interface RoomDirectoryEvents { | ||
data class JoinRoom(val roomId: RoomId) : RoomDirectoryEvents | ||
data class Search(val query: String) : RoomDirectoryEvents | ||
data object LoadMore : RoomDirectoryEvents | ||
data object JoinRoomDismissError : RoomDirectoryEvents | ||
} |
54 changes: 54 additions & 0 deletions
54
.../src/main/kotlin/io/element/android/features/roomdirectory/impl/root/RoomDirectoryNode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
*/ | ||
|
||
package io.element.android.features.roomdirectory.impl.root | ||
|
||
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 com.bumble.appyx.core.plugin.plugins | ||
import dagger.assisted.Assisted | ||
import dagger.assisted.AssistedInject | ||
import io.element.android.anvilannotations.ContributesNode | ||
import io.element.android.features.roomdirectory.api.RoomDirectoryEntryPoint | ||
import io.element.android.libraries.di.SessionScope | ||
import io.element.android.libraries.matrix.api.core.RoomId | ||
|
||
@ContributesNode(SessionScope::class) | ||
class RoomDirectoryNode @AssistedInject constructor( | ||
@Assisted buildContext: BuildContext, | ||
@Assisted plugins: List<Plugin>, | ||
private val presenter: RoomDirectoryPresenter, | ||
) : Node(buildContext, plugins = plugins) { | ||
private fun onRoomJoined(roomId: RoomId) { | ||
plugins<RoomDirectoryEntryPoint.Callback>().forEach { | ||
it.onOpenRoom(roomId) | ||
} | ||
} | ||
|
||
@Composable | ||
override fun View(modifier: Modifier) { | ||
val state = presenter.present() | ||
RoomDirectoryView( | ||
state = state, | ||
onRoomJoined = ::onRoomJoined, | ||
onBackPressed = ::navigateUp, | ||
modifier = modifier | ||
) | ||
} | ||
} |
Oops, something went wrong.