switch tabs by swipe gesture

This commit is contained in:
Fabian Freund
2025-03-13 23:24:54 +01:00
parent a5382f0726
commit db6ad1066d
2 changed files with 12 additions and 7 deletions
@@ -8,13 +8,15 @@ import 'package:text_scroll/text_scroll.dart';
class AppBarTitle extends StatelessWidget { class AppBarTitle extends StatelessWidget {
final TabState tab; final TabState tab;
final void Function()? onTap; final VoidCallback? onTap;
final void Function()? onLongPress; final VoidCallback? onLongPress;
final GestureDragEndCallback? onHorizontalDragEnd;
const AppBarTitle({ const AppBarTitle({
required this.tab, required this.tab,
this.onTap, this.onTap,
this.onLongPress, this.onLongPress,
this.onHorizontalDragEnd,
super.key, super.key,
}); });
@@ -44,6 +46,7 @@ class AppBarTitle extends StatelessWidget {
return GestureDetector( return GestureDetector(
onTap: onTap, onTap: onTap,
onLongPress: onLongPress, onLongPress: onLongPress,
onHorizontalDragEnd: onHorizontalDragEnd,
child: Row( child: Row(
children: [ children: [
TabIcon(state: tab), TabIcon(state: tab),
@@ -75,6 +75,13 @@ class BrowserBottomAppBar extends HookConsumerWidget {
.loadUrl(url: newUrl); .loadUrl(url: newUrl);
} }
}, },
onHorizontalDragEnd: (details) async {
if (details.localPosition.dx > 150) {
await ref
.read(tabRepositoryProvider.notifier)
.selectPreviousTab();
}
},
) )
: const SizedBox.shrink(); : const SizedBox.shrink();
}, },
@@ -118,11 +125,6 @@ class BrowserBottomAppBar extends HookConsumerWidget {
.show(ViewTabsSheet()); .show(ViewTabsSheet());
} }
}, },
onDoubleTap: () async {
await ref
.read(tabRepositoryProvider.notifier)
.selectPreviousTab();
},
onLongPress: () { onLongPress: () {
if (tabMenuController.isOpen) { if (tabMenuController.isOpen) {
tabMenuController.close(); tabMenuController.close();