diff --git a/features/rageshake/src/main/kotlin/io/element/android/features/rageshake/bugreport/BugReportStateProvider.kt b/features/rageshake/src/main/kotlin/io/element/android/features/rageshake/bugreport/BugReportStateProvider.kt index 35f0bb7db7..a5dd2ad947 100644 --- a/features/rageshake/src/main/kotlin/io/element/android/features/rageshake/bugreport/BugReportStateProvider.kt +++ b/features/rageshake/src/main/kotlin/io/element/android/features/rageshake/bugreport/BugReportStateProvider.kt @@ -23,7 +23,14 @@ open class BugReportStateProvider : PreviewParameterProvider { override val values: Sequence get() = sequenceOf( aBugReportState(), - aBugReportState().copy(formState = BugReportFormState.Default.copy(description = "A long enough description"), hasCrashLogs = true), + aBugReportState().copy( + formState = BugReportFormState.Default.copy( + description = "A long enough description", + sendScreenshot = true, + ), + hasCrashLogs = true, + screenshotUri = "aUri" + ), aBugReportState().copy(sending = Async.Loading()), aBugReportState().copy(sending = Async.Success(Unit)), ) diff --git a/features/rageshake/src/main/kotlin/io/element/android/features/rageshake/bugreport/BugReportView.kt b/features/rageshake/src/main/kotlin/io/element/android/features/rageshake/bugreport/BugReportView.kt index c66247f0b4..024d6beab9 100644 --- a/features/rageshake/src/main/kotlin/io/element/android/features/rageshake/bugreport/BugReportView.kt +++ b/features/rageshake/src/main/kotlin/io/element/android/features/rageshake/bugreport/BugReportView.kt @@ -51,6 +51,7 @@ import io.element.android.libraries.designsystem.components.dialogs.ErrorDialog import io.element.android.libraries.designsystem.components.form.textFieldState import io.element.android.libraries.designsystem.preview.ElementPreviewDark import io.element.android.libraries.designsystem.preview.ElementPreviewLight +import io.element.android.libraries.designsystem.preview.debugPlaceholderBackground import io.element.android.libraries.designsystem.theme.components.Button import io.element.android.libraries.designsystem.theme.components.CircularProgressIndicator import io.element.android.libraries.designsystem.theme.components.OutlinedTextField @@ -177,7 +178,8 @@ fun BugReportView( AsyncImage( modifier = Modifier.fillMaxWidth(fraction = 0.5f), model = model, - contentDescription = null + contentDescription = null, + placeholder = debugPlaceholderBackground(), ) } } diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/avatar/Avatar.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/avatar/Avatar.kt index 8d6eb0fa4b..222d2a1502 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/avatar/Avatar.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/avatar/Avatar.kt @@ -36,6 +36,7 @@ import io.element.android.libraries.designsystem.AvatarGradientEnd import io.element.android.libraries.designsystem.AvatarGradientStart import io.element.android.libraries.designsystem.preview.ElementPreviewDark import io.element.android.libraries.designsystem.preview.ElementPreviewLight +import io.element.android.libraries.designsystem.preview.debugPlaceholderAvatar import io.element.android.libraries.designsystem.theme.components.Text import timber.log.Timber @@ -69,6 +70,7 @@ private fun ImageAvatar( }, contentDescription = null, contentScale = ContentScale.Crop, + placeholder = debugPlaceholderAvatar(), modifier = modifier ) } diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/avatar/AvatarDataProvider.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/avatar/AvatarDataProvider.kt index f70240f8e2..5e4bad531c 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/avatar/AvatarDataProvider.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/avatar/AvatarDataProvider.kt @@ -23,6 +23,7 @@ open class AvatarDataProvider : PreviewParameterProvider { get() = sequenceOf( anAvatarData(), anAvatarData().copy(name = null), + anAvatarData().copy(url = "aUrl"), ) } diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/preview/Images.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/preview/Images.kt new file mode 100644 index 0000000000..f1fc1b21f0 --- /dev/null +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/preview/Images.kt @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 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.libraries.designsystem.preview + +import androidx.annotation.DrawableRes +import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.LocalInspectionMode +import androidx.compose.ui.res.painterResource +import io.element.android.libraries.designsystem.R + +/** + * I wanted to set up a FakeImageLoader as per https://github.com/coil-kt/coil/issues/1327 + * but it does not render in preview. In the meantime, you can use this trick to have image. + */ +@Composable +fun debugPlaceholder(@DrawableRes debugPreview: Int) = if (LocalInspectionMode.current) { + painterResource(id = debugPreview) +} else { + null +} + +@Composable +fun debugPlaceholderBackground() = debugPlaceholder(debugPreview = R.drawable.sample_background) + +@Composable +fun debugPlaceholderAvatar() = debugPlaceholder(debugPreview = R.drawable.sample_avatar) diff --git a/libraries/designsystem/src/main/res/drawable/sample_avatar.xml b/libraries/designsystem/src/main/res/drawable/sample_avatar.xml new file mode 100644 index 0000000000..d3e6796131 --- /dev/null +++ b/libraries/designsystem/src/main/res/drawable/sample_avatar.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + diff --git a/libraries/designsystem/src/main/res/drawable/sample_background.webp b/libraries/designsystem/src/main/res/drawable/sample_background.webp new file mode 100644 index 0000000000..b05f3b33a0 Binary files /dev/null and b/libraries/designsystem/src/main/res/drawable/sample_background.webp differ