Room directory : more cleanup and more tests
This commit is contained in:
parent
2103306387
commit
42004f251b
7 changed files with 113 additions and 27 deletions
|
|
@ -29,7 +29,11 @@
|
|||
<string name="screen_room_change_role_confirm_demote_self_action">"Demote"</string>
|
||||
<string name="screen_room_change_role_confirm_demote_self_description">"You will not be able to undo this change as you are demoting yourself, if you are the last privileged user in the room it will be impossible to regain privileges."</string>
|
||||
<string name="screen_room_change_role_confirm_demote_self_title">"Demote yourself?"</string>
|
||||
<string name="screen_room_change_role_invited_member_name">"%1$s (Pending)"</string>
|
||||
<string name="screen_room_change_role_moderators_title">"Edit Moderators"</string>
|
||||
<string name="screen_room_change_role_section_administrators">"Admins"</string>
|
||||
<string name="screen_room_change_role_section_moderators">"Moderators"</string>
|
||||
<string name="screen_room_change_role_section_users">"Members"</string>
|
||||
<string name="screen_room_change_role_unsaved_changes_description">"You have unsaved changes."</string>
|
||||
<string name="screen_room_change_role_unsaved_changes_title">"Save changes?"</string>
|
||||
<string name="screen_room_details_add_topic_title">"Add topic"</string>
|
||||
|
|
|
|||
|
|
@ -32,7 +32,22 @@ open class RoomDirectoryStateProvider : PreviewParameterProvider<RoomDirectorySt
|
|||
aRoomDirectoryState(
|
||||
query = "Element",
|
||||
roomDescriptions = aRoomDescriptionList(),
|
||||
)
|
||||
),
|
||||
aRoomDirectoryState(
|
||||
query = "Element",
|
||||
roomDescriptions = aRoomDescriptionList(),
|
||||
displayLoadMoreIndicator = true,
|
||||
),
|
||||
aRoomDirectoryState(
|
||||
query = "Element",
|
||||
roomDescriptions = aRoomDescriptionList(),
|
||||
joinRoomAction = AsyncAction.Loading,
|
||||
),
|
||||
aRoomDirectoryState(
|
||||
query = "Element",
|
||||
roomDescriptions = aRoomDescriptionList(),
|
||||
joinRoomAction = AsyncAction.Failure(Exception("Failed to join room")),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ import androidx.compose.ui.unit.dp
|
|||
import io.element.android.compound.theme.ElementTheme
|
||||
import io.element.android.compound.tokens.generated.CompoundIcons
|
||||
import io.element.android.features.roomdirectory.api.RoomDescription
|
||||
import io.element.android.features.roomdirectory.impl.R
|
||||
import io.element.android.libraries.designsystem.components.async.AsyncActionView
|
||||
import io.element.android.libraries.designsystem.components.avatar.Avatar
|
||||
import io.element.android.libraries.designsystem.components.button.BackButton
|
||||
|
|
@ -87,8 +88,8 @@ fun RoomDirectoryView(
|
|||
state = state,
|
||||
onResultClicked = ::joinRoom,
|
||||
modifier = Modifier
|
||||
.padding(padding)
|
||||
.consumeWindowInsets(padding)
|
||||
.padding(padding)
|
||||
.consumeWindowInsets(padding)
|
||||
)
|
||||
}
|
||||
)
|
||||
|
|
@ -97,6 +98,9 @@ fun RoomDirectoryView(
|
|||
onSuccess = onRoomJoined,
|
||||
onErrorDismiss = {
|
||||
state.eventSink(RoomDirectoryEvents.JoinRoomDismissError)
|
||||
},
|
||||
errorMessage = {
|
||||
stringResource(id = CommonStrings.error_unknown)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
@ -114,7 +118,7 @@ private fun RoomDirectoryTopBar(
|
|||
},
|
||||
title = {
|
||||
Text(
|
||||
text = "Room directory",
|
||||
text = stringResource(id = R.string.screen_room_directory_search_title),
|
||||
style = ElementTheme.typography.aliasScreenTitle,
|
||||
)
|
||||
}
|
||||
|
|
@ -184,10 +188,10 @@ private fun RoomDirectoryRoomList(
|
|||
@Composable
|
||||
private fun LoadMoreIndicator(modifier: Modifier = Modifier) {
|
||||
Box(
|
||||
modifier
|
||||
.fillMaxWidth()
|
||||
.wrapContentHeight()
|
||||
.padding(24.dp),
|
||||
modifier
|
||||
.fillMaxWidth()
|
||||
.wrapContentHeight()
|
||||
.padding(24.dp),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
CircularProgressIndicator(
|
||||
|
|
@ -257,14 +261,16 @@ private fun RoomDirectoryRoomRow(
|
|||
) {
|
||||
Row(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.clickable { onClick(roomDescription.roomId) }
|
||||
.padding(
|
||||
top = 12.dp,
|
||||
bottom = 12.dp,
|
||||
start = 16.dp,
|
||||
)
|
||||
.height(IntrinsicSize.Min),
|
||||
.fillMaxWidth()
|
||||
.clickable(enabled = roomDescription.canBeJoined) {
|
||||
onClick(roomDescription.roomId)
|
||||
}
|
||||
.padding(
|
||||
top = 12.dp,
|
||||
bottom = 12.dp,
|
||||
start = 16.dp,
|
||||
)
|
||||
.height(IntrinsicSize.Min),
|
||||
) {
|
||||
Avatar(
|
||||
avatarData = roomDescription.avatarData,
|
||||
|
|
@ -272,8 +278,8 @@ private fun RoomDirectoryRoomRow(
|
|||
)
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(start = 16.dp)
|
||||
.weight(1f)
|
||||
.padding(start = 16.dp)
|
||||
) {
|
||||
Text(
|
||||
text = roomDescription.name,
|
||||
|
|
@ -295,8 +301,8 @@ private fun RoomDirectoryRoomRow(
|
|||
text = stringResource(id = CommonStrings.action_join),
|
||||
color = ElementTheme.colors.textSuccessPrimary,
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterVertically)
|
||||
.padding(start = 4.dp, end = 12.dp)
|
||||
.align(Alignment.CenterVertically)
|
||||
.padding(start = 4.dp, end = 12.dp)
|
||||
)
|
||||
} else {
|
||||
Spacer(modifier = Modifier.width(24.dp))
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
<string name="screen_room_directory_search_loading_error">"Failed loading"</string>
|
||||
<string name="screen_room_directory_search_title">"Room directory"</string>
|
||||
</resources>
|
||||
|
|
@ -43,6 +43,7 @@ import androidx.compose.ui.res.stringResource
|
|||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.unit.dp
|
||||
import io.element.android.compound.tokens.generated.CompoundIcons
|
||||
import io.element.android.features.roomlist.impl.R
|
||||
import io.element.android.features.roomlist.impl.components.RoomSummaryRow
|
||||
import io.element.android.features.roomlist.impl.contentType
|
||||
import io.element.android.features.roomlist.impl.model.RoomListRoomSummary
|
||||
|
|
@ -131,8 +132,8 @@ private fun RoomListSearchContent(
|
|||
val focusRequester = FocusRequester()
|
||||
TextField(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.focusRequester(focusRequester),
|
||||
.fillMaxWidth()
|
||||
.focusRequester(focusRequester),
|
||||
value = filter,
|
||||
singleLine = true,
|
||||
onValueChange = { state.eventSink(RoomListSearchEvents.QueryChanged(it)) },
|
||||
|
|
@ -171,8 +172,8 @@ private fun RoomListSearchContent(
|
|||
) { padding ->
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(padding)
|
||||
.consumeWindowInsets(padding)
|
||||
.padding(padding)
|
||||
.consumeWindowInsets(padding)
|
||||
) {
|
||||
if (state.displayRoomDirectorySearch) {
|
||||
RoomDirectorySearchButton(
|
||||
|
|
@ -206,7 +207,7 @@ private fun RoomDirectorySearchButton(
|
|||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Button(
|
||||
text = "Browse all rooms",
|
||||
text = stringResource(id = R.string.screen_roomlist_room_directory_button_title),
|
||||
leadingIcon = IconSource.Vector(CompoundIcons.ListBulleted()),
|
||||
onClick = onClick,
|
||||
modifier = modifier,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue