From 8ca7b58a9269cfa44953b603e025dfa9cd737a9c Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 17 Jan 2024 12:12:33 +0100 Subject: [PATCH] `ErrorText`: default to `R.string.error` if no `text` is specified --- .../eu/steffo/twom/composables/errorhandling/ErrorText.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/steffo/twom/composables/errorhandling/ErrorText.kt b/app/src/main/java/eu/steffo/twom/composables/errorhandling/ErrorText.kt index 452134b..9cc9a5c 100644 --- a/app/src/main/java/eu/steffo/twom/composables/errorhandling/ErrorText.kt +++ b/app/src/main/java/eu/steffo/twom/composables/errorhandling/ErrorText.kt @@ -4,16 +4,20 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.Preview +import eu.steffo.twom.R @Composable +@Preview fun ErrorText( - text: String, modifier: Modifier = Modifier, + text: String? = null, ) { Text( modifier = modifier, - text = text, + text = text ?: stringResource(R.string.error), color = MaterialTheme.colorScheme.error, ) }