mirror of
https://github.com/openMF/mobile-wallet.git
synced 2026-02-06 11:36:57 +00:00
refactor(feature:home) : move all hardcoded strings to string resources (#1882)
Co-authored-by: Sk Niyaj Ali <niyaj639@gmail.com>
This commit is contained in:
parent
995522942a
commit
f518436313
@ -12,4 +12,22 @@
|
||||
<string name="feature_home_loading">Loading</string>
|
||||
<string name="start_sending_your_money_tax_free">Start sending money tax free!</string>
|
||||
<string name="feature_home_desc">Mifos Pay is the best place for users to receive and send money. Start saving money now!</string>
|
||||
|
||||
/* HomeScreen.kt */
|
||||
<string name="wallet_balance">Wallet Balance</string>
|
||||
<string name="arrow_up">arrow_up</string>
|
||||
<string name="view_more">View More</string>
|
||||
<string name="mark_default">Mark as Default</string>
|
||||
<string name="request">Request</string>
|
||||
<string name="request_money">Request Money</string>
|
||||
<string name="send">Send</string>
|
||||
<string name="send_money">Send Money</string>
|
||||
<string name="coin_image">Coin</string>
|
||||
<string name="account_type">Account type</string>
|
||||
|
||||
|
||||
/* HomeScreenViewModel */
|
||||
<string name="account_success">Account marked as default</string>
|
||||
<string name="account_error">Error marking account as default</string>
|
||||
<string name="no_account">"No accounts found"</string>
|
||||
</resources>
|
||||
@ -75,11 +75,21 @@ import androidx.compose.ui.unit.sp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import kotlinx.coroutines.launch
|
||||
import mobile_wallet.feature.home.generated.resources.Res
|
||||
import mobile_wallet.feature.home.generated.resources.account_type
|
||||
import mobile_wallet.feature.home.generated.resources.arrow_backward
|
||||
import mobile_wallet.feature.home.generated.resources.arrow_up
|
||||
import mobile_wallet.feature.home.generated.resources.coin_image
|
||||
import mobile_wallet.feature.home.generated.resources.feature_home_desc
|
||||
import mobile_wallet.feature.home.generated.resources.feature_home_loading
|
||||
import mobile_wallet.feature.home.generated.resources.mark_default
|
||||
import mobile_wallet.feature.home.generated.resources.request
|
||||
import mobile_wallet.feature.home.generated.resources.request_money
|
||||
import mobile_wallet.feature.home.generated.resources.send
|
||||
import mobile_wallet.feature.home.generated.resources.send_money
|
||||
import mobile_wallet.feature.home.generated.resources.start_sending_your_money_tax_free
|
||||
import mobile_wallet.feature.home.generated.resources.view_more
|
||||
import mobile_wallet.feature.home.generated.resources.wallet_balance
|
||||
import org.jetbrains.compose.resources.getString
|
||||
import org.jetbrains.compose.resources.painterResource
|
||||
import org.jetbrains.compose.resources.stringResource
|
||||
import org.jetbrains.compose.resources.vectorResource
|
||||
@ -138,7 +148,7 @@ internal fun HomeScreen(
|
||||
is HomeEvent.NavigateToTransactionScreen -> {}
|
||||
is HomeEvent.ShowToast -> {
|
||||
scope.launch {
|
||||
snackbarState.showSnackbar(event.message)
|
||||
snackbarState.showSnackbar(getString(event.message))
|
||||
}
|
||||
}
|
||||
|
||||
@ -371,7 +381,7 @@ private fun AccountCard(
|
||||
) {
|
||||
Column {
|
||||
Text(
|
||||
text = "Account Type",
|
||||
text = stringResource(Res.string.account_type),
|
||||
fontWeight = FontWeight(300),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.surface,
|
||||
@ -423,7 +433,7 @@ private fun AccountCard(
|
||||
) {
|
||||
Column {
|
||||
Text(
|
||||
text = "Wallet Balance",
|
||||
text = stringResource(Res.string.wallet_balance),
|
||||
fontWeight = FontWeight(300),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.surface,
|
||||
@ -447,7 +457,7 @@ private fun AccountCard(
|
||||
.graphicsLayer(rotationZ = 90f)
|
||||
.padding(4.dp),
|
||||
imageVector = Icons.Filled.KeyboardArrowUp,
|
||||
contentDescription = "arrow",
|
||||
contentDescription = stringResource(Res.string.arrow_up),
|
||||
tint = MaterialTheme.colorScheme.surface,
|
||||
)
|
||||
}
|
||||
@ -473,7 +483,7 @@ fun CardDropdownBox(
|
||||
) {
|
||||
Icon(
|
||||
imageVector = MifosIcons.MoreVert,
|
||||
contentDescription = "View More",
|
||||
contentDescription = stringResource(Res.string.view_more),
|
||||
)
|
||||
}
|
||||
|
||||
@ -482,7 +492,7 @@ fun CardDropdownBox(
|
||||
onDismissRequest = { showDropdown = false },
|
||||
) {
|
||||
DropdownMenuItem(
|
||||
text = { Text("Mark as Default") },
|
||||
text = { Text(stringResource(Res.string.mark_default)) },
|
||||
onClick = {
|
||||
onClickDefault()
|
||||
showDropdown = false
|
||||
@ -506,7 +516,7 @@ private fun PayRequestScreen(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.height(55.dp),
|
||||
text = "Request",
|
||||
text = stringResource(Res.string.request),
|
||||
onClick = onRequest,
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
@ -515,7 +525,7 @@ private fun PayRequestScreen(
|
||||
imageVector = vectorResource(
|
||||
Res.drawable.arrow_backward,
|
||||
),
|
||||
contentDescription = "request money",
|
||||
contentDescription = stringResource(Res.string.request_money),
|
||||
)
|
||||
},
|
||||
)
|
||||
@ -526,7 +536,7 @@ private fun PayRequestScreen(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.height(55.dp),
|
||||
text = "Send",
|
||||
text = stringResource(Res.string.send),
|
||||
onClick = onSend,
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
@ -534,7 +544,7 @@ private fun PayRequestScreen(
|
||||
.size(26.dp)
|
||||
.graphicsLayer(rotationZ = 180f),
|
||||
imageVector = vectorResource(Res.drawable.arrow_backward),
|
||||
contentDescription = "Send money",
|
||||
contentDescription = stringResource(Res.string.send_money),
|
||||
)
|
||||
},
|
||||
)
|
||||
@ -578,7 +588,7 @@ private fun MifosSendMoneyFreeCard(
|
||||
modifier = Modifier.weight(2.5f),
|
||||
contentScale = ContentScale.Fit,
|
||||
painter = painterResource(Res.drawable.coin_image),
|
||||
contentDescription = "coin Image",
|
||||
contentDescription = stringResource(Res.string.coin_image),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,6 +18,11 @@ import kotlinx.coroutines.flow.stateIn
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.serialization.Serializable
|
||||
import mobile_wallet.feature.home.generated.resources.Res
|
||||
import mobile_wallet.feature.home.generated.resources.account_error
|
||||
import mobile_wallet.feature.home.generated.resources.account_success
|
||||
import mobile_wallet.feature.home.generated.resources.no_account
|
||||
import org.jetbrains.compose.resources.StringResource
|
||||
import org.mifospay.core.common.DataState
|
||||
import org.mifospay.core.data.repository.SelfServiceRepository
|
||||
import org.mifospay.core.datastore.UserPreferencesRepository
|
||||
@ -72,7 +77,7 @@ class HomeViewModel(
|
||||
mutableStateFlow.update {
|
||||
it.copy(isRefreshing = false)
|
||||
}
|
||||
ViewState.Error("No accounts found")
|
||||
ViewState.Error(Res.string.no_account)
|
||||
}
|
||||
|
||||
is DataState.Loading -> ViewState.Loading
|
||||
@ -155,14 +160,14 @@ class HomeViewModel(
|
||||
when (result) {
|
||||
is DataState.Loading -> {}
|
||||
is DataState.Error -> {
|
||||
sendEvent(HomeEvent.ShowToast("Error marking account as default"))
|
||||
sendEvent(HomeEvent.ShowToast(Res.string.account_error))
|
||||
}
|
||||
|
||||
is DataState.Success -> {
|
||||
mutableStateFlow.update {
|
||||
it.copy(defaultAccountId = action.accountId)
|
||||
}
|
||||
sendEvent(HomeEvent.ShowToast("Account marked as default"))
|
||||
sendEvent(HomeEvent.ShowToast(Res.string.account_success))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -202,7 +207,7 @@ data class HomeState(
|
||||
sealed interface ViewState {
|
||||
data object Loading : ViewState
|
||||
|
||||
data class Error(val message: String) : ViewState
|
||||
data class Error(val message: StringResource) : ViewState
|
||||
|
||||
data class Content(
|
||||
val accounts: List<Account>,
|
||||
@ -219,7 +224,7 @@ sealed interface HomeEvent {
|
||||
data class NavigateToTransactionDetail(val accountId: Long, val transactionId: Long) : HomeEvent
|
||||
data class NavigateToAccountDetail(val accountId: Long) : HomeEvent
|
||||
|
||||
data class ShowToast(val message: String) : HomeEvent
|
||||
data class ShowToast(val message: StringResource) : HomeEvent
|
||||
}
|
||||
|
||||
sealed interface HomeAction {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user