apidash icon indicating copy to clipboard operation
apidash copied to clipboard

Add keyboard shortcut for the "Save" action

Open ClementBeal opened this issue 1 year ago • 10 comments

Tell us about the task you want to perform and are unable to do so because the feature is not available

I'm adding a lot of variables or requests and as a developer, I usually save every 2 seconds my changes. Moving the mouse to the save button is slow.

Describe the solution/feature you'd like us to add

The basic keyboard shortcut CTRL+S should be able to trigger the "save" button. It would save a lot of time and make the software more user friendly.

ClementBeal avatar Oct 05 '24 14:10 ClementBeal

Yes it will be quite useful. Thanks for raising an issue.

ashitaprasad avatar Oct 05 '24 15:10 ashitaprasad

Can you pls assign this issue to me

Rajkdea123 avatar Oct 05 '24 18:10 Rajkdea123

@Rajkdea123 we do not assign issues until we receive a draft PR which works towards a potential fix.

ashitaprasad avatar Oct 06 '24 10:10 ashitaprasad

starting work on this.... shud it also be a editable config (like bind to other keys n stuff?)

mohit-nagaraj avatar Oct 10 '24 18:10 mohit-nagaraj

@mohit-nagaraj Simple Ctrl+S should be fine for now. No need to make it an editable config.

ashitaprasad avatar Oct 11 '24 19:10 ashitaprasad

@ashitaprasad Please checkout my PR on this issue.

Rupamthxt avatar Nov 09 '24 14:11 Rupamthxt

dashboard.dart changes to support keyboard press

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';
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';

class SaveIntent extends Intent {
  const SaveIntent();
}

class DesktopDashboard extends ConsumerWidget {
  const DesktopDashboard({super.key});

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    return const Dashboard();
  }
}

class Dashboard extends ConsumerWidget {
  const Dashboard({super.key});

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final railIdx = ref.watch(navRailIndexStateProvider);
    return Shortcuts(
      shortcuts: {
        LogicalKeySet(LogicalKeyboardKey.control, 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: <Widget>[
                  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: [
                            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(),
                      ],
                    ),
                  )
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}

animator avatar Apr 06 '25 08:04 animator

I would like to request the addition of a basic keyboard shortcut — specifically, CTRL+S — that triggers the "Save" button functionality. Introducing this shortcut would align the software with standard developer workflows, greatly enhance usability, and save considerable time. It’s a small change that would significantly improve the user experience, especially for those of us working quickly and iteratively.

Ibraheem-MuhammedAmeen avatar Apr 26 '25 10:04 Ibraheem-MuhammedAmeen

I would like to request the addition of a basic keyboard shortcut — specifically, CTRL+S — that triggers the "Save" button functionality. Introducing this shortcut would align the software with standard developer workflows, greatly enhance usability, and save considerable time. It’s a small change that would significantly improve the user experience, especially for those of us working quickly and iteratively.

@Ibraheem-MuhammedAmeen We tried that before .. It was not working for all three platforms - Windows, mac, Linux. You can give it a try.

ashitaprasad avatar Apr 26 '25 23:04 ashitaprasad

hi @ashitaprasad @animator this issue still open can i work on this can you assignee this to me

mdex-geek avatar Sep 21 '25 11:09 mdex-geek