double tap previous tab
This commit is contained in:
@@ -27,6 +27,8 @@ part 'tab.g.dart';
|
||||
class TabRepository extends _$TabRepository {
|
||||
final _tabsService = GeckoTabService();
|
||||
|
||||
String? _previousTabId;
|
||||
|
||||
Future<String> addTab({
|
||||
Uri? url,
|
||||
bool selectTab = true,
|
||||
@@ -83,6 +85,14 @@ class TabRepository extends _$TabRepository {
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> selectPreviousTab() async {
|
||||
if (_previousTabId != null) {
|
||||
return selectTab(_previousTabId!);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Future<bool> 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());
|
||||
}
|
||||
});
|
||||
|
||||
+5
@@ -118,6 +118,11 @@ class BrowserBottomAppBar extends HookConsumerWidget {
|
||||
.show(ViewTabsSheet());
|
||||
}
|
||||
},
|
||||
onDoubleTap: () async {
|
||||
await ref
|
||||
.read(tabRepositoryProvider.notifier)
|
||||
.selectPreviousTab();
|
||||
},
|
||||
onLongPress: () {
|
||||
if (tabMenuController.isOpen) {
|
||||
tabMenuController.close();
|
||||
|
||||
+7
-4
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user