From 85dd4dd63c23ff8e1e010dbd1bab87c4862b271a Mon Sep 17 00:00:00 2001 From: Sander Hoeve Date: Tue, 21 May 2024 10:18:16 +0200 Subject: [PATCH] feat: Add reset app scale hotkey --- .../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 ed5a667e91862..55c2b8394c5d3 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); } }