Add RoomListConfig to be able to hide menu items. And hide them #2062.

This commit is contained in:
Benoit Marty 2023-12-19 15:09:39 +01:00
parent 93e43084e1
commit 0c99a457e4
4 changed files with 71 additions and 38 deletions

View file

@ -0,0 +1,25 @@
/*
* 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.appconfig
object RoomListConfig {
const val showInviteMenuItem = false
const val showReportProblemMenuItem = false
const val hasDropdownMenu = showInviteMenuItem || showReportProblemMenuItem
}

1
changelog.d/2062.misc Normal file
View file

@ -0,0 +1 @@
Hide room list dropdown menu.

View file

@ -38,6 +38,7 @@ anvil {
dependencies { dependencies {
implementation(projects.anvilannotations) implementation(projects.anvilannotations)
anvil(projects.anvilcodegen) anvil(projects.anvilcodegen)
implementation(projects.appconfig)
implementation(projects.libraries.core) implementation(projects.libraries.core)
implementation(projects.libraries.androidutils) implementation(projects.libraries.androidutils)
implementation(projects.libraries.architecture) implementation(projects.libraries.architecture)

View file

@ -46,6 +46,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.DpOffset import androidx.compose.ui.unit.DpOffset
import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import io.element.android.appconfig.RoomListConfig
import io.element.android.compound.theme.ElementTheme import io.element.android.compound.theme.ElementTheme
import io.element.android.compound.tokens.generated.CompoundIcons import io.element.android.compound.tokens.generated.CompoundIcons
import io.element.android.features.roomlist.impl.R import io.element.android.features.roomlist.impl.R
@ -128,8 +129,6 @@ private fun DefaultRoomListTopBar(
onMenuActionClicked: (RoomListMenuAction) -> Unit, onMenuActionClicked: (RoomListMenuAction) -> Unit,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
) { ) {
var showMenu by remember { mutableStateOf(false) }
// We need this to manually clip the top app bar in preview mode // We need this to manually clip the top app bar in preview mode
val previewAppBarHeight = if (LocalInspectionMode.current) { val previewAppBarHeight = if (LocalInspectionMode.current) {
112.dp.roundToPx() 112.dp.roundToPx()
@ -222,6 +221,8 @@ private fun DefaultRoomListTopBar(
contentDescription = stringResource(CommonStrings.action_search), contentDescription = stringResource(CommonStrings.action_search),
) )
} }
if (RoomListConfig.hasDropdownMenu) {
var showMenu by remember { mutableStateOf(false) }
IconButton( IconButton(
onClick = { showMenu = !showMenu } onClick = { showMenu = !showMenu }
) { ) {
@ -234,6 +235,7 @@ private fun DefaultRoomListTopBar(
expanded = showMenu, expanded = showMenu,
onDismissRequest = { showMenu = false } onDismissRequest = { showMenu = false }
) { ) {
if (RoomListConfig.showInviteMenuItem) {
DropdownMenuItem( DropdownMenuItem(
onClick = { onClick = {
showMenu = false showMenu = false
@ -248,6 +250,8 @@ private fun DefaultRoomListTopBar(
) )
} }
) )
}
if (RoomListConfig.showReportProblemMenuItem) {
DropdownMenuItem( DropdownMenuItem(
onClick = { onClick = {
showMenu = false showMenu = false
@ -263,6 +267,8 @@ private fun DefaultRoomListTopBar(
} }
) )
} }
}
}
}, },
scrollBehavior = scrollBehavior, scrollBehavior = scrollBehavior,
windowInsets = WindowInsets(0.dp), windowInsets = WindowInsets(0.dp),