From f2383e9f7a9518b9c6c0fb72f4e97f22fd25b05b Mon Sep 17 00:00:00 2001 From: CodeDoctorDE Date: Fri, 22 Jul 2022 17:44:49 +0200 Subject: [PATCH] Disable buttons in native window mode --- app/lib/main.dart | 17 +++----- app/lib/views/app_bar.dart | 81 ++++++++++++++++++++++---------------- app/lib/views/main.dart | 3 +- 3 files changed, 55 insertions(+), 46 deletions(-) diff --git a/app/lib/main.dart b/app/lib/main.dart index 686005a5af13..8d905d87d9b5 100644 --- a/app/lib/main.dart +++ b/app/lib/main.dart @@ -192,9 +192,11 @@ class ButterflyApp extends StatelessWidget { buildWhen: (previous, current) => previous.nativeWindowTitleBar != current.nativeWindowTitleBar, builder: (context, settings) { - windowManager.setTitleBarStyle(settings.nativeWindowTitleBar - ? TitleBarStyle.normal - : TitleBarStyle.hidden); + if (!kIsWeb && isWindow()) { + windowManager.setTitleBarStyle(settings.nativeWindowTitleBar + ? TitleBarStyle.normal + : TitleBarStyle.hidden); + } return RepositoryProvider( create: (context) => SyncService(context, context.read()), @@ -207,10 +209,6 @@ class ButterflyApp extends StatelessWidget { } Widget _buildApp() { - final virtualWindowFrameBuilder = - kIsWeb || (!Platform.isWindows && !Platform.isLinux) - ? null - : VirtualWindowFrameInit(); return BlocBuilder( buildWhen: (previous, current) => previous.theme != current.theme || @@ -230,10 +228,7 @@ class ButterflyApp extends StatelessWidget { if (child == null) { return const Center(child: CircularProgressIndicator()); } - if (kIsWeb || virtualWindowFrameBuilder == null) { - return child; - } - return virtualWindowFrameBuilder(context, child); + return child; }, darkTheme: ThemeManager.getThemeByName(state.design, dark: true), )); diff --git a/app/lib/views/app_bar.dart b/app/lib/views/app_bar.dart index ee095d3d8195..75608ab7c9aa 100644 --- a/app/lib/views/app_bar.dart +++ b/app/lib/views/app_bar.dart @@ -42,11 +42,11 @@ class PadAppBar extends StatelessWidget with PreferredSizeWidget { Widget build(BuildContext context) { var bloc = context.read(); return GestureDetector(onSecondaryTap: () { - if (isWindow()) { + if (!kIsWeb && isWindow()) { windowManager.popUpWindowMenu(); } }, onLongPress: () { - if (isWindow()) { + if (!kIsWeb && isWindow()) { windowManager.popUpWindowMenu(); } }, child: LayoutBuilder( @@ -185,44 +185,57 @@ class PadAppBar extends StatelessWidget with PreferredSizeWidget { isMobile: false, )), ]); - if (!kIsWeb && isWindow()) { + if (!kIsWeb && + isWindow() && + !context + .read() + .state + .nativeWindowTitleBar) { return DragToMoveArea(child: title); } return title; })), actions: [ BlocBuilder( - builder: (context, state) => Row( - children: [ - if (!isMobile) ...[ - IconButton( - icon: const Icon( - PhosphorIcons.arrowCounterClockwiseLight), - tooltip: AppLocalizations.of(context)!.undo, - onPressed: !bloc.canUndo - ? null - : () { - Actions.maybeInvoke( - context, UndoIntent(context)); - }, - ), - IconButton( - icon: const Icon(PhosphorIcons.arrowClockwiseLight), - tooltip: AppLocalizations.of(context)!.redo, - onPressed: !bloc.canRedo - ? null - : () { - Actions.maybeInvoke( - context, RedoIntent(context)); - }, - ), - ], - if (isWindow()) ...[ - const VerticalDivider(), - const WindowButtons() - ] - ], - ), + builder: (context, state) => + BlocBuilder( + buildWhen: (previous, current) => + previous.nativeWindowTitleBar != + current.nativeWindowTitleBar, + builder: (context, settings) => Row( + children: [ + if (!isMobile) ...[ + IconButton( + icon: const Icon(PhosphorIcons + .arrowCounterClockwiseLight), + tooltip: AppLocalizations.of(context)!.undo, + onPressed: !bloc.canUndo + ? null + : () { + Actions.maybeInvoke( + context, UndoIntent(context)); + }, + ), + IconButton( + icon: const Icon( + PhosphorIcons.arrowClockwiseLight), + tooltip: AppLocalizations.of(context)!.redo, + onPressed: !bloc.canRedo + ? null + : () { + Actions.maybeInvoke( + context, RedoIntent(context)); + }, + ), + ], + if (isWindow() && + kIsWeb && + !settings.nativeWindowTitleBar) ...[ + const VerticalDivider(), + const WindowButtons() + ] + ], + )), ) ]); }, diff --git a/app/lib/views/main.dart b/app/lib/views/main.dart index 6677c5948106..561ce4039b89 100644 --- a/app/lib/views/main.dart +++ b/app/lib/views/main.dart @@ -426,7 +426,8 @@ class _WindowButtonsState extends State with WindowListener { @override @override Widget build(BuildContext context) { - if (isWindow()) { + if (isWindow() && + !context.read().state.nativeWindowTitleBar) { return LayoutBuilder( builder: (context, constraints) => Padding( padding: const EdgeInsets.all(8.0),