Makes stringRes Stable for compose

This commit is contained in:
Vitor Pamplona 2024-08-05 15:48:06 -04:00
parent 84df86f4b6
commit ab772eb65e
2 changed files with 30 additions and 3 deletions

View File

@ -49,7 +49,19 @@ fun stringRes(id: Int): String = resourceCache.get(id) ?: stringResource(id).als
@Composable
fun stringRes(
id: Int,
vararg args: Any,
vararg args: String,
): String =
String
.format(
LocalConfiguration.current.locales.get(0),
resourceCache.get(id) ?: stringResource(id).also { resourceCache.put(id, it) },
*args,
)
@Composable
fun stringRes(
id: Int,
vararg args: Int?,
): String =
String
.format(
@ -66,7 +78,22 @@ fun stringRes(
fun stringRes(
ctx: Context,
id: Int,
vararg args: Any?,
vararg args: String?,
): String {
val res = ctx.resources
return String
.format(
res.configuration.locales.get(0),
resourceCache.get(id) ?: res.getString(id).also { resourceCache.put(id, it) },
*args,
)
}
fun stringRes(
ctx: Context,
id: Int,
vararg args: Int?,
): String {
val res = ctx.resources

View File

@ -685,7 +685,7 @@ fun authenticate(
stringRes(
context,
R.string.biometric_authentication_failed_explainer_with_error,
errString,
errString.toString(),
),
)
}