Skip to content

armgit / ente

Public Imported from GitHub
0

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

double tap for search focus immediately

laurenspriem6058955e8c14
diff --git a/mobile/apps/photos/lib/ui/home/home_bottom_nav_bar.dart b/mobile/apps/photos/lib/ui/home/home_bottom_nav_bar.dart
index 382c3e8210..6ff7a36e31 100644
--- a/mobile/apps/photos/lib/ui/home/home_bottom_nav_bar.dart
+++ b/mobile/apps/photos/lib/ui/home/home_bottom_nav_bar.dart
@@ -27,8 +27,12 @@ class HomeBottomNavigationBar extends StatefulWidget {
}
class _HomeBottomNavigationBarState extends State<HomeBottomNavigationBar> {
+ static const int _searchTabIndex = 3;
+ static const Duration _doubleTapWindow = Duration(milliseconds: 350);
late StreamSubscription<TabChangedEvent> _tabChangedEventSubscription;
int currentTabIndex = 0;
+ int? _lastTapIndex;
+ DateTime? _lastTapAt;
@override
void initState() {
@@ -77,6 +81,9 @@ class _HomeBottomNavigationBarState extends State<HomeBottomNavigationBar> {
}
void _onTabChange(int index, {String mode = 'tabChanged'}) {
+ if (mode == "OnPressed") {
+ _handleSearchTabDoubleTap(index);
+ }
debugPrint("_TabChanged called via method $mode");
Bus.instance.fire(
TabChangedEvent(
@@ -86,6 +93,21 @@ class _HomeBottomNavigationBarState extends State<HomeBottomNavigationBar> {
);
}
+ void _handleSearchTabDoubleTap(int index) {
+ final now = DateTime.now();
+ final isRepeatTap = _lastTapIndex == index &&
+ _lastTapAt != null &&
+ now.difference(_lastTapAt!) <= _doubleTapWindow;
+ _lastTapIndex = index;
+ _lastTapAt = now;
+ if (index != _searchTabIndex || !isRepeatTap) {
+ return;
+ }
+ if (currentTabIndex != _searchTabIndex) {
+ Bus.instance.fire(TabDoubleTapEvent(index));
+ }
+ }
+
@override
Widget build(BuildContext context) {
final bool filesAreSelected = widget.selectedFiles.files.isNotEmpty;