import 'dart:ui'; import 'package:flutter/material.dart'; import '../theme/app_theme.dart'; /// Conteneur avec effet de verre givré (Glassmorphism), /// bordures translucides fines et reflets subtils pour casser l'aspect standard Flutter. class GlassContainer extends StatelessWidget { final Widget child; final double borderRadius; final double blur; final EdgeInsetsGeometry padding; final EdgeInsetsGeometry margin; final Color? customBackgroundColor; final Color? borderColor; final Color? glowColor; final VoidCallback? onTap; final VoidCallback? onLongPress; const GlassContainer({ super.key, required this.child, this.borderRadius = 18.0, this.blur = 12.0, this.padding = const EdgeInsets.all(16.0), this.margin = EdgeInsets.zero, this.customBackgroundColor, this.borderColor, this.glowColor, this.onTap, this.onLongPress, }); @override Widget build(BuildContext context) { final isDark = Theme.of(context).brightness == Brightness.dark; final defaultBg = isDark ? const Color(0xFF141C26).withValues(alpha: 0.72) : Colors.white.withValues(alpha: 0.82); final defaultBorder = isDark ? Colors.white.withValues(alpha: 0.12) : Colors.black.withValues(alpha: 0.08); final resolvedBorderColor = borderColor ?? defaultBorder; final resolvedBg = customBackgroundColor ?? defaultBg; Widget content = Container( padding: padding, decoration: BoxDecoration( color: resolvedBg, borderRadius: BorderRadius.circular(borderRadius), border: Border.all(color: resolvedBorderColor, width: 1.2), boxShadow: [ if (glowColor != null) BoxShadow( color: glowColor!.withValues(alpha: isDark ? 0.25 : 0.15), blurRadius: 18, spreadRadius: -2, offset: const Offset(0, 4), ) else BoxShadow( color: Colors.black.withValues(alpha: isDark ? 0.28 : 0.04), blurRadius: 16, offset: const Offset(0, 6), ), ], ), child: child, ); if (blur > 0) { content = ClipRRect( borderRadius: BorderRadius.circular(borderRadius), child: BackdropFilter( filter: ImageFilter.blur(sigmaX: blur, sigmaY: blur), child: content, ), ); } else { content = ClipRRect( borderRadius: BorderRadius.circular(borderRadius), child: content, ); } if (margin != EdgeInsets.zero) { content = Padding(padding: margin, child: content); } if (onTap != null || onLongPress != null) { return Material( color: Colors.transparent, borderRadius: BorderRadius.circular(borderRadius), child: InkWell( borderRadius: BorderRadius.circular(borderRadius), onTap: onTap, onLongPress: onLongPress, splashColor: (glowColor ?? AppTheme.primaryColor).withValues(alpha: 0.15), highlightColor: (glowColor ?? AppTheme.primaryColor).withValues(alpha: 0.08), child: content, ), ); } return content; } }