Compare commits

..

No commits in common. "f2fe268b5bd773c585b37ef97fe9fb79f121ebe9" and "7b1c0db0cc9d1b8ca7605e36ca4a1033dc2de2d0" have entirely different histories.

11 changed files with 60 additions and 36 deletions

2
.idea/kotlinc.xml generated
View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="KotlinJpsPluginSettings"> <component name="KotlinJpsPluginSettings">
<option name="version" value="2.0.0" /> <option name="version" value="1.9.0" />
</component> </component>
</project> </project>

View File

@ -1,7 +1,9 @@
plugins { plugins {
alias(libs.plugins.android.application) alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android) alias(libs.plugins.jetbrains.kotlin.android)
alias(libs.plugins.kotlin.compose)
// https://medium.com/@rowaido.game/implementing-the-room-library-with-jetpack-compose-590d13101fa7
id("com.google.devtools.ksp")
// For Room (2024-12-17) // For Room (2024-12-17)
kotlin("kapt") kotlin("kapt")
@ -9,16 +11,19 @@ plugins {
android { android {
namespace = "com.hyperling.expensetracker" namespace = "com.hyperling.expensetracker"
compileSdk = 35 compileSdk = 34
defaultConfig { defaultConfig {
applicationId = "com.hyperling.expensetracker" applicationId = "com.hyperling.expensetracker"
minSdk = 24 minSdk = 24
targetSdk = 34 targetSdk = 34
versionCode = 1 versionCode = 1
versionName = "0.0.2" versionName = "0.0.1"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
} }
buildTypes { buildTypes {
@ -31,15 +36,26 @@ android {
} }
} }
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_1_8
} }
kotlinOptions { kotlinOptions {
jvmTarget = "11" jvmTarget = "1.8"
} }
buildFeatures { buildFeatures {
compose = true compose = true
} }
composeOptions {
kotlinCompilerExtensionVersion = "1.5.1"
// https://medium.com/@rowaido.game/implementing-the-room-library-with-jetpack-compose-590d13101fa7
//kotlinCompilerExtensionVersion = "1.5.11"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
} }
dependencies { dependencies {
@ -60,10 +76,19 @@ dependencies {
debugImplementation(libs.androidx.ui.tooling) debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest) debugImplementation(libs.androidx.ui.test.manifest)
// For Room // https://medium.com/@rowaido.game/implementing-the-room-library-with-jetpack-compose-590d13101fa7
/* This is crazy? How are people supposed to know how to do this, and especially "fix" it when it doesn't work?
implementation(libs.androidx.room.runtime)
implementation(libs.androidx.room.ktx)
ksp(libs.androidx.room.compiler)
implementation(libs.androidx.lifecycle.viewmodel.compose)
*/
// For Room (2024-12-17)
// https://www.youtube.com/watch?v=bOd3wO0uFr8&themeRefresh=1 // https://www.youtube.com/watch?v=bOd3wO0uFr8&themeRefresh=1
/* build.gradle version * / /* build.gradle version * /
def room_version: String = "2.5.0" def room_version: String = "2.6.1"
implementation"androidx.room:room-ktx:$room_version" implementation"androidx.room:room-ktx:$room_version"
kapt "androidx.room:room-compiler:$room_version" kapt "androidx.room:room-compiler:$room_version"
// */ // */

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: String, //Enum<Rate>, val rate: Enum<Rate>,
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
val ID: Int = 0, val ID: Int = 0,
) )

View File

@ -21,10 +21,10 @@ interface ExpenseDao {
@Query("SELECT * FROM expense ORDER BY name ASC") @Query("SELECT * FROM expense ORDER BY name ASC")
fun selectExpensesName(): Flow<List<Expense>> fun selectExpensesName(): Flow<List<Expense>>
@Query("SELECT * FROM expense ORDER BY cost ASC")
fun selectExpensesCost(): Flow<List<Expense>>
@Query("SELECT * FROM expense ORDER BY rate ASC") @Query("SELECT * FROM expense ORDER BY rate ASC")
fun selectExpensesRate(): Flow<List<Expense>> fun selectExpensesRate(): Flow<List<Expense>>
@Query("SELECT * FROM expense ORDER BY cost ASC")
fun selectExpensesCost(): Flow<List<Expense>>
} }

