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,6 +160,13 @@ private fun JoinRoomContent(
|
||||||
color = ElementTheme.colors.textSecondary,
|
color = ElementTheme.colors.textSecondary,
|
||||||
)
|
)
|
||||||
if (state.showMemberCount) {
|
if (state.showMemberCount) {
|
||||||
|
JoinRoomMembersCount(memberCount = state.roomInfo.dataOrNull()?.memberCount ?: 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun JoinRoomMembersCount(memberCount: Long) {
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|
@ -174,14 +182,12 @@ private fun JoinRoomContent(
|
||||||
tint = ElementTheme.colors.iconSecondary,
|
tint = ElementTheme.colors.iconSecondary,
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = "${state.roomInfo.dataOrNull()?.memberCount}",
|
text = "$memberCount",
|
||||||
style = ElementTheme.typography.fontBodySmMedium,
|
style = ElementTheme.typography.fontBodySmMedium,
|
||||||
color = ElementTheme.colors.textSecondary,
|
color = ElementTheme.colors.textSecondary,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue