Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added deeplinking for the sign up page #4169 #5332

Merged
merged 7 commits into from
Jun 7, 2024
Merged
6 changes: 0 additions & 6 deletions packages/smooth_app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ PODS:
- SDWebImageWebPCoder (0.14.6):
- libwebp (~> 1.0)
- SDWebImage/Core (~> 5.17)
- sensors_plus (0.0.1):
- Flutter
- Sentry/HybridSDK (8.21.0):
- SentryPrivate (= 8.21.0)
- sentry_flutter (0.0.1):
Expand Down Expand Up @@ -175,7 +173,6 @@ DEPENDENCIES:
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- qr_code_scanner (from `.symlinks/plugins/qr_code_scanner/ios`)
- rive_common (from `.symlinks/plugins/rive_common/ios`)
- sensors_plus (from `.symlinks/plugins/sensors_plus/ios`)
- sentry_flutter (from `.symlinks/plugins/sentry_flutter/ios`)
- share_plus (from `.symlinks/plugins/share_plus/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
Expand Down Expand Up @@ -251,8 +248,6 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/qr_code_scanner/ios"
rive_common:
:path: ".symlinks/plugins/rive_common/ios"
sensors_plus:
:path: ".symlinks/plugins/sensors_plus/ios"
sentry_flutter:
:path: ".symlinks/plugins/sentry_flutter/ios"
share_plus:
Expand Down Expand Up @@ -307,7 +302,6 @@ SPEC CHECKSUMS:
rive_common: cbbac3192af00d7341f19dae2f26298e9e37d99e
SDWebImage: dfe95b2466a9823cf9f0c6d01217c06550d7b29a
SDWebImageWebPCoder: e38c0a70396191361d60c092933e22c20d5b1380
sensors_plus: 4ee32bc7d61a055f27f88d3215ad6b6fb96a2b8e
Sentry: ebc12276bd17613a114ab359074096b6b3725203
sentry_flutter: dff1df05dc39c83d04f9330b36360fc374574c5e
SentryPrivate: d651efb234cf385ec9a1cdd3eff94b5e78a0e0fe
Expand Down
6 changes: 6 additions & 0 deletions packages/smooth_app/lib/pages/navigator/app_navigator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import 'package:smooth_app/pages/product/new_product_page.dart';
import 'package:smooth_app/pages/product/product_loader_page.dart';
import 'package:smooth_app/pages/scan/search_page.dart';
import 'package:smooth_app/pages/scan/search_product_helper.dart';
import 'package:smooth_app/pages/user_management/sign_up_page.dart';
import 'package:smooth_app/query/product_query.dart';

/// A replacement for the [Navigator], where we internally use [GoRouter].
Expand Down Expand Up @@ -227,6 +228,10 @@ class _SmoothGoRouter {
return ExternalPage(path: state.uri.queryParameters['path']!);
},
),
GoRoute(
path: _InternalAppRoutes.SIGNUP_PAGE,
builder:(_, __) => const SignUpPage(),
)
],
),
],
Expand Down Expand Up @@ -387,6 +392,7 @@ class _InternalAppRoutes {
static const String PREFERENCES_PAGE = '_preferences';
static const String SEARCH_PAGE = '_search';
static const String EXTERNAL_PAGE = '_external';
static const String SIGNUP_PAGE = '_signup';

static const String _GUIDES = '_guides';
static const String GUIDE_NUTRISCORE_V2_PAGE = '_nutriscore-v2';
Expand Down
16 changes: 16 additions & 0 deletions packages/smooth_app/lib/pages/user_management/sign_up_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:matomo_tracker/matomo_tracker.dart';
import 'package:openfoodfacts/openfoodfacts.dart';
import 'package:provider/provider.dart';
import 'package:smooth_app/data_models/preferences/user_preferences.dart';
import 'package:smooth_app/data_models/user_management_provider.dart';
import 'package:smooth_app/generic_lib/design_constants.dart';
import 'package:smooth_app/generic_lib/dialogs/smooth_alert_dialog.dart';
Expand Down Expand Up @@ -46,8 +47,20 @@ class _SignUpPageState extends State<SignUpPage> with TraceableClientMixin {
bool _subscribe = false;
bool _disagreed = false;

late UserPreferences _userPreferences;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UserPreferences is only used after a successful registration.
For all other scenarios, it's totally unnecessary.

Instead, you just need to access the preferences when you need it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay I see what you are saying


@override
String get actionName => 'Opened sign_up_page';

@override
void initState() {
super.initState();
getUserPreferences();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be careful about formatting your code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Launch the dartfmt command
https://docs.flutter.dev/tools/formatting

}

Future<void> getUserPreferences() async {
_userPreferences = await UserPreferences.getUserPreferences();
}

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -314,6 +327,7 @@ class _SignUpPageState extends State<SignUpPage> with TraceableClientMixin {
}

Future<void> _signUp() async {
///add and make complete onboarding false at signup.
final AppLocalizations appLocalisations = AppLocalizations.of(context);
_disagreed = !_agree;
setState(() {});
Expand Down Expand Up @@ -411,6 +425,8 @@ class _SignUpPageState extends State<SignUpPage> with TraceableClientMixin {
if (!mounted) {
return;
}
debugPrint('Reseting Onboarding');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For debugging purposes, you have our custom Log class

_userPreferences.resetOnboarding();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just get the preferences here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

await showDialog<void>(
context: context,
builder: (BuildContext context) => SmoothAlertDialog(
Expand Down