mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
new: custom titlebar on linux/win
This commit is contained in:
@@ -128,7 +128,10 @@ void _setupLogger() {
|
|||||||
|
|
||||||
Future<void> _initDesktopWindow() async {
|
Future<void> _initDesktopWindow() async {
|
||||||
if (!isDesktop) return;
|
if (!isDesktop) return;
|
||||||
|
|
||||||
await windowManager.ensureInitialized();
|
await windowManager.ensureInitialized();
|
||||||
|
await CustomAppBar.updateTitlebarHeight();
|
||||||
|
|
||||||
const windowOptions = WindowOptions(
|
const windowOptions = WindowOptions(
|
||||||
size: Size(400, 777),
|
size: Size(400, 777),
|
||||||
center: true,
|
center: true,
|
||||||
@@ -136,9 +139,7 @@ Future<void> _initDesktopWindow() async {
|
|||||||
skipTaskbar: false,
|
skipTaskbar: false,
|
||||||
titleBarStyle: TitleBarStyle.hidden,
|
titleBarStyle: TitleBarStyle.hidden,
|
||||||
);
|
);
|
||||||
|
|
||||||
windowManager.waitUntilReadyToShow(windowOptions, () async {
|
windowManager.waitUntilReadyToShow(windowOptions, () async {
|
||||||
if (isMacOS) await CustomAppBar.updateTitlebarHeight();
|
|
||||||
await windowManager.show();
|
await windowManager.show();
|
||||||
await windowManager.focus();
|
await windowManager.focus();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -40,31 +40,42 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
Positioned(
|
Positioned(
|
||||||
right: 0,
|
right: 0,
|
||||||
top: 0,
|
top: 0,
|
||||||
child: Row(
|
child: GestureDetector(
|
||||||
children: [
|
onVerticalDragStart: (_) {
|
||||||
const SizedBox(width: 8),
|
windowManager.startDragging();
|
||||||
IconButton(
|
},
|
||||||
icon: const Icon(Icons.minimize),
|
onHorizontalDragStart: (_) {
|
||||||
onPressed: () => windowManager.minimize(),
|
windowManager.startDragging();
|
||||||
),
|
},
|
||||||
const SizedBox(width: 8),
|
child: Row(
|
||||||
IconButton(
|
mainAxisSize: MainAxisSize.max,
|
||||||
icon: const Icon(Icons.crop_square),
|
children: [
|
||||||
onPressed: () async {
|
const SizedBox(width: 8),
|
||||||
if (await windowManager.isMaximized()) {
|
IconButton(
|
||||||
windowManager.unmaximize();
|
icon: Transform.translate(
|
||||||
} else {
|
offset: const Offset(0, -3.5),
|
||||||
windowManager.maximize();
|
child: const Icon(Icons.minimize, size: 13),
|
||||||
}
|
),
|
||||||
},
|
onPressed: () => windowManager.minimize(),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.close),
|
icon: const Icon(Icons.crop_square, size: 13),
|
||||||
onPressed: () => windowManager.close(),
|
onPressed: () async {
|
||||||
),
|
if (await windowManager.isMaximized()) {
|
||||||
const SizedBox(width: 8),
|
windowManager.unmaximize();
|
||||||
],
|
} else {
|
||||||
|
windowManager.maximize();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.close, size: 14),
|
||||||
|
onPressed: () => windowManager.close(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -78,7 +89,7 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
break;
|
break;
|
||||||
// Draw a titlebar on Linux
|
// Draw a titlebar on Linux
|
||||||
case 'linux' || 'windows':
|
case 'linux' || 'windows':
|
||||||
_titlebarHeight = 27;
|
_titlebarHeight = 37;
|
||||||
_drawTitlebar = true;
|
_drawTitlebar = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user