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

[WIP] Making history page look more like the designs #690

Closed
wants to merge 1 commit into from

Conversation

zond
Copy link
Contributor

@zond zond commented Nov 25, 2021

No description provided.

@zond zond changed the title Making history page look more like the designs [WIP] Making history page look more like the designs Nov 25, 2021
@zond
Copy link
Contributor Author

zond commented Nov 25, 2021

@jasmeet0817, @M123-dev

I have spent a lot of time trying to understand how the product lists currently work.

It seems the ProductList class is only a data container, and not a widget, and there is currently no (simple) widget that shows it's content.

The ProductListPage that seems to be the preferred way to display a ProductList is a complete full screen page, and does a lot of stuff. Exactly how it displays the product list, and what stuff it does, is controlled by parameters in the data container ProductList.

This means that the places where the app shows product lists aren't widgets composed of product-list widgets using surrounding containers and constructor parameters to control the rendering and behavior, but everything is opaquely controlled by the data container class ProductList.

Adding a new kind of product list into this structure, with a new look and behavior, would make both ProductList and ProductListPage more complex and potentially add changes and/or bugs into existing uses of it.

WDYT about this analys? Have I misunderstood something?

To avoid this I have created a new widget called SimpleProductList that will be only a simple list of products. I'm not sure about the name, maybe ProductListWidget would be better?

I intend it's detailed look and behavior to be controlled by constructor parameters as is the custom in Flutter, and provide it a ProductList that will only be used to provide the actual data to display - not how it is displayed or how it behaves.

It can then be used anywhere you want to display a page containing product lists in the more common Flutter way of composing widgets with constructor parameters instead of baking the display logic into the data container.

Currently it only displays ProductListItemSimple as content, but as those contain SmoothProductCardFound widgets that don't conform to the UX designs that will have to change.

WDYT about this architectural idea. Does it make sense?

@monsieurtanuki
Copy link
Contributor

@zond I did write ProductList and ProductListPage, and I can probably be helpful :)

  • ProductList is supposed to be only a data container
  • there is currently no specific widget to display a ProductList, just a full page called ProductListPage
  • you say you need a Widget - I suggest that you start from the ReorderableListView.builder code inside ProductListPage, that you could indeed call ProductListWidget
  • currently, UX behaviors are computed from the ProductList (and btw not by the ProductList, therefore not "opaquely controlled by the data container class")
    • there's a reason behind that - you don't display automatic history lists the same way as reorderable user-defined shopping lists
    • if you need more flexibility than having those behaviors computed automatically, nothing prevents you from adding those parameters (e.g. bool dismissible, bool reorderable) to you ProductListWidget constructor
    • but you should be careful that depending on the list type, the available "extra" data won't be the same - e.g. timestamps for history and quantity for shopping list

Don't hesitate to ask more questions. Btw I don't mind my code being thrown away (but for good reasons only), so don't be shy ;)

Copy link
Contributor

@monsieurtanuki monsieurtanuki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I though this was an issue, not a PR.
The code looks clean. I did not run it.
What I can say is that in #349 I specifically added the timestamps. I don't know if they are still supposed to be there.

@zond
Copy link
Contributor Author

zond commented Nov 25, 2021

@zond I did write ProductList and ProductListPage, and I can probably be helpful :)

Excellent, thanks!

  • ProductList is supposed to be only a data container

Still, the ProductListPage controls a lot of rendering based on functions and data provided by ProductList?

  • there is currently no specific widget to display a ProductList, just a full page called ProductListPage

Check.

  • you say you need a Widget - I suggest that you start from the ReorderableListView.builder code inside ProductListPage, that you could indeed call ProductListWidget

Sounds good, I'll look at that!

  • currently, UX behaviors are computed from the ProductList (and btw not by the ProductList, therefore not "opaquely controlled by the data container class")

    • there's a reason behind that - you don't display automatic history lists the same way as reorderable user-defined shopping lists
    • if you need more flexibility than having those behaviors computed automatically, nothing prevents you from adding those parameters (e.g. bool dismissible, bool reorderable) to you ProductListWidget constructor

That makes sense - but wouldn't that collide with how the ProductList contains the same kind of (I don't know if it contains the actual same) rendering/behavioral hints?

  • but you should be careful that depending on the list type, the available "extra" data won't be the same - e.g. timestamps for history and quantity for shopping list

Check!

Don't hesitate to ask more questions. Btw I don't mind my code being thrown away (but for good reasons only), so don't be shy ;)

That's a sound approach - but I also find it a very sound approach to not throw code away but instead try to gently add new features or improvements into the current architecture :D

I had no idea the response to my questions would be this quick, and your answers will surely help me add stuff in as gentle a way as possible 👍

@monsieurtanuki
Copy link
Contributor

@zond Your first step may be to extract the ReorderableListView.builder code I mentioned earlier into a new ProductListWidget class, and use that class in ProductListPage.
I suspect that what bothers you is more the "Page-rather-than-a-Widget" issue than the "automatic display meta-data" issue.
Good luck!

@zond
Copy link
Contributor Author

zond commented Nov 26, 2021

@zond Your first step may be to extract the ReorderableListView.builder code I mentioned earlier into a new ProductListWidget class, and use that class in ProductListPage. I suspect that what bothers you is more the "Page-rather-than-a-Widget" issue than the "automatic display meta-data" issue. Good luck!

Alright, I refactored it a bit as per your recommendation.

Do you think it's OK to redesign the ProductListWidget to look like the 'history' page in Figma - i.e. do you think it's OK if all product lists in the app start looking like that?

Copy link
Contributor

@monsieurtanuki monsieurtanuki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @zond!
Not 100% convinced: please have a look at my comments.

