Improve the preview

This commit is contained in:
Benoit Marty 2024-11-28 09:37:39 +01:00
parent 52e369396d
commit 6dcdee9928

View file

@ -23,6 +23,7 @@ import io.element.android.features.messages.impl.timeline.model.event.aTimelineI
import io.element.android.libraries.matrix.api.timeline.item.event.MessageShield import io.element.android.libraries.matrix.api.timeline.item.event.MessageShield
import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toPersistentList
open class ActionListStateProvider : PreviewParameterProvider<ActionListState> { open class ActionListStateProvider : PreviewParameterProvider<ActionListState> {
override val values: Sequence<ActionListState> override val values: Sequence<ActionListState>
@ -50,7 +51,9 @@ open class ActionListStateProvider : PreviewParameterProvider<ActionListState> {
), ),
displayEmojiReactions = true, displayEmojiReactions = true,
verifiedUserSendFailure = VerifiedUserSendFailure.None, verifiedUserSendFailure = VerifiedUserSendFailure.None,
actions = aTimelineItemActionList(), actions = aTimelineItemActionList(
copyAction = TimelineItemAction.CopyCaption,
),
) )
), ),
anActionListState( anActionListState(
@ -61,7 +64,9 @@ open class ActionListStateProvider : PreviewParameterProvider<ActionListState> {
), ),
displayEmojiReactions = true, displayEmojiReactions = true,
verifiedUserSendFailure = VerifiedUserSendFailure.None, verifiedUserSendFailure = VerifiedUserSendFailure.None,
actions = aTimelineItemActionList(), actions = aTimelineItemActionList(
copyAction = TimelineItemAction.CopyCaption,
),
) )
), ),
anActionListState( anActionListState(
@ -72,7 +77,9 @@ open class ActionListStateProvider : PreviewParameterProvider<ActionListState> {
), ),
displayEmojiReactions = true, displayEmojiReactions = true,
verifiedUserSendFailure = VerifiedUserSendFailure.None, verifiedUserSendFailure = VerifiedUserSendFailure.None,
actions = aTimelineItemActionList(), actions = aTimelineItemActionList(
copyAction = null,
),
) )
), ),
anActionListState( anActionListState(
@ -83,18 +90,22 @@ open class ActionListStateProvider : PreviewParameterProvider<ActionListState> {
), ),
displayEmojiReactions = true, displayEmojiReactions = true,
verifiedUserSendFailure = VerifiedUserSendFailure.None, verifiedUserSendFailure = VerifiedUserSendFailure.None,
actions = aTimelineItemActionList(), actions = aTimelineItemActionList(
copyAction = TimelineItemAction.CopyCaption,
),
) )
), ),
anActionListState( anActionListState(
target = ActionListState.Target.Success( target = ActionListState.Target.Success(
event = aTimelineItemEvent( event = aTimelineItemEvent(
content = aTimelineItemVoiceContent(), content = aTimelineItemVoiceContent(caption = null),
timelineItemReactions = reactionsState timelineItemReactions = reactionsState
), ),
displayEmojiReactions = true, displayEmojiReactions = true,
verifiedUserSendFailure = VerifiedUserSendFailure.None, verifiedUserSendFailure = VerifiedUserSendFailure.None,
actions = aTimelineItemActionList(), actions = aTimelineItemActionList(
copyAction = null,
),
) )
), ),
anActionListState( anActionListState(
@ -161,17 +172,19 @@ fun anActionListState(
eventSink = eventSink eventSink = eventSink
) )
fun aTimelineItemActionList(): ImmutableList<TimelineItemAction> { fun aTimelineItemActionList(
return persistentListOf( copyAction: TimelineItemAction? = TimelineItemAction.CopyText
): ImmutableList<TimelineItemAction> {
return listOfNotNull(
TimelineItemAction.Reply, TimelineItemAction.Reply,
TimelineItemAction.Forward, TimelineItemAction.Forward,
TimelineItemAction.CopyText, copyAction,
TimelineItemAction.CopyLink, TimelineItemAction.CopyLink,
TimelineItemAction.Edit, TimelineItemAction.Edit,
TimelineItemAction.Redact, TimelineItemAction.Redact,
TimelineItemAction.ReportContent, TimelineItemAction.ReportContent,
TimelineItemAction.ViewSource, TimelineItemAction.ViewSource,
) ).toPersistentList()
} }
fun aTimelineItemPollActionList(): ImmutableList<TimelineItemAction> { fun aTimelineItemPollActionList(): ImmutableList<TimelineItemAction> {