Skip to content

Commit

Permalink
feat: 4973 - "shortcut to prices app" button controlled by dev mode (#…
Browse files Browse the repository at this point in the history
…4976)

* feat: 4973 - "shortcut to prices app" button controlled by dev mode

Impacted files:
* `app_en.arb`: added 2 "prices app" labels; removed old labels
* `new_product_page.dart`: added a dev mode controlled "shortcut to prices app" button
* `plural_translation_test.dart`: removed a test about an old label
* `pubspec.lock`: wtf
* `user_preferences_dev_mode.dart`: added a dev mode "shortcut to prices app" flag

* Minor text fixes
  • Loading branch information
monsieurtanuki authored Jan 12, 2024
1 parent 692d9d7 commit 5f72b28
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 92 deletions.
39 changes: 2 additions & 37 deletions packages/smooth_app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1617,51 +1617,16 @@
"@dev_preferences_import_history_subtitle": {
"description": "User dev preferences - Import history - Subtitle"
},
"prices_app_dev_mode_flag": "Shortcut to Prices app on product page",
"prices_app_button": "Go to Prices app",
"dev_preferences_import_history_result_success": "Done",
"@dev_preferences_import_history_result_success": {
"description": "User dev preferences - Import history - Result successful"
},
"dev_mode_scan_mode_title": "Scan Mode",
"@dev_mode_scan_mode_title": {
"description": "User dev preferences - Scan mode - Title"
},
"dev_mode_scan_mode_subtitle": "Current scan mode is: \"{mode}\"",
"@dev_mode_scan_mode_subtitle": {
"description": "User dev preferences - Scan mode - Subtitle",
"placeholders": {
"mode": {
"type": "String"
}
}
},
"dev_mode_scan_mode_dialog_title": "Scan Mode",
"@dev_mode_scan_mode_dialog_title": {
"description": "User dev preferences - Scan mode - Dialog Title"
},
"dev_mode_hide_ecoscore_title": "Exclude Eco-Score",
"@dev_mode_hide_ecoscore_title": {
"description": "User dev preferences - Disable Ecoscore - Title"
},
"dev_mode_scan_camera_only": "Only camera stream, no scanning",
"@dev_mode_scan_camera_only": {
"description": "Scan mode - Camera only"
},
"dev_mode_scan_preprocess_full_image": "Camera stream and full image preprocessing, no scanning",
"@dev_mode_scan_preprocess_full_image": {
"description": "Scan mode - Preprocess full image"
},
"dev_mode_scan_preprocess_half_image": "Camera stream and half image preprocessing, no scanning",
"@dev_mode_scan_preprocess_half_image": {
"description": "Scan mode - Preprocess half image"
},
"dev_mode_scan_scan_full_image": "Full image scanning",
"@dev_mode_scan_scan_full_image": {
"description": "Scan mode - Scan full image"
},
"dev_mode_scan_scan_half_image": "Half image scanning",
"@dev_mode_scan_scan_half_image": {
"description": "Scan mode - Scan half image"
},
"search_history_item_edit_tooltip": "Reuse and edit this search",
"@search_history_item_edit_tooltip": {
"description": "A tooltip to explain the Pen button near a search term -> it allows to reuse the item"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class UserPreferencesDevMode extends AbstractUserPreferences {
static const String userPreferencesFlagAccessibilityEmoji =
'__accessibilityEmoji';
static const String userPreferencesFlagUserOrderedKP = '__userOrderedKP';
static const String userPreferencesFlagShortcutToPrices =
'__shortcutToPrices';

final TextEditingController _textFieldController = TextEditingController();

Expand Down Expand Up @@ -316,6 +318,16 @@ class UserPreferencesDevMode extends AbstractUserPreferences {
_showSuccessMessage();
},
),
UserPreferencesItemSwitch(
title: appLocalizations.prices_app_dev_mode_flag,
value: userPreferences.getFlag(userPreferencesFlagShortcutToPrices) ??
false,
onChanged: (bool value) async {
await userPreferences.setFlag(
userPreferencesFlagShortcutToPrices, value);
_showSuccessMessage();
},
),
UserPreferencesItemTile(
title: 'Preference Search...',
onTap: () async => Navigator.of(context).push(
Expand Down
16 changes: 16 additions & 0 deletions packages/smooth_app/lib/pages/product/new_product_page.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:assorted_layout_widgets/assorted_layout_widgets.dart';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
Expand All @@ -20,6 +21,7 @@ import 'package:smooth_app/generic_lib/duration_constants.dart';
import 'package:smooth_app/generic_lib/widgets/smooth_back_button.dart';
import 'package:smooth_app/generic_lib/widgets/smooth_card.dart';
import 'package:smooth_app/helpers/analytics_helper.dart';
import 'package:smooth_app/helpers/launch_url_helper.dart';
import 'package:smooth_app/pages/carousel_manager.dart';
import 'package:smooth_app/pages/preferences/user_preferences_dev_mode.dart';
import 'package:smooth_app/pages/product/common/product_list_page.dart';
Expand Down Expand Up @@ -234,6 +236,20 @@ class _ProductPageState extends State<ProductPage>
if (upToDateProduct.website != null &&
upToDateProduct.website!.trim().isNotEmpty)
WebsiteCard(upToDateProduct.website!),
if (userPreferences.getFlag(
UserPreferencesDevMode.userPreferencesFlagShortcutToPrices) ??
false)
Padding(
padding: const EdgeInsets.all(SMALL_SPACE),
child: SmoothLargeButtonWithIcon(
text: appLocalizations.prices_app_button,
icon: CupertinoIcons.tag_fill,
onPressed: () async => LaunchUrlHelper.launchURL(
'https://prices.openfoodfacts.org/app/products/${upToDateProduct.barcode!}',
false,
),
),
),
if (userPreferences.getFlag(
UserPreferencesDevMode.userPreferencesFlagUserOrderedKP) ??
false)
Expand Down
Loading

0 comments on commit 5f72b28

Please sign in to comment.