Skip to content

Commit

Permalink
Merge branch 'develop' into feat/5586_3
Browse files Browse the repository at this point in the history
  • Loading branch information
monsieurtanuki authored Oct 21, 2024
2 parents dcd7dab + a4b3632 commit 618a135
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 10 additions & 2 deletions packages/smooth_app/lib/pages/navigator/app_navigator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ class AppNavigator extends InheritedWidget {
_router.router.pushReplacement(routeName, extra: extra);
}

/// Remove all the screens from the stack
void clearStack() {
while (_router.router.canPop() == true) {
_router.router.pop();
}
}

void pop([dynamic result]) {
_router.router.pop(result);
}
Expand Down Expand Up @@ -286,7 +293,7 @@ class _SmoothGoRouter {
externalLink = true;
}
} else if (path == _ExternalRoutes.MOBILE_APP_DOWNLOAD) {
return AppRoutes.HOME;
return AppRoutes.HOME();
} else if (path == _ExternalRoutes.GUIDE_NUTRISCORE_V2) {
return AppRoutes.GUIDE_NUTRISCORE_V2;
} else if (path == _ExternalRoutes.SIGNUP) {
Expand Down Expand Up @@ -421,7 +428,8 @@ class AppRoutes {
AppRoutes._();

// Home page (or walkthrough during the onboarding)
static String get HOME => _InternalAppRoutes.HOME_PAGE;
static String HOME({bool redraw = false}) =>
'${_InternalAppRoutes.HOME_PAGE}?redraw:$redraw';

// Product details (a [Product] is mandatory in the extra)
static String PRODUCT(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,23 @@ class OnboardingFlowNavigator {
static final List<OnboardingPage> _historyOnboardingNav = <OnboardingPage>[];

Future<void> navigateToPage(BuildContext context, OnboardingPage page) async {
_userPreferences.setLastVisitedOnboardingPage(page);
await _userPreferences.setLastVisitedOnboardingPage(page);
_historyOnboardingNav.add(page);

final MaterialPageRoute<void> route = MaterialPageRoute<void>(
builder: (BuildContext context) => page.getPageWidget(context),
);
if (!context.mounted) {
return;
}

if (page.isOnboardingComplete()) {
AppNavigator.of(context).pushReplacement(AppRoutes.HOME);
AppNavigator.of(context)
..clearStack()
..pushReplacement(
AppRoutes.HOME(redraw: true),
);
} else {
final MaterialPageRoute<void> route = MaterialPageRoute<void>(
builder: (BuildContext context) => page.getPageWidget(context),
);
await Navigator.of(context).push<void>(route);
}
}
Expand Down

0 comments on commit 618a135

Please sign in to comment.