Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

feat: add instructions background #163

Merged
merged 3 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/images/instructions_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class _GameInstructionsOverlayViewState
return AppDialog(
border: Border.all(color: Colors.white24),
backgroundColor: Colors.white24,
imageProvider: Assets.images.instructionsBackground.provider(),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Expand All @@ -138,12 +139,11 @@ class _GameInstructionsOverlayViewState
},
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 24),
child: GameInstructionNavigationControls(
pageController: pageController,
),
const SizedBox(height: 24),
GameInstructionNavigationControls(
pageController: pageController,
),
const SizedBox(height: 16),
],
),
);
Expand Down
44 changes: 40 additions & 4 deletions lib/gen/assets.gen.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 16 additions & 3 deletions packages/app_ui/lib/src/widgets/app_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class AppCard extends StatelessWidget {
),
this.borderRadius = const BorderRadius.all(Radius.circular(24)),
this.border,
this.imageProvider,
super.key,
});

Expand All @@ -38,20 +39,32 @@ class AppCard extends StatelessWidget {
/// The border of the card.
final BoxBorder? border;

/// The background image of the card. Setting the image makes the [gradient]
/// and [backgroundColor] invisible. Also removes the border.
final ImageProvider<Object>? imageProvider;

@override
Widget build(BuildContext context) {
final showImage = imageProvider != null;

return Container(
constraints: const BoxConstraints(maxWidth: 328, maxHeight: 624),
decoration: BoxDecoration(
borderRadius: borderRadius,
border: border,
color: backgroundColor,
border: showImage ? null : border,
color: showImage ? null : backgroundColor,
),
child: Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
borderRadius: borderRadius,
gradient: gradient,
gradient: showImage ? null : gradient,
image: showImage
? DecorationImage(
image: imageProvider!,
fit: BoxFit.cover,
)
: null,
),
child: child,
),
Expand Down
6 changes: 6 additions & 0 deletions packages/app_ui/lib/src/widgets/app_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class AppDialog extends StatelessWidget {
),
this.borderRadius = const BorderRadius.all(Radius.circular(24)),
this.border,
this.imageProvider,
super.key,
});

Expand All @@ -43,6 +44,10 @@ class AppDialog extends StatelessWidget {
/// The border of the dialog.
final BoxBorder? border;

/// The background image of the dialog. Setting the image makes the [gradient]
/// and [backgroundColor] invisible. Also removes the border.
final ImageProvider<Object>? imageProvider;

@override
Widget build(BuildContext context) {
return Dialog(
Expand All @@ -54,6 +59,7 @@ class AppDialog extends StatelessWidget {
gradient: gradient,
backgroundColor: backgroundColor,
borderRadius: borderRadius,
imageProvider: imageProvider,
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
Expand Down