Merge pull request #3669 from element-hq/feature/bma/reduceIndentation
Ensure selectedRoomMember is not null to reduce code indentation.
This commit is contained in:
commit
44b37587cc
1 changed files with 73 additions and 75 deletions
|
|
@ -62,7 +62,7 @@ fun RoomMembersModerationView(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
Box(modifier = modifier) {
|
Box(modifier = modifier) {
|
||||||
if (state.actions.isNotEmpty()) {
|
if (state.selectedRoomMember != null && state.actions.isNotEmpty()) {
|
||||||
RoomMemberActionsBottomSheet(
|
RoomMemberActionsBottomSheet(
|
||||||
roomMember = state.selectedRoomMember,
|
roomMember = state.selectedRoomMember,
|
||||||
actions = state.actions,
|
actions = state.actions,
|
||||||
|
|
@ -186,97 +186,95 @@ fun RoomMembersModerationView(
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
private fun RoomMemberActionsBottomSheet(
|
private fun RoomMemberActionsBottomSheet(
|
||||||
roomMember: RoomMember?,
|
roomMember: RoomMember,
|
||||||
actions: ImmutableList<ModerationAction>,
|
actions: ImmutableList<ModerationAction>,
|
||||||
onSelectAction: (ModerationAction) -> Unit,
|
onSelectAction: (ModerationAction) -> Unit,
|
||||||
onDismiss: () -> Unit,
|
onDismiss: () -> Unit,
|
||||||
) {
|
) {
|
||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
if (roomMember != null && actions.isNotEmpty()) {
|
val bottomSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
||||||
val bottomSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
ModalBottomSheet(
|
||||||
ModalBottomSheet(
|
modifier = Modifier.systemBarsPadding(),
|
||||||
modifier = Modifier.systemBarsPadding(),
|
sheetState = bottomSheetState,
|
||||||
sheetState = bottomSheetState,
|
onDismissRequest = {
|
||||||
onDismissRequest = {
|
coroutineScope.launch {
|
||||||
coroutineScope.launch {
|
bottomSheetState.hide()
|
||||||
bottomSheetState.hide()
|
onDismiss()
|
||||||
onDismiss()
|
}
|
||||||
}
|
},
|
||||||
},
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.padding(vertical = 16.dp)
|
||||||
) {
|
) {
|
||||||
Column(
|
Avatar(
|
||||||
modifier = Modifier.padding(vertical = 16.dp)
|
avatarData = roomMember.getAvatarData(size = AvatarSize.RoomListManageUser),
|
||||||
) {
|
modifier = Modifier
|
||||||
Avatar(
|
.padding(bottom = 28.dp)
|
||||||
avatarData = roomMember.getAvatarData(size = AvatarSize.RoomListManageUser),
|
.align(Alignment.CenterHorizontally)
|
||||||
modifier = Modifier
|
)
|
||||||
.padding(bottom = 28.dp)
|
roomMember.displayName?.let {
|
||||||
.align(Alignment.CenterHorizontally)
|
|
||||||
)
|
|
||||||
roomMember.displayName?.let {
|
|
||||||
Text(
|
|
||||||
text = it,
|
|
||||||
style = ElementTheme.typography.fontHeadingLgBold,
|
|
||||||
maxLines = 1,
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
textAlign = TextAlign.Center,
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(start = 16.dp, end = 16.dp, bottom = 8.dp)
|
|
||||||
.fillMaxWidth()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Text(
|
Text(
|
||||||
text = roomMember.userId.toString(),
|
text = it,
|
||||||
style = ElementTheme.typography.fontBodyLgRegular,
|
style = ElementTheme.typography.fontHeadingLgBold,
|
||||||
color = ElementTheme.colors.textSecondary,
|
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis,
|
overflow = TextOverflow.Ellipsis,
|
||||||
textAlign = TextAlign.Center,
|
textAlign = TextAlign.Center,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(horizontal = 16.dp)
|
.padding(start = 16.dp, end = 16.dp, bottom = 8.dp)
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(32.dp))
|
}
|
||||||
|
Text(
|
||||||
|
text = roomMember.userId.toString(),
|
||||||
|
style = ElementTheme.typography.fontBodyLgRegular,
|
||||||
|
color = ElementTheme.colors.textSecondary,
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
textAlign = TextAlign.Center,
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(horizontal = 16.dp)
|
||||||
|
.fillMaxWidth()
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.height(32.dp))
|
||||||
|
|
||||||
for (action in actions) {
|
for (action in actions) {
|
||||||
when (action) {
|
when (action) {
|
||||||
is ModerationAction.DisplayProfile -> {
|
is ModerationAction.DisplayProfile -> {
|
||||||
ListItem(
|
ListItem(
|
||||||
headlineContent = { Text(stringResource(R.string.screen_room_member_list_manage_member_user_info)) },
|
headlineContent = { Text(stringResource(R.string.screen_room_member_list_manage_member_user_info)) },
|
||||||
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.Info())),
|
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.Info())),
|
||||||
onClick = {
|
onClick = {
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
onSelectAction(action)
|
onSelectAction(action)
|
||||||
bottomSheetState.hide()
|
bottomSheetState.hide()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
}
|
)
|
||||||
is ModerationAction.KickUser -> {
|
}
|
||||||
ListItem(
|
is ModerationAction.KickUser -> {
|
||||||
headlineContent = { Text(stringResource(R.string.screen_room_member_list_manage_member_remove)) },
|
ListItem(
|
||||||
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.Block())),
|
headlineContent = { Text(stringResource(R.string.screen_room_member_list_manage_member_remove)) },
|
||||||
onClick = {
|
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.Block())),
|
||||||
coroutineScope.launch {
|
onClick = {
|
||||||
bottomSheetState.hide()
|
coroutineScope.launch {
|
||||||
onSelectAction(action)
|
bottomSheetState.hide()
|
||||||
}
|
onSelectAction(action)
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
}
|
)
|
||||||
is ModerationAction.BanUser -> {
|
}
|
||||||
ListItem(
|
is ModerationAction.BanUser -> {
|
||||||
headlineContent = { Text(stringResource(R.string.screen_room_member_list_manage_member_remove_confirmation_ban)) },
|
ListItem(
|
||||||
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.Block())),
|
headlineContent = { Text(stringResource(R.string.screen_room_member_list_manage_member_remove_confirmation_ban)) },
|
||||||
style = ListItemStyle.Destructive,
|
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.Block())),
|
||||||
onClick = {
|
style = ListItemStyle.Destructive,
|
||||||
coroutineScope.launch {
|
onClick = {
|
||||||
bottomSheetState.hide()
|
coroutineScope.launch {
|
||||||
onSelectAction(action)
|
bottomSheetState.hide()
|
||||||
}
|
onSelectAction(action)
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue