part of 'components.dart'; class HoverBox extends StatefulWidget { const HoverBox( {super.key, required this.child, this.borderRadius = BorderRadius.zero}); final Widget child; final BorderRadius borderRadius; @override State createState() => _HoverBoxState(); } class _HoverBoxState extends State { bool isHover = false; @override Widget build(BuildContext context) { return MouseRegion( onEnter: (_) => setState(() => isHover = true), onExit: (_) => setState(() => isHover = false), cursor: SystemMouseCursors.click, child: AnimatedContainer( duration: const Duration(milliseconds: 200), decoration: BoxDecoration( color: isHover ? Theme.of(context).colorScheme.surfaceContainerLow : null, borderRadius: widget.borderRadius), child: widget.child, ), ); } } enum ButtonType { filled, outlined, text, normal } class Button extends StatefulWidget { const Button( {super.key, required this.type, required this.child, this.isLoading = false, this.width, this.height, this.padding, this.color, this.onPressedAt, required this.onPressed}); const Button.filled( {super.key, required this.child, required this.onPressed, this.width, this.height, this.padding, this.color, this.onPressedAt, this.isLoading = false}) : type = ButtonType.filled; const Button.outlined( {super.key, required this.child, required this.onPressed, this.width, this.height, this.padding, this.color, this.onPressedAt, this.isLoading = false}) : type = ButtonType.outlined; const Button.text( {super.key, required this.child, required this.onPressed, this.width, this.height, this.padding, this.color, this.onPressedAt, this.isLoading = false}) : type = ButtonType.text; const Button.normal( {super.key, required this.child, required this.onPressed, this.width, this.height, this.padding, this.color, this.onPressedAt, this.isLoading = false}) : type = ButtonType.normal; static Widget icon( {Key? key, required Widget icon, required VoidCallback onPressed, double? size, Color? color, String? tooltip}) { return _IconButton( key: key, icon: icon, onPressed: onPressed, size: size, color: color, tooltip: tooltip, ); } final ButtonType type; final Widget child; final bool isLoading; final void Function() onPressed; final void Function(Offset location)? onPressedAt; final double? width; final double? height; final EdgeInsets? padding; final Color? color; @override State