Skip to content

Commit a2b151c

Browse files
Merge pull request #474 from QueryaHub/issue/473-macos-bitsdojo-frame
fix(macos): bitsdojo custom frame and traffic-light inset (#473)
2 parents a4b054f + e08e90e commit a2b151c

3 files changed

Lines changed: 41 additions & 2 deletions

File tree

lib/features/main_screen/querya_window_title_bar.dart

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'dart:io' show Platform;
2+
13
import 'package:bitsdojo_window/bitsdojo_window.dart';
24
import 'package:flutter/material.dart' as material;
35
import 'package:querya_desktop/core/layout/ui_scale.dart';
@@ -57,6 +59,15 @@ class QueryaWindowTitleBar extends StatelessWidget {
5759
);
5860
}
5961

62+
@visibleForTesting
63+
static double titleBarLeadingInset({
64+
required bool isMacOS,
65+
required double Function(double designPx) scale,
66+
}) {
67+
// macOS traffic lights sit in the transparent titlebar (bitsdojo custom frame).
68+
return scale(isMacOS ? 72 : 16);
69+
}
70+
6071
@visibleForTesting
6172
static WindowButtonColors closeButtonColors(BuildContext context) {
6273
final wb = context.workbench;
@@ -85,7 +96,12 @@ class QueryaWindowTitleBar extends StatelessWidget {
8596
child: MoveWindow(
8697
child: Row(
8798
children: [
88-
const SizedBox(width: 16),
99+
SizedBox(
100+
width: QueryaWindowTitleBar.titleBarLeadingInset(
101+
isMacOS: Platform.isMacOS,
102+
scale: context.scaled,
103+
),
104+
),
89105
material.Icon(
90106
material.Icons.storage_rounded,
91107
size: 18,

macos/Runner/MainFlutterWindow.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import Cocoa
22
import FlutterMacOS
3+
import bitsdojo_window_macos
4+
5+
class MainFlutterWindow: BitsdojoWindow {
6+
override func bitsdojo_window_configure() -> UInt {
7+
return BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP
8+
}
39

4-
class MainFlutterWindow: NSWindow {
510
override func awakeFromNib() {
611
let flutterViewController = FlutterViewController()
712
let windowFrame = self.frame

test/features/main_screen/querya_window_title_bar_test.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,24 @@ void main() {
9797
expect(background, _customSurface);
9898
});
9999

100+
testWidgets('title bar leading inset reserves macOS traffic-light space',
101+
(tester) async {
102+
expect(
103+
QueryaWindowTitleBar.titleBarLeadingInset(
104+
isMacOS: true,
105+
scale: (v) => v,
106+
),
107+
72,
108+
);
109+
expect(
110+
QueryaWindowTitleBar.titleBarLeadingInset(
111+
isMacOS: false,
112+
scale: (v) => v,
113+
),
114+
16,
115+
);
116+
});
117+
100118
testWidgets('read-only state is persistently visible in title bar',
101119
(tester) async {
102120
await tester.pumpWidget(

0 commit comments

Comments
 (0)