commit-crimes / shelf-life

1 stars 0 forks source link

Feat/152 general bug fixes and UI improvements on overview and household creation screens #158

Closed ElMaestroZ closed 20 hours ago

ElMaestroZ commented 1 day ago

This pull request includes various changes to the test files to ensure the correct ViewModels are passed to the OverviewScreen and AddFoodItemScreen components, as well as a major bug fix and some minor formatting adjustments.

New

Formatting Adjustments:

Dearop commented 1 day ago

Bug Fix:

The issue where householdViewModel did not correctly refresh the selectedHousehold resulted in the overview screen not updating when a new item was added. The introduction of the updateSelectedHousehold() method in the HouseholdViewModel effectively resolves this problem. By refreshing the selected household upon data changes, the overview screen now accurately reflects the current state of the household’s food items. This fix enhances the application’s responsiveness and ensures data consistency across views.

UI Improvements:

Button Layout on Creation Screen:

Adapting the buttons on the creation screen to better fit small screens ensures that UI elements are accessible and visually appealing on devices with smaller display, enhancing overall user experience and broadening the app’s usability. This was a problem that we noted when running the small phone emulator.

Test Suite Updates:

Updating the test files to align with the new householdViewModel logic is crucial for maintaining code reliability. Passing the correct ViewModels to the OverviewScreen and AddFoodItemScreen components ensures that the tests accurately reflect the application’s behavior. These extensive adjustments across multiple test files are great to have.

Formatting Adjustments:

The improved code formatting in AddFoodItemScreenTest.kt and other files enhances readability and consistency. Thanks for that!

Code Analysis and Suggestions:

Exception Handling in HouseHoldRepositoryFirestore:

The change from using addOnSuccessListener and addOnFailureListener to addOnCompleteListener in the updateHousehold method is a sensible simplification. However, ensure that the onFailure callback correctly handles exceptions when the task is not successful. Logging the exception and providing meaningful error messages will aid in debugging and improve robustness.

Magic Numbers in Progress Bar Calculation:

In Thresholds.kt and FoodDisplayComponents.kt, hardcoded values (e.g., color codes, progress percentages) are used for determining the progress bar’s appearance. Defining these values as constants or enumerations with descriptive names would improve code readability and make future adjustments easier. Perhaps adding these in a seperate file like Colors.kt might be the right move?

Commenting and Documentation:

Adding comments to new methods like updateSelectedHousehold() in HouseholdViewModel would help other developers understand the purpose and usage of the method without having to come ask you.

Conclusion:

The pull request successfully fixes a significant bug and brings meaningful improvements to the user interface and testing framework. The adjustments are a thoughtful approach to enhancing our user experience and maintaining code quality. Addressing the suggestions above would further strengthen the codebase and ensure long-term maintainability. Overall, these are great changes to add. Thank you Robin for a great contribution to the code and bug fix!

sonarcloud[bot] commented 22 hours ago

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
84.4% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud