Ensure all dialogs have the same preview format.
A combined ElementThemedPreview with PreviewGroup.Dialogs for Showkase and a regular PreviewsDayNight for code coverage
This commit is contained in:
parent
b8d9c89ec4
commit
689ab61b23
7 changed files with 118 additions and 15 deletions
|
|
@ -35,8 +35,10 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Dialog
|
||||
import androidx.compose.ui.window.DialogProperties
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
import io.element.android.libraries.designsystem.preview.ElementThemedPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewGroup
|
||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||
import io.element.android.libraries.designsystem.theme.components.CircularProgressIndicator
|
||||
import io.element.android.libraries.designsystem.theme.components.DialogPreview
|
||||
import io.element.android.libraries.designsystem.theme.components.Text
|
||||
|
|
@ -141,8 +143,14 @@ private fun ProgressDialogContent(
|
|||
|
||||
@Preview(group = PreviewGroup.Dialogs)
|
||||
@Composable
|
||||
internal fun ProgressDialogPreview() = ElementThemedPreview {
|
||||
internal fun ProgressDialogContentPreview() = ElementThemedPreview {
|
||||
DialogPreview {
|
||||
ProgressDialogContent(text = "test dialog content", isCancellable = true)
|
||||
}
|
||||
}
|
||||
|
||||
@PreviewsDayNight
|
||||
@Composable
|
||||
internal fun ProgressDialogPreview() = ElementPreview {
|
||||
ProgressDialog(text = "test dialog content", isCancellable = true)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,8 +22,10 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
import io.element.android.libraries.designsystem.preview.ElementThemedPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewGroup
|
||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||
import io.element.android.libraries.designsystem.theme.components.DialogPreview
|
||||
import io.element.android.libraries.designsystem.theme.components.SimpleAlertDialogContent
|
||||
import io.element.android.libraries.ui.strings.CommonStrings
|
||||
|
|
@ -87,7 +89,7 @@ private fun ConfirmationDialogContent(
|
|||
|
||||
@Preview(group = PreviewGroup.Dialogs)
|
||||
@Composable
|
||||
internal fun ConfirmationDialogPreview() =
|
||||
internal fun ConfirmationDialogContentPreview() =
|
||||
ElementThemedPreview(showBackground = false) {
|
||||
DialogPreview {
|
||||
ConfirmationDialogContent(
|
||||
|
|
@ -102,3 +104,17 @@ internal fun ConfirmationDialogPreview() =
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
@PreviewsDayNight
|
||||
@Composable
|
||||
internal fun ConfirmationDialogPreview() = ElementPreview {
|
||||
ConfirmationDialog(
|
||||
content = "Content",
|
||||
title = "Title",
|
||||
submitText = "OK",
|
||||
cancelText = "Cancel",
|
||||
thirdButtonText = "Disable",
|
||||
onSubmitClicked = {},
|
||||
onDismiss = {}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,8 +22,10 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
import io.element.android.libraries.designsystem.preview.ElementThemedPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewGroup
|
||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||
import io.element.android.libraries.designsystem.theme.components.DialogPreview
|
||||
import io.element.android.libraries.designsystem.theme.components.SimpleAlertDialogContent
|
||||
import io.element.android.libraries.ui.strings.CommonStrings
|
||||
|
|
@ -69,7 +71,7 @@ object ErrorDialogDefaults {
|
|||
|
||||
@Preview(group = PreviewGroup.Dialogs)
|
||||
@Composable
|
||||
internal fun ErrorDialogPreview() {
|
||||
internal fun ErrorDialogContentPreview() {
|
||||
ElementThemedPreview(showBackground = false) {
|
||||
DialogPreview {
|
||||
ErrorDialogContent(
|
||||
|
|
@ -79,3 +81,12 @@ internal fun ErrorDialogPreview() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@PreviewsDayNight
|
||||
@Composable
|
||||
internal fun ErrorDialogPreview() = ElementPreview {
|
||||
ErrorDialog(
|
||||
content = "Content",
|
||||
onDismiss = {},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,10 +24,11 @@ import androidx.compose.material3.ExperimentalMaterial3Api
|
|||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.airbnb.android.showkase.annotation.ShowkaseComposable
|
||||
import io.element.android.libraries.designsystem.components.list.TextFieldListItem
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
import io.element.android.libraries.designsystem.preview.ElementThemedPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewGroup
|
||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||
import io.element.android.libraries.designsystem.theme.components.DialogPreview
|
||||
|
|
@ -100,11 +101,10 @@ private fun ListDialogContent(
|
|||
}
|
||||
}
|
||||
|
||||
@PreviewsDayNight
|
||||
@ShowkaseComposable(group = PreviewGroup.Dialogs)
|
||||
@Preview(group = PreviewGroup.Dialogs)
|
||||
@Composable
|
||||
internal fun ListDialogContentPreview() {
|
||||
ElementPreview(showBackground = false) {
|
||||
ElementThemedPreview(showBackground = false) {
|
||||
DialogPreview {
|
||||
ListDialogContent(
|
||||
listItems = {
|
||||
|
|
@ -124,3 +124,23 @@ internal fun ListDialogContentPreview() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@PreviewsDayNight
|
||||
@Composable
|
||||
internal fun ListDialogPreview() = ElementPreview {
|
||||
ListDialog(
|
||||
listItems = {
|
||||
item {
|
||||
TextFieldListItem(placeholder = "Text input", text = "", onTextChanged = {})
|
||||
}
|
||||
item {
|
||||
TextFieldListItem(placeholder = "Another text input", text = "", onTextChanged = {})
|
||||
}
|
||||
},
|
||||
title = "Dialog title",
|
||||
onDismissRequest = {},
|
||||
onSubmit = {},
|
||||
cancelText = "Cancel",
|
||||
submitText = "Save",
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,10 +26,11 @@ import androidx.compose.runtime.remember
|
|||
import androidx.compose.runtime.toMutableStateList
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.airbnb.android.showkase.annotation.ShowkaseComposable
|
||||
import io.element.android.libraries.designsystem.components.list.CheckboxListItem
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
import io.element.android.libraries.designsystem.preview.ElementThemedPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewGroup
|
||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||
import io.element.android.libraries.designsystem.theme.components.DialogPreview
|
||||
|
|
@ -124,11 +125,10 @@ private fun MultipleSelectionDialogContent(
|
|||
}
|
||||
}
|
||||
|
||||
@PreviewsDayNight
|
||||
@ShowkaseComposable(group = PreviewGroup.Dialogs)
|
||||
@Preview(group = PreviewGroup.Dialogs)
|
||||
@Composable
|
||||
internal fun MultipleSelectionDialogContentPreview() {
|
||||
ElementPreview(showBackground = false) {
|
||||
ElementThemedPreview(showBackground = false) {
|
||||
DialogPreview {
|
||||
val options = persistentListOf(
|
||||
ListOption("Option 1", "Supporting line text lorem ipsum dolor sit amet, consectetur."),
|
||||
|
|
@ -147,3 +147,22 @@ internal fun MultipleSelectionDialogContentPreview() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@PreviewsDayNight
|
||||
@Composable
|
||||
internal fun MultipleSelectionDialogPreview() = ElementPreview {
|
||||
val options = persistentListOf(
|
||||
ListOption("Option 1", "Supporting line text lorem ipsum dolor sit amet, consectetur."),
|
||||
ListOption("Option 2"),
|
||||
ListOption("Option 3"),
|
||||
)
|
||||
MultipleSelectionDialog(
|
||||
title = "Dialog title",
|
||||
options = options,
|
||||
onConfirmClicked = {},
|
||||
onDismissRequest = {},
|
||||
confirmButtonTitle = "Save",
|
||||
dismissButtonTitle = "Cancel",
|
||||
initialSelection = persistentListOf(0),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,8 +22,10 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
import io.element.android.libraries.designsystem.preview.ElementThemedPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewGroup
|
||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||
import io.element.android.libraries.designsystem.theme.components.DialogPreview
|
||||
import io.element.android.libraries.designsystem.theme.components.SimpleAlertDialogContent
|
||||
import io.element.android.libraries.ui.strings.CommonStrings
|
||||
|
|
@ -78,7 +80,7 @@ object RetryDialogDefaults {
|
|||
|
||||
@Preview(group = PreviewGroup.Dialogs)
|
||||
@Composable
|
||||
internal fun RetryDialogPreview() {
|
||||
internal fun RetryDialogContentPreview() {
|
||||
ElementThemedPreview(showBackground = false) {
|
||||
DialogPreview {
|
||||
RetryDialogContent(
|
||||
|
|
@ -89,3 +91,13 @@ internal fun RetryDialogPreview() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@PreviewsDayNight
|
||||
@Composable
|
||||
internal fun RetryDialogPreview() = ElementPreview {
|
||||
RetryDialog(
|
||||
content = "Content",
|
||||
onRetry = {},
|
||||
onDismiss = {},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ import androidx.compose.material3.ExperimentalMaterial3Api
|
|||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.airbnb.android.showkase.annotation.ShowkaseComposable
|
||||
import io.element.android.libraries.designsystem.components.list.RadioButtonListItem
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewGroup
|
||||
|
|
@ -105,8 +105,7 @@ private fun SingleSelectionDialogContent(
|
|||
}
|
||||
}
|
||||
|
||||
@PreviewsDayNight
|
||||
@ShowkaseComposable(group = PreviewGroup.Dialogs)
|
||||
@Preview(group = PreviewGroup.Dialogs)
|
||||
@Composable
|
||||
internal fun SingleSelectionDialogContentPreview() {
|
||||
ElementPreview(showBackground = false) {
|
||||
|
|
@ -127,3 +126,21 @@ internal fun SingleSelectionDialogContentPreview() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@PreviewsDayNight
|
||||
@Composable
|
||||
internal fun SingleSelectionDialogPreview() = ElementPreview {
|
||||
val options = persistentListOf(
|
||||
ListOption("Option 1"),
|
||||
ListOption("Option 2"),
|
||||
ListOption("Option 3"),
|
||||
)
|
||||
SingleSelectionDialog(
|
||||
title = "Dialog title",
|
||||
options = options,
|
||||
onOptionSelected = {},
|
||||
onDismissRequest = {},
|
||||
dismissButtonTitle = "Cancel",
|
||||
initialSelection = 0
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue