63 lines
1.7 KiB
Dart
63 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../theme/app_palette.dart';
|
|
|
|
class SurfaceCard extends StatefulWidget {
|
|
const SurfaceCard({
|
|
super.key,
|
|
required this.child,
|
|
this.padding = const EdgeInsets.all(16),
|
|
this.onTap,
|
|
this.borderRadius = 16,
|
|
this.color,
|
|
});
|
|
|
|
final Widget child;
|
|
final EdgeInsetsGeometry padding;
|
|
final VoidCallback? onTap;
|
|
final double borderRadius;
|
|
final Color? color;
|
|
|
|
@override
|
|
State<SurfaceCard> createState() => _SurfaceCardState();
|
|
}
|
|
|
|
class _SurfaceCardState extends State<SurfaceCard> {
|
|
bool _hovered = false;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final palette = context.palette;
|
|
final baseColor = widget.color ?? palette.surfacePrimary;
|
|
|
|
return MouseRegion(
|
|
onEnter: (_) => setState(() => _hovered = true),
|
|
onExit: (_) => setState(() => _hovered = false),
|
|
child: AnimatedContainer(
|
|
duration: const Duration(milliseconds: 180),
|
|
curve: Curves.easeOutCubic,
|
|
decoration: BoxDecoration(
|
|
color: _hovered ? palette.surfaceSecondary : baseColor,
|
|
borderRadius: BorderRadius.circular(widget.borderRadius),
|
|
border: Border.all(color: palette.strokeSoft),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: palette.shadow.withValues(alpha: _hovered ? 0.08 : 0.05),
|
|
blurRadius: _hovered ? 10 : 6,
|
|
offset: const Offset(0, 3),
|
|
),
|
|
],
|
|
),
|
|
child: Material(
|
|
color: Colors.transparent,
|
|
child: InkWell(
|
|
borderRadius: BorderRadius.circular(widget.borderRadius),
|
|
onTap: widget.onTap,
|
|
child: Padding(padding: widget.padding, child: widget.child),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|