Skip to content

Commit

Permalink
🧭 Added Keyboard Shortcuts to switch between search types.
Browse files Browse the repository at this point in the history
Summary:
Alt + T - for text mode searching
Alt + R - for regex mode searching
Alt + I - for image mode searching
Alt + C - for comment mode searching
  • Loading branch information
omegaui committed Dec 26, 2023
1 parent 6b61f5e commit 5e79b7c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ class _PowerSearchFieldState extends State<PowerSearchField> {
Future.delayed(
const Duration(milliseconds: 500),
() {
PowerDataHandler.searchTypeChangeListeners.add(() {
if (mounted) {
setState(() {});
}
});
focusNode.requestFocus();
},
);
Expand Down Expand Up @@ -78,10 +83,8 @@ class _PowerSearchFieldState extends State<PowerSearchField> {
.toList(),
value: PowerDataHandler.searchType,
onChanged: (value) {
setState(() {
PowerDataHandler.searchTypeUpdate(value!);
focusNode.requestFocus();
});
PowerDataHandler.searchTypeUpdate(value!);
focusNode.requestFocus();
},
),
),
Expand Down
16 changes: 16 additions & 0 deletions lib/app/powermode/presentation/power_mode_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,22 @@ class _PowerModeAppState extends State<PowerModeApp> {
rebuild();
}
},
const SingleActivator(LogicalKeyboardKey.keyT, alt: true): () {
PowerDataHandler.searchTypeUpdate(PowerSearchType.Text);
rebuild();
},
const SingleActivator(LogicalKeyboardKey.keyR, alt: true): () {
PowerDataHandler.searchTypeUpdate(PowerSearchType.Regex);
rebuild();
},
const SingleActivator(LogicalKeyboardKey.keyI, alt: true): () {
PowerDataHandler.searchTypeUpdate(PowerSearchType.Image);
rebuild();
},
const SingleActivator(LogicalKeyboardKey.keyC, alt: true): () {
PowerDataHandler.searchTypeUpdate(PowerSearchType.Comment);
rebuild();
},
},
child: Focus(
focusNode: appFocusNode,
Expand Down

0 comments on commit 5e79b7c

Please sign in to comment.