From be819cb1850c5519e2792867a8b7a57216925b80 Mon Sep 17 00:00:00 2001 From: Pierre Slamich Date: Wed, 14 Aug 2024 22:23:28 +0200 Subject: [PATCH 1/3] docs: Update README.md (#5542) --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d8a99c424d2..957dda4b4c4 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,8 @@ ## Features +Full list of features on the wiki: https://wiki.openfoodfacts.org/Mobile_App/Features + - a scan that truly matches who you are (Green: the product matches your criteria, Red: there is a problem, Gray: Help us answer you by photographing the products) - a product page that's knowledgeable, building on the vast amount of food facts we collect collaboratively, and other sources of knowledge, to help you make better food decisions From e7154a66dc69e4fb7ce222f01ad26681950d503d Mon Sep 17 00:00:00 2001 From: monsieurtanuki Date: Fri, 16 Aug 2024 11:42:45 +0200 Subject: [PATCH 2/3] feat: 5400 - flagging stores as favorite (#5533) New file: * `favorite_location_helper.dart`: Helper used to set/unset/sort stores as user favorites. Impacted files: * `dao_string_list.dart`: added a key for favorite price stores * `search_location_preloaded_item.dart`: added a "favorite" `IconButton` for price locations --- .../lib/database/dao_string_list.dart | 3 ++ .../locations/favorite_location_helper.dart | 48 +++++++++++++++++++ .../search_location_preloaded_item.dart | 14 ++++++ 3 files changed, 65 insertions(+) create mode 100644 packages/smooth_app/lib/pages/locations/favorite_location_helper.dart diff --git a/packages/smooth_app/lib/database/dao_string_list.dart b/packages/smooth_app/lib/database/dao_string_list.dart index ff42487464f..57be9377a3f 100644 --- a/packages/smooth_app/lib/database/dao_string_list.dart +++ b/packages/smooth_app/lib/database/dao_string_list.dart @@ -20,6 +20,9 @@ class DaoStringList extends AbstractDao { /// Key for the list of latest languages used in the app. static const String keyLanguages = 'languages'; + /// Key for the list of favorite stores (for price additions). + static const String keyPriceStores = 'priceStores'; + /// Max lengths of each key (null means no limit). static const Map _maxLengths = { keySearchProductHistory: 10, diff --git a/packages/smooth_app/lib/pages/locations/favorite_location_helper.dart b/packages/smooth_app/lib/pages/locations/favorite_location_helper.dart new file mode 100644 index 00000000000..6ba2dc09fae --- /dev/null +++ b/packages/smooth_app/lib/pages/locations/favorite_location_helper.dart @@ -0,0 +1,48 @@ +import 'package:smooth_app/database/dao_string_list.dart'; +import 'package:smooth_app/database/local_database.dart'; +import 'package:smooth_app/pages/locations/osm_location.dart'; + +/// Helper used to set/unset/sort stores as user favorites. +class FavoriteLocationHelper { + static const String _key = DaoStringList.keyPriceStores; + + /// Sets a store as a favorite store (or not, depending on [isFavorite]). + Future setFavorite( + final LocalDatabase localDatabase, + final OsmLocation location, + final bool isFavorite, + ) async { + final DaoStringList daoStringList = DaoStringList(localDatabase); + final String locationKey = _locationToString(location); + await daoStringList.remove(_key, locationKey); + if (isFavorite) { + await daoStringList.add(_key, locationKey); + } + } + + /// Returns true if a store was flagged as favorite. + bool isFavorite( + final LocalDatabase localDatabase, + final OsmLocation location, + ) { + final DaoStringList daoStringList = DaoStringList(localDatabase); + final List favorites = daoStringList.getAll(_key); + return _isFavorite(favorites, location); + } + + /// Returns true if a store was flagged as favorite, from stored keys. + bool _isFavorite( + final List favorites, + final OsmLocation location, + ) { + for (final String favorite in favorites) { + if (favorite == _locationToString(location)) { + return true; + } + } + return false; + } + + String _locationToString(final OsmLocation location) => + '${location.osmType}-${location.osmId}'; +} diff --git a/packages/smooth_app/lib/pages/locations/search_location_preloaded_item.dart b/packages/smooth_app/lib/pages/locations/search_location_preloaded_item.dart index a616b1dd51e..5f231769aaa 100644 --- a/packages/smooth_app/lib/pages/locations/search_location_preloaded_item.dart +++ b/packages/smooth_app/lib/pages/locations/search_location_preloaded_item.dart @@ -4,6 +4,7 @@ import 'package:smooth_app/database/dao_osm_location.dart'; import 'package:smooth_app/database/local_database.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/locations/favorite_location_helper.dart'; import 'package:smooth_app/pages/locations/location_map_page.dart'; import 'package:smooth_app/pages/locations/osm_location.dart'; import 'package:smooth_app/pages/product/common/search_preloaded_item.dart'; @@ -20,10 +21,23 @@ class SearchLocationPreloadedItem extends SearchPreloadedItem { final BuildContext context, { final VoidCallback? onDismissItem, }) { + final LocalDatabase localDatabase = context.read(); + final bool isFavorite = FavoriteLocationHelper().isFavorite( + localDatabase, + osmLocation, + ); final String? title = osmLocation.getTitle(); final String? subtitle = osmLocation.getSubtitle(); final Widget child = SmoothCard( child: ListTile( + leading: IconButton( + icon: Icon(isFavorite ? Icons.favorite : Icons.favorite_border), + onPressed: () async => FavoriteLocationHelper().setFavorite( + localDatabase, + osmLocation, + !isFavorite, + ), + ), onTap: () { if (popFirst) { // pops this result page From c8f12b3656a543dfe1529127559efcf1a0a592db Mon Sep 17 00:00:00 2001 From: Pierre Slamich Date: Fri, 16 Aug 2024 21:54:27 +0200 Subject: [PATCH 3/3] ci: On-demand auto-formatter (#5547) * ci: On-demand auto-formatter * Apply suggestions from code review --- .github/workflows/on-demand.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/on-demand.yml b/.github/workflows/on-demand.yml index 2161cd4b2cd..80f2d658b4f 100644 --- a/.github/workflows/on-demand.yml +++ b/.github/workflows/on-demand.yml @@ -38,8 +38,23 @@ jobs: run: | git remote set-branches --add origin develop git fetch origin - - name: Run linting - run: XXXXXXXX + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + #channel: stable + cache: true + flutter-version: ${{ steps.flutter-version.outputs.FLUTTER_VERSION }} + cache-key: flutter-${{ hashFiles('flutter-version.txt')}}-${{ hashFiles('packages\smooth_app\pubspec.lock')}} + + - run: flutter --version + + # Get dependencies + - name: Get dependencies + run: ci/pub_upgrade.sh + + # Check for formatting issues and fix them + - name: Check for formatting issues (run "dart format . ") + run: dart format . - name: Push changes if needed uses: stefanzweifel/git-auto-commit-action@v5 with: