Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[auth] ctrl+f to activate search box for icons

Aman Raj1b74049eb58b
diff --git a/auth/lib/ui/custom_icon_page.dart b/auth/lib/ui/custom_icon_page.dart
index fa02c85667..428871d7c0 100644
--- a/auth/lib/ui/custom_icon_page.dart
+++ b/auth/lib/ui/custom_icon_page.dart
@@ -4,6 +4,7 @@ import 'package:ente_auth/services/preference_service.dart';
import 'package:ente_auth/theme/ente_theme.dart';
import 'package:ente_auth/ui/utils/icon_utils.dart';
import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
class CustomIconPage extends StatefulWidget {
final Map<String, AllIconData> allIcons;
@@ -29,12 +30,14 @@ class _CustomIconPageState extends State<CustomIconPage> {
// Used to request focus on the search box when clicked the search icon
late FocusNode searchBoxFocusNode;
+ final Set<LogicalKeyboardKey> _pressedKeys = <LogicalKeyboardKey>{};
@override
void initState() {
_filteredIcons = widget.allIcons;
_showSearchBox = _autoFocusSearch;
searchBoxFocusNode = FocusNode();
+ ServicesBinding.instance.keyboard.addHandler(_handleKeyEvent);
super.initState();
}
@@ -42,9 +45,41 @@ class _CustomIconPageState extends State<CustomIconPage> {
void dispose() {
_textController.dispose();
searchBoxFocusNode.dispose();
+ ServicesBinding.instance.keyboard.removeHandler(_handleKeyEvent);
super.dispose();
}
+ bool _handleKeyEvent(KeyEvent event) {
+ if (event is KeyDownEvent) {
+ setState(() {
+ _pressedKeys.add(event.logicalKey);
+ if ((_pressedKeys.contains(LogicalKeyboardKey.controlLeft) ||
+ _pressedKeys.contains(LogicalKeyboardKey.control) ||
+ _pressedKeys.contains(LogicalKeyboardKey.controlRight)) &&
+ event.logicalKey == LogicalKeyboardKey.keyF) {
+ _showSearchBox = true;
+ searchBoxFocusNode.requestFocus();
+ _textController.clear();
+ _searchText = "";
+ return;
+ }
+ if (event.logicalKey == LogicalKeyboardKey.escape) {
+ setState(() {
+ _textController.clear();
+ _searchText = "";
+ _showSearchBox = false;
+ _applyFilteringAndRefresh();
+ });
+ } else if (event is KeyUpEvent) {
+ setState(() {
+ _pressedKeys.remove(event.logicalKey);
+ });
+ }
+ });
+ }
+ return false;
+ }
+
void _applyFilteringAndRefresh() {
if (_searchText.isEmpty) {
setState(() {