From 6c6eaaf58edb8f3274ca06048c2ff173d87c0f7c Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 17 Jan 2024 12:14:50 +0100 Subject: [PATCH] Allow customization of `style` in `ErrorText` and `LoadingText` --- .../eu/steffo/twom/composables/errorhandling/ErrorText.kt | 4 ++++ .../eu/steffo/twom/composables/errorhandling/LoadingText.kt | 4 ++++ 2 files changed, 8 insertions(+) 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 9cc9a5c..08d921f 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 @@ -1,10 +1,12 @@ package eu.steffo.twom.composables.errorhandling +import androidx.compose.material3.LocalTextStyle 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.text.TextStyle import androidx.compose.ui.tooling.preview.Preview import eu.steffo.twom.R @@ -14,10 +16,12 @@ import eu.steffo.twom.R fun ErrorText( modifier: Modifier = Modifier, text: String? = null, + style: TextStyle = LocalTextStyle.current ) { Text( modifier = modifier, text = text ?: stringResource(R.string.error), color = MaterialTheme.colorScheme.error, + style = style, ) } diff --git a/app/src/main/java/eu/steffo/twom/composables/errorhandling/LoadingText.kt b/app/src/main/java/eu/steffo/twom/composables/errorhandling/LoadingText.kt index dd93385..60e5d0b 100644 --- a/app/src/main/java/eu/steffo/twom/composables/errorhandling/LoadingText.kt +++ b/app/src/main/java/eu/steffo/twom/composables/errorhandling/LoadingText.kt @@ -1,10 +1,12 @@ package eu.steffo.twom.composables.errorhandling import androidx.compose.material3.LocalContentColor +import androidx.compose.material3.LocalTextStyle 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.text.TextStyle import androidx.compose.ui.tooling.preview.Preview import eu.steffo.twom.R @@ -14,10 +16,12 @@ import eu.steffo.twom.R fun LoadingText( modifier: Modifier = Modifier, text: String? = null, + style: TextStyle = LocalTextStyle.current, ) { Text( modifier = modifier, text = text ?: stringResource(R.string.loading), color = LocalContentColor.current.copy(0.4f), + style = style, ) }