Make Add New Plant Screen 🌱 #10
Make Add New Plant Screen 🌱 #10mnbpdx wants to merge 2 commits intocreate-plant-model-and-repo-and-daofrom
Conversation
|
whoops I think some of these commits are on #8, I guess this pr will just be about the add plant screen. that's better anyway. I'll fix that soon. |
2c39b0f to
db70ffa
Compare
bb89f42 to
074fee8
Compare
|
yay I fixed my local and remote branches! Okay so the git commit history / PR titles / descriptions should look reasonable now 👍 Edit: You may have noticed that this PR is currently pointing to the branch for this other PR: #8, rather than to
That's just my way of trying to keep the git commits making sense and showing that we'll merge #8 before we merge this one. |
db70ffa to
407797b
Compare
407797b to
7e2dd17
Compare
| .externalNativeBuild | ||
| .cxx | ||
| local.properties | ||
| app/schemas No newline at end of file |
There was a problem hiding this comment.
We can add stuff to the file .gitignore so that git ignores it!
Here I'm ignoring the schema file that Room generates. I felt like it was basically a build file so it felt weird to add it to version control.
There was a problem hiding this comment.
Updating some dependencies in our module level build.gradle.kts.
There was a problem hiding this comment.
Updated this Compose test file a bit.
There was a problem hiding this comment.
I think git just decided that I deleted this file since i changed it so much and moved it, but it's still in the project, just bigger; see below.
| fun getAllPlants(): Flow<List<Plant>> | ||
|
|
||
| @Query("SELECT * FROM plants WHERE id = :id") | ||
| suspend fun getPlant(id: Int): Plant? |
There was a problem hiding this comment.
Added a call to get a single plant from the database!
| import javax.inject.Inject | ||
|
|
||
| // An interface that defines what the repository needs to do | ||
| interface PlantRepository { |
There was a problem hiding this comment.
I pulled out an interface for this repository so we could use it with Hilt, but idk it felt like good practice too
| @Entity(tableName = "plants") | ||
| data class Plant( | ||
| @PrimaryKey val id: String, | ||
| @PrimaryKey(autoGenerate = true) val id: Int = 0, |
There was a problem hiding this comment.
here's where our ids are generated, since you asked
There was a problem hiding this comment.
this dope ass little file keeps track of all the versions of all the libraries we could use anywhere in our app. Both build.gradle.ktss reference this file.
If you ever want to know what version of a thing we're using, it's probably in this file!

I made a new
AddPlantScreen()(and correspondingAddPlantScreenViewModel) which allows the user to add a new plant, which is saved to a local Room/SQL database (see #8).