From b696172207c7d83b5887939bdcf8b409ed09c6b4 Mon Sep 17 00:00:00 2001 From: Gibran Chevalley Date: Fri, 20 Sep 2024 11:17:26 +0200 Subject: [PATCH] Use stringResource instead of accessing getString through a context manually --- .../infomaniak/swisstransfer/ui/components/EmptyState.kt | 9 +++------ .../screen/main/received/components/ReceivedEmptyFab.kt | 3 ++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/EmptyState.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/EmptyState.kt index a878237fd..3b9fbdbdd 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/EmptyState.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/EmptyState.kt @@ -25,7 +25,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.vector.ImageVector -import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import com.infomaniak.swisstransfer.ui.theme.Dimens import com.infomaniak.swisstransfer.ui.theme.Margin @@ -38,9 +38,6 @@ fun EmptyState( @StringRes description: Int, modifier: Modifier = Modifier, ) { - - val context = LocalContext.current - Column( modifier = modifier.fillMaxSize(), verticalArrangement = Arrangement.Center, @@ -49,13 +46,13 @@ fun EmptyState( Image(imageVector = icon, contentDescription = null) Text( - text = context.getString(title), + text = stringResource(title), style = SwissTransferTheme.typography.specificMedium22, modifier = Modifier.padding(PaddingValues(top = Margin.XLarge)), ) Text( - text = context.getString(description), + text = stringResource(description), textAlign = TextAlign.Center, style = SwissTransferTheme.typography.bodyRegular, color = SwissTransferTheme.colors.secondaryTextColor, diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/components/ReceivedEmptyFab.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/components/ReceivedEmptyFab.kt index 44979d5bd..96e171fdb 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/components/ReceivedEmptyFab.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/received/components/ReceivedEmptyFab.kt @@ -26,6 +26,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.constraintlayout.compose.ConstraintLayout import com.infomaniak.swisstransfer.R @@ -42,7 +43,7 @@ fun ReceivedEmptyFab() { val (text, icon, fab) = createRefs() Text( - text = LocalContext.current.getString(R.string.firstTransferDescription), + text = stringResource(R.string.firstTransferDescription), style = SwissTransferTheme.typography.bodyRegular, color = SwissTransferTheme.colors.secondaryTextColor, modifier = Modifier