mirror of
https://github.com/openMF/mobile-wallet.git
synced 2026-02-06 11:07:02 +00:00
refactor(feat:history): move hard-coded strings to string resources. (#1887)
Co-authored-by: Sk Niyaj Ali <niyaj639@gmail.com>
This commit is contained in:
parent
f518436313
commit
f8d0d0daf2
@ -23,5 +23,10 @@
|
||||
<string name="feature_history_loading">Loading</string>
|
||||
<string name="feature_history_no_transactions_found">No transactions found</string>
|
||||
<string name="feature_history_specific_transactions_history">Specific Transactions History</string>
|
||||
<string name="feature_history_transaction_details">Transaction Details</string>
|
||||
<string name="feature_history_share">Share</string>
|
||||
<string name="feature_history_paid_to">Paid To</string>
|
||||
<string name="feature_history_debited_from">Debited From</string>
|
||||
<string name="feature_history_error_fallback">Error</string>
|
||||
|
||||
</resources>
|
||||
@ -29,6 +29,12 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import mobile_wallet.feature.history.generated.resources.Res
|
||||
import mobile_wallet.feature.history.generated.resources.feature_history_debited_from
|
||||
import mobile_wallet.feature.history.generated.resources.feature_history_paid_to
|
||||
import mobile_wallet.feature.history.generated.resources.feature_history_transaction_date
|
||||
import mobile_wallet.feature.history.generated.resources.feature_history_transaction_id
|
||||
import org.jetbrains.compose.resources.stringResource
|
||||
import org.mifospay.core.common.CurrencyFormatter
|
||||
import org.mifospay.core.common.DateHelper
|
||||
import org.mifospay.core.model.savingsaccount.TransferDetail
|
||||
@ -57,7 +63,10 @@ internal fun TransactionDetail(
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Text(text = "Transaction ID", style = MaterialTheme.typography.labelLarge)
|
||||
Text(
|
||||
text = stringResource(Res.string.feature_history_transaction_id),
|
||||
style = MaterialTheme.typography.labelLarge,
|
||||
)
|
||||
Text(text = detail.id.toString())
|
||||
}
|
||||
|
||||
@ -70,7 +79,10 @@ internal fun TransactionDetail(
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Text(text = "Transaction Date", style = MaterialTheme.typography.labelLarge)
|
||||
Text(
|
||||
text = stringResource(Res.string.feature_history_transaction_date),
|
||||
style = MaterialTheme.typography.labelLarge,
|
||||
)
|
||||
val date = DateHelper.getDateAsString(detail.transferDate)
|
||||
Text(text = date)
|
||||
}
|
||||
@ -80,7 +92,7 @@ internal fun TransactionDetail(
|
||||
)
|
||||
|
||||
Text(
|
||||
text = "Paid To",
|
||||
text = stringResource(Res.string.feature_history_paid_to),
|
||||
style = MaterialTheme.typography.labelLarge,
|
||||
)
|
||||
|
||||
@ -148,7 +160,7 @@ internal fun TransactionDetail(
|
||||
)
|
||||
|
||||
Text(
|
||||
text = "Debited From",
|
||||
text = stringResource(Res.string.feature_history_debited_from),
|
||||
style = MaterialTheme.typography.labelLarge,
|
||||
)
|
||||
|
||||
|
||||
@ -25,6 +25,8 @@ import mobile_wallet.feature.history.generated.resources.Res
|
||||
import mobile_wallet.feature.history.generated.resources.feature_history_error
|
||||
import mobile_wallet.feature.history.generated.resources.feature_history_error_oops
|
||||
import mobile_wallet.feature.history.generated.resources.feature_history_loading
|
||||
import mobile_wallet.feature.history.generated.resources.feature_history_share
|
||||
import mobile_wallet.feature.history.generated.resources.feature_history_transaction_details
|
||||
import org.jetbrains.compose.resources.stringResource
|
||||
import org.koin.compose.viewmodel.koinViewModel
|
||||
import org.mifospay.core.designsystem.component.MifosLoadingWheel
|
||||
@ -68,7 +70,7 @@ internal fun TransactionDetailScreenContent(
|
||||
) {
|
||||
MifosScaffold(
|
||||
backPress = { onAction(TransactionDetailAction.NavigateBack) },
|
||||
topBarTitle = "Transaction Details",
|
||||
topBarTitle = stringResource(Res.string.feature_history_transaction_details),
|
||||
actions = {
|
||||
IconButton(
|
||||
onClick = {
|
||||
@ -77,7 +79,7 @@ internal fun TransactionDetailScreenContent(
|
||||
) {
|
||||
Icon(
|
||||
imageVector = MifosIcons.OutlinedShare,
|
||||
contentDescription = "Share",
|
||||
contentDescription = stringResource(Res.string.feature_history_share),
|
||||
)
|
||||
}
|
||||
},
|
||||
|
||||
@ -14,6 +14,9 @@ import androidx.lifecycle.viewModelScope
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.flow.update
|
||||
import mobile_wallet.feature.history.generated.resources.Res
|
||||
import mobile_wallet.feature.history.generated.resources.feature_history_error_fallback
|
||||
import org.jetbrains.compose.resources.StringResource
|
||||
import org.mifospay.core.common.DataState
|
||||
import org.mifospay.core.data.repository.AccountRepository
|
||||
import org.mifospay.core.model.savingsaccount.TransferDetail
|
||||
@ -58,8 +61,13 @@ internal class TransactionDetailViewModel(
|
||||
private fun handleTransferDetailReceive(action: TransferDetailReceive) {
|
||||
when (action.result) {
|
||||
is DataState.Error -> {
|
||||
val message = action.result.exception.message
|
||||
mutableStateFlow.update {
|
||||
it.copy(viewState = Error(action.result.exception.message ?: "Error"))
|
||||
if (message.isNullOrEmpty()) {
|
||||
it.copy(viewState = Error.ResourceMessage(Res.string.feature_history_error_fallback))
|
||||
} else {
|
||||
it.copy(Error.StringMessage(message))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,7 +91,11 @@ internal data class TransactionDetailState(
|
||||
) {
|
||||
internal sealed interface ViewState {
|
||||
data object Loading : ViewState
|
||||
data class Error(val message: String) : ViewState
|
||||
|
||||
sealed interface Error : ViewState {
|
||||
data class StringMessage(val message: String) : Error
|
||||
data class ResourceMessage(val message: StringResource) : Error
|
||||
}
|
||||
data class Content(val transaction: TransferDetail) : ViewState
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user