-
-
Notifications
You must be signed in to change notification settings - Fork 404
feat: Added Dashboard to price section #6559
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
base: develop
Are you sure you want to change the base?
Changes from 5 commits
d6e3872
f3938c8
829a90c
78ded75
e85730c
a886a02
4172b71
10698dd
9e7773b
dbd0c59
4e366ca
5c67691
ef43820
6eea995
933bda2
53e31fc
efed84a
7075c4d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| // TODO(chetanr25): To be implemented in OpenFoodFacts flutter package in [https://github.com/openfoodfacts/smooth-app/tree/develop/packages/smooth_app/lib/data_models] as [UserProfile] JsonSerializable | ||
|
||
| class UserProfile { | ||
| UserProfile({ | ||
| required this.userId, | ||
| required this.priceCount, | ||
| required this.priceTypeProductCount, | ||
| required this.priceTypeCategoryCount, | ||
| required this.priceKindCommunityCount, | ||
| required this.priceKindConsumptionCount, | ||
| required this.priceCurrencyCount, | ||
| required this.priceInProofOwnedCount, | ||
| required this.priceInProofNotOwnedCount, | ||
| required this.priceNotOwnedInProofOwnedCount, | ||
| required this.proofCount, | ||
| required this.proofKindCommunityCount, | ||
| required this.proofKindConsumptionCount, | ||
| required this.locationCount, | ||
| required this.locationTypeOsmCountryCount, | ||
| required this.productCount, | ||
| }); | ||
|
|
||
| factory UserProfile.fromJson(Map<String, dynamic> json) { | ||
| return UserProfile( | ||
| userId: json['user_id'] as String, | ||
| priceCount: json['price_count'] as int, | ||
| priceTypeProductCount: json['price_type_product_count'] as int, | ||
| priceTypeCategoryCount: json['price_type_category_count'] as int, | ||
| priceKindCommunityCount: json['price_kind_community_count'] as int, | ||
| priceKindConsumptionCount: json['price_kind_consumption_count'] as int, | ||
| priceCurrencyCount: json['price_currency_count'] as int, | ||
| priceInProofOwnedCount: json['price_in_proof_owned_count'] as int, | ||
| priceInProofNotOwnedCount: json['price_in_proof_not_owned_count'] as int, | ||
| priceNotOwnedInProofOwnedCount: | ||
| json['price_not_owned_in_proof_owned_count'] as int, | ||
| proofCount: json['proof_count'] as int, | ||
| proofKindCommunityCount: json['proof_kind_community_count'] as int, | ||
| proofKindConsumptionCount: json['proof_kind_consumption_count'] as int, | ||
| locationCount: json['location_count'] as int, | ||
| locationTypeOsmCountryCount: | ||
| json['location_type_osm_country_count'] as int, | ||
| productCount: json['product_count'] as int, | ||
| ); | ||
| } | ||
| final String userId; | ||
| final int priceCount; | ||
| final int priceTypeProductCount; | ||
| final int priceTypeCategoryCount; | ||
| final int priceKindCommunityCount; | ||
| final int priceKindConsumptionCount; | ||
| final int priceCurrencyCount; | ||
| final int priceInProofOwnedCount; | ||
| final int priceInProofNotOwnedCount; | ||
| final int priceNotOwnedInProofOwnedCount; | ||
| final int proofCount; | ||
| final int proofKindCommunityCount; | ||
| final int proofKindConsumptionCount; | ||
| final int locationCount; | ||
| final int locationTypeOsmCountryCount; | ||
| final int productCount; | ||
|
|
||
| Map<String, dynamic> toJson() { | ||
| return <String, dynamic>{ | ||
| 'user_id': userId, | ||
| 'price_count': priceCount, | ||
| 'price_type_product_count': priceTypeProductCount, | ||
| 'price_type_category_count': priceTypeCategoryCount, | ||
| 'price_kind_community_count': priceKindCommunityCount, | ||
| 'price_kind_consumption_count': priceKindConsumptionCount, | ||
| 'price_currency_count': priceCurrencyCount, | ||
| 'price_in_proof_owned_count': priceInProofOwnedCount, | ||
| 'price_in_proof_not_owned_count': priceInProofNotOwnedCount, | ||
| 'price_not_owned_in_proof_owned_count': priceNotOwnedInProofOwnedCount, | ||
| 'proof_count': proofCount, | ||
| 'proof_kind_community_count': proofKindCommunityCount, | ||
| 'proof_kind_consumption_count': proofKindConsumptionCount, | ||
| 'location_count': locationCount, | ||
| 'location_type_osm_country_count': locationTypeOsmCountryCount, | ||
| 'product_count': productCount, | ||
| }; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ import 'package:smooth_app/pages/preferences/user_preferences_page.dart'; | |
| import 'package:smooth_app/pages/prices/get_prices_model.dart'; | ||
| import 'package:smooth_app/pages/prices/price_button.dart'; | ||
| import 'package:smooth_app/pages/prices/price_user_button.dart'; | ||
| import 'package:smooth_app/pages/prices/prices_dashboard.dart'; | ||
| import 'package:smooth_app/pages/prices/prices_locations_page.dart'; | ||
| import 'package:smooth_app/pages/prices/prices_page.dart'; | ||
| import 'package:smooth_app/pages/prices/prices_products_page.dart'; | ||
|
|
@@ -46,6 +47,15 @@ class UserPreferencesPrices extends AbstractUserPreferences { | |
| final String userId = ProductQuery.getWriteUser().userId; | ||
| final bool isConnected = OpenFoodAPIConfiguration.globalUser != null; | ||
| return <UserPreferencesItem>[ | ||
| if (isConnected) | ||
| _getListTile( | ||
| 'My Dashboard', | ||
|
||
| () => Navigator.of(context).push( | ||
| MaterialPageRoute<void>( | ||
| builder: (BuildContext context) => PricesDashboard(), | ||
| ), | ||
| ), | ||
| Icons.dashboard), | ||
| if (isConnected) | ||
| _getListTile( | ||
| PriceUserButton.showUserTitle( | ||
|
|
||
|
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,78 @@ | ||||||
| import 'package:flutter/material.dart'; | ||||||
| import 'package:http/http.dart' as http; | ||||||
| import 'package:openfoodfacts/openfoodfacts.dart'; | ||||||
| import 'package:smooth_app/data_models/users_profile_data.dart'; | ||||||
| import 'package:smooth_app/helpers/launch_url_helper.dart'; | ||||||
| import 'package:smooth_app/pages/prices/prices_dashboard_widget.dart'; | ||||||
| import 'package:smooth_app/pages/prices/prices_user_profile.dart'; | ||||||
| import 'package:smooth_app/query/product_query.dart'; | ||||||
| import 'package:smooth_app/widgets/smooth_app_bar.dart'; | ||||||
| import 'package:smooth_app/widgets/smooth_scaffold.dart'; | ||||||
|
|
||||||
| class PricesDashboard extends StatelessWidget { | ||||||
| PricesDashboard({super.key}); | ||||||
|
||||||
| PricesDashboard({super.key}); | |
| PricesDashboard(); |
Outdated
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.
Localize
Outdated
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.
Localize
Outdated
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.
Should check snapshot.connectionState != ConnectionState.done
Outdated
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.
Outdated
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.
Is now implemented in openfoodfacts-dart.
Outdated
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.
No, not PROD, use ProductQuery.uriPricesHelper.
Outdated
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.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,201 @@ | ||||||||||||||||||||||
| import 'package:flutter/material.dart'; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | ||||||||||||||||||||||
| import 'package:openfoodfacts/openfoodfacts.dart'; | ||||||||||||||||||||||
| import 'package:smooth_app/data_models/users_profile_data.dart'; | ||||||||||||||||||||||
| import 'package:smooth_app/generic_lib/design_constants.dart'; | ||||||||||||||||||||||
| import 'package:smooth_app/generic_lib/widgets/smooth_card.dart'; | ||||||||||||||||||||||
| import 'package:smooth_app/pages/prices/get_prices_model.dart'; | ||||||||||||||||||||||
| import 'package:smooth_app/pages/prices/price_user_button.dart'; | ||||||||||||||||||||||
| import 'package:smooth_app/pages/prices/prices_proofs_page.dart'; | ||||||||||||||||||||||
| import 'package:smooth_app/pages/prices/product_prices_list.dart'; | ||||||||||||||||||||||
| import 'package:smooth_app/query/product_query.dart'; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| class PricesDashboardWidget extends StatefulWidget { | ||||||||||||||||||||||
| const PricesDashboardWidget({super.key, required this.userProfile}); | ||||||||||||||||||||||
| final UserProfile? userProfile; | ||||||||||||||||||||||
|
||||||||||||||||||||||
| final UserProfile? userProfile; | |
| final UserProfile userProfile; |
Outdated
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.
Would be faster to make it a String directly.
Outdated
Copilot
AI
May 16, 2025
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.
The Column widget does not have a 'spacing' property. Replace it with SizedBox widgets or use a widget that supports spacing.
| spacing: MEDIUM_SPACE, | |
| children: <Widget>[ | |
| categorySwitch(), | |
| const SizedBox(height: SMALL_SPACE), | |
| priceProofButton(widget.userProfile!, appLocalizations), | |
| children: <Widget>[ | |
| categorySwitch(), | |
| const SizedBox(height: MEDIUM_SPACE), | |
| priceProofButton(widget.userProfile!, appLocalizations), | |
| const SizedBox(height: MEDIUM_SPACE), |
Outdated
Copilot
AI
May 16, 2025
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.
The FutureBuilder is instantiating a new future every build call rather than using the stored 'pricesFuture'. Replace it with 'pricesFuture' to avoid unnecessary re-fetching.
| future: _getUserPrices(), | |
| future: pricesFuture, |
Outdated
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.
| Widget categorySwitch() { | |
| Widget _categorySwitch() { |
Outdated
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.
Localize.
Outdated
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.
| Widget priceProofButton( | |
| Widget _priceProofButton( |
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.
Irrelevant now as you know well: we should use
PriceUserfrom the latest openfoodfacts-dart package.