From 27259c0b3c271e30fd299d114ac5ff389f78263f Mon Sep 17 00:00:00 2001 From: monsieurtanuki Date: Sun, 2 Jun 2024 15:39:08 +0200 Subject: [PATCH] feat: 5205 - added 4 links to prices app (#5329) --- packages/smooth_app/lib/l10n/app_en.arb | 16 ++++++ packages/smooth_app/lib/l10n/app_fr.arb | 16 ++++++ .../preferences/user_preferences_account.dart | 52 ++++++++++++++----- 3 files changed, 72 insertions(+), 12 deletions(-) diff --git a/packages/smooth_app/lib/l10n/app_en.arb b/packages/smooth_app/lib/l10n/app_en.arb index 9ec768547de0..ab0e30ad5a22 100644 --- a/packages/smooth_app/lib/l10n/app_en.arb +++ b/packages/smooth_app/lib/l10n/app_en.arb @@ -1767,6 +1767,22 @@ "@user_search_prices_title": { "description": "User prices: list tile title" }, + "all_search_prices_latest_title": "Latest Prices added", + "@all_search_prices_latest_title": { + "description": "Latest prices: list tile title" + }, + "all_search_prices_top_user_title": "Top price contributors", + "@all_search_prices_top_user_title": { + "description": "Top price users: list tile title" + }, + "all_search_prices_top_location_title": "Stores with the most prices", + "@all_search_prices_top_location_title": { + "description": "Top price locations: list tile title" + }, + "all_search_prices_top_product_title": "Products with the most prices", + "@all_search_prices_top_product_title": { + "description": "Top price products: list tile title" + }, "all_search_to_be_completed_title": "All to-be-completed products", "@all_search_to_be_completed_title": { "description": "All products to be completed: list tile title" diff --git a/packages/smooth_app/lib/l10n/app_fr.arb b/packages/smooth_app/lib/l10n/app_fr.arb index 44c6bca3428f..70752c87142a 100644 --- a/packages/smooth_app/lib/l10n/app_fr.arb +++ b/packages/smooth_app/lib/l10n/app_fr.arb @@ -1767,6 +1767,22 @@ "@user_search_prices_title": { "description": "User prices: list tile title" }, + "all_search_prices_latest_title": "Derniers prix ajoutés", + "@all_search_prices_latest_title": { + "description": "Latest prices: list tile title" + }, + "all_search_prices_top_user_title": "Top contributeurs", + "@all_search_prices_top_user_title": { + "description": "Top price users: list tile title" + }, + "all_search_prices_top_location_title": "Top lieux", + "@all_search_prices_top_location_title": { + "description": "Top price locations: list tile title" + }, + "all_search_prices_top_product_title": "Top produits", + "@all_search_prices_top_product_title": { + "description": "Top price products: list tile title" + }, "all_search_to_be_completed_title": "Tous les produits à compléter", "@all_search_to_be_completed_title": { "description": "All products to be completed: list tile title" diff --git a/packages/smooth_app/lib/pages/preferences/user_preferences_account.dart b/packages/smooth_app/lib/pages/preferences/user_preferences_account.dart index 8a0062fa664f..487f41664eb9 100644 --- a/packages/smooth_app/lib/pages/preferences/user_preferences_account.dart +++ b/packages/smooth_app/lib/pages/preferences/user_preferences_account.dart @@ -210,21 +210,27 @@ class UserPreferencesAccount extends AbstractUserPreferences { localDatabase: localDatabase, myCount: _getMyCount(UserSearchType.TO_BE_COMPLETED), ), - _getListTile( + _getPriceListTile( appLocalizations.user_search_prices_title, - () async { - final UriProductHelper uriProductHelper = - ProductQuery.uriProductHelper; - final Uri uri = Uri( - scheme: uriProductHelper.scheme, - host: uriProductHelper.getHost('prices'), - path: 'app/dashboard/prices', - ); - return LaunchUrlHelper.launchURL(uri.toString()); - }, - Icons.open_in_new, + 'app/dashboard/prices', myCount: _getMyPricesCount(), ), + _getPriceListTile( + appLocalizations.all_search_prices_latest_title, + 'app/prices', + ), + _getPriceListTile( + appLocalizations.all_search_prices_top_user_title, + 'app/users', + ), + _getPriceListTile( + appLocalizations.all_search_prices_top_location_title, + 'app/locations', + ), + _getPriceListTile( + appLocalizations.all_search_prices_top_product_title, + 'app/products', + ), _buildProductQueryTile( productQuery: PagedToBeCompletedProductQuery(), title: appLocalizations.all_search_to_be_completed_title, @@ -276,6 +282,28 @@ class UserPreferencesAccount extends AbstractUserPreferences { ]; } + UserPreferencesItem _getPriceListTile( + final String title, + final String path, { + final Future? myCount, + }) => + _getListTile( + title, + () async => LaunchUrlHelper.launchURL(_getPriceUrl(path)), + Icons.open_in_new, + myCount: myCount, + ); + + String _getPriceUrl(final String path) { + final UriProductHelper uriProductHelper = ProductQuery.uriProductHelper; + final Uri uri = Uri( + scheme: uriProductHelper.scheme, + host: uriProductHelper.getHost('prices'), + path: path, + ); + return uri.toString(); + } + Future _confirmLogout() async => showDialog( context: context, builder: (BuildContext context) {