Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #757 from mhss1/develop
Browse files Browse the repository at this point in the history
Added strings for ui.statistic and fixed some strings from previous commits
  • Loading branch information
ILIYANGERMANOV authored Apr 20, 2022
2 parents 0c5f172 + 3569b71 commit 4f3c377
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ private fun BoxWithConstraintsScope.UI(
DeleteModal(
visible = deleteTrnModalVisible,
title = stringResource(R.string.confirm_deletion),
description = stringResource(R.string.confirm_deletion_description),
description = stringResource(R.string.transaction_confirm_deletion_description),
dismiss = { deleteTrnModalVisible = false }
) {
onDelete()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ private fun BoxWithConstraintsScope.UI(
DeleteModal(
visible = deleteModalVisible,
title = stringResource(R.string.confirm_deletion),
description = stringResource(R.string.confirm_loan_deletion_description),
description = stringResource(R.string.loan_confirm_deletion_description),
dismiss = { deleteModalVisible = false }
) {
onDeleteLoan()
Expand Down Expand Up @@ -485,7 +485,7 @@ private fun LoanInfoCard(
Text(
modifier = Modifier
.testTag("left_to_pay"),
text = stringResource(R.string.left_to_pay),
text = stringResource(R.string.left_to_pay, leftToPay.format(baseCurrency), baseCurrency),
style = UI.typo.nB2.style(
color = Gray,
fontWeight = FontWeight.ExtraBold
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
Expand Down Expand Up @@ -51,7 +52,7 @@ fun BoxWithConstraintsScope.PieChartStatisticBottomBar(
val isIncome = type == TransactionType.INCOME
IvyButton(
iconStart = R.drawable.ic_plus,
text = if (isIncome) "Add income" else "Add expense",
text = if (isIncome) stringResource(id = R.string.add_income) else stringResource(id = R.string.add_expense),
backgroundGradient = if (isIncome) GradientGreen else Gradient.solid(UI.colors.pureInverse),
textStyle = UI.typo.b2.style(
color = if (isIncome) White else UI.colors.pure,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
Expand Down Expand Up @@ -159,7 +160,9 @@ private fun BoxWithConstraintsScope.UI(

Text(
modifier = Modifier.padding(start = 32.dp),
text = if (transactionType == TransactionType.EXPENSE) "Expenses" else "Income",
text = if (transactionType == TransactionType.EXPENSE) stringResource(R.string.expenses) else stringResource(
R.string.income
),
style = UI.typo.b1.style(
fontWeight = FontWeight.ExtraBold
)
Expand Down Expand Up @@ -431,7 +434,7 @@ private fun CategoryAmountCard(
modifier = Modifier
.weight(1f)
.padding(end = 16.dp),
text = category?.name ?: "Unspecified",
text = category?.name ?: stringResource(R.string.unspecified),
style = UI.typo.b2.style(
color = textColor,
fontWeight = FontWeight.Bold,
Expand Down Expand Up @@ -469,7 +472,9 @@ private fun PercentText(
contrastColor: Color
) {
Text(
text = if (totalAmount != 0.0) "${((amount / totalAmount) * 100).format(2)}%" else "0%",
text = if (totalAmount != 0.0)
stringResource(R.string.percent, ((amount / totalAmount) * 100).format(2))
else stringResource(R.string.percent, "0"),
style = UI.typo.nB2.style(
color = if (selectedState) contrastColor else UI.colors.pureInverse,
fontWeight = FontWeight.Normal
Expand Down Expand Up @@ -524,7 +529,7 @@ private fun Preview_Expense() {
),
),
selectedCategory = null,
checkForUnSpecifiedCategory = {false}
checkForUnSpecifiedCategory = { false }
)
}
}
Expand Down Expand Up @@ -576,7 +581,7 @@ private fun Preview_Income() {
),
),
selectedCategory = null,
checkForUnSpecifiedCategory = {false}
checkForUnSpecifiedCategory = { false }
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.ivy.wallet.ui.statistic.level1
import androidx.compose.ui.graphics.toArgb
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.ivy.wallet.R
import com.ivy.wallet.domain.data.TransactionType
import com.ivy.wallet.domain.data.entity.Category
import com.ivy.wallet.domain.data.entity.Transaction
Expand All @@ -16,6 +17,7 @@ import com.ivy.wallet.domain.logic.currency.sumInBaseCurrency
import com.ivy.wallet.io.persistence.dao.CategoryDao
import com.ivy.wallet.io.persistence.dao.SettingsDao
import com.ivy.wallet.io.persistence.dao.TransactionDao
import com.ivy.wallet.stringRes
import com.ivy.wallet.ui.IvyWalletCtx
import com.ivy.wallet.ui.PieChartStatistic
import com.ivy.wallet.ui.onboarding.model.FromToTimeRange
Expand Down Expand Up @@ -74,7 +76,7 @@ class PieChartStatisticViewModel @Inject constructor(

private var filterExcluded = true
private val transfersCategory =
Category("Account Transfers", color = IvyLight.toArgb(), icon = "transfer")
Category(stringRes(R.string.account_transfers), color = IvyLight.toArgb(), icon = "transfer")

fun start(
screen: PieChartStatistic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand All @@ -32,6 +33,7 @@ import com.ivy.wallet.domain.data.TransactionType
import com.ivy.wallet.domain.data.entity.Account
import com.ivy.wallet.domain.data.entity.Category
import com.ivy.wallet.domain.data.entity.Transaction
import com.ivy.wallet.stringRes
import com.ivy.wallet.ui.*
import com.ivy.wallet.ui.onboarding.model.TimePeriod
import com.ivy.wallet.ui.theme.*
Expand Down Expand Up @@ -355,22 +357,21 @@ private fun BoxWithConstraintsScope.UI(
(ivyContext.screenHeight * 0.7f).toDp()
},
onPayOrGet = onPayOrGet,
emptyStateTitle = "No transactions",
emptyStateTitle = stringRes(R.string.no_transactions),

emptyStateText = stringRes(R.string.no_transactions_for_period, period.toDisplayLong(ivyContext.startDayOfMonth)),

emptyStateText = "You don't have any transactions for ${
period.toDisplayLong(ivyContext.startDayOfMonth)
}.\nYou can add one by scrolling down and tapping \"Add income\" or \"Add expense\" button at the top."
)
}
}

DeleteModal(
visible = deleteModalVisible,
title = "Confirm deletion",
title = stringResource(R.string.confirm_deletion),
description = if (account != null) {
"Note: Deleting this account will remove it permanently and delete all associated transactions with it."
stringResource(R.string.account_confirm_deletion_description)
} else {
"Note: Deleting this category will remove it permanently."
stringResource(R.string.category_confirm_deletion_description)
},
dismiss = { deleteModalVisible = false }
) {
Expand Down Expand Up @@ -562,7 +563,7 @@ fun ItemStatisticToolbar(

IvyOutlinedButton(
iconStart = R.drawable.ic_edit,
text = "Edit",
text = stringRes(R.string.edit),
borderColor = contrastColor,
iconTint = contrastColor,
textColor = contrastColor,
Expand Down Expand Up @@ -602,13 +603,13 @@ fun IncomeExpensesCards(
Spacer(Modifier.width(16.dp))

HeaderCard(
title = "INCOME",
title = stringRes(R.string.income_uppercase),
currencyCode = currency,
amount = income,
transactionCount = history
.filterIsInstance(Transaction::class.java)
.count { it.type == TransactionType.INCOME },
addButtonText = if (hasAddButtons) "Add income" else null,
addButtonText = if (hasAddButtons) stringResource(R.string.add_income) else null,
isIncome = true,

itemColor = itemColor,
Expand All @@ -620,13 +621,13 @@ fun IncomeExpensesCards(
Spacer(Modifier.width(12.dp))

HeaderCard(
title = "EXPENSES",
title = stringRes(R.string.expenses_uppercase),
currencyCode = currency,
amount = expenses,
transactionCount = history
.filterIsInstance(Transaction::class.java)
.count { it.type == TransactionType.EXPENSE },
addButtonText = if (hasAddButtons) "Add expense" else null,
addButtonText = if (hasAddButtons) stringResource(R.string.add_expense) else null,
isIncome = false,

itemColor = itemColor,
Expand Down Expand Up @@ -711,7 +712,7 @@ private fun RowScope.HeaderCard(
)
Text(
modifier = Modifier.padding(horizontal = 24.dp),
text = "transactions",
text = stringRes(R.string.transactions),
style = UI.typo.b2.style(
color = contrastColor,
fontWeight = FontWeight.Normal
Expand Down Expand Up @@ -794,7 +795,7 @@ private fun Item(
modifier = Modifier
.align(Alignment.Bottom)
.padding(bottom = 12.dp),
text = "(excluded)",
text = stringRes(R.string.excluded),
style = UI.typo.c.style(
color = account.color.toComposeColor().dynamicContrast()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import arrow.core.toOption
import com.ivy.design.navigation.Navigation
import com.ivy.wallet.R
import com.ivy.wallet.domain.data.TransactionHistoryItem
import com.ivy.wallet.domain.data.TransactionType
import com.ivy.wallet.domain.data.entity.Account
Expand All @@ -20,6 +21,7 @@ import com.ivy.wallet.domain.logic.currency.ExchangeRatesLogic
import com.ivy.wallet.domain.sync.uploader.AccountUploader
import com.ivy.wallet.domain.sync.uploader.CategoryUploader
import com.ivy.wallet.io.persistence.dao.*
import com.ivy.wallet.stringRes
import com.ivy.wallet.ui.ItemStatistic
import com.ivy.wallet.ui.IvyWalletCtx
import com.ivy.wallet.ui.onboarding.model.TimePeriod
Expand Down Expand Up @@ -429,7 +431,7 @@ class ItemStatisticViewModel @Inject constructor(

val accountTransferCategoryEnabled = categoryId != null
if (accountTransferCategoryEnabled)
_category.value = Category("Account Transfers")
_category.value = Category(stringRes(R.string.account_transfers))

val trans = transactions.filter {
it.categoryId == null && (accountFilterIdSet.contains(it.accountId) || accountFilterIdSet.contains(
Expand Down
14 changes: 12 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<string name="pay">Pay</string>
<string name="get">Get</string>
<string name="confirm_deletion">Confirm deletion</string>
<string name="confirm_deletion_description">Deleting this transaction will remove it from the transaction history and update the balance accordingly.</string>
<string name="transaction_confirm_deletion_description">Deleting this transaction will remove it from the transaction history and update the balance accordingly.</string>
<string name="confirm_account_change">Confirm Account Change</string>
<string name="confirm_account_change_description">Note: You are trying to change the account associated with the loan with an account of different currency, \nAll the loan records will be re-calculated based on today\'s exchanges rates </string>
<string name="confirm">Confirm</string>
Expand All @@ -112,7 +112,7 @@
<string name="add_loan">Add loan</string>
<string name="no_loans">No loans</string>
<string name="no_loans_description">You don\'t have any loans.\nTap the \"+ Add loan\" to add one.</string>
<string name="confirm_loan_deletion_description">Note: Deleting this loan will remove it permanently and delete all associated loan records with it.</string>
<string name="loan_confirm_deletion_description">Note: Deleting this loan will remove it permanently and delete all associated loan records with it.</string>
<string name="confirm_account_loan_change">Please wait, re-calculating all loan records</string>
<string name="paid">Paid</string>
<string name="left_to_pay">%1$s %2$s left</string>
Expand All @@ -122,4 +122,14 @@
<string name="interest">Interest</string>
<string name="no_records">No records</string>
<string name="no_records_for_the_loan">You don\'t have any records for this loan. Tap "Add record" to create one.</string>
<string name="add_income">Add income</string>
<string name="add_expense">Add expense</string>
<string name="unspecified">Unspecified</string>
<string name="percent">%1$s%</string>
<string name="account_transfers">Account Transfers</string>
<string name="no_transactions_for_period">You don\'t have any transactions for %1$s.\nYou can add one by scrolling down and tapping "Add income" or "Add expense" button at the top.</string>
<string name="account_confirm_deletion_description">Note: Deleting this account will remove it permanently and delete all associated transactions with it.</string>
<string name="category_confirm_deletion_description">Note: Deleting this category will remove it permanently.</string>
<string name="edit">Edit</string>
<string name="transactions">transactions</string>
</resources>

0 comments on commit 4f3c377

Please sign in to comment.