feature(space): better previews for Space screen
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
package io.element.android.features.space.impl.root
|
||||
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import androidx.compose.ui.tooling.preview.datasource.LoremIpsum
|
||||
import io.element.android.features.invite.api.acceptdecline.AcceptDeclineInviteState
|
||||
import io.element.android.features.invite.api.acceptdecline.anAcceptDeclineInviteState
|
||||
import io.element.android.libraries.architecture.AsyncAction
|
||||
@@ -25,60 +26,30 @@ open class SpaceStateProvider : PreviewParameterProvider<SpaceState> {
|
||||
override val values: Sequence<SpaceState>
|
||||
get() = sequenceOf(
|
||||
aSpaceState(),
|
||||
aSpaceState(parentSpace = aParentSpace(joinRule = JoinRule.Public)),
|
||||
aSpaceState(parentSpace = aParentSpace(joinRule = JoinRule.Restricted(persistentListOf()))),
|
||||
aSpaceState(children = aListOfSpaceRooms()),
|
||||
aSpaceState(
|
||||
parentSpace = aSpaceRoom(
|
||||
joinRule = JoinRule.Public
|
||||
)
|
||||
),
|
||||
aSpaceState(
|
||||
parentSpace = aSpaceRoom(
|
||||
joinRule = JoinRule.Restricted(persistentListOf())
|
||||
)
|
||||
),
|
||||
aSpaceState(
|
||||
parentSpace = aSpaceRoom(
|
||||
numJoinedMembers = 5,
|
||||
childrenCount = 10,
|
||||
worldReadable = true,
|
||||
),
|
||||
hasMoreToLoad = true,
|
||||
),
|
||||
aSpaceState(
|
||||
hasMoreToLoad = true,
|
||||
children = aListOfSpaceRooms(),
|
||||
),
|
||||
aSpaceState(
|
||||
hasMoreToLoad = false,
|
||||
parentSpace = aParentSpace(),
|
||||
children = aListOfSpaceRooms(),
|
||||
joiningRooms = setOf(RoomId("!spaceId0:example.com")),
|
||||
hasMoreToLoad = false
|
||||
),
|
||||
aSpaceState(
|
||||
hasMoreToLoad = false,
|
||||
topicViewerState = TopicViewerState.Shown(
|
||||
topic = "Description of the space goes right here. Lorem ipsum dolor sit amet consectetur. " +
|
||||
"Leo viverra morbi habitant in. Sem amet enim habitant nibh augue mauris. " +
|
||||
"Interdum mauris ultrices tincidunt proin morbi erat aenean risus nibh. " +
|
||||
"Diam amet sit fermentum vulputate faucibus."
|
||||
),
|
||||
children = aListOfSpaceRooms(),
|
||||
topicViewerState = TopicViewerState.Shown(topic = "Space description goes here." + LoremIpsum(20).values.first()),
|
||||
),
|
||||
// Add other states here
|
||||
)
|
||||
}
|
||||
|
||||
fun aSpaceState(
|
||||
parentSpace: SpaceRoom? = aSpaceRoom(
|
||||
numJoinedMembers = 5,
|
||||
childrenCount = 10,
|
||||
worldReadable = true,
|
||||
roomId = RoomId("!spaceId0:example.com"),
|
||||
),
|
||||
parentSpace: SpaceRoom? = aParentSpace(),
|
||||
children: List<SpaceRoom> = emptyList(),
|
||||
seenSpaceInvites: Set<RoomId> = emptySet(),
|
||||
joiningRooms: Set<RoomId> = emptySet(),
|
||||
joinActions: Map<RoomId, AsyncAction<Unit>> = joiningRooms.associateWith { AsyncAction.Loading },
|
||||
hideInvitesAvatar: Boolean = false,
|
||||
hasMoreToLoad: Boolean = false,
|
||||
hasMoreToLoad: Boolean = true,
|
||||
acceptDeclineInviteState: AcceptDeclineInviteState = anAcceptDeclineInviteState(),
|
||||
topicViewerState: TopicViewerState = TopicViewerState.Hidden,
|
||||
eventSink: (SpaceEvents) -> Unit = { },
|
||||
@@ -94,6 +65,19 @@ fun aSpaceState(
|
||||
eventSink = eventSink,
|
||||
)
|
||||
|
||||
private fun aParentSpace(
|
||||
joinRule: JoinRule? = null,
|
||||
): SpaceRoom {
|
||||
return aSpaceRoom(
|
||||
numJoinedMembers = 5,
|
||||
childrenCount = 10,
|
||||
worldReadable = true,
|
||||
joinRule = joinRule,
|
||||
roomId = RoomId("!spaceId0:example.com"),
|
||||
topic = "Space description goes here. " + LoremIpsum(20).values.first(),
|
||||
)
|
||||
}
|
||||
|
||||
private fun aListOfSpaceRooms(): List<SpaceRoom> {
|
||||
return listOf(
|
||||
aSpaceRoom(
|
||||
|
||||
Reference in New Issue
Block a user