Skip to content

Commit

Permalink
feat: generic card
Browse files Browse the repository at this point in the history
  • Loading branch information
vitormpp committed Nov 19, 2024
1 parent 8e48bc5 commit 38400c3
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions packages/uni_ui/lib/generic_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class GenericCard extends StatelessWidget {
this.borderRadius,
this.onClick,
this.child,
required this.tooltip,
});

final EdgeInsetsGeometry? margin;
Expand All @@ -20,16 +21,29 @@ class GenericCard extends StatelessWidget {
final double? borderRadius;
final Function? onClick;
final Widget? child;
final String tooltip;

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

return Padding(
padding: margin ?? cardTheme.margin ?? const EdgeInsets.all(4),
child: GestureDetector(
onTap: () => onClick,
return Tooltip(
message: tooltip,
child: Container(
margin: margin ?? cardTheme.margin ?? const EdgeInsets.all(4),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: shadowColor ??
cardTheme.shadowColor ??
Colors.black.withOpacity(0.15),
blurRadius: 12,
spreadRadius: -4,
offset: const Offset(0, 6),
),
],
),
child: ClipSmoothRect(
radius: SmoothBorderRadius(
cornerRadius: borderRadius ?? 20,
Expand All @@ -40,17 +54,14 @@ class GenericCard extends StatelessWidget {
color: color ??
cardTheme.color ??
theme.colorScheme.surfaceContainer,
boxShadow: [
BoxShadow(
color: shadowColor ??
cardTheme.shadowColor ??
Colors.black.withOpacity(0.25),
blurRadius: 6,
),
],
),
child: Padding(
padding: padding ?? const EdgeInsets.all(10), child: child),
padding: padding ?? const EdgeInsets.all(10),
child: GestureDetector(
onTap: onClick != null ? () => onClick!() : null,
child: child,
),
),
),
),
),
Expand Down

0 comments on commit 38400c3

Please sign in to comment.