View File

@ -42,7 +42,7 @@ fun ExpenseDialogAdd(
}, },
keyboardOptions = KeyboardOptions(capitalization = KeyboardCapitalization.Words) keyboardOptions = KeyboardOptions(capitalization = KeyboardCapitalization.Words)
) )
// TBD / TODO: Had to make this a String, can we turn it back to a Double somehow? // TBD: Had to make this a String, can we turn it back to a Double somehow?
TextField( TextField(
value = state.cost, value = state.cost,
onValueChange = { onValueChange = {
@ -53,8 +53,7 @@ fun ExpenseDialogAdd(
}, },
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Decimal) keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Decimal)
) )
// TBD / TODO: Unsure what to do here yet so that an Enum is possible. /* Unsure what to do here yet, a simple Picker type does not seems to exist?
// A simple Picker type does not seems to exist? Why? Whyyy???
TextField( TextField(
value = state.rate, value = state.rate,
onValueChange = { onValueChange = {
@ -64,7 +63,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: String): ExpenseEvent // TBD / TODO: Make this the enum. data class SetRate(val rate: Rate): ExpenseEvent
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: String = "", // TBD / TODO: Rate = Rate.MONTHLY, val rate: 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, enable this once Rate is working.
) { ) {
return return
} }
@ -67,7 +67,7 @@ class ExpenseViewModel (
isAddingExpense = false, isAddingExpense = false,
name = "", name = "",
cost = "", cost = "",
rate = "", // TBD / TODO: Rate.MONTHLY, rate = Rate.MONTHLY,
) } ) }
} }
is ExpenseEvent.SetName -> { is ExpenseEvent.SetName -> {

View File

@ -1,8 +1,5 @@
package com.hyperling.expensetracker package com.hyperling.expensetracker
/* TBD / TODO: This file exists temporarily for viewing what the old version was doing.
// TBD / TODO: Remove this file.
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
@ -141,4 +138,3 @@ fun MainPreview() {
Main() Main()
} }
} }
*/

View File

@ -1,6 +1,8 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins { plugins {
alias(libs.plugins.android.application) apply false alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.android) apply false alias(libs.plugins.jetbrains.kotlin.android) apply false
alias(libs.plugins.kotlin.compose) apply false
// https://medium.com/@rowaido.game/implementing-the-room-library-with-jetpack-compose-590d13101fa7
id("com.google.devtools.ksp") version "1.9.23-1.0.19" apply false
} }

View File

@ -1,13 +1,16 @@
[versions] [versions]
agp = "8.7.3" agp = "8.7.3"
kotlin = "2.0.0" kotlin = "1.9.0"
coreKtx = "1.15.0" coreKtx = "1.10.1"
junit = "4.13.2" junit = "4.13.2"
junitVersion = "1.2.1" junitVersion = "1.1.5"
espressoCore = "3.6.1" espressoCore = "3.5.1"
lifecycleRuntimeKtx = "2.6.1" lifecycleRuntimeKtx = "2.6.1"
activityCompose = "1.8.0" activityCompose = "1.8.0"
composeBom = "2024.04.01" composeBom = "2024.04.01"
roomCompiler = "2.6.1"
roomKtx = "2.6.1"
roomRuntime = "2.6.1"
[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" }
@ -27,6 +30,5 @@ androidx-material3 = { group = "androidx.compose.material3", name = "material3"
[plugins] [plugins]
android-application = { id = "com.android.application", version.ref = "agp" } android-application = { id = "com.android.application", version.ref = "agp" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }