| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import 'package:flutter/material.dart';
- import '../theme/app_colors.dart';
- /// The soft paper-like card used for the volume control, shortcuts and
- /// settings sections.
- class SurfaceCard extends StatelessWidget {
- const SurfaceCard({
- super.key,
- required this.child,
- this.padding = const EdgeInsets.all(24),
- this.radius = 28,
- this.color,
- this.borderColor,
- this.showShadow = true,
- this.onTap,
- });
- final Widget child;
- final EdgeInsetsGeometry padding;
- final double radius;
- final Color? color;
- final Color? borderColor;
- final bool showShadow;
- final VoidCallback? onTap;
- @override
- Widget build(BuildContext context) {
- final colors = context.colors;
- final isDark = Theme.of(context).brightness == Brightness.dark;
- final decoration = BoxDecoration(
- color: color ?? colors.surface,
- borderRadius: BorderRadius.circular(radius),
- border: Border.all(color: borderColor ?? colors.border),
- boxShadow: showShadow
- ? [
- BoxShadow(
- color: colors.shadow.withValues(alpha: isDark ? 0.24 : 0.045),
- blurRadius: isDark ? 28 : 30,
- offset: const Offset(0, 12),
- ),
- ]
- : null,
- );
- final content = Container(
- padding: padding,
- decoration: decoration,
- child: child,
- );
- if (onTap == null) return content;
- return Material(
- color: Colors.transparent,
- child: InkWell(
- onTap: onTap,
- borderRadius: BorderRadius.circular(radius),
- child: content,
- ),
- );
- }
- }
|