feature(space): better previews for Space screen
This commit is contained in:
parent
5244dddb73
commit
ff0a07279f
1 changed files with 22 additions and 38 deletions
|
|
@ -8,6 +8,7 @@
|
||||||
package io.element.android.features.space.impl.root
|
package io.element.android.features.space.impl.root
|
||||||
|
|
||||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
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.AcceptDeclineInviteState
|
||||||
import io.element.android.features.invite.api.acceptdecline.anAcceptDeclineInviteState
|
import io.element.android.features.invite.api.acceptdecline.anAcceptDeclineInviteState
|
||||||
import io.element.android.libraries.architecture.AsyncAction
|
import io.element.android.libraries.architecture.AsyncAction
|
||||||
|
|
@ -25,60 +26,30 @@ open class SpaceStateProvider : PreviewParameterProvider<SpaceState> {
|
||||||
override val values: Sequence<SpaceState>
|
override val values: Sequence<SpaceState>
|
||||||
get() = sequenceOf(
|
get() = sequenceOf(
|
||||||
aSpaceState(),
|
aSpaceState(),
|
||||||
|
aSpaceState(parentSpace = aParentSpace(joinRule = JoinRule.Public)),
|
||||||
|
aSpaceState(parentSpace = aParentSpace(joinRule = JoinRule.Restricted(persistentListOf()))),
|
||||||
|
aSpaceState(children = aListOfSpaceRooms()),
|
||||||
aSpaceState(
|
aSpaceState(
|
||||||
parentSpace = aSpaceRoom(
|
parentSpace = aParentSpace(),
|
||||||
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,
|
|
||||||
children = aListOfSpaceRooms(),
|
children = aListOfSpaceRooms(),
|
||||||
joiningRooms = setOf(RoomId("!spaceId0:example.com")),
|
joiningRooms = setOf(RoomId("!spaceId0:example.com")),
|
||||||
|
hasMoreToLoad = false
|
||||||
),
|
),
|
||||||
aSpaceState(
|
aSpaceState(
|
||||||
hasMoreToLoad = false,
|
topicViewerState = TopicViewerState.Shown(topic = "Space description goes here." + LoremIpsum(20).values.first()),
|
||||||
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(),
|
|
||||||
),
|
),
|
||||||
// Add other states here
|
// Add other states here
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun aSpaceState(
|
fun aSpaceState(
|
||||||
parentSpace: SpaceRoom? = aSpaceRoom(
|
parentSpace: SpaceRoom? = aParentSpace(),
|
||||||
numJoinedMembers = 5,
|
|
||||||
childrenCount = 10,
|
|
||||||
worldReadable = true,
|
|
||||||
roomId = RoomId("!spaceId0:example.com"),
|
|
||||||
),
|
|
||||||
children: List<SpaceRoom> = emptyList(),
|
children: List<SpaceRoom> = emptyList(),
|
||||||
seenSpaceInvites: Set<RoomId> = emptySet(),
|
seenSpaceInvites: Set<RoomId> = emptySet(),
|
||||||
joiningRooms: Set<RoomId> = emptySet(),
|
joiningRooms: Set<RoomId> = emptySet(),
|
||||||
joinActions: Map<RoomId, AsyncAction<Unit>> = joiningRooms.associateWith { AsyncAction.Loading },
|
joinActions: Map<RoomId, AsyncAction<Unit>> = joiningRooms.associateWith { AsyncAction.Loading },
|
||||||
hideInvitesAvatar: Boolean = false,
|
hideInvitesAvatar: Boolean = false,
|
||||||
hasMoreToLoad: Boolean = false,
|
hasMoreToLoad: Boolean = true,
|
||||||
acceptDeclineInviteState: AcceptDeclineInviteState = anAcceptDeclineInviteState(),
|
acceptDeclineInviteState: AcceptDeclineInviteState = anAcceptDeclineInviteState(),
|
||||||
topicViewerState: TopicViewerState = TopicViewerState.Hidden,
|
topicViewerState: TopicViewerState = TopicViewerState.Hidden,
|
||||||
eventSink: (SpaceEvents) -> Unit = { },
|
eventSink: (SpaceEvents) -> Unit = { },
|
||||||
|
|
@ -94,6 +65,19 @@ fun aSpaceState(
|
||||||
eventSink = eventSink,
|
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> {
|
private fun aListOfSpaceRooms(): List<SpaceRoom> {
|
||||||
return listOf(
|
return listOf(
|
||||||
aSpaceRoom(
|
aSpaceRoom(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue