switch tabs by swipe gesture
This commit is contained in:
+5
-2
@@ -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),
|
||||||
|
|||||||
+7
-5
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user