Skip to content

Commit

Permalink
feat(app): test if can pop for showing back button
Browse files Browse the repository at this point in the history
  • Loading branch information
tamara-slosarek authored and tamslo committed Jan 3, 2025
1 parent 749985b commit e7494c2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
10 changes: 5 additions & 5 deletions app/lib/common/widgets/tutorial/show_app_tour.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ FutureOr<void> showAppTour(
onClose: revisiting
? null
: () async {
MetaData.instance.tutorialDone = true;
await MetaData.save();
// ignore: use_build_context_synchronously
await overwriteRoutes(context, nextPage: MainRoute());
},
MetaData.instance.tutorialDone = true;
await MetaData.save();
// ignore: use_build_context_synchronously
await overwriteRoutes(context, nextPage: MainRoute());
},
lastNextButtonText: lastNextButtonText,
firstBackButtonText: revisiting ? null : context.l10n.onboarding_prev,
);
13 changes: 10 additions & 3 deletions app/lib/common/widgets/tutorial/tutorial_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,13 @@ class TutorialBuilder extends HookWidget {
ValueNotifier<int> currentPageIndex,
) {
final isFirstPage = currentPageIndex.value == 0;
final showFirstButton =
!isFirstPage || firstBackButtonText.isNotNullOrBlank;
final showFirstButton = !isFirstPage || (
firstBackButtonText.isNotNullOrBlank &&
context.router.canPop(
ignoreChildRoutes: true,
ignorePagelessRoutes: true,
)
);
final isLastPage = currentPageIndex.value == pages.length - 1;
final directionButtonTextStyle =
PharMeTheme.textTheme.titleLarge!.copyWith(fontSize: 20);
Expand All @@ -164,7 +169,9 @@ class TutorialBuilder extends HookWidget {
initiateRouteBack();
final currentRoute = context.router.current.name;
context.router.popUntil(
(route) => route.settings.name != null && route.settings.name != currentRoute,
(route) =>
route.settings.name != null &&
route.settings.name != currentRoute,
);
}
: () => currentPageIndex.value = currentPageIndex.value - 1,
Expand Down

0 comments on commit e7494c2

Please sign in to comment.