56 lines
1.4 KiB
Dart
56 lines
1.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../theme/app_theme.dart';
|
|
|
|
/// Reusable glassmorphic container widget adapting to active ThemePreset.
|
|
class GlassContainer extends StatelessWidget {
|
|
final Widget child;
|
|
final EdgeInsetsGeometry? padding;
|
|
final EdgeInsetsGeometry? margin;
|
|
final double? width;
|
|
final double? height;
|
|
final double? borderRadius;
|
|
final VoidCallback? onTap;
|
|
|
|
const GlassContainer({
|
|
super.key,
|
|
required this.child,
|
|
this.padding = const EdgeInsets.all(16),
|
|
this.margin,
|
|
this.width,
|
|
this.height,
|
|
this.borderRadius,
|
|
this.onTap,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final activeTheme = AppTheme.activePreset;
|
|
final effectiveRadius = borderRadius ?? activeTheme.borderRadius;
|
|
|
|
final body = AnimatedContainer(
|
|
duration: const Duration(milliseconds: 250),
|
|
width: width,
|
|
height: height,
|
|
margin: margin,
|
|
padding: padding,
|
|
decoration: BoxDecoration(
|
|
color: activeTheme.glassSurface,
|
|
borderRadius: BorderRadius.circular(effectiveRadius),
|
|
border: Border.all(color: activeTheme.glassBorder, width: 1),
|
|
boxShadow: activeTheme.boxShadows,
|
|
),
|
|
child: child,
|
|
);
|
|
|
|
if (onTap != null) {
|
|
return InkWell(
|
|
onTap: onTap,
|
|
borderRadius: BorderRadius.circular(effectiveRadius),
|
|
child: body,
|
|
);
|
|
}
|
|
|
|
return body;
|
|
}
|
|
}
|