Skip to content
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
6 changes: 6 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ if (isCi && buildingReleaseTask && releaseKeystorePath.isNullOrBlank()) {
)
}

configurations.matching { configuration ->
configuration.name.startsWith("hiltAnnotationProcessor")
}.configureEach {
exclude(group = "com.squareup.moshi", module = "moshi-kotlin-codegen")
}

ksp {
arg("room.schemaLocation", "$projectDir/schemas")
arg("room.incremental", "true")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import androidx.compose.material3.Button
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.FilterChip
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExposedDropdownMenuAnchorType
import androidx.compose.material3.ExposedDropdownMenuBox
import androidx.compose.material3.ExposedDropdownMenuDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.MenuAnchorType
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
Expand Down Expand Up @@ -284,7 +284,7 @@ private fun AccountTypeDropdown(
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = expanded) },
modifier = Modifier
.fillMaxWidth()
.menuAnchor(MenuAnchorType.PrimaryNotEditable),
.menuAnchor(ExposedDropdownMenuAnchorType.PrimaryNotEditable),
)
ExposedDropdownMenu(
expanded = expanded,
Expand Down Expand Up @@ -389,7 +389,7 @@ private fun CurrencyDropdown(
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = expanded) },
modifier = Modifier
.fillMaxWidth()
.menuAnchor(MenuAnchorType.PrimaryNotEditable),
.menuAnchor(ExposedDropdownMenuAnchorType.PrimaryNotEditable),
)
ExposedDropdownMenu(
expanded = expanded,
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/pledgerio/app/ui/accounts/AccountTypeUi.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.pledgerio.app.ui.accounts

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.TrendingDown
import androidx.compose.material.icons.automirrored.filled.TrendingUp
import androidx.compose.material.icons.filled.AccountBalance
import androidx.compose.material.icons.filled.CreditCard
import androidx.compose.material.icons.filled.Group
import androidx.compose.material.icons.filled.Payments
import androidx.compose.material.icons.filled.Savings
import androidx.compose.material.icons.filled.Store
import androidx.compose.material.icons.filled.TrendingDown
import androidx.compose.material.icons.filled.TrendingUp
import androidx.compose.material.icons.filled.Wallet
import androidx.compose.ui.graphics.vector.ImageVector
import com.pledgerio.app.domain.model.Account
Expand All @@ -23,8 +23,8 @@ fun accountTypeIcon(typeCode: String): ImageVector {
AccountType.CASH -> Icons.Default.Wallet
AccountType.CREDITOR -> Icons.Default.Store
AccountType.DEBTOR -> Icons.Default.Payments
AccountType.LOAN, AccountType.MORTGAGE, AccountType.LIABILITY -> Icons.Default.TrendingDown
AccountType.INVESTMENT -> Icons.Default.TrendingUp
AccountType.LOAN, AccountType.MORTGAGE, AccountType.LIABILITY -> Icons.AutoMirrored.Filled.TrendingDown
AccountType.INVESTMENT -> Icons.AutoMirrored.Filled.TrendingUp
AccountType.CHECKING -> when (typeCode.lowercase()) {
"joined", "joined_savings" -> Icons.Default.Group
else -> Icons.Default.AccountBalance
Expand All @@ -39,7 +39,7 @@ fun AccountTypeGroup.icon(): ImageVector = when (this) {
AccountTypeGroup.EVERYDAY -> Icons.Default.AccountBalance
AccountTypeGroup.SAVINGS -> Icons.Default.Savings
AccountTypeGroup.CREDIT -> Icons.Default.CreditCard
AccountTypeGroup.LIABILITIES -> Icons.Default.TrendingDown
AccountTypeGroup.LIABILITIES -> Icons.AutoMirrored.Filled.TrendingDown
AccountTypeGroup.COUNTERPARTY -> Icons.Default.Payments
AccountTypeGroup.OTHER -> Icons.Default.AccountBalance
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.TrendingDown
import androidx.compose.material.icons.automirrored.filled.TrendingUp
import androidx.compose.material.icons.filled.ArrowDownward
import androidx.compose.material.icons.filled.ArrowUpward
import androidx.compose.material.icons.filled.School
import androidx.compose.material.icons.filled.Receipt
import androidx.compose.material.icons.filled.Search
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material.icons.filled.TrendingDown
import androidx.compose.material.icons.filled.TrendingUp
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
Expand Down Expand Up @@ -376,9 +376,9 @@ fun TransactionItem(
) {
Icon(
imageVector = when (transaction.type) {
TransactionType.DEBIT -> Icons.Default.TrendingUp
TransactionType.CREDIT -> Icons.Default.TrendingDown
TransactionType.TRANSFER -> Icons.Default.TrendingUp
TransactionType.DEBIT -> Icons.AutoMirrored.Filled.TrendingUp
TransactionType.CREDIT -> Icons.AutoMirrored.Filled.TrendingDown
TransactionType.TRANSFER -> Icons.AutoMirrored.Filled.TrendingUp
},
contentDescription = null,
tint = when (transaction.type) {
Expand Down
80 changes: 48 additions & 32 deletions app/src/main/java/com/pledgerio/app/ui/reports/ReportsViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -193,42 +193,58 @@ class ReportsViewModel @Inject constructor(
type: ReportType,
month: YearMonth,
) {
val result = when (type) {
ReportType.INCOME_EXPENSE -> reportRepository.getIncomeExpenseSummary(month)
ReportType.CATEGORY -> reportRepository.getCategoryBreakdown(month)
ReportType.BUDGET -> reportRepository.getBudgetPerformance(month)
ReportType.NET_WORTH -> reportRepository.getNetWorthTrend(month)
ReportType.BALANCE -> reportRepository.getAccountBalances(month)
when (type) {
ReportType.INCOME_EXPENSE -> applySingleReportResult(
result = reportRepository.getIncomeExpenseSummary(month),
) { cleared, data ->
cleared.copy(incomeExpense = data)
}
ReportType.CATEGORY -> applySingleReportResult(
result = reportRepository.getCategoryBreakdown(month),
) { cleared, data ->
cleared.copy(partitions = data)
}
ReportType.BALANCE -> applySingleReportResult(
result = reportRepository.getAccountBalances(month),
) { cleared, data ->
cleared.copy(partitions = data)
}
ReportType.BUDGET -> applySingleReportResult(
result = reportRepository.getBudgetPerformance(month),
) { cleared, data ->
cleared.copy(budgetItems = data)
}
ReportType.NET_WORTH -> applySingleReportResult(
result = reportRepository.getNetWorthTrend(month),
) { cleared, data ->
cleared.copy(netWorthTrend = data.inMonth(month))
}
ReportType.OVERVIEW -> return
}
}

private fun baseSingleReportState(): ReportsUiState {
return _uiState.value.copy(
isLoading = false,
isRefreshing = false,
error = null,
overview = null,
lastUpdatedAtMillis = System.currentTimeMillis(),
incomeExpense = null,
partitions = emptyList(),
budgetItems = emptyList(),
netWorthTrend = emptyList(),
)
}

private inline fun <T> applySingleReportResult(
result: Resource<T>,
mapSuccess: (ReportsUiState, T) -> ReportsUiState,
) {
when (result) {
is Resource.Success -> {
val cleared = _uiState.value.copy(
isLoading = false,
isRefreshing = false,
error = null,
overview = null,
lastUpdatedAtMillis = System.currentTimeMillis(),
incomeExpense = null,
partitions = emptyList(),
budgetItems = emptyList(),
netWorthTrend = emptyList(),
)
_uiState.value = when (type) {
ReportType.INCOME_EXPENSE -> cleared.copy(
incomeExpense = result.data as IncomeExpenseSummary,
)
ReportType.CATEGORY, ReportType.BALANCE -> cleared.copy(
partitions = result.data as List<PartitionAmount>,
)
ReportType.BUDGET -> cleared.copy(
budgetItems = result.data as List<BudgetPerformanceItem>,
)
ReportType.NET_WORTH -> cleared.copy(
netWorthTrend = (result.data as List<DatedAmount>).inMonth(month),
)
ReportType.OVERVIEW -> cleared
}
val cleared = baseSingleReportState()
_uiState.value = mapSuccess(cleared, result.data)
}
is Resource.Error -> {
_uiState.update {
Expand Down
7 changes: 0 additions & 7 deletions app/src/main/java/com/pledgerio/app/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalView
import androidx.core.view.WindowCompat

Expand Down Expand Up @@ -68,12 +67,6 @@ fun PledgerTheme(
if (!view.isInEditMode) {
SideEffect {
val window = (view.context as Activity).window
window.statusBarColor = if (darkTheme) {
HeaderGradientTopDark.toArgb()
} else {
HeaderGradientTopLight.toArgb()
}
window.navigationBarColor = colorScheme.background.toArgb()
WindowCompat.getInsetsController(window, view).apply {
isAppearanceLightStatusBars = false
isAppearanceLightNavigationBars = !darkTheme
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.TrendingDown
import androidx.compose.material.icons.automirrored.filled.TrendingUp
import androidx.compose.material.icons.filled.South
import androidx.compose.material.icons.filled.SwapHoriz
import androidx.compose.material.icons.filled.TrendingDown
import androidx.compose.material.icons.filled.TrendingUp
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
Expand Down Expand Up @@ -57,8 +57,8 @@ data class TransactionTypeStyle(
)

fun transactionTypeStyle(type: TransactionType): TransactionTypeStyle = when (type) {
TransactionType.DEBIT -> TransactionTypeStyle("Income", Icons.Default.TrendingUp, IncomeGreen)
TransactionType.CREDIT -> TransactionTypeStyle("Expense", Icons.Default.TrendingDown, ExpenseRed)
TransactionType.DEBIT -> TransactionTypeStyle("Income", Icons.AutoMirrored.Filled.TrendingUp, IncomeGreen)
TransactionType.CREDIT -> TransactionTypeStyle("Expense", Icons.AutoMirrored.Filled.TrendingDown, ExpenseRed)
TransactionType.TRANSFER -> TransactionTypeStyle("Transfer", Icons.Default.SwapHoriz, PledgerGreen)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExposedDropdownMenuAnchorType
import androidx.compose.material3.ExposedDropdownMenuBox
import androidx.compose.material3.ExposedDropdownMenuDefaults
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.MenuAnchorType
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -137,7 +137,7 @@ private fun OwnedAccountPicker(
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = expanded) },
modifier = Modifier
.fillMaxWidth()
.menuAnchor(MenuAnchorType.PrimaryNotEditable),
.menuAnchor(ExposedDropdownMenuAnchorType.PrimaryNotEditable),
)
ExposedDropdownMenu(
expanded = expanded,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.TrendingDown
import androidx.compose.material.icons.automirrored.filled.TrendingUp
import androidx.compose.material.icons.filled.SwapHoriz
import androidx.compose.material.icons.filled.TrendingDown
import androidx.compose.material.icons.filled.TrendingUp
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
Expand Down Expand Up @@ -49,15 +49,15 @@ fun TransactionTypeSelector(
) {
TypeSegment(
label = stringResource(R.string.transaction_type_income),
icon = Icons.Default.TrendingUp,
icon = Icons.AutoMirrored.Filled.TrendingUp,
selected = selected == TransactionType.DEBIT,
accent = IncomeGreen,
onClick = { onSelected(TransactionType.DEBIT) },
modifier = Modifier.weight(1f),
)
TypeSegment(
label = stringResource(R.string.transaction_type_expense),
icon = Icons.Default.TrendingDown,
icon = Icons.AutoMirrored.Filled.TrendingDown,
selected = selected == TransactionType.CREDIT,
accent = ExpenseRed,
onClick = { onSelected(TransactionType.CREDIT) },
Expand Down
Loading