mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-04 19:10:43 +00:00
Merge pull request #7881 from element-hq/feature/bma/fixRoomSelectScroll
Fix room list not scrollable in the room select screen when there is a single account
This commit is contained in:
+14
-5
@@ -177,7 +177,14 @@ fun RoomSelectView(
|
|||||||
Modifier
|
Modifier
|
||||||
.padding(paddingValues)
|
.padding(paddingValues)
|
||||||
.consumeWindowInsets(paddingValues)
|
.consumeWindowInsets(paddingValues)
|
||||||
.nestedScroll(accountSwitchScrollBehavior.nestedScrollConnection)
|
.then(
|
||||||
|
// Only when the account switch section is displayed, else its unknown height would consume all the scroll events
|
||||||
|
if (state.showAccountSwitch && !state.isSearchActive) {
|
||||||
|
Modifier.nestedScroll(accountSwitchScrollBehavior.nestedScrollConnection)
|
||||||
|
} else {
|
||||||
|
Modifier
|
||||||
|
}
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
SearchBar(
|
SearchBar(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@@ -194,16 +201,18 @@ fun RoomSelectView(
|
|||||||
resultState = state.resultState,
|
resultState = state.resultState,
|
||||||
showBackButton = false,
|
showBackButton = false,
|
||||||
) { summaries ->
|
) { summaries ->
|
||||||
|
LazyColumn(
|
||||||
|
state = lazyListState,
|
||||||
|
contentPadding = lazyColumnContentPadding,
|
||||||
|
) {
|
||||||
if (summaries.isNotEmpty()) {
|
if (summaries.isNotEmpty()) {
|
||||||
|
item {
|
||||||
ListSectionHeader(
|
ListSectionHeader(
|
||||||
title = stringResource(CommonStrings.common_header_rooms),
|
title = stringResource(CommonStrings.common_header_rooms),
|
||||||
hasDivider = false,
|
hasDivider = false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
LazyColumn(
|
}
|
||||||
state = lazyListState,
|
|
||||||
contentPadding = lazyColumnContentPadding,
|
|
||||||
) {
|
|
||||||
item {
|
item {
|
||||||
SelectedRoomsHelper(
|
SelectedRoomsHelper(
|
||||||
selectedRooms = state.selectedRooms,
|
selectedRooms = state.selectedRooms,
|
||||||
|
|||||||
+39
@@ -13,8 +13,12 @@ import androidx.activity.ComponentActivity
|
|||||||
import androidx.compose.ui.test.AndroidComposeUiTest
|
import androidx.compose.ui.test.AndroidComposeUiTest
|
||||||
import androidx.compose.ui.test.ExperimentalTestApi
|
import androidx.compose.ui.test.ExperimentalTestApi
|
||||||
import androidx.compose.ui.test.assertIsDisplayed
|
import androidx.compose.ui.test.assertIsDisplayed
|
||||||
|
import androidx.compose.ui.test.assertIsNotDisplayed
|
||||||
import androidx.compose.ui.test.onNodeWithText
|
import androidx.compose.ui.test.onNodeWithText
|
||||||
|
import androidx.compose.ui.test.onRoot
|
||||||
import androidx.compose.ui.test.performClick
|
import androidx.compose.ui.test.performClick
|
||||||
|
import androidx.compose.ui.test.performTouchInput
|
||||||
|
import androidx.compose.ui.test.swipeUp
|
||||||
import androidx.compose.ui.test.v2.runAndroidComposeUiTest
|
import androidx.compose.ui.test.v2.runAndroidComposeUiTest
|
||||||
import io.element.android.libraries.designsystem.theme.components.SearchBarResultState
|
import io.element.android.libraries.designsystem.theme.components.SearchBarResultState
|
||||||
import io.element.android.libraries.matrix.api.core.RoomId
|
import io.element.android.libraries.matrix.api.core.RoomId
|
||||||
@@ -29,6 +33,7 @@ import io.element.android.tests.testutils.EventsRecorder
|
|||||||
import io.element.android.tests.testutils.clickOn
|
import io.element.android.tests.testutils.clickOn
|
||||||
import io.element.android.tests.testutils.robolectric.RobolectricTest
|
import io.element.android.tests.testutils.robolectric.RobolectricTest
|
||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
|
import kotlinx.collections.immutable.toImmutableList
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.robolectric.annotation.Config
|
import org.robolectric.annotation.Config
|
||||||
|
|
||||||
@@ -123,6 +128,33 @@ class RoomSelectViewTest : RobolectricTest() {
|
|||||||
onNodeWithText(activity!!.getString(CommonStrings.common_switch_account)).assertDoesNotExist()
|
onNodeWithText(activity!!.getString(CommonStrings.common_switch_account)).assertDoesNotExist()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `the room list can be scrolled when there is no other account`() = runAndroidComposeUiTest {
|
||||||
|
setRoomSelectView(
|
||||||
|
aRoomSelectState(
|
||||||
|
mode = RoomSelectMode.Share,
|
||||||
|
resultState = SearchBarResultState.Results(aLongRoomList()),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
onNodeWithText("Room 0").assertIsDisplayed()
|
||||||
|
onRoot().performTouchInput { swipeUp() }
|
||||||
|
onNodeWithText("Room 0").assertIsNotDisplayed()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `the room list can be scrolled when there are other accounts`() = runAndroidComposeUiTest {
|
||||||
|
setRoomSelectView(
|
||||||
|
aRoomSelectState(
|
||||||
|
mode = RoomSelectMode.Share,
|
||||||
|
resultState = SearchBarResultState.Results(aLongRoomList()),
|
||||||
|
otherAccounts = persistentListOf(aMatrixUser(id = "@bob:example.org", displayName = "Bob")),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
onNodeWithText("Room 0").assertIsDisplayed()
|
||||||
|
onRoot().performTouchInput { swipeUp() }
|
||||||
|
onNodeWithText("Room 0").assertIsNotDisplayed()
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `an error is displayed instead of the rooms if they cannot be loaded`() = runAndroidComposeUiTest<ComponentActivity> {
|
fun `an error is displayed instead of the rooms if they cannot be loaded`() = runAndroidComposeUiTest<ComponentActivity> {
|
||||||
setRoomSelectView(
|
setRoomSelectView(
|
||||||
@@ -150,3 +182,10 @@ private fun AndroidComposeUiTest<ComponentActivity>.setRoomSelectView(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun aLongRoomList() = List(30) { index ->
|
||||||
|
aSelectRoomInfo(
|
||||||
|
roomId = RoomId("!room$index:domain"),
|
||||||
|
name = "Room $index",
|
||||||
|
)
|
||||||
|
}.toImmutableList()
|
||||||
|
|||||||
Reference in New Issue
Block a user