From 566ebde1dd96396cf8cf80bd1917c28aa809346e Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Mon, 24 Feb 2025 21:59:41 +0800 Subject: [PATCH] :bug: Fix windows tray issue --- lib/main.dart | 8 +++-- lib/screens/home.dart | 1 - lib/widgets/navigation/app_scaffold.dart | 45 +++++++++--------------- 3 files changed, 23 insertions(+), 31 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 12d5994..e025f6a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -369,7 +369,7 @@ class _AppSplashScreenState extends State<_AppSplashScreen> with TrayListener { if (kIsWeb || Platform.isAndroid || Platform.isIOS) return; await localNotifier.setup( - appName: 'solian', + appName: 'Solian', shortcutPolicy: ShortcutPolicy.requireCreate, ); } @@ -429,7 +429,11 @@ class _AppSplashScreenState extends State<_AppSplashScreen> with TrayListener { break; case 'exit': _appLifecycleListener?.dispose(); - SystemChannels.platform.invokeMethod('SystemNavigator.pop'); + if (Platform.isWindows) { + appWindow.close(); + } else { + SystemChannels.platform.invokeMethod('SystemNavigator.pop'); + } break; } } diff --git a/lib/screens/home.dart b/lib/screens/home.dart index 5886f44..9617e7f 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -2,7 +2,6 @@ import 'dart:math' as math; import 'dart:ui'; import 'package:easy_localization/easy_localization.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:gap/gap.dart'; import 'package:go_router/go_router.dart'; diff --git a/lib/widgets/navigation/app_scaffold.dart b/lib/widgets/navigation/app_scaffold.dart index ace70c0..6b4dca1 100644 --- a/lib/widgets/navigation/app_scaffold.dart +++ b/lib/widgets/navigation/app_scaffold.dart @@ -188,29 +188,16 @@ class AppRootScaffold extends StatelessWidget { child: Text( 'Solar Network', style: GoogleFonts.spaceGrotesk(), - textAlign: !kIsWeb - ? Platform.isMacOS - ? TextAlign.center - : null - : null, ).padding(horizontal: 12, vertical: 5), ), if (!Platform.isMacOS) - Row( - mainAxisSize: MainAxisSize.min, - children: [ - Expanded(child: MoveWindow()), - Row( - children: [ - MinimizeWindowButton( - colors: windowButtonColor), - MaximizeWindowButton( - colors: windowButtonColor), - CloseWindowButton( - colors: windowButtonColor), - ], - ), - ], + MinimizeWindowButton(colors: windowButtonColor), + if (!Platform.isMacOS) + MaximizeWindowButton(colors: windowButtonColor), + if (!Platform.isMacOS) + CloseWindowButton( + colors: windowButtonColor, + onPressed: () => appWindow.hide(), ), ], ), @@ -226,16 +213,18 @@ class AppRootScaffold extends StatelessWidget { child: NotifyIndicator()), if (ResponsiveBreakpoints.of(context).smallerOrEqualTo(MOBILE)) Positioned( - bottom: safeBottom > 0 ? safeBottom : 16, - left: 0, - right: 0, - child: ConnectionIndicator()) + bottom: safeBottom > 0 ? safeBottom : 16, + left: 0, + right: 0, + child: ConnectionIndicator(), + ) else Positioned( - top: safeTop > 0 ? safeTop : 16, - left: 0, - right: 0, - child: ConnectionIndicator()), + top: safeTop > 0 ? safeTop : 16, + left: 0, + right: 0, + child: ConnectionIndicator(), + ), ], ), drawer: !isExpandedDrawer ? AppNavigationDrawer() : null,