android, desktop: disabling user picker items when chat is stopped (#3696)
This commit is contained in:
parent
ab8a87acad
commit
3918c5306d
@ -245,23 +245,31 @@ fun UserPicker(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun UserProfilePickerItem(u: User, unreadCount: Int = 0, onLongClick: () -> Unit = {}, openSettings: () -> Unit = {}, onClick: () -> Unit) {
|
fun UserProfilePickerItem(
|
||||||
|
u: User,
|
||||||
|
unreadCount: Int = 0,
|
||||||
|
enabled: Boolean = chatModel.chatRunning.value == true || chatModel.connectedToRemote,
|
||||||
|
onLongClick: () -> Unit = {},
|
||||||
|
openSettings: () -> Unit = {},
|
||||||
|
onClick: () -> Unit
|
||||||
|
) {
|
||||||
Row(
|
Row(
|
||||||
Modifier
|
Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.sizeIn(minHeight = 46.dp)
|
.sizeIn(minHeight = 46.dp)
|
||||||
.combinedClickable(
|
.combinedClickable(
|
||||||
|
enabled = enabled,
|
||||||
onClick = if (u.activeUser) openSettings else onClick,
|
onClick = if (u.activeUser) openSettings else onClick,
|
||||||
onLongClick = onLongClick,
|
onLongClick = onLongClick,
|
||||||
interactionSource = remember { MutableInteractionSource() },
|
interactionSource = remember { MutableInteractionSource() },
|
||||||
indication = if (!u.activeUser) LocalIndication.current else null
|
indication = if (!u.activeUser) LocalIndication.current else null
|
||||||
)
|
)
|
||||||
.onRightClick { onLongClick() }
|
.onRightClick { if (enabled) onLongClick() }
|
||||||
.padding(start = DEFAULT_PADDING_HALF, end = DEFAULT_PADDING),
|
.padding(start = DEFAULT_PADDING_HALF, end = DEFAULT_PADDING),
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
UserProfileRow(u)
|
UserProfileRow(u, enabled)
|
||||||
if (u.activeUser) {
|
if (u.activeUser) {
|
||||||
Icon(painterResource(MR.images.ic_done_filled), null, Modifier.size(20.dp), tint = MaterialTheme.colors.onBackground)
|
Icon(painterResource(MR.images.ic_done_filled), null, Modifier.size(20.dp), tint = MaterialTheme.colors.onBackground)
|
||||||
} else if (u.hidden) {
|
} else if (u.hidden) {
|
||||||
@ -289,7 +297,7 @@ fun UserProfilePickerItem(u: User, unreadCount: Int = 0, onLongClick: () -> Unit
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun UserProfileRow(u: User) {
|
fun UserProfileRow(u: User, enabled: Boolean = chatModel.chatRunning.value == true || chatModel.connectedToRemote) {
|
||||||
Row(
|
Row(
|
||||||
Modifier
|
Modifier
|
||||||
.widthIn(max = windowWidth() * 0.7f)
|
.widthIn(max = windowWidth() * 0.7f)
|
||||||
@ -304,7 +312,7 @@ fun UserProfileRow(u: User) {
|
|||||||
u.displayName,
|
u.displayName,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(start = 10.dp, end = 8.dp),
|
.padding(start = 10.dp, end = 8.dp),
|
||||||
color = MenuTextColor,
|
color = if (enabled) MenuTextColor else MaterialTheme.colors.secondary,
|
||||||
fontWeight = if (u.activeUser) FontWeight.Medium else FontWeight.Normal
|
fontWeight = if (u.activeUser) FontWeight.Medium else FontWeight.Normal
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user