From d660c52b9184992e3397d4536e4bce540faaef9f Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 1 Feb 2024 17:28:27 +0100 Subject: [PATCH] Create `LocalizableError?.DisplayErrorText` --- .../composables/errorhandling/LocalizableError.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/src/main/java/eu/steffo/twom/composables/errorhandling/LocalizableError.kt b/app/src/main/java/eu/steffo/twom/composables/errorhandling/LocalizableError.kt index 6cba1bc..3fbfca0 100644 --- a/app/src/main/java/eu/steffo/twom/composables/errorhandling/LocalizableError.kt +++ b/app/src/main/java/eu/steffo/twom/composables/errorhandling/LocalizableError.kt @@ -4,6 +4,7 @@ import android.util.Log import androidx.annotation.StringRes import androidx.compose.runtime.Composable import androidx.compose.runtime.MutableState +import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import kotlinx.coroutines.CancellationException @@ -31,6 +32,16 @@ fun LocalizableError?.Display(contents: @Composable (rendered: String) -> Unit) contents(rendered) } +@Composable +fun LocalizableError?.DisplayErrorText(modifier: Modifier = Modifier) { + this.Display { + ErrorText( + modifier = modifier, + text = it, + ) + } +} + suspend fun MutableState.capture( @StringRes error: Int, coroutine: suspend () -> Unit,