Skip to content

Commit

Permalink
feat(app): maybe fit tutorial content
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Feb 25, 2025
1 parent d930901 commit 7f9f790
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ FutureOr<void> showDrugSelectionIntro(BuildContext context) =>
await MetaData.save();
},
firstBackButtonText: context.l10n.onboarding_prev,
fitToContent: true,
);
31 changes: 21 additions & 10 deletions app/lib/common/widgets/tutorial/tutorial_builder.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:expandable_page_view/expandable_page_view.dart';

import '../../module.dart';
import '../scrollable_stack_with_indicator.dart';
import 'tutorial_page.dart';
Expand All @@ -9,12 +11,14 @@ class TutorialBuilder extends HookWidget {
required this.initiateRouteBack,
this.lastNextButtonText,
this.firstBackButtonText,
required this.fitToContent,
});

final List<TutorialPage> pages;
final String? lastNextButtonText;
final String? firstBackButtonText;
final void Function() initiateRouteBack;
final bool fitToContent;

Widget getImageAsset(String assetPath) {
return Container(
Expand All @@ -33,23 +37,30 @@ class TutorialBuilder extends HookWidget {
);
final currentPageIndex = useState(0);
final pageController = usePageController(initialPage: currentPageIndex.value);
final pageView = fitToContent
? ExpandablePageView(
controller: pageController,
onPageChanged: (newPage) => currentPageIndex.value = newPage,
children: pageWidgets.toList(),
)
: Expanded(
child: PageView(
controller: pageController,
onPageChanged: (newPage) => currentPageIndex.value = newPage,
children: pageWidgets.toList(),
)
);
return Padding(
padding: EdgeInsets.only(
left: PharMeTheme.largeSpace,
bottom: PharMeTheme.largeSpace,
right: PharMeTheme.largeSpace,
left: PharMeTheme.mediumSpace,
bottom: PharMeTheme.mediumSpace,
right: PharMeTheme.mediumSpace,
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: PageView(
controller: pageController,
onPageChanged: (newPage) => currentPageIndex.value = newPage,
children: pageWidgets.toList(),
),
),
pageView,
Padding(
padding: EdgeInsets.only(top: PharMeTheme.smallSpace),
child: _buildActionBar(context, currentPageIndex, pageController),
Expand Down
2 changes: 2 additions & 0 deletions app/lib/common/widgets/tutorial/tutorial_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class TutorialController {
String? lastNextButtonText,
String? firstBackButtonText,
FutureOr<void> Function()? onClose,
bool fitToContent = false,
}) async {
if (_isOpen) return null;
_isOpen = true;
Expand All @@ -41,6 +42,7 @@ class TutorialController {
lastNextButtonText: lastNextButtonText,
firstBackButtonText: firstBackButtonText,
initiateRouteBack: initiateRouteBack,
fitToContent: fitToContent,
),
);
_isOpen = false;
Expand Down
8 changes: 8 additions & 0 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.3.9"
expandable_page_view:
dependency: "direct main"
description:
name: expandable_page_view
sha256: "210dc6961cfc29f7ed42867824eb699c9a4b9b198a7c04b8bdc1c05844969dc6"
url: "https://pub.dev"
source: hosted
version: "1.0.17"
fake_async:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies:
dartx: ^1.1.0
debug_overlay: ^0.2.11
dropdown_button2: ^2.3.9
expandable_page_view: ^1.0.17
flutter:
sdk: flutter
flutter_bloc: ^8.0.1
Expand Down

0 comments on commit 7f9f790

Please sign in to comment.