Closed frostymate closed 1 day ago
Some difficulties were encountered as my first attempt of passing the selectedFoodItem as a parameter was quite complicated to test and was very complex. So instead I am using the viewModel in order to interact and store the selectedFoodItem.
The Coverage of New Code is under 80 but for the main files modified/added they have a high coverage. The other files will have their coverage increased before M2.
Failed conditions
71.7% Coverage on New Code (required ≥ 80%)
These changes collectively enhance the user experience by providing detailed views of individual food items and ensuring robust test coverage for new features.This pull request introduces a new feature allowing users to view details of individual food items within the
ShelfLife
app. The changes include updates to navigation, view models, and UI components to support this feature. I have added nice UI Screen. However, there are things to be worked on as I need to add testing which will be done in [#91], additionally there are some values like font sizes that are hardcoded that I will eventually do. Finally, I believe that the database has to be structured in a way that food items should be collections and each food item should have sub-collections containing their instances. This would make retrieval of instances of the same Food Item very efficient however this is quite an ambitious task that I will leave for M3.Navigation and Routing Enhancements:
IndividualFoodItemScreen
to the list of composable screens inMainActivity.kt
and defined a new route for it. [1] [2]INDIVIDUAL_FOOD_ITEM
inNavigationActions.kt
and a navigation methodnavigateToIndividualFood
. [1] [2]ViewModel Updates:
searchedFoodItems
state flow and methodssetSelectedFoodItem
and its corresponding getter toHouseholdViewModel.kt
to manage and retrieved the clicked food item. [1] [2]UI Component Modifications:
FoodDisplayComponents.kt
to make food items clickable and pass a click handler toFoodItemCard
. [1] [2] [3] [4]Overview.kt
to handle food item clicks and navigate to the individual food item screen.New UI Screen:
IndividualFoodItemScreen
to display detailed information about a selected food item, including its name, image, and nutritional facts.New Utility Component:
FoodItemDetails.kt
to encapsulate the display logic for food item details.Test Coverage:
IndividualFoodItemScreen
to verify correct display and navigation behavior.FoodItemDetailsTest
to ensure theFoodItemDetails
component displays food item details correctly.Code Refactoring:
ListFoodItemsViewModel
andHouseholdViewModel
open classes to allow for easier testing and extension. [1] [2]build.gradle.kts
and other files for consistency and readability. [1] [2]