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

Create LocalizableError?.DisplayErrorText

This commit is contained in:
Steffo 2024-02-01 17:28:27 +01:00
parent 789e029467
commit d660c52b91
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0

View file

@ -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<LocalizableError?>.capture(
@StringRes error: Int,
coroutine: suspend () -> Unit,