From 8f9091376db068d2432e3815f85a87d26ba2deaf Mon Sep 17 00:00:00 2001 From: Fabian Freund Date: Thu, 13 Mar 2025 22:05:51 +0100 Subject: [PATCH] double tap previous tab --- .../features/geckoview/domain/repositories/tab.dart | 11 +++++++++++ .../widgets/browser_modules/bottom_app_bar.dart | 5 +++++ .../presentation/widgets/tabs_action_button.dart | 11 +++++++---- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/app/lib/features/geckoview/domain/repositories/tab.dart b/app/lib/features/geckoview/domain/repositories/tab.dart index e0604553..681bd52b 100644 --- a/app/lib/features/geckoview/domain/repositories/tab.dart +++ b/app/lib/features/geckoview/domain/repositories/tab.dart @@ -27,6 +27,8 @@ part 'tab.g.dart'; class TabRepository extends _$TabRepository { final _tabsService = GeckoTabService(); + String? _previousTabId; + Future addTab({ Uri? url, bool selectTab = true, @@ -83,6 +85,14 @@ class TabRepository extends _$TabRepository { ); } + Future selectPreviousTab() async { + if (_previousTabId != null) { + return selectTab(_previousTabId!); + } + + return false; + } + Future selectTab(String tabId) async { final containerId = await ref .read(tabDataRepositoryProvider.notifier) @@ -227,6 +237,7 @@ class TabRepository extends _$TabRepository { ref.listen(selectedTabProvider, (previous, tabId) async { if (tabId != null) { + _previousTabId = previous; await db.tabDao.touchTab(tabId, timestamp: DateTime.now()); } }); diff --git a/app/lib/features/geckoview/features/browser/presentation/widgets/browser_modules/bottom_app_bar.dart b/app/lib/features/geckoview/features/browser/presentation/widgets/browser_modules/bottom_app_bar.dart index 9f61a22f..22dbee11 100644 --- a/app/lib/features/geckoview/features/browser/presentation/widgets/browser_modules/bottom_app_bar.dart +++ b/app/lib/features/geckoview/features/browser/presentation/widgets/browser_modules/bottom_app_bar.dart @@ -118,6 +118,11 @@ class BrowserBottomAppBar extends HookConsumerWidget { .show(ViewTabsSheet()); } }, + onDoubleTap: () async { + await ref + .read(tabRepositoryProvider.notifier) + .selectPreviousTab(); + }, onLongPress: () { if (tabMenuController.isOpen) { tabMenuController.close(); diff --git a/app/lib/features/geckoview/features/browser/presentation/widgets/tabs_action_button.dart b/app/lib/features/geckoview/features/browser/presentation/widgets/tabs_action_button.dart index 28ff607b..ae2f6b48 100644 --- a/app/lib/features/geckoview/features/browser/presentation/widgets/tabs_action_button.dart +++ b/app/lib/features/geckoview/features/browser/presentation/widgets/tabs_action_button.dart @@ -4,12 +4,14 @@ import 'package:lensai/features/geckoview/domain/providers/tab_list.dart'; class TabsActionButton extends HookConsumerWidget { final bool isActive; - final VoidCallback onTap; - final VoidCallback onLongPress; + final VoidCallback? onTap; + final VoidCallback? onDoubleTap; + final VoidCallback? onLongPress; const TabsActionButton({ - required this.onTap, - required this.onLongPress, + this.onTap, + this.onDoubleTap, + this.onLongPress, this.isActive = false, super.key, }); @@ -24,6 +26,7 @@ class TabsActionButton extends HookConsumerWidget { return InkWell( onTap: onTap, + onDoubleTap: onDoubleTap, onLongPress: onLongPress, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 15.0),