From db6ad1066dace5895cf8aca8a698da2ba0dfe2e8 Mon Sep 17 00:00:00 2001 From: Fabian Freund Date: Thu, 13 Mar 2025 23:24:54 +0100 Subject: [PATCH] switch tabs by swipe gesture --- .../widgets/browser_modules/app_bar_title.dart | 7 +++++-- .../widgets/browser_modules/bottom_app_bar.dart | 12 +++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/lib/features/geckoview/features/browser/presentation/widgets/browser_modules/app_bar_title.dart b/app/lib/features/geckoview/features/browser/presentation/widgets/browser_modules/app_bar_title.dart index 4c8cd022..9981ba4a 100644 --- a/app/lib/features/geckoview/features/browser/presentation/widgets/browser_modules/app_bar_title.dart +++ b/app/lib/features/geckoview/features/browser/presentation/widgets/browser_modules/app_bar_title.dart @@ -8,13 +8,15 @@ import 'package:text_scroll/text_scroll.dart'; class AppBarTitle extends StatelessWidget { final TabState tab; - final void Function()? onTap; - final void Function()? onLongPress; + final VoidCallback? onTap; + final VoidCallback? onLongPress; + final GestureDragEndCallback? onHorizontalDragEnd; const AppBarTitle({ required this.tab, this.onTap, this.onLongPress, + this.onHorizontalDragEnd, super.key, }); @@ -44,6 +46,7 @@ class AppBarTitle extends StatelessWidget { return GestureDetector( onTap: onTap, onLongPress: onLongPress, + onHorizontalDragEnd: onHorizontalDragEnd, child: Row( children: [ TabIcon(state: tab), 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 22dbee11..fe287ef1 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 @@ -75,6 +75,13 @@ class BrowserBottomAppBar extends HookConsumerWidget { .loadUrl(url: newUrl); } }, + onHorizontalDragEnd: (details) async { + if (details.localPosition.dx > 150) { + await ref + .read(tabRepositoryProvider.notifier) + .selectPreviousTab(); + } + }, ) : const SizedBox.shrink(); }, @@ -118,11 +125,6 @@ class BrowserBottomAppBar extends HookConsumerWidget { .show(ViewTabsSheet()); } }, - onDoubleTap: () async { - await ref - .read(tabRepositoryProvider.notifier) - .selectPreviousTab(); - }, onLongPress: () { if (tabMenuController.isOpen) { tabMenuController.close();