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

Replace hard-coded strings in the app UI #751

Merged
merged 11 commits into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions app/src/main/java/com/ivy/wallet/ui/accounts/AccountsTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
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 Down Expand Up @@ -98,7 +99,7 @@ private fun BoxWithConstraintsScope.UI(

Column {
Text(
text = "Accounts",
text = stringResource(R.string.accounts),
style = UI.typo.b1.style(
color = UI.colors.pureInverse,
fontWeight = FontWeight.ExtraBold
Expand All @@ -109,11 +110,10 @@ private fun BoxWithConstraintsScope.UI(
Spacer(Modifier.height(4.dp))

Text(
text = "Total: $baseCurrency ${
text = stringResource(R.string.total, baseCurrency,
totalBalanceWithExcluded.format(
baseCurrency
)
}",
baseCurrency
)),
style = UI.typo.nB2.style(
color = Gray,
fontWeight = FontWeight.Bold
Expand Down Expand Up @@ -233,9 +233,9 @@ private fun AccountCard(

IncomeExpensesRow(
currency = currency,
incomeLabel = "INCOME THIS MONTH",
incomeLabel = stringResource(R.string.month_income),
income = accountData.monthlyIncome,
expensesLabel = "EXPENSES THIS MONTH",
expensesLabel = stringResource(R.string.month_expenses),
expenses = accountData.monthlyExpenses
)

Expand Down Expand Up @@ -289,7 +289,7 @@ private fun AccountHeader(
modifier = Modifier
.align(Alignment.Bottom)
.padding(bottom = 4.dp),
text = "(excluded)",
text = stringResource(R.string.excluded),
style = UI.typo.c.style(
color = account.color.toComposeColor().dynamicContrast()
)
Expand Down Expand Up @@ -389,4 +389,4 @@ private fun PreviewAccountsTab() {
onEditAccount = { _, _ -> }
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.ivy.wallet.R
import com.ivy.design.l0_system.UI
import com.ivy.design.l0_system.style
import com.ivy.wallet.ui.theme.wallet.AmountCurrencyB1
Expand All @@ -19,9 +21,9 @@ fun IncomeExpensesRow(
modifier: Modifier = Modifier,
textColor: Color = UI.colors.pureInverse,
dividerColor: Color = UI.colors.medium,
incomeLabel: String = "INCOME",
incomeLabel: String = stringResource(R.string.income_uppercase),
income: Double,
expensesLabel: String = "EXPENSES",
expensesLabel: String = stringResource(R.string.expenses_uppercase),
expenses: Double,
currency: String,
center: Boolean = true,
Expand Down Expand Up @@ -113,4 +115,4 @@ private fun LabelAmountColumn(
}

}
}
}
5 changes: 3 additions & 2 deletions app/src/main/java/com/ivy/wallet/ui/balance/BalanceScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.rotate
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 @@ -144,7 +145,7 @@ private fun ColumnScope.CurrentBalance(
) {
Text(
modifier = Modifier.align(Alignment.CenterHorizontally),
text = "CURRENT BALANCE",
text = stringResource(R.string.current_balance),
style = UI.typo.b2.style(
color = Gray,
fontWeight = FontWeight.ExtraBold
Expand All @@ -170,7 +171,7 @@ private fun ColumnScope.BalanceAfterPlannedPayments(
Text(
modifier = Modifier
.padding(horizontal = 32.dp),
text = "BALANCE AFTER PLANNED PAYMENTS",
text = stringResource(R.string.balance_after_payments),
style = UI.typo.b2.style(
color = Orange,
fontWeight = FontWeight.ExtraBold
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import androidx.compose.runtime.livedata.observeAsState
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.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import com.google.accompanist.insets.systemBarsPadding
import com.ivy.wallet.R
import com.ivy.design.l0_system.UI
import com.ivy.design.l0_system.style
import com.ivy.wallet.ui.ConnectBank
Expand Down Expand Up @@ -69,21 +71,21 @@ private fun UI(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
IvyButton(text = "Connect") {
IvyButton(text = stringResource(R.string.connect)) {
onConnect()
}

Spacer(Modifier.height(24.dp))

IvyButton(text = "Sync transactions") {
IvyButton(text = stringResource(R.string.sync_transactions)) {
onFetchTransactions()
}

if (opSyncTransactions is OpResult.Loading) {
Spacer(Modifier.height(24.dp))

Text(
text = "Syncing transactions...",
text = stringResource(R.string.syncing_transactions),
style = UI.typo.b2.style(
color = Orange,
fontWeight = FontWeight.ExtraBold
Expand All @@ -97,7 +99,7 @@ private fun UI(
verticalAlignment = Alignment.CenterVertically
) {
Text(
"Bank sync enabled:"
stringResource(R.string.bank_sync_enabled)
)

Spacer(Modifier.width(16.dp))
Expand All @@ -111,7 +113,7 @@ private fun UI(

Spacer(Modifier.height(24.dp))

IvyButton(text = "Remove customer") {
IvyButton(text = stringResource(R.string.remove_customer)) {
onRemoveCustomer()
}
}
Expand All @@ -128,4 +130,4 @@ private fun Preview() {
onConnect = {}
)
}
}
}
5 changes: 3 additions & 2 deletions app/src/main/java/com/ivy/wallet/ui/budget/BudgetBottomBar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import com.ivy.wallet.R
import com.ivy.wallet.ui.IvyWalletPreview
Expand All @@ -20,7 +21,7 @@ internal fun BoxWithConstraintsScope.BudgetBottomBar(
) {
BackBottomBar(onBack = onClose) {
IvyButton(
text = "Add budget",
text = stringResource(R.string.add_budget),
iconStart = R.drawable.ic_plus
) {
onAdd()
Expand All @@ -45,4 +46,4 @@ private fun PreviewBottomBar() {
onClose = {}
)
}
}
}
17 changes: 9 additions & 8 deletions app/src/main/java/com/ivy/wallet/ui/budget/BudgetScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
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 @@ -131,9 +132,8 @@ private fun BoxWithConstraintsScope.UI(
Spacer(Modifier.weight(1f))

NoBudgetsEmptyState(
emptyStateTitle = "No budgets",
emptyStateText = "You don't have any budgets set.\n" +
"Tap the \"+ Add budget\" to add one."
emptyStateTitle = stringResource(R.string.no_budgets),
emptyStateText = stringResource(R.string.no_budgets)
)

Spacer(Modifier.weight(1f))
Expand Down Expand Up @@ -208,7 +208,7 @@ private fun Toolbar(
.padding(start = 24.dp, end = 16.dp)
) {
Text(
text = "Budgets",
text = stringResource(R.string.budgets),
style = UI.typo.h2.style(
color = UI.colors.pureInverse,
fontWeight = FontWeight.ExtraBold
Expand All @@ -231,19 +231,20 @@ private fun Toolbar(
Spacer(Modifier.height(4.dp))

val categoryBudgetText = if (categoryBudgetsTotal > 0) {
"${categoryBudgetsTotal.format(baseCurrency)} $baseCurrency for categories"
stringResource(R.string.for_categories, categoryBudgetsTotal.format(baseCurrency), baseCurrency)
} else ""

val appBudgetMaxText = if (appBudgetMax > 0) {
"${appBudgetMax.format(baseCurrency)} $baseCurrency app budget"
stringResource(R.string.app_budget, appBudgetMax.format(baseCurrency), baseCurrency)
} else ""

val hasBothBudgetTypes =
categoryBudgetText.isNotBlank() && appBudgetMaxText.isNotBlank()
Text(
modifier = Modifier.testTag("budgets_info_text"),
text = if (hasBothBudgetTypes)
"Budget info: $categoryBudgetText / $appBudgetMaxText" else "Budget info: $categoryBudgetText$appBudgetMaxText",
stringResource(R.string.budget_info_both, categoryBudgetText, appBudgetMaxText)
else stringResource(R.string.budget_info, categoryBudgetText, appBudgetMaxText),
style = UI.typo.nC.style(
color = Gray,
fontWeight = FontWeight.ExtraBold
Expand Down Expand Up @@ -437,4 +438,4 @@ private fun Preview_Budgets() {
onReorder = {}
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import com.ivy.wallet.R
import com.ivy.wallet.ui.IvyWalletPreview
Expand All @@ -20,7 +21,7 @@ internal fun BoxWithConstraintsScope.CategoriesBottomBar(
) {
BackBottomBar(onBack = onClose) {
IvyButton(
text = "Add category",
text = stringResource(R.string.add_category),
iconStart = R.drawable.ic_plus
) {
onAddCategory()
Expand All @@ -45,4 +46,4 @@ private fun PreviewBottomBar() {
onClose = {}
)
}
}
}
8 changes: 5 additions & 3 deletions app/src/main/java/com/ivy/wallet/ui/charts/ChartsScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
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 All @@ -19,6 +20,7 @@ import com.google.accompanist.insets.systemBarsPadding
import com.ivy.design.api.navigation
import com.ivy.design.l0_system.UI
import com.ivy.design.l0_system.style
import com.ivy.wallet.R
import com.ivy.wallet.domain.data.entity.Category
import com.ivy.wallet.domain.fp.charts.ChartPeriod
import com.ivy.wallet.domain.fp.charts.IncomeExpenseChartPoint
Expand Down Expand Up @@ -169,7 +171,7 @@ private fun Toolbar() {
Spacer(Modifier.width(32.dp))

Text(
text = "Charts",
text = stringResource(R.string.charts),
style = UI.typo.h2.style(
fontWeight = FontWeight.ExtraBold
)
Expand Down Expand Up @@ -202,7 +204,7 @@ private fun Period(
modifier = Modifier.clickable {
togglePeriod()
},
text = "Period:",
text = stringResource(R.string.period),
style = UI.typo.b1
)

Expand Down Expand Up @@ -275,4 +277,4 @@ private fun Preview() {
baseCurrencyCode = "BGN",
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import com.ivy.design.l0_system.style
import com.ivy.wallet.R
import com.ivy.wallet.domain.data.entity.Category
import com.ivy.wallet.domain.fp.charts.ChartPeriod
import com.ivy.wallet.stringRes
import com.ivy.wallet.ui.charts.CategoryValues
import com.ivy.wallet.ui.charts.toValue
import com.ivy.wallet.ui.onboarding.model.toCloseTimeRangeUnsafe
Expand Down Expand Up @@ -81,7 +82,7 @@ fun LazyListScope.categoryCharts(
item {
CategoriesChart(
period = period,
title = "Expenses",
title = stringRes(R.string.expenses),
baseCurrencyCode = baseCurrencyCode,
categoryValues = categoryExpenseValues,
countChart = false
Expand All @@ -91,7 +92,7 @@ fun LazyListScope.categoryCharts(
item {
CategoriesChart(
period = period,
title = "Expenses count",
title = stringRes(R.string.expenses_count),
baseCurrencyCode = baseCurrencyCode,
categoryValues = categoryExpenseCount,
countChart = true
Expand All @@ -101,7 +102,7 @@ fun LazyListScope.categoryCharts(
item {
CategoriesChart(
period = period,
title = "Income",
title = stringRes(R.string.income),
titleColor = Green,
baseCurrencyCode = baseCurrencyCode,
categoryValues = categoryIncomeValues,
Expand All @@ -112,7 +113,7 @@ fun LazyListScope.categoryCharts(
item {
CategoriesChart(
period = period,
title = "Income count",
title = stringRes(R.string.income_count),
titleColor = Green,
baseCurrencyCode = baseCurrencyCode,
categoryValues = categoryIncomeCount,
Expand Down Expand Up @@ -192,4 +193,4 @@ private fun CategoriesChart(
// )

}
}
}
Loading