Skip to content

Commit

Permalink
Merge branch 'develop' into ux/nutrition_page
Browse files Browse the repository at this point in the history
  • Loading branch information
M123-dev authored Apr 4, 2022
2 parents 71048eb + 7453743 commit efe1511
Show file tree
Hide file tree
Showing 145 changed files with 3,520 additions and 2,802 deletions.
10 changes: 6 additions & 4 deletions packages/smooth_app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@

# Open Food Facts - Codename: "Smooth App"

A new Flutter application by [Open Food Facts](https://github.com/openfoodfacts). You can install it on [Android](https://play.google.com/store/apps/details?id=org.openfoodfacts.app) or [iPhone/iPad](https://apps.apple.com/us/app/smooth-app/id1526747703). Note that a internal development build ([Android](https://play.google.com/apps/internaltest/4700279390303733107) or [iPhone/iPad](https://testflight.apple.com/join/dIhF6Gi4) )if you'd like to use the results of your PRs quicker.
A new Flutter application by [`Open Food Facts`](https://github.com/openfoodfacts) that can be installed both on [Android](https://play.google.com/store/apps/details?id=org.openfoodfacts.app) or [iOS](https://apps.apple.com/us/app/smooth-app/id1526747703) devices. Use the internal development build ([Android](https://play.google.com/apps/internaltest/4700279390303733107) or [iPhone/iPad](https://testflight.apple.com/join/dIhF6Gi4)) if you'd like to use the results of your PRs quicker.


## Getting Started
- On GitHub, [you can start here to get some inspiration](https://github.com/openfoodfacts/smooth-app/issues/525)
- You can join the Open Food Facts's Slack here : [Get an invite](https://slack.openfoodfacts.org) - [Open our Slack](https://openfoodfacts.slack.com).
## Building


## Building
In order to build the application, make sure you are in the packages/smooth_app directory and run these commands :
- flutter pub get
- flutter run


## Wiki & Doc
## Wiki & Docs
- [Project Smoothie - Open Food Facts wiki](https://wiki.openfoodfacts.org/Project_Smoothie)
- [Documentation (from code), on GitHub Pages](https://openfoodfacts.github.io/smooth-app/)
- [Smoothie GitHub wiki](https://github.com/openfoodfacts/smooth-app/wiki)

## General Flutter doc
## General Flutter docs
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
- For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:openfoodfacts/model/KnowledgePanelElement.dart';
import 'package:openfoodfacts/model/KnowledgePanels.dart';
import 'package:smooth_app/cards/product_cards/knowledge_panels/knowledge_panel_card.dart';
Expand All @@ -7,6 +8,8 @@ import 'package:smooth_app/cards/product_cards/knowledge_panels/knowledge_panel_
import 'package:smooth_app/cards/product_cards/knowledge_panels/knowledge_panel_world_map_card.dart';
import 'package:smooth_app/generic_lib/design_constants.dart';
import 'package:smooth_app/generic_lib/smooth_html_widget.dart';
import 'package:smooth_app/helpers/launch_url_helper.dart';
import 'package:smooth_app/helpers/product_cards_helper.dart';

class KnowledgePanelElementCard extends StatelessWidget {
const KnowledgePanelElementCard({
Expand All @@ -21,8 +24,8 @@ class KnowledgePanelElementCard extends StatelessWidget {
Widget build(BuildContext context) {
switch (knowledgePanelElement.elementType) {
case KnowledgePanelElementType.TEXT:
return SmoothHtmlWidget(
knowledgePanelElement.textElement!.html,
return _KnowledgePanelTextElementCard(
textElement: knowledgePanelElement.textElement!,
);
case KnowledgePanelElementType.IMAGE:
return Image.network(
Expand Down Expand Up @@ -51,3 +54,60 @@ class KnowledgePanelElementCard extends StatelessWidget {
}
}
}

/// A Knowledge Panel Text element may contain a source.
/// This widget add this information if needed and allows to open the url
/// (if provided)
class _KnowledgePanelTextElementCard extends StatelessWidget {
const _KnowledgePanelTextElementCard({
required this.textElement,
Key? key,
}) : super(key: key);

final KnowledgePanelTextElement textElement;

@override
Widget build(BuildContext context) {
final AppLocalizations appLocalizations = AppLocalizations.of(context)!;

Widget text = SmoothHtmlWidget(
textElement.html,
);

if (hasSource) {
text = Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
text,
const SizedBox(
height: MEDIUM_SPACE,
),
// Remove Icon
IconTheme.merge(
data: const IconThemeData(
size: 0.0,
),
child: addPanelButton(
appLocalizations
.knowledge_panel_text_source(textElement.sourceText!),
iconData: null,
onPressed: () {
LaunchUrlHelper.launchURL(
textElement.sourceUrl!,
false,
);
},
),
),
],
);
}

return text;
}

bool get hasSource =>
textElement.sourceText?.isNotEmpty == true &&
textElement.sourceUrl?.isNotEmpty == true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ class KnowledgePanelTitleCard extends StatelessWidget {
iconWidget = <Widget>[];
}
return Padding(
padding: const EdgeInsets.only(top: SMALL_SPACE),
padding: const EdgeInsets.only(
top: VERY_SMALL_SPACE,
bottom: VERY_SMALL_SPACE,
),
child: Row(
children: <Widget>[
...iconWidget,
Expand Down
4 changes: 3 additions & 1 deletion packages/smooth_app/lib/data_models/onboarding_loader.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:smooth_app/data_models/onboarding_data_knowledge_panels.dart';
import 'package:smooth_app/data_models/onboarding_data_product.dart';
import 'package:smooth_app/database/local_database.dart';
Expand All @@ -21,7 +22,8 @@ class OnboardingLoader {
await LoadingDialog.run<void>(
context: context,
future: _downloadData(),
title: 'Loading internet data', // TODO(monsieurtanuki): localize
title: AppLocalizations.of(context)!
.onboarding_welcome_loading_dialog_title,
);
return;
case OnboardingPage.NOT_STARTED:
Expand Down
73 changes: 41 additions & 32 deletions packages/smooth_app/lib/generic_lib/loading_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ class LoadingDialog<T> {
required final BuildContext context,
required final Future<T> future,
final String? title,
}) async =>
LoadingDialog<T>._()._run(
context: context,
future: future,
title: title ?? 'Downloading data', // TODO(monsieurtanuki): localize
);
}) {
final AppLocalizations? appLocalizations = AppLocalizations.of(context);
return LoadingDialog<T>._()._run(
context: context,
future: future,
title: title ?? appLocalizations!.loading_dialog_default_title,
);
}

/// Shows an loading error dialog.
///
Expand All @@ -33,20 +35,25 @@ class LoadingDialog<T> {
}) async =>
showDialog<void>(
context: context,
builder: (BuildContext context) => SmoothAlertDialog(
close: false,
body: ListTile(
leading: const Icon(Icons.error),
title: Text(title ??
'Could not download data'), // TODO(monsieurtanuki): localize
),
actions: <SmoothActionButton>[
SmoothActionButton(
text: AppLocalizations.of(context)!.close,
onPressed: () => Navigator.pop(context),
builder: (BuildContext context) {
final AppLocalizations? appLocalizations =
AppLocalizations.of(context);
return SmoothAlertDialog(
close: false,
body: ListTile(
leading: const Icon(Icons.error),
title: Text(
title ?? appLocalizations!.loading_dialog_default_error_message,
),
),
],
),
actions: <SmoothActionButton>[
SmoothActionButton(
text: appLocalizations!.close,
onPressed: () => Navigator.pop(context),
),
],
);
},
);

/// Displays "downloading" dialog while actually downloading
Expand Down Expand Up @@ -80,18 +87,20 @@ class LoadingDialog<T> {
Widget _getDialog(
final BuildContext context,
final String title,
) =>
SmoothAlertDialog(
close: false,
body: ListTile(
leading: const CircularProgressIndicator(),
title: Text(title),
) {
final AppLocalizations? appLocalizations = AppLocalizations.of(context);
return SmoothAlertDialog(
close: false,
body: ListTile(
leading: const CircularProgressIndicator(),
title: Text(title),
),
actions: <SmoothActionButton>[
SmoothActionButton(
text: appLocalizations!.stop,
onPressed: () => _popDialog(context, null),
),
actions: <SmoothActionButton>[
SmoothActionButton(
text: AppLocalizations.of(context)!.stop,
onPressed: () => _popDialog(context, null),
),
],
);
],
);
}
}
42 changes: 23 additions & 19 deletions packages/smooth_app/lib/l10n/app_aa.arb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"description": "Looking for: ${BARCODE}"
},
"@Introduction screen": {},
"welcomeToOpenFoodFacts": "Welcome to Open Food Facts",
"welcomeToOpenFoodFacts": "Welcome to Open Food Facts",
"@welcomeToOpenFoodFacts": {},
"whatIsOff": "Open Food Facts is a global non-profit powered by local communities.",
"@whatIsOff": {
Expand Down Expand Up @@ -174,7 +174,7 @@
"sign_up_page_producer_checkbox": "I am a food producer",
"sign_up_page_producer_hint": "Producer/brand",
"sign_up_page_producer_error_empty": "Please enter a producer or a brand name",
"sign_up_page_subscribe_checkbox": "I'd like to subscribe to the Open Food Facts newsletter (You can unsubscribe from it at all time)",
"sign_up_page_subscribe_checkbox": "I'd like to subscribe to the Open Food Facts newsletter (You can unsubscribe from it at any time)",
"@Settings": {},
"settingsTitle": "Settings",
"@settingsTitle": {
Expand Down Expand Up @@ -202,7 +202,7 @@
"description": "Button label: Opens a pop up window where all ways to get support are shown"
},
"support_join_slack": "Ask for help in our Slack channel",
"support_via_email": "Send us a e-mail",
"support_via_email": "Send us an e-mail",
"termsOfUse": "Terms of use",
"@termsOfUse": {},
"about_this_app": "About this app",
Expand Down Expand Up @@ -254,7 +254,7 @@
"@saving_answer": {
"description": "Dialog shown to users after they have answered a question, while the answer is being saved in the BE."
},
"contribute_to_get_rewards": "Help food transparency and get reward badges",
"contribute_to_get_rewards": "Help improve food transparency and get rewards",
"@contribute_to_get_rewards": {
"description": "Button description shown on a product, clicking the button opens a card with unanswered product questions, users can answer these to contribute to Open food facts and gain rewards."
},
Expand All @@ -264,7 +264,7 @@
"description": "Page title: Page where the ranking preferences can be changed"
},
"myPreferences_profile_title": "Your Profile",
"myPreferences_profile_subtitle": "Set app settings and find out advices.",
"myPreferences_profile_subtitle": "Change app settings and get advice.",
"myPreferences_settings_title": "App Settings",
"myPreferences_settings_subtitle": "Dark mode, Theme, ...",
"myPreferences_food_title": "Food Preferences",
Expand Down Expand Up @@ -362,7 +362,7 @@
"@missing_product": {},
"add_product_take_photos": "Take photos of the packaging to add this product to Open Food Facts",
"@add_product_take_photos": {},
"add_product_take_photos_descriptive": "Please take the following photos and the Open Food Facts engine can work out the rest!",
"add_product_take_photos_descriptive": "Please take some photos and the Open Food Facts engine can work out the rest!",
"@add_product_take_photos_descriptive": {},
"add_product_information_button_label": "Add product information",
"@add_product_information_button_label": {},
Expand Down Expand Up @@ -457,7 +457,7 @@
"description": "Confirmation, that the product data got canceled by the user"
},
"product_internet_error": "Impossible to fetch information about this product due to a network error.",
"cached_results_from": "Cached results from:",
"cached_results_from": "Show results from:",
"@cached_results_from": {
"description": "Cached results from: x time ago (time ago should not be added to the string)"
},
Expand Down Expand Up @@ -488,7 +488,7 @@
"@product_improvement_obsolete_nutrition_image": {
"description": "Message for ProductImprovement.OBSOLETE_NUTRITION_IMAGE"
},
"product_improvement_origins_to_be_completed": "The Eco-Score takes into account the origins of the ingredients. Please take a photo of them (ingredient list and/or any geographic claim or edit the product) so that they can be taken into account.",
"product_improvement_origins_to_be_completed": "The Eco-Score takes into account the origins of the ingredients. Please take a photo of the ingredient list and/or any geographic claim or edit the product, so they can be taken into account.",
"@product_improvement_origins_to_be_completed": {
"description": "Message for ProductImprovement.ORIGINS_TO_BE_COMPLETED"
},
Expand Down Expand Up @@ -520,12 +520,12 @@
"@clear": {
"description": "Clears a product list"
},
"really_clear": "Do you really want to clear this list?",
"product_compatibility_unknown": "Product Compatibility Unknown",
"really_clear": "Do you really want to delete this list?",
"product_compatibility_unknown": "Compatibility Unknown",
"@product_compatibility_unknown": {
"description": "Product compatibility summary title"
},
"product_compatibility_incompatible": "Does not match",
"product_compatibility_incompatible": "Doesn't match",
"@product_compatibility_incompatible": {
"description": "Product compatibility summary title"
},
Expand All @@ -541,35 +541,35 @@
"percent": {}
}
},
"plural_ago_days": "{count,plural, =1{one day ago} other{{count} days ago}}",
"plural_ago_days": "{count,plural, one {} =1{one day ago} other{{count} days ago}}",
"@plural_ago_days": {
"description": "Cached results from: x days ago",
"placeholders": {
"count": {}
}
},
"plural_ago_hours": "{count,plural, =1{one hour ago} other{{count} hours ago}}",
"plural_ago_hours": "{count,plural, one {} =1{one hour ago} other{{count} hours ago}}",
"@plural_ago_hours": {
"description": "Cached results from: x hours ago",
"placeholders": {
"count": {}
}
},
"plural_ago_minutes": "{count,plural, =0{less than a minute ago} =1{one minute ago} other{{count} minutes ago}}",
"plural_ago_minutes": "{count,plural, one {} =0{less than a minute ago} =1{one minute ago} other{{count} minutes ago}}",
"@plural_ago_minutes": {
"description": "Cached results from: x minutes ago",
"placeholders": {
"count": {}
}
},
"plural_ago_months": "{count,plural, =1{one month ago} other{{count} months ago}}",
"plural_ago_months": "{count,plural, one {} =1{one month ago} other{{count} months ago}}",
"@plural_ago_months": {
"description": "Cached results from: x months ago",
"placeholders": {
"count": {}
}
},
"plural_ago_weeks": "{count,plural, =1{one week ago} other{{count} weeks ago}}",
"plural_ago_weeks": "{count,plural, one {} =1{one week ago} other{{count} weeks ago}}",
"@plural_ago_weeks": {
"description": "Cached results from: x weeks ago",
"placeholders": {
Expand All @@ -583,7 +583,7 @@
"count": {}
}
},
"compare_products_mode": "Compare Mode",
"compare_products_mode": "Compare",
"@compare_products_mode": {
"description": "Button to switch to 'compare products mode'"
},
Expand All @@ -595,15 +595,19 @@
"faq": "FAQ",
"discover": "Discover",
"how_to_contribute": "How to Contribute",
"main_app_color": "Main color of the app",
"main_app_color": "Theme",
"@main_app_color": {
"description": "Heading for the section to pick the main app color"
},
"hint_knowledge_panel_message": "Your can tap on any part of the card to get more details about what you see. Try it now!",
"@hint_knowledge_panel_message": {
"description": "Hint popup indicating the card is clickable during onboarding"
},
"consent_analytics_title": "Send anonymous analytics",
"@consent_analytics_title": {
"description": "Title for the consent analytics UI Page"
},
"consent_analytics_body1": "Help the Open Food Facts volunteer to improve the app.You decide if you want to send anonymous analytics.",
"consent_analytics_body1": "Help the Open Food Facts volunteer to improve the app. You decide if you want to send anonymous analytics.",
"@conset_analytics_body1": {
"description": "first paragraph for the consent analytics UI Page"
},
Expand Down
Loading

0 comments on commit efe1511

Please sign in to comment.