Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a list system (also enabling a scan history) #21

Closed
8 tasks
teolemon opened this issue Oct 4, 2020 · 23 comments
Closed
8 tasks

Implement a list system (also enabling a scan history) #21

teolemon opened this issue Oct 4, 2020 · 23 comments

Comments

@teolemon
Copy link
Member

teolemon commented Oct 4, 2020

Principles
Lists should be:

  • private to your device
  • exportable
  • optionally syncable across your devices using built-in system mechanisms such as iCloud or Google Drive app backup
  • importable

Lists should be:

  • very flexible although we can prepopulate with popular assumptions (eaten list, shopping list)
  • prevent 2 lists with the same name
  • sortable by date, nutriscore, brand, quantity, product name
  • History should be a special list
@monsieurtanuki
Copy link
Contributor

@teolemon I'm new to openfoodfacts and I may say stupid things:

  • I guess list items are foods
  • each food has a Primary Key (barcode?)
  • there shouldn't be twice the same item in a list
  • lists are ordered (and can be reordered by the user if we're talking about user-defined lists)
  • I don't think there shouldn't be a predefined list of sorting fields - I guess all we need is the PK of each food, and then retrieve whatever field needed in order to sort
  • we should be able not only to sort, but to filter: I have my favorite vegetarian list but today I'm in a vegan mood - I can filter out the dairy and egg foods
  • in additional to the PK of each food, we need to keep a timestamp - at least for the history lists

I haven't had a look at the code yet, so I don't know the kind of db currently used. But it shouldn't be problematic; I guess even shared preferences would do the job.

In first approach I can see 2 obvious use-cases for the lists: scan history, and browse history (of course later user-defined lists can be implemented too, but that would involve more UX dev - add, remove, reorder). For the moment we can imagine displaying scan and browse histories in the "Profile" tab.

@teolemon
Copy link
Member Author

teolemon commented Dec 20, 2020

A lot of very good points.
On the 3rd point (which is related to the timestamp one), 2 use cases: quantities, and also repeated scanning. But those can come later.

@monsieurtanuki monsieurtanuki self-assigned this Dec 29, 2020
@monsieurtanuki
Copy link
Contributor

Regarding history, I suggest the following Sembast record structure:

  • key: barcode (String)
  • value: List<dynamic>
    • 'latest_time': timestamp
    • 'count': int

With this we will be able to perform the following actions:

  • add a product to the history (for instance when the detail page of the product is opened)
  • list the history products, ordered by descending timestamp
  • list the history products, ordered by the number of times they were accessed (= added to history)

@monsieurtanuki
Copy link
Contributor

Waiting for #55

@M123-dev
Copy link
Member

Is the list-system the "Track" area in the navigation bar, or should it serve another purpose

@monsieurtanuki
Copy link
Contributor

@M123-dev Actually I'm already working on this issue, on the data-structure / database side, and I'll finish within a week.
I guess you can work on the UX aspect of this issue.

@M123-dev
Copy link
Member

@monsieurtanuki I'll have a look at it when it's finished. I should be done with the dark mode today or tomorrow. I always have a hard time choosing colors.

@monsieurtanuki
Copy link
Contributor

Now that we have a brand-new database (#55) I'm ready to work on lists.

Which will be a great help while developing other features: for some reasons I work with the products that match "Salmon" to see how the "preferred" lists look like, and I'm fed up with asking the internet the 500 first "salmon"s over and over again just because I want to check the colors ;)

@monsieurtanuki
Copy link
Contributor

I've been working on it this morning, and it looks VERY good...

@PrimaelQuemerais
Copy link
Member

Well that's some great teasing @monsieurtanuki waiting for the PR to try it out 😄

monsieurtanuki referenced this issue in monsieurtanuki/smooth-app Jan 10, 2021
…he database

... and automagically asking the end-user if they want to see the cache

New files:
* `dao_product.dart`
* `dao_product_list.dart`
* `database_product_list_supplier.dart`
* `product_list.dart`
* `product_list_supplier.dart`
* `product_query_page_helper.dart`
* `query_product_list_supplier.dart`

Impacted files:
* `choose_page.dart`: now uses `ProductQueryPageHelper` in order to get database or http results; refactored
* `continuous_scan_model.dart`: minor refactoring due to DAO
* `group_product_query.dart`: now implements new method `getProductList`
* `keywords_product_query.dart`: now implements new method `getProductList`
* `local_database.dart`: now it's version 2; refactored using the new DAO classes
* `product_query.dart`: new method `getProductList`
* `product_query_model.dart`: now we use a `ProductListSupplier` instead of a `ProductQuery`
* `product_query_page.dart`: now we use a `ProductListSupplier` instead of a `ProductQuery`
monsieurtanuki added a commit that referenced this issue Jan 11, 2021
feature/#21 - automatically storing keywords and group results into the database
@monsieurtanuki
Copy link
Contributor

I'll PR the scanned product list this week-end.

There'll still be UX questions like:

  • what to do with several identical barcodes in the same list - keep only the latest?
  • the scanned product list is displayed in a carousel - should we be able to display it in a more conventional list view too?
  • for the moment there's no "refresh product" action - what should trigger it?
  • how should we erase items, or clear the whole list?

@M123-dev
Copy link
Member

M123-dev commented Jan 16, 2021

@monsieurtanuki
Regarding double barcodes, I would say that the user himself (per list) can set whether they should be overwritten or entered twice in the list.

I don't know if that's too much of a hassle, but maybe you could have a number of different views, like you mentioned before.
Here are a few examples of what I'm thinking of, what do you think about:

TimeLine View (dublicate on)

e.g. for the scan or eaten history. Here we could show the "quality of the food" with the colors on the side:
timeline_status

Plain View (Dublicates optional):

Like the lists in the categories

Summary view / Count view

(counted together) e.g. for a shopping list.

grafik

Delete and Reload

I think a kind of custom dropdown on a LongPress would fit best into the design. This gives the option to update, delete, this could be further extendet, for example when the longpress is on a List not a entry we could also enter maybe future list settings.
I answered a question about custom dropdowns on Stackoverflow a few days ago. Therefore I can say that the OverlayEntry offers a easy way to build something like this.

monsieurtanuki referenced this issue in monsieurtanuki/smooth-app Jan 16, 2021
…or its history

New file:
* `scan_page.dart`: helper class to be used on top of `AlternativeContinuousScanPage` and `ContinuousScanPage`

Impacted files:
* `alternative_continuous_scan_page.dart`: `ContinuousScanModel` is now initialized upstream by `ScanPage`
* `continuous_scan_model.dart`: now a `ChangeNotifier`, uses a `ProductList` and database cache
* `continuous_scan_page.dart`: `ContinuousScanModel` is now initialized upstream by `ScanPage`
* `contribution_page.dart`: uses the new `ScanPage` widget instead of the 2 scan pages
* `local_database.dart`: removed the dummy notify listener method
* `main.dart`: uses the new `ScanPage` widget instead of the 2 scan pages
* `personalized_ranking_page.dart`: now we use a `ProductList` as input
* `product_list.dart`: added a `getProduct` method and a "scan list" identifier
* `product_page.dart`: unrelated UI fixes
* `product_query_page.dart`: slight refactoring
* `smooth_it_model.dart`: now we use `ProductList`
* `smooth_product_carousel.dart`: added the new "CACHED" product possibility; fixed an init bug
monsieurtanuki added a commit that referenced this issue Jan 17, 2021
feature/#21 - scan now uses local database, for product look up and for its history
@monsieurtanuki
Copy link
Contributor

Regarding the refresh/clear/rename list actions, I suggest an old-fashioned menu:
Simulator Screen Shot - iPhone 8 Plus - 2021-01-20 at 14 14 22
Simulator Screen Shot - iPhone 8 Plus - 2021-01-20 at 14 14 27
(of course renaming the scanned product list does not mean anything)

@M123-dev
Copy link
Member

@monsieurtanuki In Slack in #general there was a question / suggestion, which I think could go well with the lists:

[...] Is there any app which allows users to compose meals from products (with defined portions/amounts) and shows aggregated nutritional information? [...]

That with defined portions / amounts is difficult to do, but one thing that I think would be very useful is a kind of list summary. So how many calories are in the list, is everything vegetarian / vegan. What do you think of the idea?

@kosciej
Copy link

kosciej commented Jan 25, 2021

@M123-dev Hi, I've posted this messange on Slack. Part with summary is exactly what I imagined.

I'll elaborate on amounts/portions part. I thought about some way to select the portion size from predefined list - spoon, pinch, cup or amount in grams (list might be defined per product category).
Based on that, the exact amount of product will be calculated (teaspoon - 5ml) and added to summary. I'm aware that different products may have different density so the exact values might be off.

Sample user story:
I want to make scrambled eggs for breakfast. I scan the eggs, add to the list and pick amount I want to use (3 eggs). Then I scan butter (1 spoon). I see the final summary. I adjust amount of high fat butter by picking smaller portion (teaspoon instead of spoon).

@monsieurtanuki
Copy link
Contributor

My next steps on this issue are:

  1. create an implicit "product history" list, where a product is added to the list each time the page product is displayed
  2. create a hard-coded "favorite product" list
  3. let end-users create their own lists ("my vegan breakfast", "Typical Saturday shopping", ...)

I've just had another (brillant?) idea: attach an icon to a list - which seems straightforward for scanned products (barcode icon), favorites (heart), history (history icon). We'll let users select icons from a list for their custom lists.
With this icon, you can add a row of icons on top of a product, with the obvious meaning "this product belong to the x, y and z lists" (and with a click on the icon you can add it to / remove it from the list).

@M123-dev @kosciej That's not exactly an answer to your comments, I know, but I think your comments would deserve a new issue: once we've got custom lists, what do we do with them?
That being said, I'm not sure if the product data we extract for the moment contains all the nutrient values. Which we would need if we had to implement what @kosciej suggests.
And in general, that would mean creating aggregation rules.

@kosciej
Copy link

kosciej commented Jan 25, 2021

@monsieurtanuki my proposal looks indeed like out of scope, but related to this one. I'll create separate issue.

@M123-dev
Copy link
Member

The idea with the icons is great.
To the problem with the missing data. When #107 is done we could build this together, then the lists would passively contribute to improving the database.

@monsieurtanuki
Copy link
Contributor

@M123-dev I don't know if it's a problem of_ missing_ data. The OFF server has most of the time all the nutrient data, it's just that we don't extract them when we download the products in smoothie. Should we extract everything? That's an existential question about the purpose of smoothie and the granularity of the data it uses.

@monsieurtanuki
Copy link
Contributor

I've just replaced the "track" bottom navigation button with a "lists" button, as "track" is not used for the moment.
A first screenshot about that:
Simulator Screen Shot - iPhone 8 Plus - 2021-01-25 at 12 15 55

@monsieurtanuki
Copy link
Contributor

monsieurtanuki commented Jan 29, 2021

I'm still working on lists:

  • dismissible products (swipe gesture)
  • copy/paste a list

[Edit] done in #134.

@monsieurtanuki
Copy link
Contributor

@teolemon Well, I guess the lists are now naturally embedded in smoothie.
Feel free to close the issue if everything is fine so far.

@M123-dev M123-dev added the lists label Mar 15, 2021
@M123-dev
Copy link
Member

I think we are save to close this rn since the basics are implemented, a bit work is still to do ref #166

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants