Join Room : improve a bit
This commit is contained in:
parent
6d86dbd996
commit
59df98dcac
2 changed files with 31 additions and 27 deletions
|
|
@ -48,7 +48,7 @@ class JoinRoomPresenter @AssistedInject constructor(
|
||||||
val userMembership by roomListService.getUserMembershipForRoom(roomId).collectAsState(initial = Optional.empty())
|
val userMembership by roomListService.getUserMembershipForRoom(roomId).collectAsState(initial = Optional.empty())
|
||||||
val joinAuthorisationStatus = joinAuthorisationStatus(userMembership)
|
val joinAuthorisationStatus = joinAuthorisationStatus(userMembership)
|
||||||
val roomInfo by produceState<AsyncData<RoomInfo>>(initialValue = AsyncData.Uninitialized, key1 = userMembership) {
|
val roomInfo by produceState<AsyncData<RoomInfo>>(initialValue = AsyncData.Uninitialized, key1 = userMembership) {
|
||||||
when {
|
value = when {
|
||||||
userMembership.isPresent -> {
|
userMembership.isPresent -> {
|
||||||
val roomInfo = matrixClient.getRoom(roomId)?.use {
|
val roomInfo = matrixClient.getRoom(roomId)?.use {
|
||||||
RoomInfo(
|
RoomInfo(
|
||||||
|
|
@ -59,11 +59,9 @@ class JoinRoomPresenter @AssistedInject constructor(
|
||||||
roomAvatarUrl = it.avatarUrl
|
roomAvatarUrl = it.avatarUrl
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
value = roomInfo?.let { AsyncData.Success(it) } ?: AsyncData.Failure(Exception("Failed to load room info"))
|
roomInfo?.let { AsyncData.Success(it) } ?: AsyncData.Failure(Exception("Failed to load room info"))
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
value = AsyncData.Uninitialized
|
|
||||||
}
|
}
|
||||||
|
else -> AsyncData.Uninitialized
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.heightIn
|
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.layout.widthIn
|
import androidx.compose.foundation.layout.widthIn
|
||||||
|
|
@ -132,7 +131,9 @@ private fun JoinRoomContent(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = modifier.padding(all = 16.dp),
|
modifier = modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(all = 16.dp),
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
) {
|
) {
|
||||||
when (state.roomInfo) {
|
when (state.roomInfo) {
|
||||||
|
|
@ -159,30 +160,35 @@ private fun JoinRoomContent(
|
||||||
color = ElementTheme.colors.textSecondary,
|
color = ElementTheme.colors.textSecondary,
|
||||||
)
|
)
|
||||||
if (state.showMemberCount) {
|
if (state.showMemberCount) {
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
JoinRoomMembersCount(memberCount = state.roomInfo.dataOrNull()?.memberCount ?: 0)
|
||||||
Row(
|
|
||||||
modifier = Modifier
|
|
||||||
.background(color = ElementTheme.colors.bgSubtleSecondary, shape = CircleShape)
|
|
||||||
.widthIn(min = 48.dp)
|
|
||||||
.padding(all = 2.dp),
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
imageVector = CompoundIcons.UserProfile(),
|
|
||||||
contentDescription = null,
|
|
||||||
tint = ElementTheme.colors.iconSecondary,
|
|
||||||
)
|
|
||||||
Text(
|
|
||||||
text = "${state.roomInfo.dataOrNull()?.memberCount}",
|
|
||||||
style = ElementTheme.typography.fontBodySmMedium,
|
|
||||||
color = ElementTheme.colors.textSecondary,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun JoinRoomMembersCount(memberCount: Long) {
|
||||||
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.background(color = ElementTheme.colors.bgSubtleSecondary, shape = CircleShape)
|
||||||
|
.widthIn(min = 48.dp)
|
||||||
|
.padding(all = 2.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = CompoundIcons.UserProfile(),
|
||||||
|
contentDescription = null,
|
||||||
|
tint = ElementTheme.colors.iconSecondary,
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = "$memberCount",
|
||||||
|
style = ElementTheme.typography.fontBodySmMedium,
|
||||||
|
color = ElementTheme.colors.textSecondary,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
private fun JoinRoomTopBar(
|
private fun JoinRoomTopBar(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue