Skip to content

Commit

Permalink
refactor(app): add function to create tutorial image asset
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Sep 4, 2024
1 parent 050d2ac commit fc5c135
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions app/lib/common/widgets/tutorial/tutorial_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ class TutorialBuilder extends HookWidget {
final List<TutorialPage> pages;
final String? lastNextButtonText;

Widget getImageAsset(String assetPath) {
return Container(
color: PharMeTheme.onSurfaceColor,
child: Center(child: Image.asset(assetPath)),
);
}

@override
Widget build(BuildContext context) {
final currentPageIndex = useState(0);
Expand Down Expand Up @@ -39,19 +46,13 @@ class TutorialBuilder extends HookWidget {
final content = currentPage.content != null
? currentPage.content!(context)
: null;
final imageAsset = currentPage.assetPath != null
? Container(
color: PharMeTheme.onSurfaceColor,
child: Center(child: Image.asset(currentPage.assetPath!)),
)
: null;
final titleStyle = PharMeTheme.textTheme.headlineMedium!.copyWith(
fontSize: PharMeTheme.textTheme.headlineSmall!.fontSize,
);
final assetContainer = imageAsset != null
final assetContainer = currentPage.assetPath != null
? Stack(
children: [
imageAsset,
getImageAsset(currentPage.assetPath!),
Positioned(
top: PharMeTheme.smallSpace,
right: PharMeTheme.smallSpace,
Expand Down Expand Up @@ -98,7 +99,7 @@ class TutorialBuilder extends HookWidget {
),
SizedBox(height: PharMeTheme.smallToMediumSpace),
Expanded(
child: imageAsset,
child: getImageAsset(currentPage.assetPath!),
),
],
),
Expand Down

0 comments on commit fc5c135

Please sign in to comment.