Change rate to a String since Java is mad about the enum.

This commit is contained in:
Hyperling 2025-01-09 16:03:35 -07:00
parent 8b8ef62cbf
commit 6e05298f3d
5 changed files with 7 additions and 6 deletions

View File

@ -7,7 +7,7 @@ import androidx.room.PrimaryKey
data class Expense ( data class Expense (
val name: String, val name: String,
val cost: String, val cost: String,
val rate: Enum<Rate>, val rate: String, //Enum<Rate>,
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
val ID: Int = 0, val ID: Int = 0,
) )

View File

@ -53,7 +53,8 @@ fun ExpenseDialogAdd(
}, },
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Decimal) keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Decimal)
) )
/* Unsure what to do here yet, a simple Picker type does not seems to exist? // TBD / TODO: Unsure what to do here yet so that an Enum is possible.
// A simple Picker type does not seems to exist? Why? Whyyy???
TextField( TextField(
value = state.rate, value = state.rate,
onValueChange = { onValueChange = {
@ -63,7 +64,7 @@ fun ExpenseDialogAdd(
Text(text = "Rate") Text(text = "Rate")
}, },
) )
*/ // */
} }
}, },
confirmButton = { confirmButton = {

View File

@ -4,7 +4,7 @@ sealed interface ExpenseEvent {
object SaveExpense: ExpenseEvent object SaveExpense: ExpenseEvent
data class SetName(val name: String): ExpenseEvent data class SetName(val name: String): ExpenseEvent
data class SetCost(val cost: String): ExpenseEvent data class SetCost(val cost: String): ExpenseEvent
data class SetRate(val rate: Rate): ExpenseEvent data class SetRate(val rate: String): ExpenseEvent // TBD / TODO: Make this the enum.
object ShowDialog: ExpenseEvent object ShowDialog: ExpenseEvent
object HideDialog: ExpenseEvent object HideDialog: ExpenseEvent
data class SortExpenses(val sortType: SortType): ExpenseEvent data class SortExpenses(val sortType: SortType): ExpenseEvent

View File

@ -4,7 +4,7 @@ data class ExpenseState(
val expenses: List<Expense> = emptyList(), val expenses: List<Expense> = emptyList(),
val name: String = "", val name: String = "",
val cost: String = "", val cost: String = "",
val rate: Rate = Rate.MONTHLY, val rate: String = "", // TBD / TODO: Rate = Rate.MONTHLY,
val isAddingExpense: Boolean = false, val isAddingExpense: Boolean = false,
val sortType: SortType = SortType.NAME, val sortType: SortType = SortType.NAME,
) )

View File

@ -52,7 +52,7 @@ class ExpenseViewModel (
if (name.isBlank() if (name.isBlank()
|| cost.isBlank() || cost.isBlank()
//|| rate.isBlank() # TBD / TODO: Enable this once Rate is working. || rate.isBlank() // TBD / TODO: Enable this once Rate is working.
) { ) {
return return
} }