init
This commit is contained in:
@@ -33,7 +33,6 @@ android {
|
|||||||
create("benchmark") {
|
create("benchmark") {
|
||||||
initWith(getByName("release"))
|
initWith(getByName("release"))
|
||||||
|
|
||||||
// 🔑 Critical settings for Macrobenchmark
|
|
||||||
isDebuggable = false
|
isDebuggable = false
|
||||||
isMinifyEnabled = false
|
isMinifyEnabled = false
|
||||||
isShrinkResources = false
|
isShrinkResources = false
|
||||||
@@ -111,6 +110,7 @@ dependencies {
|
|||||||
implementation(libs.androidx.datastore.preferences)
|
implementation(libs.androidx.datastore.preferences)
|
||||||
|
|
||||||
implementation(libs.icons.material.symbols.outlined.android)
|
implementation(libs.icons.material.symbols.outlined.android)
|
||||||
|
implementation(libs.icons.material.symbols.outlined.filled.android)
|
||||||
|
|
||||||
implementation("com.google.dagger:hilt-android:2.57.1")
|
implementation("com.google.dagger:hilt-android:2.57.1")
|
||||||
ksp("com.google.dagger:hilt-android-compiler:2.57.1")
|
ksp("com.google.dagger:hilt-android-compiler:2.57.1")
|
||||||
|
|||||||
@@ -150,4 +150,8 @@ data class Filter(
|
|||||||
fun without(category: Category): Filter {
|
fun without(category: Category): Filter {
|
||||||
return this.copy(categories = categories - category)
|
return this.copy(categories = categories - category)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isDefault(): Boolean {
|
||||||
|
return this.categories.isEmpty() && startAmount == 0.0 && endAmount == Double.MAX_VALUE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -14,9 +14,7 @@ import cc.n0th1ng.tripmoney.data.dao.TripDao
|
|||||||
import cc.n0th1ng.tripmoney.data.entity.Category
|
import cc.n0th1ng.tripmoney.data.entity.Category
|
||||||
import cc.n0th1ng.tripmoney.data.entity.ExchangeRate
|
import cc.n0th1ng.tripmoney.data.entity.ExchangeRate
|
||||||
import cc.n0th1ng.tripmoney.data.entity.Expense
|
import cc.n0th1ng.tripmoney.data.entity.Expense
|
||||||
import cc.n0th1ng.tripmoney.data.entity.ExpenseDto
|
|
||||||
import cc.n0th1ng.tripmoney.data.entity.Trip
|
import cc.n0th1ng.tripmoney.data.entity.Trip
|
||||||
import cc.n0th1ng.tripmoney.screens.listexpense.toEpochMilli
|
|
||||||
import cc.n0th1ng.tripmoney.utils.Currencies
|
import cc.n0th1ng.tripmoney.utils.Currencies
|
||||||
import cc.n0th1ng.tripmoney.utils.Icons
|
import cc.n0th1ng.tripmoney.utils.Icons
|
||||||
import cc.n0th1ng.tripmoney.utils.colors
|
import cc.n0th1ng.tripmoney.utils.colors
|
||||||
@@ -26,9 +24,7 @@ import dagger.hilt.InstallIn
|
|||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
import dagger.hilt.components.SingletonComponent
|
import dagger.hilt.components.SingletonComponent
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Delay
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
@@ -36,7 +32,6 @@ import java.time.LocalDateTime
|
|||||||
import java.time.ZoneOffset
|
import java.time.ZoneOffset
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
import kotlin.random.nextInt
|
|
||||||
|
|
||||||
@Database(
|
@Database(
|
||||||
entities = [Trip::class, Expense::class, Category::class, ExchangeRate::class],
|
entities = [Trip::class, Expense::class, Category::class, ExchangeRate::class],
|
||||||
@@ -176,6 +171,51 @@ private class DatabasePrepopulator(
|
|||||||
icon = Icons.GROCERIES,
|
icon = Icons.GROCERIES,
|
||||||
color = colors.random()
|
color = colors.random()
|
||||||
),
|
),
|
||||||
|
Category(
|
||||||
|
name = "Zakupy1",
|
||||||
|
icon = Icons.GROCERIES,
|
||||||
|
color = colors.random()
|
||||||
|
),
|
||||||
|
Category(
|
||||||
|
name = "Zakupy2",
|
||||||
|
icon = Icons.GROCERIES,
|
||||||
|
color = colors.random()
|
||||||
|
),
|
||||||
|
Category(
|
||||||
|
name = "Zakupy3",
|
||||||
|
icon = Icons.GROCERIES,
|
||||||
|
color = colors.random()
|
||||||
|
),
|
||||||
|
Category(
|
||||||
|
name = "Zakupy4",
|
||||||
|
icon = Icons.GROCERIES,
|
||||||
|
color = colors.random()
|
||||||
|
),
|
||||||
|
Category(
|
||||||
|
name = "Zakupy5",
|
||||||
|
icon = Icons.GROCERIES,
|
||||||
|
color = colors.random()
|
||||||
|
),
|
||||||
|
Category(
|
||||||
|
name = "Zakupy6",
|
||||||
|
icon = Icons.GROCERIES,
|
||||||
|
color = colors.random()
|
||||||
|
),
|
||||||
|
Category(
|
||||||
|
name = "Zakupy7",
|
||||||
|
icon = Icons.GROCERIES,
|
||||||
|
color = colors.random()
|
||||||
|
),
|
||||||
|
Category(
|
||||||
|
name = "Zakupy8",
|
||||||
|
icon = Icons.GROCERIES,
|
||||||
|
color = colors.random()
|
||||||
|
),
|
||||||
|
Category(
|
||||||
|
name = "Zakupy9 ",
|
||||||
|
icon = Icons.GROCERIES,
|
||||||
|
color = colors.random()
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.O)
|
@RequiresApi(Build.VERSION_CODES.O)
|
||||||
@@ -193,7 +233,7 @@ private class DatabasePrepopulator(
|
|||||||
|
|
||||||
|
|
||||||
val expense = Expense(
|
val expense = Expense(
|
||||||
categoryId = Random.nextInt(1, 5),
|
categoryId = Random.nextInt(1, sampleCategories.size),
|
||||||
tripId = 1,
|
tripId = 1,
|
||||||
amount = Random.nextDouble(0.1, 300.0),
|
amount = Random.nextDouble(0.1, 300.0),
|
||||||
currency = Currencies.entries.random().name,
|
currency = Currencies.entries.random().name,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import androidx.paging.PagingSource
|
|||||||
import androidx.room.Dao
|
import androidx.room.Dao
|
||||||
import androidx.room.Delete
|
import androidx.room.Delete
|
||||||
import androidx.room.Query
|
import androidx.room.Query
|
||||||
|
import androidx.room.RewriteQueriesToDropUnusedColumns
|
||||||
import androidx.room.Transaction
|
import androidx.room.Transaction
|
||||||
import androidx.room.Upsert
|
import androidx.room.Upsert
|
||||||
import cc.n0th1ng.tripmoney.data.entity.Category
|
import cc.n0th1ng.tripmoney.data.entity.Category
|
||||||
@@ -18,6 +19,8 @@ interface ExpenseDao {
|
|||||||
suspend fun insert(expense: Expense)
|
suspend fun insert(expense: Expense)
|
||||||
|
|
||||||
|
|
||||||
|
@Transaction
|
||||||
|
@RewriteQueriesToDropUnusedColumns
|
||||||
@Query(
|
@Query(
|
||||||
"""
|
"""
|
||||||
SELECT * FROM expense
|
SELECT * FROM expense
|
||||||
@@ -87,13 +90,17 @@ interface ExpenseDao {
|
|||||||
|
|
||||||
@Query(
|
@Query(
|
||||||
"""
|
"""
|
||||||
SELECT trip.budget - IFNULL(SUM(expense.amount * expense.rate), 0)
|
SELECT
|
||||||
|
CASE
|
||||||
|
WHEN trip.budget = 0 THEN NULL
|
||||||
|
ELSE trip.budget - IFNULL(SUM(expense.amount * expense.rate), 0)
|
||||||
|
END
|
||||||
FROM trip
|
FROM trip
|
||||||
LEFT JOIN expense ON expense.trip_id = trip.id
|
LEFT JOIN expense ON expense.trip_id = trip.id
|
||||||
WHERE trip.id = :tripId
|
WHERE trip.id = :tripId
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
fun budgetLeft(tripId: Int): Double
|
fun budgetLeft(tripId: Int): Double?
|
||||||
|
|
||||||
@Delete
|
@Delete
|
||||||
suspend fun delete(expense: Expense)
|
suspend fun delete(expense: Expense)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import androidx.room.ColumnInfo
|
|||||||
import androidx.room.Embedded
|
import androidx.room.Embedded
|
||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
||||||
import androidx.room.ForeignKey
|
import androidx.room.ForeignKey
|
||||||
|
import androidx.room.Index
|
||||||
import androidx.room.PrimaryKey
|
import androidx.room.PrimaryKey
|
||||||
import androidx.room.Relation
|
import androidx.room.Relation
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
@@ -17,7 +18,8 @@ import java.time.LocalDateTime
|
|||||||
childColumns = arrayOf("category_id"),
|
childColumns = arrayOf("category_id"),
|
||||||
onUpdate = ForeignKey.CASCADE,
|
onUpdate = ForeignKey.CASCADE,
|
||||||
onDelete = ForeignKey.CASCADE
|
onDelete = ForeignKey.CASCADE
|
||||||
)]
|
)],
|
||||||
|
indices = [Index(value = ["category_id"], unique = true)]
|
||||||
)
|
)
|
||||||
@Immutable
|
@Immutable
|
||||||
data class Expense(
|
data class Expense(
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import cc.n0th1ng.tripmoney.data.entity.ExpenseDto
|
|||||||
import cc.n0th1ng.tripmoney.utils.Currencies
|
import cc.n0th1ng.tripmoney.utils.Currencies
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
|
import java.util.OptionalDouble
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ExpenseRepository @Inject constructor(
|
class ExpenseRepository @Inject constructor(
|
||||||
@@ -20,7 +21,7 @@ class ExpenseRepository @Inject constructor(
|
|||||||
private val exchangeRateRepository: ExchangeRateRepository
|
private val exchangeRateRepository: ExchangeRateRepository
|
||||||
) {
|
) {
|
||||||
|
|
||||||
fun getBudgetLeft(tripId: Int): Double {
|
fun getBudgetLeft(tripId: Int): Double? {
|
||||||
return expenseDao.budgetLeft(tripId)
|
return expenseDao.budgetLeft(tripId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import androidx.compose.material.icons.filled.Close
|
|||||||
import androidx.compose.material.icons.filled.Menu
|
import androidx.compose.material.icons.filled.Menu
|
||||||
import androidx.compose.material3.AlertDialog
|
import androidx.compose.material3.AlertDialog
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
|
import androidx.compose.material3.ButtonDefaults
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.FilterChip
|
import androidx.compose.material3.FilterChip
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
@@ -21,7 +22,6 @@ import androidx.compose.material3.IconButton
|
|||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.OutlinedTextField
|
import androidx.compose.material3.OutlinedTextField
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TextField
|
|
||||||
import androidx.compose.material3.TextFieldDefaults
|
import androidx.compose.material3.TextFieldDefaults
|
||||||
import androidx.compose.material3.TopAppBar
|
import androidx.compose.material3.TopAppBar
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
@@ -38,7 +38,6 @@ import androidx.compose.ui.res.painterResource
|
|||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.input.ImeAction
|
import androidx.compose.ui.text.input.ImeAction
|
||||||
import androidx.compose.ui.text.input.KeyboardType
|
import androidx.compose.ui.text.input.KeyboardType
|
||||||
import androidx.compose.ui.text.input.TextFieldValue
|
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.navigation.NavHostController
|
import androidx.navigation.NavHostController
|
||||||
import cc.n0th1ng.tripmoney.Filter
|
import cc.n0th1ng.tripmoney.Filter
|
||||||
@@ -121,7 +120,11 @@ fun TopBar(
|
|||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
tint = MaterialTheme.colorScheme.primary,
|
tint = MaterialTheme.colorScheme.primary,
|
||||||
painter = painterResource(drawable.materialsymbols_ic_filter_alt_outlined),
|
painter = painterResource(
|
||||||
|
if (filter.isDefault())
|
||||||
|
drawable.materialsymbols_ic_filter_alt_outlined
|
||||||
|
else com.composables.icons.materialsymbols.outlinedfilled.R.drawable.materialsymbols_ic_filter_alt_outlined_filled
|
||||||
|
),
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
modifier = Modifier.clickable(onClick = {
|
modifier = Modifier.clickable(onClick = {
|
||||||
showFilter = true
|
showFilter = true
|
||||||
@@ -150,7 +153,11 @@ fun TopBar(
|
|||||||
showFilter = false
|
showFilter = false
|
||||||
},
|
},
|
||||||
categories = categories,
|
categories = categories,
|
||||||
filter = filter
|
filter = filter,
|
||||||
|
onClear = {
|
||||||
|
onFilterChange(Filter())
|
||||||
|
showFilter = false
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -161,6 +168,7 @@ fun TopBar(
|
|||||||
fun FilterDialog(
|
fun FilterDialog(
|
||||||
onDismiss: () -> Unit,
|
onDismiss: () -> Unit,
|
||||||
onSave: (Filter) -> Unit,
|
onSave: (Filter) -> Unit,
|
||||||
|
onClear: () -> Unit,
|
||||||
categories: List<Category>,
|
categories: List<Category>,
|
||||||
filter: Filter
|
filter: Filter
|
||||||
) {
|
) {
|
||||||
@@ -168,7 +176,15 @@ fun FilterDialog(
|
|||||||
var fromAmountString by remember { mutableStateOf(filter.startAmount.toString()) }
|
var fromAmountString by remember { mutableStateOf(filter.startAmount.toString()) }
|
||||||
var toAmountString by remember { mutableStateOf(filter.endAmount.toString()) }
|
var toAmountString by remember { mutableStateOf(filter.endAmount.toString()) }
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
onDismiss, {
|
onDismissRequest = onDismiss,
|
||||||
|
dismissButton = {
|
||||||
|
Button(
|
||||||
|
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.secondary),
|
||||||
|
enabled = true,
|
||||||
|
onClick = onClear
|
||||||
|
) { Text(stringResource(R.string.clear)) }
|
||||||
|
},
|
||||||
|
confirmButton = {
|
||||||
Button(
|
Button(
|
||||||
enabled = true,
|
enabled = true,
|
||||||
onClick = {
|
onClick = {
|
||||||
@@ -181,7 +197,7 @@ fun FilterDialog(
|
|||||||
text = {
|
text = {
|
||||||
Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||||
Text(text = "Categories")
|
Text(text = "Categories")
|
||||||
FlowRow(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
|
FlowRow(horizontalArrangement = Arrangement.spacedBy(7.dp)) {
|
||||||
categories.forEach {
|
categories.forEach {
|
||||||
FilterChip(selected = filter.categories.contains(it), onClick = {
|
FilterChip(selected = filter.categories.contains(it), onClick = {
|
||||||
filter = if (filter.categories.contains(it)) {
|
filter = if (filter.categories.contains(it)) {
|
||||||
@@ -189,7 +205,12 @@ fun FilterDialog(
|
|||||||
} else {
|
} else {
|
||||||
filter.with(it)
|
filter.with(it)
|
||||||
}
|
}
|
||||||
}, label = { Text(text = it.name) })
|
}, label = {
|
||||||
|
Row(horizontalArrangement = Arrangement.spacedBy(5.dp)) {
|
||||||
|
Icon(painterResource(it.icon.resource), contentDescription = null)
|
||||||
|
Text(text = it.name)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AmountTextField(label = "from", onValueChange = { newText ->
|
AmountTextField(label = "from", onValueChange = { newText ->
|
||||||
@@ -265,7 +286,8 @@ fun PreviewFilterDialog() {
|
|||||||
onDismiss = {},
|
onDismiss = {},
|
||||||
onSave = {},
|
onSave = {},
|
||||||
categories = categoriesToPreview,
|
categories = categoriesToPreview,
|
||||||
filter = Filter()
|
filter = Filter(),
|
||||||
|
onClear = {}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -487,7 +487,7 @@ fun NumberKeyboard(
|
|||||||
onLongClick = onLongBackspaceClick
|
onLongClick = onLongBackspaceClick
|
||||||
)
|
)
|
||||||
|
|
||||||
"+", "÷", "-", "×" -> KeyboardButton(
|
"+", "÷", "−", "×" -> KeyboardButton(
|
||||||
text = key,
|
text = key,
|
||||||
onClick = { onOperatorClick(key) },
|
onClick = { onOperatorClick(key) },
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
@@ -541,7 +541,7 @@ fun KeyboardButton(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val keyboard = listOf(
|
val keyboard = listOf(
|
||||||
listOf("+", "-", "×", "÷"),
|
listOf("+", "−", "×", "÷"),
|
||||||
listOf("1", "2", "3"),
|
listOf("1", "2", "3"),
|
||||||
listOf("4", "5", "6"),
|
listOf("4", "5", "6"),
|
||||||
listOf("7", "8", "9"),
|
listOf("7", "8", "9"),
|
||||||
|
|||||||
@@ -363,7 +363,7 @@ fun ExpenseCard(
|
|||||||
colors = CardDefaults.elevatedCardColors()
|
colors = CardDefaults.elevatedCardColors()
|
||||||
.copy(containerColor = MaterialTheme.colorScheme.surfaceContainer),
|
.copy(containerColor = MaterialTheme.colorScheme.surfaceContainer),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth(0.9f)
|
.fillMaxWidth(0.95f)
|
||||||
.height(70.dp)
|
.height(70.dp)
|
||||||
.combinedClickable(
|
.combinedClickable(
|
||||||
enabled = true,
|
enabled = true,
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
|||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material3.CardDefaults
|
import androidx.compose.material3.CardDefaults
|
||||||
import androidx.compose.material3.ElevatedCard
|
import androidx.compose.material3.ElevatedCard
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
@@ -32,7 +34,6 @@ import androidx.compose.ui.res.painterResource
|
|||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.core.graphics.toColorInt
|
import androidx.core.graphics.toColorInt
|
||||||
import androidx.core.graphics.toColorLong
|
|
||||||
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
|
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
|
||||||
import cc.n0th1ng.tripmoney.data.dto.SummaryPerCategory
|
import cc.n0th1ng.tripmoney.data.dto.SummaryPerCategory
|
||||||
import cc.n0th1ng.tripmoney.data.entity.Category
|
import cc.n0th1ng.tripmoney.data.entity.Category
|
||||||
@@ -73,7 +74,7 @@ fun StatisticsScreen(
|
|||||||
summaryPerCategoryList: List<SummaryPerCategory>,
|
summaryPerCategoryList: List<SummaryPerCategory>,
|
||||||
summaryAmount: Double,
|
summaryAmount: Double,
|
||||||
tripCurrency: Currencies,
|
tripCurrency: Currencies,
|
||||||
moneyLeft: Double
|
moneyLeft: Double?
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@@ -104,7 +105,7 @@ fun StatisticsScreen(
|
|||||||
@Composable
|
@Composable
|
||||||
fun Summary(
|
fun Summary(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
amount: Double,
|
amount: Double?,
|
||||||
currency: String,
|
currency: String,
|
||||||
text: String,
|
text: String,
|
||||||
icon: Int,
|
icon: Int,
|
||||||
@@ -117,7 +118,8 @@ fun Summary(
|
|||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.padding(10.dp),
|
modifier = Modifier.padding(10.dp),
|
||||||
verticalArrangement = Arrangement.spacedBy(10.dp)
|
verticalArrangement = Arrangement.spacedBy(10.dp),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically,
|
modifier = Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically,
|
||||||
@@ -141,6 +143,7 @@ fun Summary(
|
|||||||
|
|
||||||
}
|
}
|
||||||
Text(
|
Text(
|
||||||
|
if (amount == null) "∞" else
|
||||||
"%.2f %s".format(amount, currency),
|
"%.2f %s".format(amount, currency),
|
||||||
style = MaterialTheme.typography.titleLarge,
|
style = MaterialTheme.typography.titleLarge,
|
||||||
)
|
)
|
||||||
@@ -156,7 +159,10 @@ fun SummaryPerCategoryCard(summaryPerCategoryList: List<SummaryPerCategory>) {
|
|||||||
.copy(containerColor = MaterialTheme.colorScheme.surfaceContainer)
|
.copy(containerColor = MaterialTheme.colorScheme.surfaceContainer)
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.padding(15.dp),
|
modifier = Modifier
|
||||||
|
.padding(15.dp)
|
||||||
|
.verticalScroll(rememberScrollState()),
|
||||||
|
|
||||||
verticalArrangement = Arrangement.spacedBy(5.dp)
|
verticalArrangement = Arrangement.spacedBy(5.dp)
|
||||||
) {
|
) {
|
||||||
summaryPerCategoryList.forEach {
|
summaryPerCategoryList.forEach {
|
||||||
@@ -204,7 +210,7 @@ fun CategoryCard(modifier: Modifier = Modifier, summaryPerCategory: SummaryPerCa
|
|||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.height(40.dp)
|
.height(30.dp)
|
||||||
.fillMaxWidth(0.12f + (0.90f - 0.12f) * summaryPerCategory.percent)
|
.fillMaxWidth(0.12f + (0.90f - 0.12f) * summaryPerCategory.percent)
|
||||||
.clip(RoundedCornerShape(16.dp))
|
.clip(RoundedCornerShape(16.dp))
|
||||||
.background(MaterialTheme.colorScheme.primary)
|
.background(MaterialTheme.colorScheme.primary)
|
||||||
@@ -213,7 +219,7 @@ fun CategoryCard(modifier: Modifier = Modifier, summaryPerCategory: SummaryPerCa
|
|||||||
verticalArrangement = Arrangement.Center,
|
verticalArrangement = Arrangement.Center,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.padding(11.dp)
|
.padding(vertical = 5.dp, horizontal = 10.dp)
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
"%d%%".format((summaryPerCategory.percent * 100).toInt()),
|
"%d%%".format((summaryPerCategory.percent * 100).toInt()),
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import org.apache.commons.csv.CSVFormat
|
|||||||
import org.apache.commons.csv.CSVPrinter
|
import org.apache.commons.csv.CSVPrinter
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
|
import java.util.OptionalDouble
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlin.collections.mapValues
|
import kotlin.collections.mapValues
|
||||||
|
|
||||||
@@ -41,7 +42,7 @@ open class ExpenseAndCategoryViewModel @Inject constructor(
|
|||||||
private val tripRepo: TripRepository
|
private val tripRepo: TripRepository
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
|
|
||||||
fun getBudgetLeft(tripId: Int): Double {
|
fun getBudgetLeft(tripId: Int): Double? {
|
||||||
return expenseRepo.getBudgetLeft(tripId)
|
return expenseRepo.getBudgetLeft(tripId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,4 +40,5 @@
|
|||||||
<string name="money_left">Money left</string>
|
<string name="money_left">Money left</string>
|
||||||
<string name="add_expense_settings">Open add expense form on startup</string>
|
<string name="add_expense_settings">Open add expense form on startup</string>
|
||||||
<string name="yesterday">Yesterday</string>
|
<string name="yesterday">Yesterday</string>
|
||||||
|
<string name="clear">Clear</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -1,17 +1,26 @@
|
|||||||
[versions]
|
[versions]
|
||||||
agp = "8.13.2"
|
agp = "8.13.2"
|
||||||
|
commonsCsv = "1.14.1"
|
||||||
datastorePreferences = "1.2.1"
|
datastorePreferences = "1.2.1"
|
||||||
|
desugar_jdk_libsVersion = "2.1.5"
|
||||||
|
hiltAndroid = "2.59.2"
|
||||||
|
hiltNavigationCompose = "1.3.0"
|
||||||
iconsMaterialSymbolsOutlinedAndroid = "2.2.1"
|
iconsMaterialSymbolsOutlinedAndroid = "2.2.1"
|
||||||
kotlin = "2.2.21"
|
kotlin = "2.2.21"
|
||||||
coreKtx = "1.10.1"
|
coreKtx = "1.10.1"
|
||||||
junit = "4.13.2"
|
junit = "4.13.2"
|
||||||
junitVersion = "1.1.5"
|
junitVersion = "1.1.5"
|
||||||
espressoCore = "3.5.1"
|
espressoCore = "3.5.1"
|
||||||
|
kotlinxSerializationJsonJvm = "1.11.0"
|
||||||
|
ktorClientCore = "3.4.3"
|
||||||
|
ktorClientOkhttp = "3.4.3"
|
||||||
lifecycleRuntimeKtx = "2.6.1"
|
lifecycleRuntimeKtx = "2.6.1"
|
||||||
activityCompose = "1.8.0"
|
activityCompose = "1.8.0"
|
||||||
composeBom = "2024.09.00"
|
composeBom = "2024.09.00"
|
||||||
navigationCompose = "2.9.7"
|
navigationCompose = "2.9.7"
|
||||||
foundationLayout = "1.10.5"
|
foundationLayout = "1.10.5"
|
||||||
|
pagingCompose = "3.4.2"
|
||||||
|
roomCompiler = "2.8.4"
|
||||||
uiautomator = "2.3.0"
|
uiautomator = "2.3.0"
|
||||||
benchmarkMacroJunit4 = "1.2.4"
|
benchmarkMacroJunit4 = "1.2.4"
|
||||||
baselineprofile = "1.2.4"
|
baselineprofile = "1.2.4"
|
||||||
@@ -21,7 +30,22 @@ uiTestJunit4 = "1.10.6"
|
|||||||
[libraries]
|
[libraries]
|
||||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||||
androidx-datastore-preferences = { module = "androidx.datastore:datastore-preferences", version.ref = "datastorePreferences" }
|
androidx-datastore-preferences = { module = "androidx.datastore:datastore-preferences", version.ref = "datastorePreferences" }
|
||||||
|
#androidx-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "hiltNavigationCompose" }
|
||||||
|
#androidx-paging-compose = { module = "androidx.paging:paging-compose", version.ref = "pagingCompose" }
|
||||||
|
#androidx-paging-runtime = { module = "androidx.paging:paging-runtime", version.ref = "pagingCompose" }
|
||||||
|
#androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "roomCompiler" }
|
||||||
|
#androidx-room-guava = { module = "androidx.room:room-guava", version.ref = "roomCompiler" }
|
||||||
|
#androidx-room-ktx = { module = "androidx.room:room-ktx", version.ref = "roomCompiler" }
|
||||||
|
#androidx-room-paging = { module = "androidx.room:room-paging", version.ref = "roomCompiler" }
|
||||||
|
#androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "roomCompiler" }
|
||||||
|
#androidx-room-rxjava3 = { module = "androidx.room:room-rxjava3", version.ref = "roomCompiler" }
|
||||||
|
#androidx-room-rxjava2 = { module = "androidx.room:room-rxjava2", version.ref = "roomCompiler" }
|
||||||
|
#androidx-room-testing = { module = "androidx.room:room-testing", version.ref = "roomCompiler" }
|
||||||
|
#commons-csv = { module = "org.apache.commons:commons-csv", version.ref = "commonsCsv" }
|
||||||
|
#hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hiltAndroid" }
|
||||||
|
#hilt-android-compiler = { module = "com.google.dagger:hilt-android-compiler", version.ref = "hiltAndroid" }
|
||||||
icons-material-symbols-outlined-android = { module = "com.composables:icons-material-symbols-outlined-android", version.ref = "iconsMaterialSymbolsOutlinedAndroid" }
|
icons-material-symbols-outlined-android = { module = "com.composables:icons-material-symbols-outlined-android", version.ref = "iconsMaterialSymbolsOutlinedAndroid" }
|
||||||
|
icons-material-symbols-outlined-filled-android = { module = "com.composables:icons-material-symbols-outlined-filled-android", version.ref = "iconsMaterialSymbolsOutlinedAndroid" }
|
||||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||||
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
||||||
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
|
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
|
||||||
@@ -41,6 +65,10 @@ androidx-uiautomator = { group = "androidx.test.uiautomator", name = "uiautomato
|
|||||||
androidx-benchmark-macro-junit4 = { group = "androidx.benchmark", name = "benchmark-macro-junit4", version.ref = "benchmarkMacroJunit4" }
|
androidx-benchmark-macro-junit4 = { group = "androidx.benchmark", name = "benchmark-macro-junit4", version.ref = "benchmarkMacroJunit4" }
|
||||||
androidx-profileinstaller = { group = "androidx.profileinstaller", name = "profileinstaller", version.ref = "profileinstaller" }
|
androidx-profileinstaller = { group = "androidx.profileinstaller", name = "profileinstaller", version.ref = "profileinstaller" }
|
||||||
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4", version.ref = "uiTestJunit4" }
|
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4", version.ref = "uiTestJunit4" }
|
||||||
|
kotlinx-serialization-json-jvm = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json-jvm", version.ref = "kotlinxSerializationJsonJvm" }
|
||||||
|
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktorClientCore" }
|
||||||
|
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktorClientOkhttp" }
|
||||||
|
tools-desugar_jdk_libs = { module = "com.android.tools:desugar_jdk_libs", version.ref = "desugar_jdk_libsVersion" }
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
|
|||||||
Reference in New Issue
Block a user