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

feat(cat-voices): account creation task picture #879

Merged
merged 3 commits into from
Sep 24, 2024
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
100 changes: 100 additions & 0 deletions catalyst_voices/lib/pages/account/creation/task_picture.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart';
import 'package:catalyst_voices_brands/catalyst_voices_brands.dart';
import 'package:flutter/material.dart';

enum TaskPictureType {
normal,
success,
error;

Color _foregroundColor(ThemeData theme) {
return switch (this) {
// TODO(damian-molinski): Color should come from colors scheme
TaskPictureType.normal => const Color(0xFF0C288D),
TaskPictureType.success => theme.colors.successContainer!,
TaskPictureType.error => theme.colors.errorContainer!,
};
}

Color _backgroundColor(ThemeData theme) {
return switch (this) {
// TODO(damian-molinski): Color should come from colors scheme
TaskPictureType.normal => const Color(0xFFCCE2FF),
TaskPictureType.success => theme.colors.success!,
TaskPictureType.error => theme.colorScheme.error,
};
}
}

class TaskKeychainPicture extends StatelessWidget {
final TaskPictureType type;

const TaskKeychainPicture({
super.key,
this.type = TaskPictureType.normal,
});

@override
Widget build(BuildContext context) {
return TaskPicture(
child: TaskPictureIconBox(
type: type,
child: VoicesAssets.images.keychain.buildIcon(allowSize: false),
),
);
}
}

class TaskPicture extends StatelessWidget {
final Widget child;

const TaskPicture({
super.key,
required this.child,
});

@override
Widget build(BuildContext context) {
return Stack(
alignment: Alignment.topRight,
children: [
CatalystImage.asset(VoicesAssets.images.taskIllustration.path),
child,
],
);
}
}

class TaskPictureIconBox extends StatelessWidget {
final TaskPictureType type;
final Widget child;

const TaskPictureIconBox({
super.key,
this.type = TaskPictureType.normal,
required this.child,
});

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);

final foregroundColor = type._foregroundColor(theme);
final backgroundColor = type._backgroundColor(theme);

final iconThemeData = IconThemeData(color: foregroundColor);

return IconTheme(
data: iconThemeData,
child: Container(
constraints: BoxConstraints.tight(const Size.square(125)),
decoration: BoxDecoration(
color: backgroundColor,
shape: BoxShape.circle,
),
alignment: Alignment.center,
child: child,
),
);
}
}
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.

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

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

Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ extension SvgGenImageExt on SvgGenImage {
String? semanticsLabel,
bool excludeFromSemantics = false,
double? size,
bool allowSize = true,
BoxFit fit = BoxFit.contain,
Alignment alignment = Alignment.center,
bool matchTextDirection = false,
Expand All @@ -105,6 +106,7 @@ extension SvgGenImageExt on SvgGenImage {
semanticsLabel: semanticsLabel,
excludeFromSemantics: excludeFromSemantics,
size: size,
allowSize: allowSize,
fit: fit,
alignment: alignment,
matchTextDirection: matchTextDirection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ class CatalystSvgIcon extends StatelessWidget {
/// See [SvgPicture.width] and [SvgPicture.height]
final double? size;

/// Whether [size] can be applied to final widget.
final bool allowSize;

/// See [SvgPicture.fit]
final BoxFit fit;

Expand Down Expand Up @@ -54,6 +57,7 @@ class CatalystSvgIcon extends StatelessWidget {
this.bytesLoader, {
super.key,
this.size,
this.allowSize = true,
this.fit = BoxFit.contain,
this.alignment = Alignment.center,
this.matchTextDirection = false,
Expand All @@ -77,6 +81,7 @@ class CatalystSvgIcon extends StatelessWidget {
String? package = 'catalyst_voices_assets',
SvgTheme? theme,
this.size,
this.allowSize = true,
this.fit = BoxFit.contain,
this.alignment = Alignment.center,
this.matchTextDirection = false,
Expand All @@ -101,7 +106,7 @@ class CatalystSvgIcon extends StatelessWidget {

@override
Widget build(BuildContext context) {
final effectiveSize = size ?? IconTheme.of(context).size;
final effectiveSize = allowSize ? size ?? IconTheme.of(context).size : null;
final effectiveColorFilter = allowColorFilter
? _colorFilter ?? IconTheme.of(context).asColorFilter()
: null;
Expand Down
Loading