From 859eaf903becf0df1f931ce793d1736ba1683b5a Mon Sep 17 00:00:00 2001 From: Sander Hoeve <50213029+Trapiz@users.noreply.github.com> Date: Thu, 30 May 2024 02:30:40 +0200 Subject: [PATCH] feat: add reset app scale hotkey (#5386) Co-authored-by: Mathias Mogensen --- .../workspace/presentation/home/hotkeys.dart | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/hotkeys.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/hotkeys.dart index e979f102e3..b2d9945b2b 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/home/hotkeys.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/hotkeys.dart @@ -141,6 +141,16 @@ class _HomeHotKeysState extends State { keyDownHandler: (_) => _scaleWithStep(-0.1), ), + // Reset app scaling + HotKeyItem( + hotKey: HotKey( + KeyCode.digit0, + modifiers: [Platform.isMacOS ? KeyModifier.meta : KeyModifier.control], + scope: HotKeyScope.inapp, + ), + keyDownHandler: (_) => _scaleToSize(1), + ), + // Open settings dialog openSettingsHotKey(context, widget.userProfile), ]; @@ -182,7 +192,11 @@ class _HomeHotKeysState extends State { Log.info('scale the app from $currentScaleFactor to $textScale'); - ScaledWidgetsFlutterBinding.instance.scaleFactor = (_) => textScale; - await windowSizeManager.setScaleFactor(textScale); + await _scaleToSize(textScale); + } + + Future _scaleToSize(double size) async { + ScaledWidgetsFlutterBinding.instance.scaleFactor = (_) => size; + await windowSizeManager.setScaleFactor(size); } }