68 lines
1.6 KiB
Dart
68 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:window_manager/window_manager.dart';
|
|
|
|
class CustomTitleBar extends StatelessWidget {
|
|
const CustomTitleBar({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Positioned(
|
|
top: 0,
|
|
left: 0,
|
|
right: 0,
|
|
child: DragToMoveArea(
|
|
child: SizedBox(
|
|
height: 40,
|
|
child: Stack(
|
|
children: [
|
|
const Positioned.fill(
|
|
child: SizedBox.shrink(),
|
|
),
|
|
Positioned(
|
|
right: 0,
|
|
top: 0,
|
|
bottom: 0,
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
_BarButton(
|
|
icon: Icons.horizontal_rule,
|
|
onTap: () => windowManager.minimize(),
|
|
),
|
|
_BarButton(
|
|
icon: Icons.close,
|
|
onTap: () => windowManager.close(),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _BarButton extends StatelessWidget {
|
|
final IconData icon;
|
|
final VoidCallback onTap;
|
|
|
|
const _BarButton({required this.icon, required this.onTap});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GestureDetector(
|
|
onTap: onTap,
|
|
child: MouseRegion(
|
|
cursor: SystemMouseCursors.click,
|
|
child: SizedBox(
|
|
width: 44,
|
|
height: 40,
|
|
child: Icon(icon, color: Colors.white54, size: 18),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|