From c3236452daff61185eda60c8b06ec405d3119153 Mon Sep 17 00:00:00 2001 From: Rupamthxt Date: Fri, 8 Nov 2024 02:58:32 +0530 Subject: [PATCH 1/7] Added shortcut key "ctrl + s" for saving projects on the go. --- .../common_widgets/sidebar_save_button.dart | 49 ++-- lib/screens/dashboard.dart | 233 ++++++++++-------- 2 files changed, 163 insertions(+), 119 deletions(-) diff --git a/lib/screens/common_widgets/sidebar_save_button.dart b/lib/screens/common_widgets/sidebar_save_button.dart index 46390ac44..e0def66f8 100644 --- a/lib/screens/common_widgets/sidebar_save_button.dart +++ b/lib/screens/common_widgets/sidebar_save_button.dart @@ -10,28 +10,9 @@ class SaveButton extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - final overlayWidget = OverlayWidgetTemplate(context: context); - final savingData = ref.watch(saveDataStateProvider); - final hasUnsavedChanges = ref.watch(hasUnsavedChangesProvider); - return TextButton.icon( - onPressed: (savingData || !hasUnsavedChanges) - ? null - : () async { - overlayWidget.show( - widget: const SavingOverlay(saveCompleted: false)); - await ref - .read(collectionStateNotifierProvider.notifier) - .saveData(); - await ref - .read(environmentsStateNotifierProvider.notifier) - .saveEnvironments(); - overlayWidget.hide(); - overlayWidget.show( - widget: const SavingOverlay(saveCompleted: true)); - await Future.delayed(const Duration(seconds: 1)); - overlayWidget.hide(); - }, + return TextButton.icon( + onPressed: () {saveData(context, ref);} , icon: const Icon( Icons.save, size: 20, @@ -42,4 +23,30 @@ class SaveButton extends ConsumerWidget { ), ); } + + static void saveData(BuildContext context, WidgetRef ref) async { + final savingData = ref.watch(saveDataStateProvider); + final hasUnsavedChanges = ref.watch(hasUnsavedChangesProvider); + final overlayWidget = OverlayWidgetTemplate(context: context); + (savingData || !hasUnsavedChanges) + ? null + :{ + overlayWidget.show( + widget: const SavingOverlay(saveCompleted: false)), + + await ref + .read(collectionStateNotifierProvider.notifier) + .saveData(), + await ref + .read(environmentsStateNotifierProvider.notifier) + .saveEnvironments(), + overlayWidget.hide(), + overlayWidget.show( + widget: const SavingOverlay(saveCompleted: true)), + await Future.delayed(const Duration(seconds: 1)), + overlayWidget.hide(), + }; + } } + + diff --git a/lib/screens/dashboard.dart b/lib/screens/dashboard.dart index d71b30082..f5c0befaa 100644 --- a/lib/screens/dashboard.dart +++ b/lib/screens/dashboard.dart @@ -1,5 +1,6 @@ import 'package:apidash_design_system/apidash_design_system.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:apidash/providers/providers.dart'; import 'package:apidash/widgets/widgets.dart'; @@ -10,120 +11,156 @@ import 'home_page/home_page.dart'; import 'history/history_page.dart'; import 'settings_page.dart'; +class SaveIntent extends Intent {} + class Dashboard extends ConsumerWidget { const Dashboard({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { + + bool isControlPressed = false; + void onKey(KeyEvent event) { + if (event is KeyDownEvent) { + if (event.logicalKey == LogicalKeyboardKey.controlLeft || + event.logicalKey == LogicalKeyboardKey.controlRight) { + isControlPressed = true; + } + if (event.logicalKey == LogicalKeyboardKey.keyS && isControlPressed) { + SaveButton.saveData(context, ref); + } + } + if (event is KeyUpEvent) { + if (event.logicalKey == LogicalKeyboardKey.controlLeft || + event.logicalKey == LogicalKeyboardKey.controlRight) { + isControlPressed = false; + } + } + } + FocusNode _focusNode = FocusNode(); final railIdx = ref.watch(navRailIndexStateProvider); return Scaffold( - body: SafeArea( - child: Row( - children: [ - Column( - children: [ - SizedBox( - height: kIsMacOS ? 32.0 : 16.0, - width: 64, - ), - Column( - mainAxisSize: MainAxisSize.min, - children: [ - IconButton( - isSelected: railIdx == 0, - onPressed: () { - ref.read(navRailIndexStateProvider.notifier).state = 0; - }, - icon: const Icon(Icons.auto_awesome_mosaic_outlined), - selectedIcon: const Icon(Icons.auto_awesome_mosaic), - ), - Text( - 'Requests', - style: Theme.of(context).textTheme.labelSmall, - ), - kVSpacer10, - IconButton( - isSelected: railIdx == 1, - onPressed: () { - ref.read(navRailIndexStateProvider.notifier).state = 1; - }, - icon: const Icon(Icons.laptop_windows_outlined), - selectedIcon: const Icon(Icons.laptop_windows), - ), - Text( - 'Variables', - style: Theme.of(context).textTheme.labelSmall, - ), - kVSpacer10, - IconButton( - isSelected: railIdx == 2, - onPressed: () { - ref.read(navRailIndexStateProvider.notifier).state = 2; - }, - icon: const Icon(Icons.history_outlined), - selectedIcon: const Icon(Icons.history_rounded), - ), - Text( - 'History', - style: Theme.of(context).textTheme.labelSmall, - ), - ], - ), - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.end, + body: KeyboardListener( + autofocus: true, + onKeyEvent: onKey, + focusNode: _focusNode, + child: SafeArea( + child: Row( + children: [ + Column( + children: [ + SizedBox( + height: kIsMacOS ? 32.0 : 16.0, + width: 64, + ), + Column( + mainAxisSize: MainAxisSize.min, children: [ - Padding( - padding: const EdgeInsets.only(bottom: 16.0), - child: NavbarButton( - railIdx: railIdx, - selectedIcon: Icons.help, - icon: Icons.help_outline, - label: 'About', - showLabel: false, - isCompact: true, - onTap: () { - showAboutAppDialog(context); - }, - ), + IconButton( + isSelected: railIdx == 0, + onPressed: () { + ref + .read(navRailIndexStateProvider.notifier) + .state = 0; + }, + icon: + const Icon(Icons.auto_awesome_mosaic_outlined), + selectedIcon: const Icon(Icons.auto_awesome_mosaic), ), - Padding( - padding: const EdgeInsets.only(bottom: 16.0), - child: NavbarButton( - railIdx: railIdx, - buttonIdx: 3, - selectedIcon: Icons.settings, - icon: Icons.settings_outlined, - label: 'Settings', - showLabel: false, - isCompact: true, - ), + Text( + 'Requests', + style: Theme.of(context).textTheme.labelSmall, + ), + kVSpacer10, + IconButton( + isSelected: railIdx == 1, + onPressed: () { + ref + .read(navRailIndexStateProvider.notifier) + .state = 1; + }, + icon: const Icon(Icons.laptop_windows_outlined), + selectedIcon: const Icon(Icons.laptop_windows), + ), + Text( + 'Variables', + style: Theme.of(context).textTheme.labelSmall, + ), + kVSpacer10, + IconButton( + isSelected: railIdx == 2, + onPressed: () { + ref + .read(navRailIndexStateProvider.notifier) + .state = 2; + }, + icon: const Icon(Icons.history_outlined), + selectedIcon: const Icon(Icons.history_rounded), + ), + Text( + 'History', + style: Theme.of(context).textTheme.labelSmall, ), ], ), - ), - ], - ), - VerticalDivider( - thickness: 1, - width: 1, - color: Theme.of(context).colorScheme.surfaceContainerHighest, - ), - Expanded( - child: IndexedStack( - alignment: AlignmentDirectional.topCenter, - index: railIdx, - children: const [ - HomePage(), - EnvironmentPage(), - HistoryPage(), - SettingsPage(), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Padding( + padding: const EdgeInsets.only(bottom: 16.0), + child: NavbarButton( + railIdx: railIdx, + selectedIcon: Icons.help, + icon: Icons.help_outline, + label: 'About', + showLabel: false, + isCompact: true, + onTap: () { + showAboutAppDialog(context); + }, + ), + ), + Padding( + padding: const EdgeInsets.only(bottom: 16.0), + child: NavbarButton( + railIdx: railIdx, + buttonIdx: 3, + selectedIcon: Icons.settings, + icon: Icons.settings_outlined, + label: 'Settings', + showLabel: false, + isCompact: true, + ), + ), + ], + ), + ), ], ), - ) - ], + VerticalDivider( + thickness: 1, + width: 1, + color: + Theme.of(context).colorScheme.surfaceContainerHighest, + ), + Expanded( + child: IndexedStack( + alignment: AlignmentDirectional.topCenter, + index: railIdx, + children: const [ + HomePage(), + EnvironmentPage(), + HistoryPage(), + SettingsPage(), + ], + ), + ) + ], + ), ), ), ); } } + From f73dbe38e1c9e488c5cdf403b2c476229b7030db Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Sun, 10 Nov 2024 18:07:19 +0530 Subject: [PATCH 2/7] update save data --- lib/common/utils.dart | 13 +++++++ .../common_widgets/sidebar_save_button.dart | 37 ++++--------------- 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/lib/common/utils.dart b/lib/common/utils.dart index 8eaf2b2c4..8bf14c4df 100644 --- a/lib/common/utils.dart +++ b/lib/common/utils.dart @@ -1,6 +1,8 @@ +import 'package:apidash/providers/providers.dart'; import 'package:flutter/material.dart'; import 'package:apidash/utils/utils.dart'; import 'package:apidash/widgets/widgets.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; Future saveCollection( Map data, ScaffoldMessengerState sm) async { @@ -18,3 +20,14 @@ Future saveCollection( sm.hideCurrentSnackBar(); sm.showSnackBar(getSnackBar(message, small: false)); } + +Future saveData(BuildContext context, WidgetRef ref) async { + final overlayWidget = OverlayWidgetTemplate(context: context); + overlayWidget.show(widget: const SavingOverlay(saveCompleted: false)); + await ref.read(collectionStateNotifierProvider.notifier).saveData(); + await ref.read(environmentsStateNotifierProvider.notifier).saveEnvironments(); + overlayWidget.hide(); + overlayWidget.show(widget: const SavingOverlay(saveCompleted: true)); + await Future.delayed(const Duration(seconds: 1)); + overlayWidget.hide(); +} diff --git a/lib/screens/common_widgets/sidebar_save_button.dart b/lib/screens/common_widgets/sidebar_save_button.dart index e0def66f8..6084651f1 100644 --- a/lib/screens/common_widgets/sidebar_save_button.dart +++ b/lib/screens/common_widgets/sidebar_save_button.dart @@ -3,16 +3,21 @@ import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:apidash/consts.dart'; import 'package:apidash/providers/providers.dart'; -import 'package:apidash/widgets/widgets.dart'; +import '../../common/utils.dart'; class SaveButton extends ConsumerWidget { const SaveButton({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { - + final savingData = ref.watch(saveDataStateProvider); + final hasUnsavedChanges = ref.watch(hasUnsavedChangesProvider); return TextButton.icon( - onPressed: () {saveData(context, ref);} , + onPressed: (savingData || !hasUnsavedChanges) + ? null + : () async { + await saveData(context, ref); + }, icon: const Icon( Icons.save, size: 20, @@ -23,30 +28,4 @@ class SaveButton extends ConsumerWidget { ), ); } - - static void saveData(BuildContext context, WidgetRef ref) async { - final savingData = ref.watch(saveDataStateProvider); - final hasUnsavedChanges = ref.watch(hasUnsavedChangesProvider); - final overlayWidget = OverlayWidgetTemplate(context: context); - (savingData || !hasUnsavedChanges) - ? null - :{ - overlayWidget.show( - widget: const SavingOverlay(saveCompleted: false)), - - await ref - .read(collectionStateNotifierProvider.notifier) - .saveData(), - await ref - .read(environmentsStateNotifierProvider.notifier) - .saveEnvironments(), - overlayWidget.hide(), - overlayWidget.show( - widget: const SavingOverlay(saveCompleted: true)), - await Future.delayed(const Duration(seconds: 1)), - overlayWidget.hide(), - }; - } } - - From 65a8544a42be7592c47599046738e7a5a1dcb8e5 Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Sun, 10 Nov 2024 18:10:17 +0530 Subject: [PATCH 3/7] Update utils.dart --- lib/common/utils.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/common/utils.dart b/lib/common/utils.dart index 8bf14c4df..cf61ce224 100644 --- a/lib/common/utils.dart +++ b/lib/common/utils.dart @@ -1,8 +1,8 @@ -import 'package:apidash/providers/providers.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:apidash/providers/providers.dart'; import 'package:apidash/utils/utils.dart'; import 'package:apidash/widgets/widgets.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; Future saveCollection( Map data, ScaffoldMessengerState sm) async { From 289e43e5f0655710e9502e1f0c9bfb5741da628d Mon Sep 17 00:00:00 2001 From: Rupamthxt Date: Sun, 10 Nov 2024 18:41:26 +0530 Subject: [PATCH 4/7] Implemented direct reference to saveData as it has been moved under utils file. --- lib/screens/dashboard.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/screens/dashboard.dart b/lib/screens/dashboard.dart index f5c0befaa..597a401cd 100644 --- a/lib/screens/dashboard.dart +++ b/lib/screens/dashboard.dart @@ -10,6 +10,7 @@ import 'envvar/environment_page.dart'; import 'home_page/home_page.dart'; import 'history/history_page.dart'; import 'settings_page.dart'; +import 'package:apidash/common/utils.dart'; class SaveIntent extends Intent {} @@ -27,7 +28,7 @@ class Dashboard extends ConsumerWidget { isControlPressed = true; } if (event.logicalKey == LogicalKeyboardKey.keyS && isControlPressed) { - SaveButton.saveData(context, ref); + saveData(context, ref); } } if (event is KeyUpEvent) { From f31776f43221e33ec9c2ba6e5b83beace4039030 Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Mon, 11 Nov 2024 12:59:39 +0530 Subject: [PATCH 5/7] update --- lib/app.dart | 2 +- lib/screens/dashboard.dart | 259 ++++++++++++++++++------------------- 2 files changed, 126 insertions(+), 135 deletions(-) diff --git a/lib/app.dart b/lib/app.dart index ac6f708bf..4d51a5539 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -140,7 +140,7 @@ class DashApp extends ConsumerWidget { ? const App() : context.isMediumWindow ? const MobileDashboard() - : const Dashboard(), + : const DesktopDashboard(), if (kIsWindows) SizedBox( height: 29, diff --git a/lib/screens/dashboard.dart b/lib/screens/dashboard.dart index 597a401cd..a4c133a53 100644 --- a/lib/screens/dashboard.dart +++ b/lib/screens/dashboard.dart @@ -5,163 +5,154 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:apidash/providers/providers.dart'; import 'package:apidash/widgets/widgets.dart'; import 'package:apidash/consts.dart'; +import '../common/utils.dart'; import 'common_widgets/common_widgets.dart'; import 'envvar/environment_page.dart'; import 'home_page/home_page.dart'; import 'history/history_page.dart'; import 'settings_page.dart'; -import 'package:apidash/common/utils.dart'; -class SaveIntent extends Intent {} +class SaveIntent extends Intent { + const SaveIntent(); +} + +class DesktopDashboard extends ConsumerWidget { + const DesktopDashboard({super.key}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + return Shortcuts( + shortcuts: { + LogicalKeySet(LogicalKeyboardKey.meta, LogicalKeyboardKey.keyS): + const SaveIntent(), + LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.keyS): + const SaveIntent(), + }, + child: Actions( + actions: { + SaveIntent: + CallbackAction(onInvoke: (intent) => saveData(context, ref)), + }, + child: const Dashboard(), + ), + ); + } +} class Dashboard extends ConsumerWidget { const Dashboard({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { - - bool isControlPressed = false; - void onKey(KeyEvent event) { - if (event is KeyDownEvent) { - if (event.logicalKey == LogicalKeyboardKey.controlLeft || - event.logicalKey == LogicalKeyboardKey.controlRight) { - isControlPressed = true; - } - if (event.logicalKey == LogicalKeyboardKey.keyS && isControlPressed) { - saveData(context, ref); - } - } - if (event is KeyUpEvent) { - if (event.logicalKey == LogicalKeyboardKey.controlLeft || - event.logicalKey == LogicalKeyboardKey.controlRight) { - isControlPressed = false; - } - } - } - FocusNode _focusNode = FocusNode(); final railIdx = ref.watch(navRailIndexStateProvider); return Scaffold( - body: KeyboardListener( - autofocus: true, - onKeyEvent: onKey, - focusNode: _focusNode, - child: SafeArea( - child: Row( - children: [ - Column( - children: [ - SizedBox( - height: kIsMacOS ? 32.0 : 16.0, - width: 64, - ), - Column( - mainAxisSize: MainAxisSize.min, + body: SafeArea( + child: Row( + children: [ + Column( + children: [ + SizedBox( + height: kIsMacOS ? 32.0 : 16.0, + width: 64, + ), + Column( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + isSelected: railIdx == 0, + onPressed: () { + ref.read(navRailIndexStateProvider.notifier).state = 0; + }, + icon: const Icon(Icons.auto_awesome_mosaic_outlined), + selectedIcon: const Icon(Icons.auto_awesome_mosaic), + ), + Text( + 'Requests', + style: Theme.of(context).textTheme.labelSmall, + ), + kVSpacer10, + IconButton( + isSelected: railIdx == 1, + onPressed: () { + ref.read(navRailIndexStateProvider.notifier).state = 1; + }, + icon: const Icon(Icons.laptop_windows_outlined), + selectedIcon: const Icon(Icons.laptop_windows), + ), + Text( + 'Variables', + style: Theme.of(context).textTheme.labelSmall, + ), + kVSpacer10, + IconButton( + isSelected: railIdx == 2, + onPressed: () { + ref.read(navRailIndexStateProvider.notifier).state = 2; + }, + icon: const Icon(Icons.history_outlined), + selectedIcon: const Icon(Icons.history_rounded), + ), + Text( + 'History', + style: Theme.of(context).textTheme.labelSmall, + ), + ], + ), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.end, children: [ - IconButton( - isSelected: railIdx == 0, - onPressed: () { - ref - .read(navRailIndexStateProvider.notifier) - .state = 0; - }, - icon: - const Icon(Icons.auto_awesome_mosaic_outlined), - selectedIcon: const Icon(Icons.auto_awesome_mosaic), - ), - Text( - 'Requests', - style: Theme.of(context).textTheme.labelSmall, - ), - kVSpacer10, - IconButton( - isSelected: railIdx == 1, - onPressed: () { - ref - .read(navRailIndexStateProvider.notifier) - .state = 1; - }, - icon: const Icon(Icons.laptop_windows_outlined), - selectedIcon: const Icon(Icons.laptop_windows), - ), - Text( - 'Variables', - style: Theme.of(context).textTheme.labelSmall, - ), - kVSpacer10, - IconButton( - isSelected: railIdx == 2, - onPressed: () { - ref - .read(navRailIndexStateProvider.notifier) - .state = 2; - }, - icon: const Icon(Icons.history_outlined), - selectedIcon: const Icon(Icons.history_rounded), + Padding( + padding: const EdgeInsets.only(bottom: 16.0), + child: NavbarButton( + railIdx: railIdx, + selectedIcon: Icons.help, + icon: Icons.help_outline, + label: 'About', + showLabel: false, + isCompact: true, + onTap: () { + showAboutAppDialog(context); + }, + ), ), - Text( - 'History', - style: Theme.of(context).textTheme.labelSmall, + Padding( + padding: const EdgeInsets.only(bottom: 16.0), + child: NavbarButton( + railIdx: railIdx, + buttonIdx: 3, + selectedIcon: Icons.settings, + icon: Icons.settings_outlined, + label: 'Settings', + showLabel: false, + isCompact: true, + ), ), ], ), - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Padding( - padding: const EdgeInsets.only(bottom: 16.0), - child: NavbarButton( - railIdx: railIdx, - selectedIcon: Icons.help, - icon: Icons.help_outline, - label: 'About', - showLabel: false, - isCompact: true, - onTap: () { - showAboutAppDialog(context); - }, - ), - ), - Padding( - padding: const EdgeInsets.only(bottom: 16.0), - child: NavbarButton( - railIdx: railIdx, - buttonIdx: 3, - selectedIcon: Icons.settings, - icon: Icons.settings_outlined, - label: 'Settings', - showLabel: false, - isCompact: true, - ), - ), - ], - ), - ), + ), + ], + ), + VerticalDivider( + thickness: 1, + width: 1, + color: Theme.of(context).colorScheme.surfaceContainerHighest, + ), + Expanded( + child: IndexedStack( + alignment: AlignmentDirectional.topCenter, + index: railIdx, + children: const [ + HomePage(), + EnvironmentPage(), + HistoryPage(), + SettingsPage(), ], ), - VerticalDivider( - thickness: 1, - width: 1, - color: - Theme.of(context).colorScheme.surfaceContainerHighest, - ), - Expanded( - child: IndexedStack( - alignment: AlignmentDirectional.topCenter, - index: railIdx, - children: const [ - HomePage(), - EnvironmentPage(), - HistoryPage(), - SettingsPage(), - ], - ), - ) - ], - ), + ) + ], ), ), ); } } - From c53773073564762854f57e11d653d26b556a1c17 Mon Sep 17 00:00:00 2001 From: Rupamthxt Date: Mon, 11 Nov 2024 18:27:22 +0530 Subject: [PATCH 6/7] Implemented Save Shortcut. --- lib/screens/dashboard.dart | 225 ++++++++++++++++++------------------- 1 file changed, 112 insertions(+), 113 deletions(-) diff --git a/lib/screens/dashboard.dart b/lib/screens/dashboard.dart index a4c133a53..454f7c643 100644 --- a/lib/screens/dashboard.dart +++ b/lib/screens/dashboard.dart @@ -21,21 +21,7 @@ class DesktopDashboard extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - return Shortcuts( - shortcuts: { - LogicalKeySet(LogicalKeyboardKey.meta, LogicalKeyboardKey.keyS): - const SaveIntent(), - LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.keyS): - const SaveIntent(), - }, - child: Actions( - actions: { - SaveIntent: - CallbackAction(onInvoke: (intent) => saveData(context, ref)), - }, - child: const Dashboard(), - ), - ); + return const Dashboard(); } } @@ -45,112 +31,125 @@ class Dashboard extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final railIdx = ref.watch(navRailIndexStateProvider); - return Scaffold( - body: SafeArea( - child: Row( - children: [ - Column( - children: [ - SizedBox( - height: kIsMacOS ? 32.0 : 16.0, - width: 64, - ), - Column( - mainAxisSize: MainAxisSize.min, - children: [ - IconButton( - isSelected: railIdx == 0, - onPressed: () { - ref.read(navRailIndexStateProvider.notifier).state = 0; - }, - icon: const Icon(Icons.auto_awesome_mosaic_outlined), - selectedIcon: const Icon(Icons.auto_awesome_mosaic), - ), - Text( - 'Requests', - style: Theme.of(context).textTheme.labelSmall, - ), - kVSpacer10, - IconButton( - isSelected: railIdx == 1, - onPressed: () { - ref.read(navRailIndexStateProvider.notifier).state = 1; - }, - icon: const Icon(Icons.laptop_windows_outlined), - selectedIcon: const Icon(Icons.laptop_windows), - ), - Text( - 'Variables', - style: Theme.of(context).textTheme.labelSmall, - ), - kVSpacer10, - IconButton( - isSelected: railIdx == 2, - onPressed: () { - ref.read(navRailIndexStateProvider.notifier).state = 2; - }, - icon: const Icon(Icons.history_outlined), - selectedIcon: const Icon(Icons.history_rounded), - ), - Text( - 'History', - style: Theme.of(context).textTheme.labelSmall, - ), - ], - ), - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.end, + return Shortcuts( + shortcuts: { + LogicalKeySet(LogicalKeyboardKey.controlLeft, LogicalKeyboardKey.keyS): const SaveIntent(), + }, + child: Actions( + actions: { + SaveIntent: CallbackAction(onInvoke: (intent) => saveData(context, ref)) + }, + child: FocusScope( + autofocus: true, + child: Scaffold( + body: SafeArea( + child: Row( + children: [ + Column( children: [ - Padding( - padding: const EdgeInsets.only(bottom: 16.0), - child: NavbarButton( - railIdx: railIdx, - selectedIcon: Icons.help, - icon: Icons.help_outline, - label: 'About', - showLabel: false, - isCompact: true, - onTap: () { - showAboutAppDialog(context); - }, - ), + SizedBox( + height: kIsMacOS ? 32.0 : 16.0, + width: 64, ), - Padding( - padding: const EdgeInsets.only(bottom: 16.0), - child: NavbarButton( - railIdx: railIdx, - buttonIdx: 3, - selectedIcon: Icons.settings, - icon: Icons.settings_outlined, - label: 'Settings', - showLabel: false, - isCompact: true, + Column( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + isSelected: railIdx == 0, + onPressed: () { + ref.read(navRailIndexStateProvider.notifier).state = 0; + }, + icon: const Icon(Icons.auto_awesome_mosaic_outlined), + selectedIcon: const Icon(Icons.auto_awesome_mosaic), + ), + Text( + 'Requests', + style: Theme.of(context).textTheme.labelSmall, + ), + kVSpacer10, + IconButton( + isSelected: railIdx == 1, + onPressed: () { + ref.read(navRailIndexStateProvider.notifier).state = 1; + }, + icon: const Icon(Icons.laptop_windows_outlined), + selectedIcon: const Icon(Icons.laptop_windows), + ), + Text( + 'Variables', + style: Theme.of(context).textTheme.labelSmall, + ), + kVSpacer10, + IconButton( + isSelected: railIdx == 2, + onPressed: () { + ref.read(navRailIndexStateProvider.notifier).state = 2; + }, + icon: const Icon(Icons.history_outlined), + selectedIcon: const Icon(Icons.history_rounded), + ), + Text( + 'History', + style: Theme.of(context).textTheme.labelSmall, + ), + ], + ), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Padding( + padding: const EdgeInsets.only(bottom: 16.0), + child: NavbarButton( + railIdx: railIdx, + selectedIcon: Icons.help, + icon: Icons.help_outline, + label: 'About', + showLabel: false, + isCompact: true, + onTap: () { + showAboutAppDialog(context); + }, + ), + ), + Padding( + padding: const EdgeInsets.only(bottom: 16.0), + child: NavbarButton( + railIdx: railIdx, + buttonIdx: 3, + selectedIcon: Icons.settings, + icon: Icons.settings_outlined, + label: 'Settings', + showLabel: false, + isCompact: true, + ), + ), + ], ), ), ], ), - ), - ], - ), - VerticalDivider( - thickness: 1, - width: 1, - color: Theme.of(context).colorScheme.surfaceContainerHighest, - ), - Expanded( - child: IndexedStack( - alignment: AlignmentDirectional.topCenter, - index: railIdx, - children: const [ - HomePage(), - EnvironmentPage(), - HistoryPage(), - SettingsPage(), + VerticalDivider( + thickness: 1, + width: 1, + color: Theme.of(context).colorScheme.surfaceContainerHighest, + ), + Expanded( + child: IndexedStack( + alignment: AlignmentDirectional.topCenter, + index: railIdx, + children: const [ + HomePage(), + EnvironmentPage(), + HistoryPage(), + SettingsPage(), + ], + ), + ) ], ), - ) - ], + ), + ), ), ), ); From 5032b0f6ac61f9a37ccd0789ed8337684bae4029 Mon Sep 17 00:00:00 2001 From: Rupamthxt Date: Tue, 12 Nov 2024 23:03:29 +0530 Subject: [PATCH 7/7] Update --- lib/screens/dashboard.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/screens/dashboard.dart b/lib/screens/dashboard.dart index 454f7c643..698b3fd98 100644 --- a/lib/screens/dashboard.dart +++ b/lib/screens/dashboard.dart @@ -33,11 +33,11 @@ class Dashboard extends ConsumerWidget { final railIdx = ref.watch(navRailIndexStateProvider); return Shortcuts( shortcuts: { - LogicalKeySet(LogicalKeyboardKey.controlLeft, LogicalKeyboardKey.keyS): const SaveIntent(), + LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.keyS): const SaveIntent(), }, child: Actions( actions: { - SaveIntent: CallbackAction(onInvoke: (intent) => saveData(context, ref)) + SaveIntent : CallbackAction(onInvoke: (intent) => saveData(context, ref)) }, child: FocusScope( autofocus: true,