Skip to content

feat: Added price count badges #6493

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

Open
wants to merge 20 commits into
base: develop
Choose a base branch
from

Conversation

asim-sahoo
Copy link

What

  • Added a price count badge to proof details and grid view for better visibility.
  • Refactored ProofGridItem for a cleaner layout and better readability.
  • Adjusted container styling for better readability.

Screenshot

Fixes bug(s)

@monsieurtanuki monsieurtanuki self-requested a review March 30, 2025 05:44
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 @asim-sahoo!
Some things to change in your code, as you can read in my comments. And probably more, later.
Btw in your screenshots you don't show proofs but product images. I hope you didn't pollute the PROD server with irrelevant pictures - you tested prices on DEV/TEST, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove that file from the PR, it has nothing to do with your code.

Copy link
Author

Choose a reason for hiding this comment

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

the changes were auto generated, I have reverted the changes but its still showing in the changed files.
same with the .gitignore file. I have no idea why its showing changed although there is no difference. can you please help me with this

@@ -26,6 +26,7 @@ class PriceProofPage extends StatefulWidget {

class _PriceProofPageState extends State<PriceProofPage> {
List<Price>? _existingPrices;
bool _isLoading = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

_isLoading has no purpose in your code, so please remove it.

),
// Display price count badge on the detail screen
if (!_isLoading && _existingPrices != null)
Positioned(
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of a Stack and a Positioned, please just us a Badge, cf. prices_card.dart.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

yes

Comment on lines 158 to 160
setState(() {
_isLoading = false;
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
setState(() {
_isLoading = false;
});

Comment on lines 169 to 171
setState(() {
_isLoading = false;
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
setState(() {
_isLoading = false;
});

Comment on lines 213 to 215
/// Created a simplified version of _PriceProofImage if needed for transition
class PriceProofImage extends StatelessWidget {
const PriceProofImage(
Copy link
Contributor

Choose a reason for hiding this comment

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

Just trying to understand: you're creating dead code, and you want it to be public instead of private, right?

}

/// Widget to display a grid of proofs with price count badges
class ProofGridItem extends StatefulWidget {
Copy link
Contributor

Choose a reason for hiding this comment

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

I may be old-fashioned but what is that code doing here in an unrelated file?

Assuming that this code is useful, it should be either in a specific file OR in a place where it makes sense, for instance where it's used, that is prices_proofs_page.dart, where there is a grid.


Future<void> _loadPrices() async {
if (PriceModel.isProofNotGoodEnough(widget.proof)) {
setState(() {
Copy link
Contributor

Choose a reason for hiding this comment

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

For the record you're supposed to check if(mounted) before setState in an async code.

Comment on lines 143 to 144
// Used our new ProofGridItem widget
child: ProofGridItem(
Copy link
Contributor

Choose a reason for hiding this comment

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

Just put your change into the existing code, in that case in _PriceProofImage.

Comment on lines 174 to 177
setState(() {
_existingPrices = prices.value.items ?? <Price>[];
_isLoading = false;
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
setState(() {
_existingPrices = prices.value.items ?? <Price>[];
_isLoading = false;
});
_existingPrices = prices.value.items ?? <Price>[];
if (mounted) {
setState(() {});
}

@asim-sahoo
Copy link
Author

@monsieurtanuki I’ve made all the requested changes. Since this is my first PR and I’m still learning, I might have made a few mistakes. I’d really appreciate your review. Thanks!

@asim-sahoo
Copy link
Author

asim-sahoo commented Mar 30, 2025

Hi @asim-sahoo! Some things to change in your code, as you can read in my comments. And probably more, later. Btw in your screenshots you don't show proofs but product images. I hope you didn't pollute the PROD server with irrelevant pictures - you tested prices on DEV/TEST, right?

Could you clarify this for me? I ran the app using Flutter and created an account to test the feature. Is there anything else I need to do to ensure the testing was done correctly?
Also in the screenshots I have shown that the Prices count badges which are needed according to the issue have been added.

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.

@asim-sahoo Generally speaking, in this PR you're not asked to be inventive, you're asked to be lazy:

  • just add a Badge on top of proof images in both proof grid and proof page cases
  • as this badge is being used in 2 places, it does make sense to make a specific class in a specific file for that

Oh, and please don't push again and again while someone's reviewing your code.

child: _PriceProofImage(proof,
squareSize: squareSize),
},

Copy link
Contributor

Choose a reason for hiding this comment

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

Your code needs to be systematically formatted.
Have a look at Android Studio on how to make it automatic.

.gitignore Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't want to see this file here.
Add some spaces here and here, make it as it used to be, whatever, this file doesn't belong here.

Copy link
Author

Choose a reason for hiding this comment

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

I've reverted all the changes to their original state, but they are still appearing in the changed section. Additionally, I don’t see any differences in the files so I dont know what to do. Could you please advise on how to resolve this?

Copy link
Contributor

Choose a reason for hiding this comment

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

We don't want to see this file here.
Add some spaces here and here, make it as it used to be, whatever, this file doesn't belong here.

Copy link
Author

Choose a reason for hiding this comment

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

I've reverted all the changes to their original state, but they are still appearing in the changed section. Additionally, I don’t see any differences in the files so I dont know what to do. Could you please advise on how to resolve this?

Comment on lines 24 to 25
/// Badge showing the number of prices with a payment icon
class PriceBadge extends StatelessWidget {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please keep it simple and just use a Badge, as already mentioned. And forget about your additional icon.

If you really want to create your own widget - to be used in both proof grid and single proof pages:

  • create a specific file, like proof_badge.dart
  • create a specific widget, like ProofBadge

class _PriceProofImage extends StatefulWidget {
const _PriceProofImage({
required this.proof,
required this.onTap,
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 of changing the parameters?

@monsieurtanuki
Copy link
Contributor

Could you clarify this for me? I ran the app using Flutter and created an account to test the feature. Is there anything else I need to do to ensure the testing was done correctly? Also in the screenshots I have shown that the Prices count badges which are needed according to the issue have been added.

You did add crap data to the prices PROD server. Those are not proof images. Proofs are related to prices, they can be receipts or price tags.
If you want to have more freedom to play, you can go in the app to the "Profile" tab, "Contribute", "Software development", "Activate the dev mode", then go to the "dev mode" and set the servers to TEST instead of PROD.
For your supposed "proofs", now it's too late anyway. That's not dramatic, but generally speaking be careful where you create data, it might be in PROD environment.

@asim-sahoo
Copy link
Author

Could you clarify this for me? I ran the app using Flutter and created an account to test the feature. Is there anything else I need to do to ensure the testing was done correctly? Also in the screenshots I have shown that the Prices count badges which are needed according to the issue have been added.

You did add crap data to the prices PROD server. Those are not proof images. Proofs are related to prices, they can be receipts or price tags. If you want to have more freedom to play, you can go in the app to the "Profile" tab, "Contribute", "Software development", "Activate the dev mode", then go to the "dev mode" and set the servers to TEST instead of PROD. For your supposed "proofs", now it's too late anyway. That's not dramatic, but generally speaking be careful where you create data, it might be in PROD environment.

Apologies for that. I'll make sure to be more cautious in the future. I appreciate the clarification regarding proof images and the importance of distinguishing between PROD and TEST environments. Moving forward, I'll use the TEST server for development and testing to avoid adding unintended data.
Once this issue is resolved, I'll remove my account to ensure that no dummy data remains in the system. Thanks for your patience and guidance!

@asim-sahoo
Copy link
Author

@monsieurtanuki I have made the changes. please review and tell me if further changes is required or not.
image
image

@teolemon
Copy link
Member

Also the build is red because of:
info • Missing type annotation • packages/smooth_app/lib/pages/prices/price_proof_page.dart:82:19 • always_specify_types
warning • Unused import: 'package:auto_size_text/auto_size_text.dart' • packages/smooth_app/lib/pages/prices/prices_proofs_page.dart:1:8 • unused_import
warning • Unused import: 'package:smooth_app/generic_lib/design_constants.dart' • packages/smooth_app/lib/pages/prices/prices_proofs_page.dart:7:8 • unused_import
warning • The left operand can't be null, so the right operand is never executed • packages/smooth_app/lib/pages/prices/prices_proofs_page.dart:207:48 • dead_null_aware_expression

@asim-sahoo
Copy link
Author

Also the build is red because of: info • Missing type annotation • packages/smooth_app/lib/pages/prices/price_proof_page.dart:82:19 • always_specify_types warning • Unused import: 'package:auto_size_text/auto_size_text.dart' • packages/smooth_app/lib/pages/prices/prices_proofs_page.dart:1:8 • unused_import warning • Unused import: 'package:smooth_app/generic_lib/design_constants.dart' • packages/smooth_app/lib/pages/prices/prices_proofs_page.dart:7:8 • unused_import warning • The left operand can't be null, so the right operand is never executed • packages/smooth_app/lib/pages/prices/prices_proofs_page.dart:207:48 • dead_null_aware_expression

fixed

@codecov-commenter
Copy link

codecov-commenter commented Apr 1, 2025

Codecov Report

Attention: Patch coverage is 0% with 30 lines in your changes missing coverage. Please review.

Project coverage is 5.88%. Comparing base (4d9c7fc) to head (6bc0b79).
Report is 823 commits behind head on develop.

Files with missing lines Patch % Lines
.../smooth_app/lib/pages/prices/price_proof_page.dart 0.00% 17 Missing ⚠️
...mooth_app/lib/pages/prices/prices_proofs_page.dart 0.00% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           develop   #6493      +/-   ##
==========================================
- Coverage     9.54%   5.88%   -3.67%     
==========================================
  Files          325     496     +171     
  Lines        16411   29556   +13145     
==========================================
+ Hits          1567    1739     +172     
- Misses       14844   27817   +12973     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@g123k g123k changed the title feat: Added price count badges. feat: Added price count badges Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Status: 💬 To discuss and validate
Development

Successfully merging this pull request may close these issues.

Show price count in more places on proofs
4 participants