Refactor habit tracking app: update Gradle settings, add type converters, and improve UI components

This commit is contained in:
bobbert committed 2026-02-25 01:23:49 +00:00
1 parent f838d1f628
commit 1904106d16
8 files changed
+47 -10

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
+1
View File
@@ -0,0 +1 @@
/build
+8 -7
View File
@@ -2,15 +2,12 @@ plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.ksp)
alias(libs.plugins.kotlin.android)
}
android {
namespace = "com.example.madwellbeingapp"
compileSdk {
version = release(36) {
minorApiLevel = 1
}
}
compileSdk = 36
defaultConfig {
applicationId = "com.example.madwellbeingapp"
@@ -32,12 +29,15 @@ android {
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
buildFeatures {
compose = true
}
kotlinOptions {
jvmTarget = "17"
}
}
dependencies {
@@ -53,6 +53,7 @@ dependencies {
// Room
implementation(libs.androidx.room.runtime)
implementation(libs.androidx.room.ktx)
implementation(libs.core.ktx)
ksp(libs.androidx.room.compiler)
// Navigation Compose
@@ -0,0 +1,18 @@
package com.example.madwellbeingapp.data
import androidx.room.TypeConverter
import com.example.madwellbeingapp.data.model.HabitCategory
class Converters {
@TypeConverter
fun fromCategory(category: HabitCategory): String {
return category.name
}
@TypeConverter
fun toCategory(value: String): HabitCategory {
return HabitCategory.valueOf(value)
}
}
@@ -4,12 +4,14 @@ import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import androidx.room.TypeConverters
import com.example.madwellbeingapp.data.dao.HabitDao
import com.example.madwellbeingapp.data.dao.HabitLogDao
import com.example.madwellbeingapp.data.model.Habit
import com.example.madwellbeingapp.data.model.HabitLog
@Database(entities = [Habit::class, HabitLog::class], version = 1, exportSchema = false)
@TypeConverters(Converters::class)
abstract class HabitDatabase : RoomDatabase() {
abstract fun habitDao(): HabitDao
@@ -16,7 +16,7 @@ interface HabitDao {
suspend fun insert(habit: Habit): Long
@Update
suspend fun update(habit: Habit)
suspend fun update(habit: Habit): Int
@Delete
suspend fun delete(habit: Habit): Int
@@ -22,7 +22,6 @@ import androidx.compose.material3.ExposedDropdownMenuDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.MenuAnchorType
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Switch
@@ -132,7 +131,7 @@ fun AddEditHabitScreen(
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = categoryExpanded) },
modifier = Modifier
.fillMaxWidth()
.menuAnchor(MenuAnchorType.PrimaryNotEditable),
.menuAnchor(),
shape = RoundedCornerShape(12.dp)
)
ExposedDropdownMenu(
+1
View File
@@ -3,4 +3,5 @@ plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.compose) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.kotlin.android) apply false
}