import 'package:flutter/material.dart'; class MwWindowChrome extends StatelessWidget { const MwWindowChrome({ super.key, required this.onDrag, required this.onDoubleTap, required this.onMinimize, required this.onMaximizeRestore, required this.onClose, this.showMaximize = true, }); final VoidCallback onDrag; final VoidCallback onDoubleTap; final VoidCallback onMinimize; final VoidCallback onMaximizeRestore; final VoidCallback onClose; final bool showMaximize; @override Widget build(BuildContext context) { return Container( height: 40.0, padding: .symmetric(horizontal: 12.0), child: Row( spacing: 4.0, children: [ const Spacer(), _WindowButton( icon: Icons.remove, label: 'Свернуть', onPressed: onMinimize, ), if (showMaximize) _WindowButton( icon: Icons.crop_square, label: 'Развернуть или восстановить', onPressed: onMaximizeRestore, ), _WindowButton( icon: Icons.close, label: 'Закрыть', destructive: true, onPressed: onClose, ), ], ), ); } } class _WindowButton extends StatelessWidget { const _WindowButton({ required this.icon, required this.label, required this.onPressed, this.destructive = false, }); final IconData icon; final String label; final VoidCallback onPressed; final bool destructive; @override Widget build(BuildContext context) { final scheme = Theme.of(context).colorScheme; return Tooltip( message: label, child: Semantics( button: true, label: label, child: IconButton( onPressed: onPressed, icon: Icon(icon, size: 16), color: scheme.onSurfaceVariant, hoverColor: destructive ? scheme.error.withAlpha(180) : scheme.onSurface.withAlpha(20), focusColor: scheme.primary.withAlpha(50), style: IconButton.styleFrom( tapTargetSize: .shrinkWrap, visualDensity: VisualDensity( horizontal: VisualDensity.minimumDensity, vertical: VisualDensity.minimumDensity, ), fixedSize: const Size(36.0, 28.0), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(4.0), ), ), ), ), ); } }