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,46 +221,53 @@ private fun DefaultRoomListTopBar(
contentDescription = stringResource(CommonStrings.action_search), contentDescription = stringResource(CommonStrings.action_search),
) )
} }
IconButton( if (RoomListConfig.hasDropdownMenu) {
onClick = { showMenu = !showMenu } var showMenu by remember { mutableStateOf(false) }
) { IconButton(
Icon( onClick = { showMenu = !showMenu }
imageVector = CompoundIcons.OverflowVertical, ) {
contentDescription = null, Icon(
) imageVector = CompoundIcons.OverflowVertical,
} contentDescription = null,
DropdownMenu( )
expanded = showMenu, }
onDismissRequest = { showMenu = false } DropdownMenu(
) { expanded = showMenu,
DropdownMenuItem( onDismissRequest = { showMenu = false }
onClick = { ) {
showMenu = false if (RoomListConfig.showInviteMenuItem) {
onMenuActionClicked(RoomListMenuAction.InviteFriends) DropdownMenuItem(
}, onClick = {
text = { Text(stringResource(id = CommonStrings.action_invite)) }, showMenu = false
leadingIcon = { onMenuActionClicked(RoomListMenuAction.InviteFriends)
Icon( },
imageVector = CompoundIcons.ShareAndroid, text = { Text(stringResource(id = CommonStrings.action_invite)) },
tint = ElementTheme.materialColors.secondary, leadingIcon = {
contentDescription = null, Icon(
imageVector = CompoundIcons.ShareAndroid,
tint = ElementTheme.materialColors.secondary,
contentDescription = null,
)
}
) )
} }
) if (RoomListConfig.showReportProblemMenuItem) {
DropdownMenuItem( DropdownMenuItem(
onClick = { onClick = {
showMenu = false showMenu = false
onMenuActionClicked(RoomListMenuAction.ReportBug) onMenuActionClicked(RoomListMenuAction.ReportBug)
}, },
text = { Text(stringResource(id = CommonStrings.common_report_a_problem)) }, text = { Text(stringResource(id = CommonStrings.common_report_a_problem)) },
leadingIcon = { leadingIcon = {
Icon( Icon(
imageVector = CompoundIcons.ChatProblem, imageVector = CompoundIcons.ChatProblem,
tint = ElementTheme.materialColors.secondary, tint = ElementTheme.materialColors.secondary,
contentDescription = null, contentDescription = null,
)
}
) )
} }
) }
} }
}, },
scrollBehavior = scrollBehavior, scrollBehavior = scrollBehavior,