Add some previews.
This commit is contained in:
parent
6d9e79132b
commit
3851653d39
2 changed files with 64 additions and 0 deletions
|
|
@ -46,13 +46,18 @@ import androidx.compose.ui.graphics.Path
|
||||||
import androidx.compose.ui.graphics.Shape
|
import androidx.compose.ui.graphics.Shape
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||||
import androidx.compose.ui.unit.Density
|
import androidx.compose.ui.unit.Density
|
||||||
import androidx.compose.ui.unit.LayoutDirection
|
import androidx.compose.ui.unit.LayoutDirection
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import com.google.accompanist.placeholder.material.placeholder
|
import com.google.accompanist.placeholder.material.placeholder
|
||||||
import io.element.android.features.roomlist.model.RoomListRoomSummary
|
import io.element.android.features.roomlist.model.RoomListRoomSummary
|
||||||
|
import io.element.android.features.roomlist.model.RoomListRoomSummaryProvider
|
||||||
import io.element.android.libraries.designsystem.components.avatar.Avatar
|
import io.element.android.libraries.designsystem.components.avatar.Avatar
|
||||||
|
import io.element.android.libraries.designsystem.preview.ElementPreviewDark
|
||||||
|
import io.element.android.libraries.designsystem.preview.ElementPreviewLight
|
||||||
import io.element.android.libraries.designsystem.theme.ElementTheme
|
import io.element.android.libraries.designsystem.theme.ElementTheme
|
||||||
import io.element.android.libraries.designsystem.theme.components.Text
|
import io.element.android.libraries.designsystem.theme.components.Text
|
||||||
import io.element.android.libraries.designsystem.theme.roomListPlaceHolder
|
import io.element.android.libraries.designsystem.theme.roomListPlaceHolder
|
||||||
|
|
@ -192,3 +197,18 @@ class PercentRectangleSizeShape(private val percent: Float) : Shape {
|
||||||
return Outline.Generic(path)
|
return Outline.Generic(path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Preview
|
||||||
|
@Composable
|
||||||
|
internal fun RoomSummaryRowLightPreview(@PreviewParameter(RoomListRoomSummaryProvider::class) data: RoomListRoomSummary) =
|
||||||
|
ElementPreviewLight { ContentToPreview(data) }
|
||||||
|
|
||||||
|
@Preview
|
||||||
|
@Composable
|
||||||
|
internal fun RoomSummaryRowDarkPreview(@PreviewParameter(RoomListRoomSummaryProvider::class) data: RoomListRoomSummary) =
|
||||||
|
ElementPreviewDark { ContentToPreview(data) }
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun ContentToPreview(data: RoomListRoomSummary) {
|
||||||
|
RoomSummaryRow(data)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 New Vector Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.roomlist.model
|
||||||
|
|
||||||
|
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||||
|
import io.element.android.libraries.designsystem.components.avatar.AvatarData
|
||||||
|
import io.element.android.libraries.matrix.core.RoomId
|
||||||
|
|
||||||
|
open class RoomListRoomSummaryProvider : PreviewParameterProvider<RoomListRoomSummary> {
|
||||||
|
override val values: Sequence<RoomListRoomSummary>
|
||||||
|
get() = sequenceOf(
|
||||||
|
aRoomListRoomSummary(),
|
||||||
|
aRoomListRoomSummary().copy(lastMessage = null),
|
||||||
|
aRoomListRoomSummary().copy(hasUnread = true),
|
||||||
|
aRoomListRoomSummary().copy(timestamp = "88:88"),
|
||||||
|
aRoomListRoomSummary().copy(timestamp = "88:88", hasUnread = true),
|
||||||
|
aRoomListRoomSummary().copy(isPlaceholder = true),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun aRoomListRoomSummary() = RoomListRoomSummary(
|
||||||
|
id = "!roomId",
|
||||||
|
roomId = RoomId("!roomId"),
|
||||||
|
name = "Room name",
|
||||||
|
hasUnread = false,
|
||||||
|
timestamp = null,
|
||||||
|
lastMessage = "Last message",
|
||||||
|
avatarData = AvatarData("!roomId", "Room name"),
|
||||||
|
isPlaceholder = false,
|
||||||
|
)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue