diff --git a/packages/smooth_app/assets/onboarding/analytics.svg b/packages/smooth_app/assets/onboarding/analytics.svg
deleted file mode 100644
index b392299bf6d..00000000000
--- a/packages/smooth_app/assets/onboarding/analytics.svg
+++ /dev/null
@@ -1,27 +0,0 @@
-
diff --git a/packages/smooth_app/lib/data_models/onboarding_loader.dart b/packages/smooth_app/lib/data_models/onboarding_loader.dart
index 33a193971f3..b80bdf25923 100644
--- a/packages/smooth_app/lib/data_models/onboarding_loader.dart
+++ b/packages/smooth_app/lib/data_models/onboarding_loader.dart
@@ -49,9 +49,6 @@ class OnboardingLoader {
case OnboardingPage.ECO_CARD_EXAMPLE:
case OnboardingPage.PREFERENCES_PAGE:
case OnboardingPage.PERMISSIONS_PAGE:
- // nothing special to do
- return;
- case OnboardingPage.CONSENT_PAGE:
// that was the last page of onboarding: after that, we clean up
await _unloadData();
return;
diff --git a/packages/smooth_app/lib/l10n/app_en.arb b/packages/smooth_app/lib/l10n/app_en.arb
index 950c5651882..0f0c2c3e221 100644
--- a/packages/smooth_app/lib/l10n/app_en.arb
+++ b/packages/smooth_app/lib/l10n/app_en.arb
@@ -1103,18 +1103,6 @@
"@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 volunteers to improve the app. You decide whether to submit anonymous analytics.",
- "@conset_analytics_body1": {
- "description": "first paragraph for the consent analytics UI Page"
- },
- "consent_analytics_body2": "If you change your mind, this option can be enabled and disabled at any time from the settings.",
- "@consent_analytics_body2": {
- "description": "second paragraph for the consent analytics UI Page"
- },
"permissions_page_title": "Camera access",
"@permissions_page_title": {
"description": "Title for the camera permission's page (onboarding)"
diff --git a/packages/smooth_app/lib/pages/onboarding/consent_analytics_page.dart b/packages/smooth_app/lib/pages/onboarding/consent_analytics_page.dart
deleted file mode 100644
index 9f8d0b1793f..00000000000
--- a/packages/smooth_app/lib/pages/onboarding/consent_analytics_page.dart
+++ /dev/null
@@ -1,149 +0,0 @@
-import 'dart:io';
-
-import 'package:auto_size_text/auto_size_text.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter_gen/gen_l10n/app_localizations.dart';
-import 'package:flutter_svg/flutter_svg.dart';
-import 'package:provider/provider.dart';
-import 'package:smooth_app/data_models/onboarding_loader.dart';
-import 'package:smooth_app/data_models/preferences/user_preferences.dart';
-import 'package:smooth_app/database/local_database.dart';
-import 'package:smooth_app/generic_lib/design_constants.dart';
-import 'package:smooth_app/helpers/app_helper.dart';
-import 'package:smooth_app/pages/onboarding/onboarding_bottom_bar.dart';
-import 'package:smooth_app/pages/onboarding/onboarding_flow_navigator.dart';
-import 'package:smooth_app/themes/theme_provider.dart';
-import 'package:smooth_app/widgets/smooth_text.dart';
-
-class ConsentAnalyticsPage extends StatelessWidget {
- const ConsentAnalyticsPage(this.backgroundColor);
-
- final Color backgroundColor;
-
- @override
- Widget build(BuildContext context) {
- final Size screenSize = MediaQuery.sizeOf(context);
- final AppLocalizations appLocalizations = AppLocalizations.of(context);
- return ColoredBox(
- color: backgroundColor,
- child: SafeArea(
- bottom: Platform.isAndroid,
- child: Column(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Expanded(
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: LARGE_SPACE),
- child: Center(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.start,
- crossAxisAlignment: CrossAxisAlignment.center,
- mainAxisSize: MainAxisSize.min,
- children: [
- SvgPicture.asset(
- 'assets/onboarding/analytics.svg',
- width: screenSize.width * .50,
- package: AppHelper.APP_PACKAGE,
- ),
- const SizedBox(height: LARGE_SPACE),
- AutoSizeText(
- appLocalizations.consent_analytics_title,
- maxLines: 2,
- style: Theme.of(context).textTheme.displayLarge!.apply(
- color: const Color.fromARGB(255, 51, 51, 51)),
- textAlign: TextAlign.center,
- ),
- const SizedBox(height: SMALL_SPACE),
- AutoSizeText(
- appLocalizations.consent_analytics_body1,
- maxLines: 3,
- textAlign: TextAlign.center,
- style: WellSpacedTextHelper.TEXT_STYLE_WITH_WELL_SPACED,
- ),
- const SizedBox(height: SMALL_SPACE),
- AutoSizeText(
- appLocalizations.consent_analytics_body2,
- maxLines: 3,
- textAlign: TextAlign.center,
- style: WellSpacedTextHelper.TEXT_STYLE_WITH_WELL_SPACED,
- ),
- ],
- ),
- ),
- ),
- ),
- OnboardingBottomBar(
- leftButton: _buildButton(
- context,
- appLocalizations.refuse_button_label,
- false,
- const Color(0xFFA08D84),
- Colors.white,
- ),
- rightButton: _buildButton(
- context,
- appLocalizations.authorize_button_label,
- true,
- Colors.white,
- Colors.black,
- ),
- backgroundColor: backgroundColor,
- semanticsHorizontalOrder: false,
- ),
- ],
- ),
- ),
- );
- }
-
- static const OnboardingPage _onboardingPage = OnboardingPage.CONSENT_PAGE;
-
- Future _analyticsLogic(
- bool accept,
- UserPreferences userPreferences,
- LocalDatabase localDatabase,
- BuildContext context,
- final ThemeProvider themeProvider,
- ) async {
- await userPreferences.setCrashReports(accept);
- await userPreferences.setUserTracking(accept);
-
- themeProvider.finishOnboarding();
- if (!context.mounted) {
- return;
- }
- await OnboardingLoader(localDatabase).runAtNextTime(
- _onboardingPage,
- context,
- );
-
- if (!context.mounted) {
- return;
- }
- await OnboardingFlowNavigator(userPreferences).navigateToPage(
- context,
- _onboardingPage.getNextPage(),
- );
- }
-
- Widget _buildButton(
- final BuildContext context,
- final String label,
- final bool isAccepted,
- final Color backgroundColor,
- final Color foregroundColor,
- ) =>
- OnboardingBottomButton(
- onPressed: () async => _analyticsLogic(
- isAccepted,
- context.read(),
- context.read(),
- context,
- context.read(),
- ),
- backgroundColor: backgroundColor,
- foregroundColor: foregroundColor,
- label: label,
- );
-}
diff --git a/packages/smooth_app/lib/pages/onboarding/onboarding_flow_navigator.dart b/packages/smooth_app/lib/pages/onboarding/onboarding_flow_navigator.dart
index 0fa723075c5..f1c3752bf17 100644
--- a/packages/smooth_app/lib/pages/onboarding/onboarding_flow_navigator.dart
+++ b/packages/smooth_app/lib/pages/onboarding/onboarding_flow_navigator.dart
@@ -3,7 +3,6 @@ import 'package:provider/provider.dart';
import 'package:smooth_app/data_models/preferences/user_preferences.dart';
import 'package:smooth_app/database/local_database.dart';
import 'package:smooth_app/pages/navigator/app_navigator.dart';
-import 'package:smooth_app/pages/onboarding/consent_analytics_page.dart';
import 'package:smooth_app/pages/onboarding/permissions_page.dart';
import 'package:smooth_app/pages/onboarding/preferences_page.dart';
import 'package:smooth_app/pages/onboarding/reinvention_page.dart';
@@ -23,7 +22,6 @@ enum OnboardingPage {
ECO_CARD_EXAMPLE,
PREFERENCES_PAGE,
PERMISSIONS_PAGE,
- CONSENT_PAGE,
ONBOARDING_COMPLETE;
OnboardingPage getPrevPage() {
@@ -62,8 +60,6 @@ enum OnboardingPage {
return const Color(0xFFEBF1FF);
case OnboardingPage.PERMISSIONS_PAGE:
return const Color(0xFFEBF1FF);
- case OnboardingPage.CONSENT_PAGE:
- return const Color(0xFFFFF2DF);
case OnboardingPage.ONBOARDING_COMPLETE:
// whatever, it's not used
return Colors.black;
@@ -99,11 +95,6 @@ enum OnboardingPage {
context,
PermissionsPage(backgroundColor),
);
- case OnboardingPage.CONSENT_PAGE:
- return _wrapWidgetInCustomBackNavigator(
- context,
- ConsentAnalyticsPage(backgroundColor),
- );
case OnboardingPage.ONBOARDING_COMPLETE:
return ExternalScanCarouselManager(child: PageManager());
}
diff --git a/packages/smooth_app/lib/pages/onboarding/permissions_page.dart b/packages/smooth_app/lib/pages/onboarding/permissions_page.dart
index 3459526b53c..effc3fcb9a6 100644
--- a/packages/smooth_app/lib/pages/onboarding/permissions_page.dart
+++ b/packages/smooth_app/lib/pages/onboarding/permissions_page.dart
@@ -13,6 +13,7 @@ import 'package:smooth_app/helpers/provider_helper.dart';
import 'package:smooth_app/pages/onboarding/onboarding_bottom_bar.dart';
import 'package:smooth_app/pages/onboarding/onboarding_flow_navigator.dart';
import 'package:smooth_app/resources/app_animations.dart' as animations;
+import 'package:smooth_app/themes/theme_provider.dart';
import 'package:smooth_app/widgets/smooth_text.dart';
class PermissionsPage extends StatefulWidget {
@@ -42,7 +43,7 @@ class _PermissionsPageState extends State {
PermissionListener newValue,
) {
if (newValue.value.isGranted && !_eventConsumed) {
- _moveToNextScreen(context);
+ _endOnboarding(context);
_eventConsumed = true;
}
},
@@ -53,56 +54,62 @@ class _PermissionsPageState extends State {
child: Column(
children: [
Expanded(
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: LARGE_SPACE),
- child: Center(
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- LayoutBuilder(builder:
- (BuildContext context, BoxConstraints constraints) {
- return SizedBox.square(
- dimension: constraints.maxWidth * 0.5,
- child: Transform.rotate(
- angle: -0.2,
- child: const animations.BarcodeAnimation(),
- ),
- );
- }),
- const SizedBox(height: LARGE_SPACE),
- AutoSizeText(
- appLocalizations.permissions_page_title,
- maxLines: 2,
- style: Theme.of(context).textTheme.displayLarge!.apply(
- color: const Color.fromARGB(255, 51, 51, 51)),
- textAlign: TextAlign.center,
- ),
- const SizedBox(height: SMALL_SPACE),
- AutoSizeText(
- appLocalizations.permissions_page_body1,
- maxLines: 2,
- textAlign: TextAlign.center,
- style: WellSpacedTextHelper.TEXT_STYLE_WITH_WELL_SPACED,
- ),
- const SizedBox(height: MEDIUM_SPACE),
- AutoSizeText(
- appLocalizations.permissions_page_body2,
- maxLines: 3,
- textAlign: TextAlign.center,
- style: WellSpacedTextHelper.TEXT_STYLE_WITH_WELL_SPACED,
- ),
- ],
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: LARGE_SPACE),
+ child: Center(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ LayoutBuilder(builder:
+ (BuildContext context, BoxConstraints constraints) {
+ return SizedBox.square(
+ dimension: constraints.maxWidth * 0.5,
+ child: Transform.rotate(
+ angle: -0.2,
+ child: const animations.BarcodeAnimation(),
+ ),
+ );
+ }),
+ const SizedBox(height: LARGE_SPACE),
+ AutoSizeText(
+ appLocalizations.permissions_page_title,
+ maxLines: 2,
+ style: Theme.of(context)
+ .textTheme
+ .displayLarge!
+ .apply(
+ color: const Color.fromARGB(255, 51, 51, 51)),
+ textAlign: TextAlign.center,
+ ),
+ const SizedBox(height: SMALL_SPACE),
+ AutoSizeText(
+ appLocalizations.permissions_page_body1,
+ maxLines: 2,
+ textAlign: TextAlign.center,
+ style:
+ WellSpacedTextHelper.TEXT_STYLE_WITH_WELL_SPACED,
+ ),
+ const SizedBox(height: MEDIUM_SPACE),
+ AutoSizeText(
+ appLocalizations.permissions_page_body2,
+ maxLines: 3,
+ textAlign: TextAlign.center,
+ style:
+ WellSpacedTextHelper.TEXT_STYLE_WITH_WELL_SPACED,
+ ),
+ ],
+ ),
),
),
- )),
+ ),
OnboardingBottomBar(
leftButton: !Platform.isIOS
? _IgnoreButton(
- onPermissionIgnored: () => _moveToNextScreen(context),
+ onPermissionIgnored: () => _endOnboarding(context),
)
: null,
rightButton: _AskPermissionButton(
- onPermissionIgnored: () => _moveToNextScreen(context),
+ onPermissionIgnored: () => _endOnboarding(context),
),
backgroundColor: widget.backgroundColor,
semanticsHorizontalOrder: false,
@@ -116,7 +123,12 @@ class _PermissionsPageState extends State {
static const OnboardingPage _onboardingPage = OnboardingPage.PERMISSIONS_PAGE;
- Future _moveToNextScreen(BuildContext context) async {
+ Future _endOnboarding(BuildContext context) async {
+ context.read().finishOnboarding();
+
+ if (!context.mounted) {
+ return;
+ }
await OnboardingLoader(context.read()).runAtNextTime(
_onboardingPage,
context,
diff --git a/packages/smooth_app/lib/pages/onboarding/reinvention_page.dart b/packages/smooth_app/lib/pages/onboarding/reinvention_page.dart
index f3885371196..d828945725b 100644
--- a/packages/smooth_app/lib/pages/onboarding/reinvention_page.dart
+++ b/packages/smooth_app/lib/pages/onboarding/reinvention_page.dart
@@ -33,8 +33,16 @@ class OnboardingHomePage extends StatelessWidget {
final LocalDatabase localDatabase =
context.read();
- await OnboardingLoader(localDatabase)
- .runAtNextTime(OnboardingPage.HOME_PAGE, context);
+ /// Enable crash reports and user tracking by default
+ /// (Can be disabled by the user later in the settings)
+ await userPreferences.setCrashReports(true);
+ await userPreferences.setUserTracking(true);
+
+ if (context.mounted) {
+ await OnboardingLoader(localDatabase)
+ .runAtNextTime(OnboardingPage.HOME_PAGE, context);
+ }
+
if (context.mounted) {
await OnboardingFlowNavigator(userPreferences).navigateToPage(
context,
diff --git a/packages/smooth_app/lib/themes/theme_provider.dart b/packages/smooth_app/lib/themes/theme_provider.dart
index 6acfd5e4c5f..aa0c46686b4 100644
--- a/packages/smooth_app/lib/themes/theme_provider.dart
+++ b/packages/smooth_app/lib/themes/theme_provider.dart
@@ -43,7 +43,10 @@ class ThemeProvider with ChangeNotifier {
void finishOnboarding() {
setOnboardingComplete(true);
- notifyListeners();
+
+ WidgetsBinding.instance
+ ..addPostFrameCallback((_) => notifyListeners())
+ ..ensureVisualUpdate();
}
ThemeMode get currentThemeMode {