diff --git a/packages/smooth_app/lib/main.dart b/packages/smooth_app/lib/main.dart index 74660c87377..70ba4abdeb0 100644 --- a/packages/smooth_app/lib/main.dart +++ b/packages/smooth_app/lib/main.dart @@ -3,7 +3,6 @@ import 'dart:io'; import 'package:app_store_shared/app_store_shared.dart'; import 'package:dart_ping_ios/dart_ping_ios.dart'; -import 'package:device_preview/device_preview.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -85,12 +84,7 @@ Future launchSmoothApp({ await AnalyticsHelper.initSentry( appRunner: () => runApp(const SmoothApp())); } else { - runApp( - DevicePreview( - enabled: true, - builder: (_) => const SmoothApp(), - ), - ); + runApp(const SmoothApp()); } } diff --git a/packages/smooth_app/lib/pages/guides/guide/guide_nutriscore_v2.dart b/packages/smooth_app/lib/pages/guides/guide/guide_nutriscore_v2.dart index 1036d512bc6..638945823d8 100644 --- a/packages/smooth_app/lib/pages/guides/guide/guide_nutriscore_v2.dart +++ b/packages/smooth_app/lib/pages/guides/guide/guide_nutriscore_v2.dart @@ -11,9 +11,10 @@ class GuideNutriscoreV2 extends StatelessWidget { @override Widget build(BuildContext context) { - return const GuidesPage( - header: _NutriscoreHeader(), - body: [ + return GuidesPage( + pageName: 'NutriscoreV2', + header: const _NutriscoreHeader(), + body: const [ _NutriScoreSection1(), _NutriScoreSection2(), _NutriScoreSection3(), @@ -21,7 +22,10 @@ class GuideNutriscoreV2 extends StatelessWidget { _NutriScoreSection5(), ], footer: SliverToBoxAdapter( - child: GuidesFooter(), + child: GuidesFooter( + shareMessage: 'guide_nutriscore_v2_share_message'.translation, + shareUrl: 'guide_nutriscore_v2_share_link'.translation, + ), ), ); } diff --git a/packages/smooth_app/lib/pages/guides/helpers/guides_content.dart b/packages/smooth_app/lib/pages/guides/helpers/guides_content.dart index de37e4318b5..73a1a06228c 100644 --- a/packages/smooth_app/lib/pages/guides/helpers/guides_content.dart +++ b/packages/smooth_app/lib/pages/guides/helpers/guides_content.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:matomo_tracker/matomo_tracker.dart'; import 'package:provider/provider.dart'; import 'package:sliver_tools/sliver_tools.dart'; import 'package:smooth_app/generic_lib/design_constants.dart'; @@ -15,6 +16,7 @@ class GuidesPage extends StatelessWidget { const GuidesPage({ required this.header, required this.body, + required this.pageName, this.footer, super.key, }); @@ -23,6 +25,9 @@ class GuidesPage extends StatelessWidget { final List body; final Widget? footer; + // Page name for the Analytics event + final String pageName; + @override Widget build(BuildContext context) { return Scaffold( @@ -33,6 +38,7 @@ class GuidesPage extends StatelessWidget { builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.connectionState == ConnectionState.done) { return _GuidesPageBody( + pageName: pageName, slivers: [ header, ...body, @@ -46,11 +52,21 @@ class GuidesPage extends StatelessWidget { } } -class _GuidesPageBody extends StatelessWidget { - _GuidesPageBody({required this.slivers}); +class _GuidesPageBody extends StatefulWidget { + const _GuidesPageBody({ + required this.slivers, + required this.pageName, + }) : assert(pageName.length > 0); final List slivers; + final String pageName; + + @override + State<_GuidesPageBody> createState() => _GuidesPageBodyState(); +} +class _GuidesPageBodyState extends State<_GuidesPageBody> + with TraceableClientMixin { final ScrollController _controller = ScrollController(); @override @@ -92,11 +108,14 @@ class _GuidesPageBody extends StatelessWidget { GuidesHeader.HEADER_HEIGHT - kToolbarHeight, ], ), - slivers: slivers, + slivers: widget.slivers, ), ), ); } + + @override + String get actionName => 'Opened ${widget.pageName}'; } class GuidesParagraph extends StatelessWidget { diff --git a/packages/smooth_app/lib/pages/guides/helpers/guides_footer.dart b/packages/smooth_app/lib/pages/guides/helpers/guides_footer.dart index 833ef35b69e..a7eb31b43f3 100644 --- a/packages/smooth_app/lib/pages/guides/helpers/guides_footer.dart +++ b/packages/smooth_app/lib/pages/guides/helpers/guides_footer.dart @@ -1,11 +1,21 @@ import 'dart:math' as math; import 'package:flutter/material.dart'; +import 'package:share_plus/share_plus.dart'; import 'package:smooth_app/generic_lib/design_constants.dart'; +import 'package:smooth_app/helpers/analytics_helper.dart'; +import 'package:smooth_app/pages/guides/helpers/guides_translations.dart'; import 'package:smooth_app/themes/smooth_theme_colors.dart'; class GuidesFooter extends StatelessWidget { - const GuidesFooter({super.key}); + const GuidesFooter({ + required this.shareUrl, + this.shareMessage, + super.key, + }); + + final String? shareMessage; + final String shareUrl; @override Widget build(BuildContext context) { @@ -38,20 +48,30 @@ class GuidesFooter extends StatelessWidget { vertical: VERY_LARGE_SPACE, ), ), - // TODO(g123k): Implement sharing functionality - child: const Text( - 'Partager', - style: TextStyle( + child: Text( + 'guide_share_label'.translation, + style: const TextStyle( fontWeight: FontWeight.bold, fontSize: 15.5, ), ), - onPressed: () {}, + onPressed: () { + Share.share(_shareText); + AnalyticsHelper.trackOutlink(url: shareUrl); + }, ), ), ), ); } + + String get _shareText { + if (shareMessage?.isNotEmpty == true) { + return '$shareMessage\n$shareUrl'; + } else { + return shareUrl; + } + } } class _FooterPainter extends CustomPainter { diff --git a/packages/smooth_app/lib/pages/preferences/user_preferences_faq.dart b/packages/smooth_app/lib/pages/preferences/user_preferences_faq.dart index 1be62fad6a7..a4658059dff 100644 --- a/packages/smooth_app/lib/pages/preferences/user_preferences_faq.dart +++ b/packages/smooth_app/lib/pages/preferences/user_preferences_faq.dart @@ -71,7 +71,7 @@ class UserPreferencesFaq extends AbstractUserPreferences { NutriScoreValue.b, true, ), - onTap: () => Navigator.of(context).push( + onTap: () => Navigator.of(context, rootNavigator: true).push( MaterialPageRoute( builder: (BuildContext context) => const GuideNutriscoreV2(), ), diff --git a/packages/smooth_app/pubspec.lock b/packages/smooth_app/pubspec.lock index 37ba4d391f2..d0d2778b988 100644 --- a/packages/smooth_app/pubspec.lock +++ b/packages/smooth_app/pubspec.lock @@ -406,14 +406,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.7.10" - device_frame: - dependency: transitive - description: - name: device_frame - sha256: afe76182aec178d171953d9b4a50a43c57c7cf3c77d8b09a48bf30c8fa04dd9d - url: "https://pub.dev" - source: hosted - version: "1.1.0" device_info_plus: dependency: "direct main" description: @@ -430,14 +422,6 @@ packages: url: "https://pub.dev" source: hosted version: "7.0.0" - device_preview: - dependency: "direct main" - description: - name: device_preview - sha256: "2f097bf31b929e15e6756dbe0ec1bcb63952ab9ed51c25dc5a2c722d2b21fdaf" - url: "https://pub.dev" - source: hosted - version: "1.1.0" diacritic: dependency: "direct main" description: @@ -767,14 +751,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.8.5+3" - freezed_annotation: - dependency: transitive - description: - name: freezed_annotation - sha256: c3fd9336eb55a38cc1bbd79ab17573113a8deccd0ecbbf926cca3c62803b5c2d - url: "https://pub.dev" - source: hosted - version: "2.4.1" fuchsia_remote_debug_protocol: dependency: transitive description: flutter diff --git a/packages/smooth_app/pubspec.yaml b/packages/smooth_app/pubspec.yaml index f0abe234a2a..062dd8007bd 100644 --- a/packages/smooth_app/pubspec.yaml +++ b/packages/smooth_app/pubspec.yaml @@ -17,7 +17,6 @@ dependencies: barcode_widget: 2.0.4 carousel_slider: 4.2.1 cupertino_icons: 1.0.8 - device_preview: 1.1.0 flutter_svg: 2.0.10+1 flutter_map: 6.1.0 html: 0.15.4