-
-
Notifications
You must be signed in to change notification settings - Fork 368
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
Draft
vinay769
wants to merge
11
commits into
openfoodfacts:develop
Choose a base branch
from
vinay769:feature/receipt-price-icons-ui
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
eedb630
feat: Add receipt and price icons to prices screen
vinay769 db1f5ec
Merge branch 'develop' into feature/receipt-price-icons-ui
vinay769 9df5045
style: Format code to pass CI/CD formatting check
vinay769 9804cd2
style: Format code to pass CI/CD formatting check
vinay769 3caf9ef
style: Format code to pass CI/CD formatting check
vinay769 b5ef09c
chore: Remove comments, revert pubspec.lock, GeneratedPluginRegistran…
vinay769 390257b
Merge origin/develop: Integrate latest develop changes
vinay769 5fa1dc4
updating the price_proof_card
vinay769 fb61397
feat: Add receipt and price tag icons, support long labels
vinay769 26fe393
removed packages/smooth_app/pubspec.lock
vinay769 8706ee5
removed packages/smooth_app/macos/Flutter/GeneratedPluginRegistrant.s…
vinay769 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,30 +74,17 @@ class PriceProofCard extends StatelessWidget { | |
child: SmoothLargeButtonWithIcon( | ||
text: !model.hasImage | ||
? appLocalizations.prices_proof_find | ||
: model.proofType.getTitle(appLocalizations), | ||
: model.proofType == ProofType.receipt | ||
? appLocalizations.prices_proof_receipt | ||
: appLocalizations.prices_proof_price_tag, | ||
leadingIcon: !model.hasImage | ||
? const Icon(_iconTodo) | ||
: const Icon(_iconDone), | ||
onPressed: model.proof != null | ||
? null | ||
: () async { | ||
final List<_ProofSource> sources = | ||
_ProofSource.getPossibleProofSources( | ||
includeMyProofs: includeMyProofs, | ||
); | ||
// not very likely | ||
if (sources.isEmpty) { | ||
return; | ||
} | ||
final _ProofSource? proofSource; | ||
if (sources.length == 1) { | ||
proofSource = sources.first; | ||
} else { | ||
proofSource = await _ProofSource.select( | ||
context, | ||
sources: sources, | ||
); | ||
} | ||
final _ProofSource? proofSource = | ||
await _ProofSource.select(context); | ||
if (proofSource == null) { | ||
return; | ||
} | ||
|
@@ -110,26 +97,54 @@ class PriceProofCard extends StatelessWidget { | |
), | ||
LayoutBuilder( | ||
builder: (BuildContext context, BoxConstraints constraints) => Row( | ||
children: (const <ProofType>[ | ||
ProofType.receipt, | ||
ProofType.priceTag, | ||
]) | ||
.map<Widget>( | ||
(final ProofType item) => SizedBox( | ||
width: constraints.maxWidth / 2, | ||
child: RadioListTile<ProofType>( | ||
title: Text(item.getTitle(appLocalizations)), | ||
value: item, | ||
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, | ||
), | ||
), | ||
], | ||
), | ||
), | ||
], | ||
), | ||
), | ||
], | ||
|
@@ -143,18 +158,6 @@ enum _ProofSource { | |
gallery, | ||
history; | ||
|
||
String getTitle(final AppLocalizations appLocalizations) => switch (this) { | ||
_ProofSource.camera => appLocalizations.settings_app_camera, | ||
_ProofSource.gallery => appLocalizations.gallery_source_label, | ||
_ProofSource.history => appLocalizations.user_search_proofs_title, | ||
}; | ||
|
||
IconData getIconData() => switch (this) { | ||
_ProofSource.camera => Icons.camera_rounded, | ||
_ProofSource.gallery => Icons.perm_media_rounded, | ||
_ProofSource.history => Icons.document_scanner_rounded, | ||
}; | ||
|
||
Future<void> process( | ||
final BuildContext context, | ||
final PriceModel model, | ||
|
@@ -189,40 +192,29 @@ enum _ProofSource { | |
} | ||
} | ||
|
||
static List<_ProofSource> getPossibleProofSources({ | ||
required final bool includeMyProofs, | ||
}) { | ||
final List<_ProofSource> result = <_ProofSource>[]; | ||
final bool hasCamera = CameraHelper.hasACamera; | ||
if (hasCamera) { | ||
result.add(_ProofSource.camera); | ||
} | ||
result.add(_ProofSource.gallery); | ||
if (includeMyProofs) { | ||
result.add(_ProofSource.history); | ||
} | ||
return result; | ||
} | ||
|
||
static Future<_ProofSource?> select( | ||
final BuildContext context, { | ||
required final List<_ProofSource> sources, | ||
}) async { | ||
static Future<_ProofSource?> select(final BuildContext context) async { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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). |
||
final AppLocalizations appLocalizations = AppLocalizations.of(context); | ||
final bool hasCamera = CameraHelper.hasACamera; | ||
|
||
return showSmoothListOfChoicesModalSheet<_ProofSource>( | ||
context: context, | ||
title: appLocalizations.prices_proof_find, | ||
labels: sources.map<String>( | ||
(_ProofSource source) => source.getTitle(appLocalizations), | ||
), | ||
prefixIcons: sources | ||
.map<Widget>( | ||
(_ProofSource source) => Icon(source.getIconData()), | ||
) | ||
.toList(), | ||
labels: <String>[ | ||
if (hasCamera) appLocalizations.settings_app_camera, | ||
appLocalizations.gallery_source_label, | ||
appLocalizations.user_search_proofs_title, | ||
], | ||
prefixIcons: <Widget>[ | ||
if (hasCamera) const Icon(Icons.camera_rounded), | ||
const Icon(Icons.perm_media_rounded), | ||
const Icon(Icons.document_scanner_rounded), | ||
], | ||
addEndArrowToItems: true, | ||
values: sources, | ||
values: <_ProofSource>[ | ||
_ProofSource.camera, | ||
_ProofSource.gallery, | ||
_ProofSource.history, | ||
], | ||
); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 0 additions & 44 deletions
44
packages/smooth_app/macos/Flutter/GeneratedPluginRegistrant.swift
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.