Skip to content

Commit a4c7bf1

Browse files
committed
Fix widows titleBar,
1 parent f249ab7 commit a4c7bf1

3 files changed

Lines changed: 64 additions & 62 deletions

File tree

lib/main.dart

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import 'dart:io';
2+
3+
import 'package:device_info_plus/device_info_plus.dart';
14
import 'package:flutter/foundation.dart';
25
import 'package:flutter/material.dart';
36
import 'package:flutter_acrylic/flutter_acrylic.dart';
@@ -15,13 +18,14 @@ Future<void> main() async {
1518
// Window.disableZoomButton();
1619
Window.makeTitlebarTransparent();
1720

18-
WindowOptions windowOptions = const WindowOptions(
19-
size: Size(1250, 700),
21+
WindowOptions windowOptions = WindowOptions(
22+
size: const Size(1250, 700),
2023
center: true,
21-
backgroundColor: Colors.transparent,
24+
// backgroundColor: Colors.transparent,
2225
skipTaskbar: false,
23-
titleBarStyle: TitleBarStyle.hidden,
24-
minimumSize: Size(1100, 600),
26+
titleBarStyle: Platform.isMacOS ? TitleBarStyle.hidden : TitleBarStyle.normal,
27+
title: 'Open Dev',
28+
minimumSize: const Size(1100, 600),
2529
);
2630

2731
windowManager.waitUntilReadyToShow(windowOptions, () async {
@@ -30,24 +34,17 @@ Future<void> main() async {
3034
});
3135
}
3236

33-
// await Window.setEffect(
34-
// effect: WindowEffect.mica,
35-
// );
36-
37-
// if (Platform.isWindows) {
38-
// await Window.hideWindowControls();
39-
// }
37+
if (Platform.isWindows) {
38+
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
39+
WindowsDeviceInfo deviceInfoWindows = await deviceInfo.windowsInfo;
40+
if (deviceInfoWindows.productName.contains('Windows 11')) {
41+
await Window.setEffect(
42+
effect: WindowEffect.mica,
43+
);
44+
}
45+
}
4046

4147
runApp(const MyApp());
42-
// if (Platform.isWindows) {
43-
// doWhenWindowReady(() {
44-
// appWindow
45-
// ..minSize = Size(640, 360)
46-
// ..size = Size(720, 540)
47-
// ..alignment = Alignment.center
48-
// ..show();
49-
// });
50-
// }
5148
}
5249

5350
class MyApp extends StatelessWidget {
@@ -59,16 +56,14 @@ class MyApp extends StatelessWidget {
5956
title: 'Open Dev',
6057
theme: ThemeData(useMaterial3: true, colorScheme: lightColorScheme),
6158
darkTheme: ThemeData(useMaterial3: true, colorScheme: darkColorScheme),
62-
// darkTheme: ThemeData.dark(
63-
// // colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
64-
// useMaterial3: true,
65-
// ),
66-
// theme: ThemeData(
67-
// colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
68-
// useMaterial3: true,
69-
// ),
7059
debugShowCheckedModeBanner: false,
71-
home: kIsWeb ? const BaseView() : const SafeArea(child: TitlebarSafeArea(child: BaseView())),
60+
home: kIsWeb
61+
? const BaseView()
62+
: const SafeArea(
63+
child: TitlebarSafeArea(
64+
child: BaseView(),
65+
),
66+
),
7267
);
7368
}
7469
}

lib/views/base_view.dart

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -44,38 +44,41 @@ class _BaseViewState extends State<BaseView> {
4444
Widget build(BuildContext context) {
4545
return Scaffold(
4646
backgroundColor: Colors.transparent,
47-
body: Row(
48-
mainAxisAlignment: MainAxisAlignment.start,
49-
children: [
50-
SideMenuWidget(sideMenu: sideMenu),
51-
const VerticalDivider(
52-
width: 0,
53-
),
54-
Expanded(
55-
child: PageView(
56-
controller: pageController,
57-
children: [
58-
DashboardView(sideMenu: sideMenu),
59-
const JsonView(),
60-
const XmlView(),
61-
const CronView(),
62-
const UnixTimeView(),
63-
const ReadmeView(),
64-
const NewsView(),
65-
const Base64View(),
66-
const JwtView(),
67-
const HashView(),
68-
const ColorView(),
69-
const RegexView(),
70-
const LoremView(),
71-
const PasswordView(),
72-
const QrView(),
73-
const ImageView(),
74-
const UrlView()
75-
],
47+
body: Padding(
48+
padding: const EdgeInsets.only(top: 8),
49+
child: Row(
50+
mainAxisAlignment: MainAxisAlignment.start,
51+
children: [
52+
SideMenuWidget(sideMenu: sideMenu),
53+
const VerticalDivider(
54+
width: 0,
7655
),
77-
),
78-
],
56+
Expanded(
57+
child: PageView(
58+
controller: pageController,
59+
children: [
60+
DashboardView(sideMenu: sideMenu),
61+
const JsonView(),
62+
const XmlView(),
63+
const CronView(),
64+
const UnixTimeView(),
65+
const ReadmeView(),
66+
const NewsView(),
67+
const Base64View(),
68+
const JwtView(),
69+
const HashView(),
70+
const ColorView(),
71+
const RegexView(),
72+
const LoremView(),
73+
const PasswordView(),
74+
const QrView(),
75+
const ImageView(),
76+
const UrlView()
77+
],
78+
),
79+
),
80+
],
81+
),
7982
),
8083
);
8184
}

lib/widgets/side_menu_widget.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'dart:io';
33
import 'package:easy_sidemenu/easy_sidemenu.dart';
44
import 'package:flutter/cupertino.dart';
55
import 'package:flutter/material.dart';
6+
import 'package:flutter_acrylic/flutter_acrylic.dart';
67
import 'package:flutter_acrylic/widgets/transparent_macos_sidebar.dart';
78

89
class SideMenuWidget extends StatelessWidget {
@@ -163,6 +164,9 @@ class SideMenuWidget extends StatelessWidget {
163164
);
164165
}
165166

166-
return Platform.isMacOS ? TransparentMacOSSidebar(child: _side()) : _side();
167+
return TransparentMacOSSidebar(
168+
effect: Platform.isMacOS ? WindowEffect.sidebar : WindowEffect.mica,
169+
child: _side(),
170+
);
167171
}
168172
}

0 commit comments

Comments
 (0)