I don't know what the product list looks like in Figma.
I don't know either how the concept of product list is supposed to evolve.
If the concepts of user defined lists, shopping lists and pantries are discarded, and if we only have history lists, I guess you can get rid of some code because you'll always have the following parameters: reorderable = false, timestamps = true, dismissible = true.

My main question is: what do you really need if you want to "make history page look more like the designs", as the title of this PR suggests?

@@ -4,7 +4,7 @@ import 'package:provider/provider.dart';
import 'package:qr_code_scanner/qr_code_scanner.dart';
import 'package:smooth_app/data_models/continuous_scan_model.dart';
import 'package:smooth_app/pages/personalized_ranking_page.dart';
import 'package:smooth_app/pages/smooth_bottom_navigation_bar.dart';
import 'package:smooth_app/pages/smooth_bottom_navigation_bar.dart' as navbar;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point? I assume that SmoothBottomNavigationBar has an explicit name, that the name is long enough, and that it's used in a context where there's no ambiguity.
I won't reject the PR just for that, though. I guess it's about personal coding preferences.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was because for some reason the compiler complained that SmoothBottomNavigationBar was defined in two files - I had no clue what caused it by this fixed it.

Now I can't repro that problem, so I removed the fix :)

);
}

static String _getDaysAgoLabel(final int daysAgo) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're refactoring, you'd be better off creating a new file dedicated to "some time ago" labels. Maybe some_time_ago_helper.dart, with String getDaysAgoLabel(final int daysAgo, final AppLocalizations appLocalizations). With actual translations, at least in TODOs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines 33 to 45
final AppLocalizations appLocalizations = AppLocalizations.of(context)!;
return Column(
children: <Widget>[
AppBar(
backgroundColor: Colors.white,
foregroundColor: Colors.black,
title: Text(appLocalizations.history),
),
Expanded(child: ProductListWidget(productList)),
],
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was still to use ProductListPage, that would mainly use the new class ProductListWidget where most of the page's code would have been moved.

The way the project evolved, ProductListPage is now only used by the history page. If you don't use it in the history page anymore, everything you do in ProductListPage is basically maintaining dead code.

And I'm not convinced that using a Column with an AppBar then a body (and without a navigation bar) is such a good idea compared to a standard Scaffold.

My suggestion: let history page use ProductListPage, that uses the new class ProductListWidget.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be happy to remove ProductListPage if it's unused, but see
image

I don't remember why I did it using Column containing AppBar... I changed it to a Scaffold now.

Nesting 'pages' seems strange - if we want to use ProductListPage only or the history page, then we could just rename it to HistoryPage.

Also, see the image above - ProductList is still used for the custom product lists (which I don't know if they are going away or not).

@zond
Copy link
Contributor Author

zond commented Nov 29, 2021

Hi @zond! Not 100% convinced: please have a look at my comments.

I don't know what the product list looks like in Figma. I don't know either how the concept of product list is supposed to evolve. If the concepts of user defined lists, shopping lists and pantries are discarded, and if we only have history lists, I guess you can get rid of some code because you'll always have the following parameters: reorderable = false, timestamps = true, dismissible = true.

I don't know if they are going away or not (I'm just trying to pick up some tasks from @jasmeet0817), but even if they are not, I assume we will want the same styling and look on all lists of products.

Mainly I'm talking about visual differences, how the different icons are laid out etc

My main question is: what do you really need if you want to "make history page look more like the designs", as the title of this PR suggests?

This is the history page from the Figma design:
image

@zond zond force-pushed the history_page branch 3 times, most recently from 63da93d to 74a4ff9 Compare November 29, 2021 08:30
…aking the current ProductListPage even more complex.
Copy link
Contributor

@monsieurtanuki monsieurtanuki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @zond!
Assuming that the Figma screenshots are correct - e.g. no timestamp displayed - and as you consider in HistoryPage that you use the default version of ProductListWidget (no reorderable; no dismissible, no timestamps), I would highly simplify the code and remove everything about reordeable, dismissible and timestamps (e.g. _Meta).
Basically that would mean a simple ListView. Much easier to read. Keeping "dismissible" would make sense, though (and setting it to true for history), and is not in contradiction with the screenshots.

That being said:

@jasmeet0817
Copy link
Contributor

Hi @zond! Not 100% convinced: please have a look at my comments.
I don't know what the product list looks like in Figma. I don't know either how the concept of product list is supposed to evolve. If the concepts of user defined lists, shopping lists and pantries are discarded, and if we only have history lists, I guess you can get rid of some code because you'll always have the following parameters: reorderable = false, timestamps = true, dismissible = true.

I don't know if they are going away or not (I'm just trying to pick up some tasks from @jasmeet0817), but even if they are not, I assume we will want the same styling and look on all lists of products.

Hi, sorry for late reply. They are going away indeed, we only need the product list in two places:

  1. History page
  2. Compare page (note we may need to display two the list in two different sections).
    image

Mainly I'm talking about visual differences, how the different icons are laid out etc

My main question is: what do you really need if you want to "make history page look more like the designs", as the title of this PR suggests?

This is the history page from the Figma design: image

@zond
Copy link
Contributor Author

zond commented Dec 8, 2021

After discussion with @jasmeet0817 we decided that the simplest thing to do is to scrap this PR and make a new one that only changes the look of the row in the product list, since that is the most important difference between the UX designs and what's here currently.

@monsieurtanuki
Copy link
Contributor

@zond @jasmeet0817 That makes sense, especially now that I've started to refactor the database AND trim all the pantry stuff en passant. The code looks much clearer.

@zond zond closed this Dec 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants