Skip to content

feat: Add receipt and price icons to prices screen #6421

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

Closed

Conversation

vinay769
Copy link
Contributor

@vinay769 vinay769 commented Mar 6, 2025

What

  • Added receipt and price icons to the price page to improve visual clarity and user understanding.
  • Change the RadioListTile Widget to Radio widget to show the icon of receipt and price tag

  feat, for Features enhancing User Experience and User Interface

Screenshot

Screenshot 2025-03-07 010736

Part of 

@teolemon
Copy link
Member

teolemon commented Mar 7, 2025

@vinay769 Run dart format --set-exit-if-changed .
Formatted packages/smooth_app/lib/pages/prices/price_proof_card.dart
Formatted 567 files (1 changed) in 1.88 seconds.
Error: Process completed with exit code 1.

@vinay769
Copy link
Contributor Author

vinay769 commented Mar 8, 2025

hello @teolemon Ran dart format command and can you please review thanks

Copy link
Member

@AshAman999 AshAman999 left a comment

Choose a reason for hiding this comment

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

Hey @vinay769

Left some comments

@codecov-commenter
Copy link

codecov-commenter commented Mar 10, 2025

Codecov Report

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

Project coverage is 5.84%. Comparing base (4d9c7fc) to head (b5ef09c).
Report is 800 commits behind head on develop.

Files with missing lines Patch % Lines
.../smooth_app/lib/pages/prices/price_proof_card.dart 0.00% 16 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           develop   #6421      +/-   ##
==========================================
- Coverage     9.54%   5.84%   -3.71%     
==========================================
  Files          325     490     +165     
  Lines        16411   29259   +12848     
==========================================
+ Hits          1567    1711     +144     
- Misses       14844   27548   +12704     

☔ 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.

@vinay769
Copy link
Contributor Author

vinay769 commented Mar 10, 2025

done with this thanks to @AshAman999 @teolemon please take a look

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 @vinay769!

There are conflicts to be fixed, because of recent changes in the master branch.
You should add your IconData in ProofTypeExtension.

I'm very worried about the UI.
You're lucky because your screenshots are in English, with small words.
Would you please try with different longer labels? I suggest "Ticket de caisse" and "Etiquette de prix".

@vinay769
Copy link
Contributor Author

Okay thanks for you valuable feedback @monsieurtanuki i was working on this and get back to you ASAP with great solution

@vinay769
Copy link
Contributor Author

hello @monsieurtanuki @teolemon
Screenshot_20250315_235626
Screenshot_20250315_235335

  1. is it okay to put icon after text
  2. is i have a permission to change the font size to fit the text in one line

if both the above answer is yes then the UI is ready to merge
please help me with this
thank you

@monsieurtanuki
Copy link
Contributor

Hi @vinay769!
I'm not a big fan of the UI.
Would you try with 2 rows of radio buttons, instead of 2 columns? Please post the screenshots.

@vinay769
Copy link
Contributor Author

hello @monsieurtanuki
Screenshot_20250316_125220
Screenshot_20250316_125141

Would you kindly review the following code and provide feedback for optimization?

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 @vinay769!
Please have a look at my comments.

Would you try with 2 rows of radio buttons, instead of 2 columns? Please post the screenshots.

In case my demand is not explicit enough given the polysemous concepts of rows and columns (especially in flutter), let me draw what I intended.
* Column 1 | * Column 2
and
* Row 1 _______________
* Row 2 _______________

child: RadioListTile<ProofType>(
title: Text(item.getTitle(appLocalizations)),
value: item,
children: <Widget>[
Copy link
Contributor

Choose a reason for hiding this comment

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

You've rolled back the previous code.
Please stick to the previous code unless you have a good reason. Duplicating code is not a good reason.

final BuildContext context, {
required final List<_ProofSource> sources,
}) async {
static Future<_ProofSource?> select(final BuildContext context) async {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please stick to the previous code (especially as you've removed bug fixes).
Besides, _ProofSource has nothing to do with the current PR, therefore I wouldn't expect reviewing that code.
Unless there's a good reason.

@g123k
Copy link
Collaborator

g123k commented Mar 17, 2025

Hello @vinay769,

You can use the following layout:
iPhone 14 Pro Max Copy

  • The toggle is now on top of the screen
  • For the custom icons, I will add them later (or edit your PR)

This component will be used elsewhere in the app, so don't hesitate to make it generic.
It doesn't necessarily rely on an existing Widget in the Material and Cupertino libs.

@vinay769
Copy link
Contributor Author

Hello @vinay769,

You can use the following layout:
iPhone 14 Pro Max Copy

  • The toggle is now on top of the screen
  • For the custom icons, I will add them later (or edit your PR)

This component will be used elsewhere in the app, so don't hesitate to make it generic.
It doesn't necessarily rely on an existing Widget in the Material and Cupertino libs.

Thanks @g123k for this.

@g123k
Copy link
Collaborator

g123k commented Apr 14, 2025

Any update on this?
If you can't work on this PR, please let us know.

@vinay769
Copy link
Contributor Author

Hello @g123k,
I am currently not working on this issue. Please feel free to assign it to someone else who is interested in resolving it.
Thank you!

@g123k g123k marked this pull request as draft April 17, 2025 05:55
@teolemon teolemon requested a review from Copilot May 16, 2025 19:37
@teolemon
Copy link
Member

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully adds icons to the price page for ProofType.receipt and ProofType.priceTag, enhancing visual clarity as intended. The change from RadioListTile to Radio widgets facilitates this.

However, there are critical concerns regarding file deletions:

  1. pubspec.lock Deletion: This file is essential for reproducible builds as it locks dependency versions. Deleting it can lead to inconsistent builds and unexpected behavior. This file must be restored to its state before this PR's changes, or regenerated correctly if dependencies were intentionally updated (though no such changes are evident in pubspec.yaml in this PR).
  2. GeneratedPluginRegistrant.swift Deletion: This file is typically auto-generated and crucial for macOS plugin registration. Its deletion might break macOS builds or functionality if macOS support is intended. Please clarify if this deletion was intentional and provide context, or restore the file.

Additionally, there are a few areas with potential unintended behavioral changes and opportunities for code improvement, detailed in the specific comments. Due to the critical file deletions and potential behavioral changes, I recommend addressing these issues before merging.

Summary of Findings

  • Critical File Deletion: pubspec.lock: The pubspec.lock file has been deleted. This file is crucial for reproducible builds and should be restored or correctly regenerated.
  • Critical File Deletion: GeneratedPluginRegistrant.swift: The GeneratedPluginRegistrant.swift file for macOS has been deleted. This could break macOS builds/functionality and needs clarification or restoration.
  • Potential Behavioral Change: forcedProofType: The forcedProofType condition is no longer used to disable the onChanged callback for proof type radio buttons in price_proof_card.dart. This might be an unintended behavioral change if forcedProofType was meant to make the selection read-only. (Commented)
  • Code Duplication in UI: The UI for ProofType.receipt and ProofType.priceTag radio options in price_proof_card.dart is duplicated. Refactoring into a helper method is recommended. (Commented)
  • Potential Behavioral Change: includeMyProofs: The _ProofSource.select method in price_proof_card.dart now seems to always include the 'history' option, whereas previously this was conditional based on includeMyProofs. This could be an intended simplification or an oversight. (Commented)
  • TODOs in ProofTypeExtension.getIcon(): The new getIcon() method in proof_type_extensions.dart has TODO comments and throws UnimplementedError for ProofType.gdprRequest and ProofType.shopImport. While this might be acceptable if these types are not currently used in this UI context, it's good to plan for their handling if they might appear. (Not commented due to severity settings)

Merge Readiness

This pull request should not be merged in its current state due to the critical deletion of pubspec.lock and GeneratedPluginRegistrant.swift. These file changes need immediate attention and likely reversal or justification.

Additionally, there are potential behavioral changes related to forcedProofType and includeMyProofs that need clarification to ensure no regressions are introduced. The identified code duplication should also be addressed for better maintainability.

Once these critical and high-priority issues are resolved, the PR will be in a much better state for merging. I am unable to approve pull requests, but I recommend further review after these changes are made.

Comment on lines +108 to +111
onChanged: model.proof != null
? null
: (final ProofType? proofType) =>
model.proofType = proofType!,

Choose a reason for hiding this comment

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

high

It appears the forcedProofType condition is no longer used to disable the onChanged callback for the radio buttons. Previously, if forcedProofType != null, the RadioListTile was disabled. Now, the Radio widget's onChanged is only disabled if model.proof != null.

Was it intentional to remove the disabling effect of forcedProofType? If forcedProofType is meant to make the proof type selection non-editable, this change could introduce a regression.

Comment on lines +100 to +147
children: <Widget>[
SizedBox(
width: constraints.maxWidth / 2,
child: Row(
children: [
Radio<ProofType>(
value: ProofType.receipt,
groupValue: model.proofType,
onChanged:
model.proof != null || forcedProofType != null
? null
: (final ProofType? proofType) =>
model.proofType = proofType!,
onChanged: model.proof != null
? null
: (final ProofType? proofType) =>
model.proofType = proofType!,
),
),
)
.toList(),
Icon(ProofType.receipt.getIcon()),
const SizedBox(width: 8),
Expanded(
child: Text(
appLocalizations.prices_proof_receipt,
maxLines: 2,
),
),
],
),
),
SizedBox(
width: constraints.maxWidth / 2,
child: Row(
children: [
Radio<ProofType>(
value: ProofType.priceTag,
groupValue: model.proofType,
onChanged: model.proof != null
? null
: (final ProofType? proofType) =>
model.proofType = proofType!,
),
Icon(ProofType.priceTag.getIcon()),
const SizedBox(width: 8),
Expanded(
child: Text(
appLocalizations.prices_proof_price_tag,
maxLines: 2,
),
),
],
),
),
],

Choose a reason for hiding this comment

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

medium

The UI structure for displaying the ProofType.receipt radio option (lines 101-123) and the ProofType.priceTag radio option (lines 124-146) is nearly identical. This introduces code duplication.

Could we consider refactoring this into a reusable widget or a helper method? For example, a method like Widget _buildProofTypeRadioOption(BuildContext context, ProofType proofType, BoxConstraints constraints, PriceModel model) could encapsulate the common logic, making the code more concise and maintainable.

Comment on lines +86 to +87
final _ProofSource? proofSource =
await _ProofSource.select(context);

Choose a reason for hiding this comment

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

medium

The logic for selecting a _ProofSource has been simplified. Previously, _ProofSource.getPossibleProofSources (which accepted an includeMyProofs parameter) was used to determine the available sources. This method has been removed (Diff 4), and _ProofSource.select now seems to always include _ProofSource.history as an option.

If includeMyProofs was previously false in some scenarios, this would mean the 'history' option wasn't available. Is it intended for the 'history' option to always be present now, regardless of the context where includeMyProofs might have been used?

@github-project-automation github-project-automation bot moved this from Backlog to Ready in 💸 Open Prices May 16, 2025
@github-project-automation github-project-automation bot moved this from 💬 To discuss and validate to 🏗️ In Progress in 🤳🥫 The Open Food Facts mobile app (Android & iOS) May 16, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the prices screen by adding distinct receipt and price-tag icons and refactors the proof-type selection UI.

  • Introduces a getIcon() extension for ProofType to provide corresponding icons
  • Replaces RadioListTile with a custom Radio + Icon + Text layout
  • Simplifies the proof-source selection modal by removing the includeMyProofs parameter

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
packages/smooth_app/macos/Flutter/GeneratedPluginRegistrant.swift Deleted auto-generated plugin registrant (likely unintended)
packages/smooth_app/lib/pages/prices/proof_type_extensions.dart Imported Material and added getIcon() extension for ProofType
packages/smooth_app/lib/pages/prices/price_proof_card.dart Updated UI to use Radio widgets with icons and simplified selection logic
Comments suppressed due to low confidence (2)

packages/smooth_app/macos/Flutter/GeneratedPluginRegistrant.swift:1

  • Removing the entire GeneratedPluginRegistrant.swift may break macOS plugin registration, as this file is auto-generated and should not be manually deleted.
 -//

packages/smooth_app/lib/pages/prices/price_proof_card.dart:87

  • The selection now always shows all proof sources and ignores the original includeMyProofs flag, altering intended behavior when includeMyProofs is false.
                      final _ProofSource? proofSource = await _ProofSource.select(context);

Comment on lines +19 to +22
// TODO: Handle this case.
ProofType.gdprRequest => throw UnimplementedError(),
// TODO: Handle this case.
ProofType.shopImport => throw UnimplementedError(),
Copy link
Preview

Copilot AI May 16, 2025

Choose a reason for hiding this comment

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

[nitpick] The getIcon() method throws UnimplementedError for gdprRequest and shopImport, potentially causing runtime crashes. Consider handling or documenting these cases.

Suggested change
// TODO: Handle this case.
ProofType.gdprRequest => throw UnimplementedError(),
// TODO: Handle this case.
ProofType.shopImport => throw UnimplementedError(),
ProofType.gdprRequest => Icons.privacy_tip, // Placeholder icon for GDPR Request
ProofType.shopImport => Icons.store, // Placeholder icon for Shop Import

Copilot uses AI. Check for mistakes.

addEndArrowToItems: true,
values: sources,
values: <_ProofSource>[
_ProofSource.camera,
Copy link
Preview

Copilot AI May 16, 2025

Choose a reason for hiding this comment

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

The values list always includes camera, but the labels and prefixIcons lists conditionally omit it when hasCamera is false, causing misalignment between labels, icons, and values.

Suggested change
_ProofSource.camera,
if (hasCamera) _ProofSource.camera,

Copilot uses AI. Check for mistakes.

Comment on lines +103 to +144
child: Row(
children: [
Radio<ProofType>(
value: ProofType.receipt,
groupValue: model.proofType,
onChanged:
model.proof != null || forcedProofType != null
? null
: (final ProofType? proofType) =>
model.proofType = proofType!,
onChanged: model.proof != null
? null
: (final ProofType? proofType) =>
model.proofType = proofType!,
),
),
)
.toList(),
Icon(ProofType.receipt.getIcon()),
const SizedBox(width: 8),
Expanded(
child: Text(
appLocalizations.prices_proof_receipt,
maxLines: 2,
),
),
],
),
),
SizedBox(
width: constraints.maxWidth / 2,
child: Row(
children: [
Radio<ProofType>(
value: ProofType.priceTag,
groupValue: model.proofType,
onChanged: model.proof != null
? null
: (final ProofType? proofType) =>
model.proofType = proofType!,
),
Icon(ProofType.priceTag.getIcon()),
const SizedBox(width: 8),
Expanded(
child: Text(
appLocalizations.prices_proof_price_tag,
maxLines: 2,
),
),
],
Copy link
Preview

Copilot AI May 16, 2025

Choose a reason for hiding this comment

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

[nitpick] The layout for Receipt and PriceTag is duplicated. Consider abstracting common logic (e.g., iterating over a list of types) to reduce repetition and ease future updates.

Copilot uses AI. Check for mistakes.

@g123k
Copy link
Collaborator

g123k commented Jun 9, 2025

There is no activity on this PR.
Also, we will revamp this screen, so I close this issue.

Thanks for this contribution @vinay769

@g123k g123k closed this Jun 9, 2025
@github-project-automation github-project-automation bot moved this from Ready to Done in 💸 Open Prices Jun 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Add receipt and price tag icons
6 participants