1
Fork 0
mirror of https://github.com/Steffo99/twom.git synced 2024-11-21 23:54:26 +00:00

Allow customization of style in ErrorText and LoadingText

This commit is contained in:
Steffo 2024-01-17 12:14:50 +01:00
parent b7bfcb74a7
commit 6c6eaaf58e
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0
2 changed files with 8 additions and 0 deletions

View file

@ -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,
)
}

View file

@ -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,
)
}