Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cat-voices): task picture scaling #882

Merged
merged 3 commits into from
Sep 25, 2024
Merged
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
37 changes: 30 additions & 7 deletions catalyst_voices/lib/pages/account/creation/task_picture.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,45 @@ class TaskKeychainPicture extends StatelessWidget {
}

class TaskPicture extends StatelessWidget {
final Size preferredSize;
final Widget child;

// Original size is 125 but we want to have it scale with overall picture
static const _childSizeFactor = 125 / 354;

const TaskPicture({
super.key,
// Original asset sizes. "Magic number" from figma.
this.preferredSize = const Size(354, 340),
required this.child,
});

@override
Widget build(BuildContext context) {
return Stack(
alignment: Alignment.topRight,
children: [
CatalystImage.asset(VoicesAssets.images.taskIllustration.path),
child,
],
return LayoutBuilder(
builder: (context, constraints) {
final size = constraints
.constrainSizeAndAttemptToPreserveAspectRatio(preferredSize);
final childSize = Size.square(size.width * _childSizeFactor);

return SizedBox.fromSize(
size: size,
child: Stack(
alignment: Alignment.topRight,
children: [
CatalystImage.asset(
VoicesAssets.images.taskIllustration.path,
width: size.width,
height: size.height,
),
ConstrainedBox(
constraints: BoxConstraints.tight(childSize),
child: child,
),
],
),
);
},
);
}
}
Expand All @@ -87,7 +111,6 @@ class TaskPictureIconBox extends StatelessWidget {
return IconTheme(
data: iconThemeData,
child: Container(
constraints: BoxConstraints.tight(const Size.square(125)),
decoration: BoxDecoration(
color: backgroundColor,
shape: BoxShape.circle,
Expand Down
Loading