Skip to content

Comments

Make Add New Plant Screen 🌱 #10

Open
mnbpdx wants to merge 2 commits intocreate-plant-model-and-repo-and-daofrom
add-demo-create-new-plant-functionality
Open

Make Add New Plant Screen 🌱 #10
mnbpdx wants to merge 2 commits intocreate-plant-model-and-repo-and-daofrom
add-demo-create-new-plant-functionality

Conversation

@mnbpdx
Copy link
Owner

@mnbpdx mnbpdx commented Jul 20, 2024

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

@mnbpdx mnbpdx added the enhancement New feature or request label Jul 20, 2024
@mnbpdx mnbpdx self-assigned this Jul 20, 2024
@mnbpdx mnbpdx requested review from Tearemuptara and removed request for Tearemuptara July 20, 2024 08:45
@mnbpdx
Copy link
Owner Author

mnbpdx commented Jul 20, 2024

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.

@mnbpdx mnbpdx changed the title Add Local Storage and Add New Plant Screen 🌱 Make Add New Plant Screen 🌱 Jul 20, 2024
@mnbpdx mnbpdx changed the base branch from main to create-plant-model-and-repo-and-dao July 20, 2024 08:52
@mnbpdx mnbpdx force-pushed the add-demo-create-new-plant-functionality branch from 2c39b0f to db70ffa Compare July 20, 2024 19:11
@mnbpdx mnbpdx force-pushed the create-plant-model-and-repo-and-dao branch from bb89f42 to 074fee8 Compare July 20, 2024 19:15
@mnbpdx
Copy link
Owner Author

mnbpdx commented Jul 20, 2024

yay I fixed my local and remote branches! rebaseing my way out of that particular weird git state is something that's eluded me for a long time, but I finally understand what I was doing wrong

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 main:

image

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.

@mnbpdx mnbpdx force-pushed the add-demo-create-new-plant-functionality branch from db70ffa to 407797b Compare July 20, 2024 20:57
@mnbpdx mnbpdx force-pushed the add-demo-create-new-plant-functionality branch from 407797b to 7e2dd17 Compare July 20, 2024 20:57
.externalNativeBuild
.cxx
local.properties
app/schemas No newline at end of file
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating some dependencies in our module level build.gradle.kts.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this Compose test file a bit.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pulled out an interface for this repository so we could use it with Hilt, but idk it felt like good practice too

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hilt stuff!

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The model!

@Entity(tableName = "plants")
data class Plant(
@PrimaryKey val id: String,
@PrimaryKey(autoGenerate = true) val id: Int = 0,
Copy link
Owner Author

@mnbpdx mnbpdx Jul 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here's where our ids are generated, since you asked

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@mnbpdx mnbpdx marked this pull request as ready for review July 20, 2024 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant