carekit-apple / CareKit

CareKit is an open source software framework for creating apps that help people better understand and manage their health.
https://www.researchandcare.org
Other
2.41k stars 444 forks source link

[Proposal] Category Card, OCKTaskCategory, organization of OCKTasks #355

Open kutakmir opened 4 years ago

kutakmir commented 4 years ago

I'd like to propose a card component that will enable us to organize tasks by category. Something similar to the Apple Health app's Browse panel. For that purpose, there would be a new entity -> OCKTaskCategory. Currently, there is a groupIdentifier in the OCKTask that fits this purpose, but that doesn't allow for efficient querying of all the available categories.

The OCKTaskCategory will have a title: String and an icon: UIImage properties. The design will be very similar to the Apple Health app.

In addition to this card + model layer stack (CareKit Store and Core Data), there could be a ViewController portion with a search bar and index bar.

....

Then a similar pattern can be used for displaying Care Plans as they are another, currently supported, way of organizing OCKTasks.

This is something that I can implement and submit a PR.

What do you think? Is this a desirable addition to CareKit?

pthealthtech commented 4 years ago

This functionality would be very beneficial.

gavirawson-apple commented 4 years ago

This sounds like a great idea! If you would like to work on this feature, we would be happy to merge it into the framework. Otherwise we can build it out on our end.

For the Core Data step, it will be helpful to look at the way notes are set up in the schema. There is one note entity with potential relationships to the owner of the note. You can setup a new OCKCategory entity in the same manner, which will allow you to perform a query such as "Give me all categories that belong to a task." Going this route will save you from creating a separate category for each entity (OCKTaskCategory, OCKCarePlanCategory, etc).

The view controller portion sounds great as well. It might be a good route to query and display each category, and allow the developer to define what to do when the category is tapped (perhaps through a delegate method). That way, the view controller will be flexible for a variety of use cases.

If you're feeling super ambitious, you could take a shot at keeping the displayed categories synchronized with the ones in the database (I.E if a category is removed from the database, it should no longer be displayed in the view). This will be a bit challenging - we're happy to either work with you on this part or append that functionality for you to your PR.