Skip to content

Commit

Permalink
Improvements from code review.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marlon D. Rocha committed Mar 19, 2024
1 parent 0f2937f commit 13fbf5c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class LocalOperationDataSource: KoinComponent, OperationDataSource {
id = -1,
amount = 0.0,
description = "Test",
type = OperationType.INCOME.operation,
category = Category.EDUCATION.name,
type = OperationType.INCOME,
category = Category.EDUCATION,
date = LocalDateTime(2024, 3, 6, 1, 1 ,1, 1),
isPeriodic = false,
)
Expand Down
6 changes: 5 additions & 1 deletion composeApp/src/commonMain/kotlin/domain/model/Category.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,9 @@ enum class Category(val categoryName: String, val primaryColor: Color,
TRAVEL("Travel", indigo500, indigo600, Res.drawable.ic_travel),
TRANSPORT("Transport", purple600, purple500, Res.drawable.ic_transport),
GIFTS_DONATIONS("Gifts & Donations", pink600, pink500, Res.drawable.ic_gifts),
MISCELLANEOUS("Miscellaneous", rose600, rose500, Res.drawable.ic_miscellaneous)
MISCELLANEOUS("Miscellaneous", rose600, rose500, Res.drawable.ic_miscellaneous);

companion object {
fun all(): Array<Category> = enumValues<Category>()
}
}
5 changes: 2 additions & 3 deletions composeApp/src/commonMain/kotlin/domain/model/Operation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ package domain.model

import kotlinx.datetime.LocalDateTime


data class Operation(
val id: Long,
val amount: Double,
val description: String,
val type: String,
val category: String,
val type: OperationType,
val category: Category,
val date: LocalDateTime,
val isPeriodic: Boolean,
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,11 @@ import presentation.theme.income

enum class OperationType(val operation: String, val color: Color) {
EXPENSE("Expense", expense),
INCOME("Income", income)
INCOME("Income", income);

companion object {
private fun all(): Array<OperationType> = enumValues<OperationType>()

fun operationNames(): List<String> = all().map { it.operation }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import domain.model.Category
import domain.model.OperationType
import moe.tlaster.precompose.koin.koinViewModel
Expand Down Expand Up @@ -92,22 +91,10 @@ internal fun NewOperationScreen(
}

val tabContentColors = listOf(expense, income)
val operations = listOf(OperationType.EXPENSE.operation, OperationType.INCOME.operation)
val operations = OperationType.operationNames().toList()

//TODO: Remover esta lista ao implementar lógica de navegação para tela de categorias
val categories = listOf(
Category.TRAVEL,
Category.DINING_OUT,
Category.HEALTH_WELLNESS,
Category.EDUCATION,
Category.ENTERTAINMENT,
Category.GIFTS_DONATIONS,
Category.GROCERIES,
Category.INCOME,
Category.MISCELLANEOUS,
Category.TRANSPORT,
Category.SUBSCRIPTION
)
val categories = Category.all()

Scaffold(
topBar = {
Expand Down Expand Up @@ -216,10 +203,10 @@ fun Selector(modifier: Modifier = Modifier, icon: DrawableResource? = null,
.height(INPUT_HEIGHT)
.clip(MaterialTheme.shapes.small)
.background(MaterialTheme.colors.surface)
.padding(SMALL_PADDING)
.clickable { onSelectorClick() },
.clickable { onSelectorClick() }
.padding(SMALL_PADDING),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
horizontalArrangement = Arrangement.spacedBy(EXTRA_SMALL_PADDING)
) {
icon?.let {
Icon(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import kotlin.test.Test
class TabBarTest {

private val tabContentColors = listOf(expense, income)
private val tabItems = listOf(OperationType.EXPENSE.operation, OperationType.INCOME.operation)
private val tabItems = OperationType.operationNames()

@OptIn(ExperimentalTestApi::class)
@Test
Expand Down

0 comments on commit 13fbf5c

Please sign in to comment.