chore: previews on many components
This commit is contained in:
parent
8c4615f207
commit
45bfefbebf
|
|
@ -62,6 +62,13 @@ fun CollapsibleCard(
|
|||
fun CollapsibleCardPreview() {
|
||||
CollapsibleCard(
|
||||
title = "Title",
|
||||
content = { Text(text = "Content") }
|
||||
content = {
|
||||
Text(
|
||||
text = "Content",
|
||||
modifier = Modifier
|
||||
.padding(10.dp)
|
||||
.fillMaxWidth()
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ fun SheetClickable(
|
|||
label: @Composable (TextStyle) -> Unit,
|
||||
onClick: () -> Unit,
|
||||
) {
|
||||
Box(modifier = Modifier.padding(bottom = 8.dp)) {
|
||||
Box(modifier = Modifier.padding(vertical = 4.dp)) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.clip(MaterialTheme.shapes.medium)
|
||||
|
|
@ -46,7 +46,7 @@ fun SheetClickable(
|
|||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Preview(showBackground = true)
|
||||
@Composable
|
||||
fun SettingsCategoryPreview() {
|
||||
SheetClickable(
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import androidx.compose.ui.draw.clip
|
|||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import chat.revolt.R
|
||||
|
|
@ -130,4 +131,16 @@ fun UserAvatarWidthPlaceholder(
|
|||
modifier = Modifier
|
||||
.width(size)
|
||||
)
|
||||
}
|
||||
|
||||
// Note - Preview will not render due to Glide not being able to load images in preview (NPE)
|
||||
// including here anyways on the off chance that it gets fixed in the future, or we switch to Coil lol
|
||||
@Preview
|
||||
@Composable
|
||||
fun UserAvatarWithPresencePreview() {
|
||||
UserAvatar(
|
||||
username = "infi",
|
||||
userId = "01F1WKM5TK2V6KCZWR6DGBJDTZ",
|
||||
presence = Presence.Online
|
||||
)
|
||||
}
|
||||
|
|
@ -7,6 +7,8 @@ import androidx.compose.foundation.layout.padding
|
|||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
|
|
@ -45,14 +47,20 @@ fun AnyLink(text: String, action: () -> Unit, modifier: Modifier = Modifier) {
|
|||
)
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Preview(showBackground = true)
|
||||
@Composable
|
||||
fun WeblinkPreview() {
|
||||
Weblink(text = "https://revolt.chat", url = "https://revolt.chat")
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Preview(showBackground = true)
|
||||
@Composable
|
||||
fun AnyLinkPreview() {
|
||||
AnyLink(text = "Click me!", action = {})
|
||||
val clicked = remember {
|
||||
mutableStateOf(0)
|
||||
}
|
||||
|
||||
AnyLink(text = "Click me! #${clicked.value}", action = {
|
||||
clicked.value++
|
||||
})
|
||||
}
|
||||
|
|
@ -13,9 +13,11 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import chat.revolt.R
|
||||
import chat.revolt.api.routes.microservices.autumn.FileArgs
|
||||
import java.io.File
|
||||
|
||||
@Composable
|
||||
fun AttachmentManager(
|
||||
|
|
@ -61,4 +63,30 @@ fun AttachmentManager(
|
|||
Spacer(modifier = Modifier.width(8.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun AttachmentManagerPreview() {
|
||||
AttachmentManager(
|
||||
attachments = listOf(
|
||||
FileArgs(
|
||||
filename = "file1.png",
|
||||
contentType = "image/png",
|
||||
file = File("file1.png"),
|
||||
),
|
||||
FileArgs(
|
||||
filename = "file2.png",
|
||||
contentType = "image/png",
|
||||
file = File("file2.png"),
|
||||
),
|
||||
FileArgs(
|
||||
filename = "file3.png",
|
||||
contentType = "image/png",
|
||||
file = File("file3.png"),
|
||||
),
|
||||
),
|
||||
uploading = false,
|
||||
onRemove = {}
|
||||
)
|
||||
}
|
||||
|
|
@ -8,6 +8,9 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import chat.revolt.R
|
||||
import chat.revolt.api.schemas.ChannelType
|
||||
|
||||
|
|
@ -53,4 +56,24 @@ fun ChannelIcon(
|
|||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ChannelTypeProvider : PreviewParameterProvider<ChannelType> {
|
||||
override val values: Sequence<ChannelType>
|
||||
get() = sequenceOf(
|
||||
ChannelType.TextChannel,
|
||||
ChannelType.VoiceChannel,
|
||||
ChannelType.SavedMessages,
|
||||
ChannelType.DirectMessage,
|
||||
ChannelType.Group,
|
||||
)
|
||||
|
||||
override val count: Int
|
||||
get() = values.count()
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun ChannelIconPreview(@PreviewParameter(ChannelTypeProvider::class) channelType: ChannelType) {
|
||||
ChannelIcon(channelType = channelType)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@Composable
|
||||
|
|
@ -46,4 +47,15 @@ fun ThemeChip(
|
|||
style = MaterialTheme.typography.labelLarge
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun SelectedThemeChipPreview() {
|
||||
ThemeChip(
|
||||
color = Color.Red,
|
||||
text = "Red",
|
||||
selected = true,
|
||||
onClick = {}
|
||||
)
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import chat.revolt.R
|
||||
|
|
@ -53,4 +54,10 @@ fun DisconnectedScreen(
|
|||
Text(stringResource(R.string.tap_to_retry))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(showBackground = true, showSystemUi = true)
|
||||
@Composable
|
||||
fun DisconnectedScreenPreview() {
|
||||
DisconnectedScreen(onRetry = {})
|
||||
}
|
||||
Loading…
Reference in New Issue