mikaelacaron / Basic-Car-Maintenance

A basic app to track your car's maintenance. Open source for Hacktoberfest 2023. Beginners are welcome!
https://mikaelacaron.github.io/Basic-Car-Maintenance/documentation/basic_car_maintenance/
Apache License 2.0
214 stars 123 forks source link

implement Add Odometer Reading AppIntent #247

Closed OmarHegazy93 closed 9 months ago

OmarHegazy93 commented 10 months ago

What it Does

To achieve this task, I had to make some refactoring for the app flow by:

  1. Removing the dependency for the AuthenticationViewModel for almost all viewModels, as they all needed the UserID only
  2. UserID is currently saved to UserDefaults, as a next step we will need to figure out a better or safer way for saving it
  3. Make getVehicles() method default implemented as both MainTabViewModel and SettingsViewModel are using it for fetching vehicles

For the AppIntent itself:

  1. The query used to fetch the vehicles is using MainTabViewModel and if no vehicles available, then it will return an error
  2. DistanceUnit enum is used to make more readable for selecting Distance unit
  3. Validation is applied to Distance and Date

How I Tested

Happy scenario

  1. Install the app
  2. Make sure at least one vehicle is added in the app by going to Settings tab > Add Vehicle
  3. Switch to Shortcuts app
  4. Tab on the + on the top right corner
  5. Tab on ⨁ Add Action
  6. Select Apps tab
  7. Tab on Basic Car
  8. Tab on Add Odometer Reading
  9. Add data for all fields and tab the play button on the bottom right corner
  10. See the result

Unhappy scenario

  1. Install the app
  2. Make sure at least one vehicle is added in the app by going to Settings tab > Add Vehicle
  3. Switch to Shortcuts app
  4. Tab on the + on the top right corner
  5. Tab on ⨁ Add Action
  6. Select Apps tab
  7. Tab on Basic Car
  8. Tab on Add Odometer Reading
  9. Try to set distance value to zero or negative value or set the date to past
  10. See the result

Notes

Screenshot

mikaelacaron commented 9 months ago

Closing now that Hacktoberfest is over, and I don't want to merge this solution right now. Thanks again for contributing! It's much appreciated! Feel free to pick up any issues even though Hacktoberfest is over